Skip to content

Commit

Permalink
fix: dnsx parsing output loading error (#422)
Browse files Browse the repository at this point in the history
  • Loading branch information
ocervell authored Sep 13, 2024
1 parent bebddb1 commit b9e98da
Showing 1 changed file with 22 additions and 24 deletions.
46 changes: 22 additions & 24 deletions secator/tasks/dnsx.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,35 +23,33 @@ class dnsx(ReconDns):
'resolver': {'type': str, 'short': 'r', 'help': 'List of resolvers to use (file or comma separated)'},
'wildcard_domain': {'type': str, 'short': 'wd', 'help': 'Domain name for wildcard filtering'},
}

item_loaders = []
install_cmd = 'go install -v github.com/projectdiscovery/dnsx/cmd/dnsx@latest'
install_github_handle = 'projectdiscovery/dnsx'
profile = 'io'

@staticmethod
def item_loader(self, line):
items = []
try:
item = json.loads(line)
if self.orig: # original dnsx output
return item
host = item['host']
record_types = ['a', 'aaaa', 'cname', 'mx', 'ns', 'txt', 'srv', 'ptr', 'soa', 'axfr', 'caa']
for _type in record_types:
values = item.get(_type, [])
for value in values:
name = value
extra_data = {}
if isinstance(value, dict):
name = value['name']
extra_data = {k: v for k, v in value.items() if k != 'name'}
items.append({
'host': host,
'name': name,
'type': _type.upper(),
'extra_data': extra_data
})
except json.decoder.JSONDecodeError:
pass

return items
except json.JSONDecodeError:
return
if self.orig: # original dnsx JSON output
yield item
return
host = item['host']
record_types = ['a', 'aaaa', 'cname', 'mx', 'ns', 'txt', 'srv', 'ptr', 'soa', 'axfr', 'caa']
for _type in record_types:
values = item.get(_type, [])
for value in values:
name = value
extra_data = {}
if isinstance(value, dict):
name = value['name']
extra_data = {k: v for k, v in value.items() if k != 'name'}
yield {
'host': host,
'name': name,
'type': _type.upper(),
'extra_data': extra_data
}

0 comments on commit b9e98da

Please sign in to comment.