-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add dns tool fact readers * add dig dns tool * add dnsenum tool * simplify some rule conditions * add dnsrecon tool * add fierce dns tool * add TODO for parsing dnsrecon json output * parse dnsrecon json output, fixes to dns commands --------- Signed-off-by: Patrick Double <pat@patdouble.com>
- Loading branch information
Showing
56 changed files
with
2,078 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import re | ||
|
||
from experta import Fact | ||
|
||
from shadycompass.config import ToolCategory | ||
from shadycompass.facts import FactReader, fact_reader_registry, check_file_signature, guess_target, TargetHostname, \ | ||
ScanPresent | ||
|
||
_DNS_LINE_PATTERN = re.compile(r'^(\S+)[.]\s+\d+\s+IN\s+A+\s+(\S+)$', re.MULTILINE) | ||
_SERVER_PATTERN = re.compile(r'SERVER:\s+(\S+)#(\d+)\((\S+)\)\s+\(([A-Z]+)\)') | ||
|
||
|
||
class DigReader(FactReader): | ||
def read_facts(self, file_path: str) -> list[Fact]: | ||
if not check_file_signature(file_path, '<<>> DiG '): | ||
return [] | ||
print(f"[*] Reading dig findings from {file_path}") | ||
targets = set() | ||
resolutions = set() | ||
result = [] | ||
with open(file_path, 'rt') as file: | ||
for line in file.readlines(): | ||
m = _SERVER_PATTERN.search(line) | ||
if m: | ||
hostname_args = dict() | ||
target = guess_target(m.group(3)) | ||
targets.add(target) | ||
if isinstance(target, TargetHostname): | ||
hostname_args['hostname'] = target.get_hostname() | ||
result.append(ScanPresent(category=ToolCategory.dns_scanner, name='dig', | ||
addr=m.group(1), port=int(m.group(2)), | ||
**hostname_args)) | ||
continue | ||
if line.startswith(';'): | ||
continue | ||
m = _DNS_LINE_PATTERN.search(line) | ||
if m: | ||
target = guess_target(m.group(2)) | ||
targets.add(target) | ||
hostname = m.group(1).rstrip('.') | ||
targets.add(TargetHostname(hostname=hostname)) | ||
resolutions.add(target.get_resolution(hostname, False)) | ||
|
||
result.extend(targets) | ||
result.extend(resolutions) | ||
return result | ||
|
||
|
||
fact_reader_registry.append(DigReader()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import re | ||
import xml.etree.ElementTree as ET | ||
|
||
from experta import Fact | ||
|
||
from shadycompass.config import ToolCategory | ||
from shadycompass.facts import FactReader, fact_reader_registry, check_file_signature, guess_target, TargetHostname, \ | ||
ScanPresent | ||
|
||
DNSENUM_FILENAME_PATTERN = re.compile(r'dnsenum(?:-subdomains)?-([^/\\]+[.][a-z]{2,6})(?:-[\w-]+?)?[.]\w{3,5}$') | ||
|
||
|
||
class DnsEnumReader(FactReader): | ||
def read_facts(self, file_path: str) -> list[Fact]: | ||
if not check_file_signature(file_path, '<magictree class="MtBranchObject">'): | ||
return [] | ||
print(f"[*] Reading dnsenum subdomain findings from {file_path}") | ||
m = DNSENUM_FILENAME_PATTERN.search(file_path) | ||
dns_hostname = m.group(1) | ||
|
||
result = [] | ||
targets = set() | ||
resolutions = set() | ||
tree = ET.parse(file_path) | ||
for host_el in tree.findall('.//host'): | ||
addr = host_el.text.strip() | ||
hostname_el = host_el.find('hostname') | ||
if hostname_el is not None: | ||
hostname = hostname_el.text.strip() | ||
target = guess_target(addr) | ||
targets.add(target) | ||
targets.add(TargetHostname(hostname=hostname)) | ||
resolutions.add(target.get_resolution(hostname, False)) | ||
|
||
result.extend(targets) | ||
result.extend(resolutions) | ||
|
||
if len(result) > 0: | ||
dns_hostname_args = {} | ||
if isinstance(guess_target(dns_hostname), TargetHostname): | ||
dns_hostname_args['hostname'] = dns_hostname | ||
else: | ||
dns_hostname_args['addr'] = dns_hostname | ||
result.append(ScanPresent(category=ToolCategory.dns_scanner, name='dnsenum', port=53, **dns_hostname_args)) | ||
|
||
return result | ||
|
||
|
||
fact_reader_registry.append(DnsEnumReader()) |
Oops, something went wrong.