Skip to content

Commit

Permalink
Merge pull request #82 from tlansec/bugfix/cidr_notation_ips
Browse files Browse the repository at this point in the history
Avoid parsing CIDR notation IPs
  • Loading branch information
pedramamini authored Aug 28, 2024
2 parents b737020 + a2dcb43 commit 653b8b5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
5 changes: 2 additions & 3 deletions iocextract.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def ipv4_len(ip_len=3):
[\[\(\\]*?\.[\]\)]*?
){3}
(?:[1-9]?\d|1\d\d|2[0-4]\d|25[0-5])
(?:(?=[^\d\.])|$)
(?:(?=[^\d\.])|$)(?!\/\d{1,2}(?!\d))
""",
re.VERBOSE,
)
Expand All @@ -262,7 +262,7 @@ def ipv4_len(ip_len=3):
){4}
([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])
(?:[1-9]?\d|1\d\d|2[0-4]\d|25[0-5])
(?:(?=[^\d\.])|$)
(?:(?=[^\d\.])|$)(?!\/\d{1,2}(?!\d))
""",
re.VERBOSE,
)
Expand Down Expand Up @@ -611,7 +611,6 @@ def ipv4_str(data):
# Iterates over any ip address with 4 numbers after the final (3rd) octet
for ip_address in ipv4_len(4).finditer(data):
pass

if refang:
yield refang_ipv4(ip_address.group(0))
else:
Expand Down
1 change: 1 addition & 0 deletions test_data/invalid.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ x.x.x.x
tooshor.t
tooshor.
adc83b191b1c6ea0fd8b46cd9f32e592fc
100.20.30.0/24

0 comments on commit 653b8b5

Please sign in to comment.