Skip to content

Commit

Permalink
dns parsing fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
SkelSec committed Aug 29, 2024
1 parent 7144d32 commit 2291c52
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion msldap/_version.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

__version__ = "0.5.11"
__version__ = "0.5.12"
__banner__ = \
"""
# msldap %s
Expand Down
1 change: 1 addition & 0 deletions msldap/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1680,6 +1680,7 @@ async def dnattrs(self, dn, attrs:List[str]):
if err is not None:
raise err
return entry['attributes'], None
return None, None #no results
except Exception as e:
return None, e

Expand Down
19 changes: 16 additions & 3 deletions msldap/wintypes/dnsp/strcutures.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# parts of the dns implementation was taken from https://github.com/dirkjanm/adidnsdump
import enum
import io
import socket
import datetime
from typing import List

Expand Down Expand Up @@ -136,7 +135,14 @@ def from_bytes(data):
@staticmethod
def from_buffer(buff:io.BytesIO):
res = DNS_RPC_RECORD_A()
res.IpAddress = socket.inet_ntoa(buff.read(4))
#webassembly...
#res.IpAddress = socket.inet_ntoa(buff.read(4))
ipv4_bytes = buff.read(4)

# Convert each byte to an integer and join them with dots to form the IPv4 address
ipv4_str = '.'.join(str(byte) for byte in ipv4_bytes)
res.IpAddress = ipv4_str

return res

def to_line(self, separator = '\t'):
Expand All @@ -156,7 +162,14 @@ def from_bytes(data):
@staticmethod
def from_buffer(buff:io.BytesIO):
res = DNS_RPC_RECORD_AAAA()
res.IpAddress = socket.inet_ntop(socket.AF_INET6, buff.read(16))
# webassembly pyodide has problems with socket implementation
#res.IpAddress = socket.inet_ntop(socket.AF_INET6, buff.read(16))
ipv6_bytes = buff.read(16)
ipv6_hex = ''.join(f'{byte:02x}' for byte in ipv6_bytes)

# Convert the hex string into the standard IPv6 format
ipv6_str = ":".join(ipv6_hex[i:i + 4] for i in range(0, 32, 4))
res.IpAddress = ipv6_str
return res

def to_line(self, separator = '\t'):
Expand Down

0 comments on commit 2291c52

Please sign in to comment.