Skip to content

Commit ce13623

Browse files
authored
Merge pull request #557 from blacklanternsecurity/dev
Dev->Main
2 parents ea7bbb2 + 28921b1 commit ce13623

File tree

4 files changed

+55
-27
lines changed

4 files changed

+55
-27
lines changed

baddns/modules/txt.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from baddns.lib.findings import Finding
66

77
import logging
8+
import ipaddress
89

910
log = logging.getLogger(__name__)
1011

@@ -41,6 +42,14 @@ async def dispatch(self):
4142
for match in DNSManager.dns_name_regex.finditer(txt_record):
4243
start, end = match.span()
4344
host = txt_record[start:end]
45+
46+
try:
47+
# Check if the host is an IP address
48+
ipaddress.ip_address(host)
49+
continue # Skip this match if it's a valid IP address
50+
except ValueError:
51+
pass
52+
4453
self.infomsg(f"Found host [{host}] in TXT record [{txt_record}] and analyzing with CNAME module")
4554

4655
cname_instance_direct = BadDNS_cname(
@@ -56,7 +65,7 @@ async def dispatch(self):
5665
self.cname_findings_direct.append(
5766
{
5867
"finding": cname_instance_direct.analyze(),
59-
"description": "Vulnerable Host in TXT Record",
68+
"description": f"Vulnerable Host [{host}] in TXT Record",
6069
"trigger": self.target_dnsmanager.target,
6170
}
6271
)

poetry.lock

+23-23
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "baddns"
3-
version = "1.6.0"
3+
version = "1.7.0"
44
description = "Check subdomains for subdomain takeovers and other DNS tomfoolery"
55
authors = ["liquidsec <[email protected]>"]
66
repository = "https://github.com/blacklanternsecurity/baddns"
@@ -56,4 +56,4 @@ build-backend = "poetry_dynamic_versioning.backend"
5656
[tool.poetry-dynamic-versioning]
5757
enable = true
5858
metadata = true
59-
format = '1.6.{distance}'
59+
format = '1.7.{distance}'

tests/txt_test.py

+20-1
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,30 @@ async def test_txt_match(fs, mock_dispatch_whois, configure_mock_resolver):
2020
assert findings
2121
expected = {
2222
"target": "bad.dns",
23-
"description": "Vulnerable Host in TXT Record. Original Event: [Dangling CNAME, probable subdomain takeover (NXDOMAIN technique)]",
23+
"description": "Vulnerable Host [baddns.azurewebsites.net] in TXT Record. Original Event: [Dangling CNAME, probable subdomain takeover (NXDOMAIN technique)]",
2424
"confidence": "PROBABLE",
2525
"signature": "Microsoft Azure Takeover Detection",
2626
"indicator": "azurewebsites.net",
2727
"trigger": "bad.dns",
2828
"module": "TXT",
2929
}
3030
assert any(expected == finding.to_dict() for finding in findings)
31+
32+
33+
@pytest.mark.asyncio
34+
async def test_txt_dontmatchip(fs, mock_dispatch_whois, configure_mock_resolver):
35+
mock_data = {
36+
"bad.dns": {"TXT": ["some text 100.100.100.100 some more text"]},
37+
"_NXDOMAIN": ["baddns.azurewebsites.net"],
38+
}
39+
mock_resolver = configure_mock_resolver(mock_data)
40+
target = "bad.dns"
41+
mock_signature_load(fs, "nucleitemplates_azure-takeover-detection.yml")
42+
signatures = load_signatures("/tmp/signatures")
43+
baddns_txt = BadDNS_txt(target, signatures=signatures, dns_client=mock_resolver)
44+
45+
findings = None
46+
if await baddns_txt.dispatch():
47+
findings = baddns_txt.analyze()
48+
49+
assert not findings

0 commit comments

Comments
 (0)