Skip to content

Commit 555ee41

Browse files
committed
Fixed bad parsing of FQDN targets in sectools.
Release 2.3.3
1 parent 1ae9e41 commit 555ee41

File tree

2 files changed

+37
-33
lines changed

2 files changed

+37
-33
lines changed

apachetomcatscanner/__main__.py

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from concurrent.futures import ThreadPoolExecutor
1919

2020

21-
VERSION = "2.3.2"
21+
VERSION = "2.3.3"
2222

2323
banner = """Apache Tomcat Scanner v%s - by @podalirius_\n""" % VERSION
2424

@@ -28,7 +28,7 @@ def load_targets(options, config):
2828

2929
# Loading targets from domain computers
3030
if options.auth_domain is not None and options.auth_user is not None and (options.auth_password is not None or options.auth_hash is not None) and options.servers_only is False:
31-
if options.verbose:
31+
if options.debug:
3232
print("[debug] Loading targets from computers in the domain '%s'" % options.auth_domain)
3333
targets = get_computers_from_domain(
3434
auth_domain=options.auth_domain,
@@ -40,7 +40,7 @@ def load_targets(options, config):
4040

4141
# Loading targets from domain servers
4242
if options.auth_domain is not None and options.auth_user is not None and (options.auth_password is not None or options.auth_hash is not None) and options.servers_only is True:
43-
if options.verbose:
43+
if options.debug:
4444
print("[debug] Loading targets from servers in the domain '%s'" % options.auth_domain)
4545
targets = get_servers_from_domain(
4646
auth_domain=options.auth_domain,
@@ -53,7 +53,7 @@ def load_targets(options, config):
5353
# Loading targets line by line from a targets file
5454
if options.targets_file is not None:
5555
if os.path.exists(options.targets_file):
56-
if options.verbose:
56+
if options.debug:
5757
print("[debug] Loading targets line by line from targets file '%s'" % options.targets_file)
5858
f = open(options.targets_file, "r")
5959
for line in f.readlines():
@@ -64,7 +64,7 @@ def load_targets(options, config):
6464

6565
# Loading targets from --target option
6666
if len(options.target) != 0:
67-
if options.verbose:
67+
if options.debug:
6868
print("[debug] Loading targets from --target options")
6969
for target in options.target:
7070
targets.append(target)
@@ -83,6 +83,9 @@ def load_targets(options, config):
8383
final_targets.append(target)
8484
elif is_fqdn(target):
8585
final_targets.append(target)
86+
else:
87+
if options.debug:
88+
print("[debug] Target '%s' was not added." % target)
8689

8790
final_targets = sorted(list(set(final_targets)))
8891
return final_targets
@@ -102,33 +105,34 @@ def load_ports(options, config):
102105
def parseArgs():
103106
print(banner)
104107
parser = argparse.ArgumentParser(description="A python script to scan for Apache Tomcat server vulnerabilities.")
105-
parser.add_argument("-v", "--verbose", default=False, action="store_true", help='Verbose mode. (default: False)')
106-
parser.add_argument("--debug", default=False, action="store_true", help='Debug mode, for huge verbosity. (default: False)')
107-
parser.add_argument("-C", "--list-cves", default=False, action="store_true", help='List CVE ids affecting each version found. (default: False)')
108-
parser.add_argument("-T", "--threads", default=8, type=int, help='Number of threads (default: 5)')
109-
parser.add_argument("-s", "--servers-only", default=False, action="store_true", help='If querying ActiveDirectory, only get servers and not all computer objects. (default: False)')
110-
111-
parser.add_argument("--only-http", default=False, action="store_true", help='Scan only with HTTP scheme. (default: False, scanning with both HTTP and HTTPs)')
112-
parser.add_argument("--only-https", default=False, action="store_true", help='Scan only with HTTPs scheme. (default: False, scanning with both HTTP and HTTPs)')
113-
parser.add_argument("--no-check-certificate", default=False, action="store_true", help='Do not check certificate. (default: False)')
114-
115-
parser.add_argument("--xlsx", default=None, type=str, help='Export results to XLSX')
116-
parser.add_argument("--json", default=None, type=str, help='Export results to JSON')
117-
118-
group_configuration = parser.add_argument_group()
119-
group_configuration.add_argument("-PI", "--proxy-ip", default=None, type=str, help='Proxy IP.')
120-
group_configuration.add_argument("-PP", "--proxy-port", default=None, type=int, help='Proxy port')
121-
group_configuration.add_argument("-rt", "--request-timeout", default=1, type=int, help='')
122-
123-
group_targets_source = parser.add_argument_group()
124-
group_targets_source.add_argument("-tf", "--targets-file", default=None, type=str, help='Path to file containing a line by line list of targets.')
108+
parser.add_argument("-v", "--verbose", default=False, action="store_true", help="Verbose mode. (default: False)")
109+
parser.add_argument("--debug", default=False, action="store_true", help="Debug mode, for huge verbosity. (default: False)")
110+
parser.add_argument("-C", "--list-cves", default=False, action="store_true", help="List CVE ids affecting each version found. (default: False)")
111+
parser.add_argument("-T", "--threads", default=8, type=int, help="Number of threads (default: 5)")
112+
parser.add_argument("-s", "--servers-only", default=False, action="store_true", help="If querying ActiveDirectory, only get servers and not all computer objects. (default: False)")
113+
114+
parser.add_argument("--only-http", default=False, action="store_true", help="Scan only with HTTP scheme. (default: False, scanning with both HTTP and HTTPs)")
115+
parser.add_argument("--only-https", default=False, action="store_true", help="Scan only with HTTPs scheme. (default: False, scanning with both HTTP and HTTPs)")
116+
parser.add_argument("--no-check-certificate", default=False, action="store_true", help="Do not check certificate. (default: False)")
117+
118+
group_export = parser.add_argument_group("Advanced configuration")
119+
group_export.add_argument("--xlsx", default=None, type=str, help="Export results to XLSX")
120+
group_export.add_argument("--json", default=None, type=str, help="Export results to JSON")
121+
122+
group_configuration = parser.add_argument_group("Advanced configuration")
123+
group_configuration.add_argument("-PI", "--proxy-ip", default=None, type=str, help="Proxy IP.")
124+
group_configuration.add_argument("-PP", "--proxy-port", default=None, type=int, help="Proxy port")
125+
group_configuration.add_argument("-rt", "--request-timeout", default=1, type=int, help="Set the timeout of HTTP requests.")
126+
127+
group_targets_source = parser.add_argument_group("Targets")
128+
group_targets_source.add_argument("-tf", "--targets-file", default=None, type=str, help="Path to file containing a line by line list of targets.")
125129
group_targets_source.add_argument("-tt", "--target", default=[], type=str, action='append', help='Target IP, FQDN or CIDR')
126-
group_targets_source.add_argument("-tp", "--target-ports", default="8080", type=str, help='Target ports to scan top search for Apache Tomcat servers.')
127-
group_targets_source.add_argument("-ad", "--auth-domain", default=None, type=str, help='Windows domain to authenticate to.')
128-
group_targets_source.add_argument("-ai", "--auth-dc-ip", default=None, type=str, help='IP of the domain controller.')
129-
group_targets_source.add_argument("-au", "--auth-user", default=None, type=str, help='Username of the domain account.')
130-
group_targets_source.add_argument("-ap", "--auth-password", default=None, type=str, help='Password of the domain account.')
131-
group_targets_source.add_argument("-ah", "--auth-hash", default=None, type=str, help='LM:NT hashes to pass the hash for this user.')
130+
group_targets_source.add_argument("-tp", "--target-ports", default="8080", type=str, help="Target ports to scan top search for Apache Tomcat servers.")
131+
group_targets_source.add_argument("-ad", "--auth-domain", default=None, type=str, help="Windows domain to authenticate to.")
132+
group_targets_source.add_argument("-ai", "--auth-dc-ip", default=None, type=str, help="IP of the domain controller.")
133+
group_targets_source.add_argument("-au", "--auth-user", default=None, type=str, help="Username of the domain account.")
134+
group_targets_source.add_argument("-ap", "--auth-password", default=None, type=str, help="Password of the domain account.")
135+
group_targets_source.add_argument("-ah", "--auth-hash", default=None, type=str, help="LM:NT hashes to pass the hash for this user.")
132136

133137
args = parser.parse_args()
134138

@@ -137,7 +141,7 @@ def parseArgs():
137141
print("\n[!] No targets specified.")
138142
sys.exit(0)
139143

140-
if args.auth_password is not None and args.auth_hash is not None:
144+
if (args.auth_password is not None) and (args.auth_hash is not None):
141145
parser.print_help()
142146
print("\n[!] Options --auth-password/--auth-hash are mutually exclusive.")
143147
sys.exit(0)

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
sectools>=1.3.6
1+
sectools>=1.3.7
22
xlsxwriter
33
requests

0 commit comments

Comments
 (0)