Skip to content

Commit

Permalink
Added handling of IPv4 CIDR ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
p0dalirius committed Mar 19, 2024
1 parent 26188de commit aaa3ed8
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
36 changes: 34 additions & 2 deletions coercer/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
import argparse
import os
import sys

from sectools.network.domains import is_fqdn
from sectools.network.ip import is_ipv4_cidr, is_ipv4_addr, is_ipv6_addr, expand_cidr, expand_port_range
from coercer.core.Reporter import Reporter
from coercer.structures.Credentials import Credentials
from coercer.core.modes.scan import action_scan
Expand Down Expand Up @@ -186,7 +187,38 @@ def main():
print("[!] Could not open targets file '%s'." % options.targets_file)
sys.exit(0)

credentials = Credentials(username=options.username, password=options.password, domain=options.domain, lmhash=lmhash, nthash=nthash)
# Sort uniq on targets list
targets = sorted(list(set(targets)))

final_targets = []
# Parsing target to filter IP/DNS/CIDR
for target in targets:
if is_ipv4_cidr(target):
final_targets += [ip for ip in expand_cidr(target)]
elif is_ipv4_addr(target):
final_targets.append(target)
elif is_ipv6_addr(target):
final_targets.append(target)
elif is_fqdn(target):
final_targets.append(target)
elif target.startswith("http://") or target.startswith("https://"):
import urllib.parse
target = urllib.parse.urlparse(target).netloc
final_targets.append(target)
else:
if options.debug:
print("[debug] Target '%s' was not added." % target)

# Sort
targets = sorted(list(set(final_targets)))

credentials = Credentials(
username=options.username,
password=options.password,
domain=options.domain,
lmhash=lmhash,
nthash=nthash
)

# Processing actions
if options.mode == "coerce":
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
impacket
xlsxwriter
jinja2
jinja2
sectools

0 comments on commit aaa3ed8

Please sign in to comment.