Skip to content

Commit c084979

Browse files
authored
[bugfix] Fix bug where provided credentials are not tested (#43)
* Add verbose mode * Fix bug where provided creds are not tested
1 parent e2b5b20 commit c084979

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

apachetomcatscanner/Config.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,15 @@ def load_credentials_from_options(self, username, password, usernames_file, pass
6666
f.close()
6767

6868
if len(usernames) != 0 and len(passwords) != 0:
69-
self.credentials = {"credentials": []}
69+
self.credentials = []
7070
for username in usernames:
7171
for password in passwords:
72-
self.credentials["credentials"].append({
72+
self.credentials.append({
7373
"username": username,
7474
"password": password,
7575
"description": ""
7676
})
77-
return True
78-
else:
79-
return False
77+
return len(self.credentials)
8078

8179
# Get / Set functions
8280

apachetomcatscanner/__main__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ def main():
213213

214214
config = Config()
215215
config.set_debug_mode(options.debug)
216+
config.set_verbose_mode(options.verbose)
216217
config.set_no_colors(options.no_colors)
217218
config.set_request_available_schemes(only_http=options.only_http, only_https=options.only_https)
218219
config.set_request_timeout(options.request_timeout)
@@ -222,7 +223,9 @@ def main():
222223
config.set_list_cves_mode(options.list_cves)
223224
config.set_show_cves_descriptions_mode(options.show_cves_descriptions)
224225

225-
config.load_credentials_from_options(options.tomcat_username, options.tomcat_password, options.tomcat_usernames_file, options.tomcat_passwords_file)
226+
number_of_tested_credentials = config.load_credentials_from_options(options.tomcat_username, options.tomcat_password, options.tomcat_usernames_file, options.tomcat_passwords_file)
227+
if config.verbose_mode:
228+
print("[verbose] %s credentials will be tested per target" % number_of_tested_credentials)
226229

227230
vulns_db = VulnerabilitiesDB(config=config)
228231
reporter = Reporter(config=config, vulns_db=vulns_db)

apachetomcatscanner/utils/scan.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def get_version_from_malformed_http_request(url, config):
9191
return None
9292

9393

94-
def try_default_credentials(url_manager, config):
94+
def try_credentials(url_manager, config):
9595
found_credentials = []
9696
try:
9797
for credentials in config.credentials:
@@ -112,7 +112,7 @@ def try_default_credentials(url_manager, config):
112112
found_credentials.append((r.status_code, credentials))
113113
return found_credentials
114114
except Exception as e:
115-
config.debug("Error in get_version_from_malformed_http_request('%s'): %s " % (url_manager, e))
115+
config.debug(f"Error : {e} ")
116116
return found_credentials
117117

118118

@@ -155,7 +155,7 @@ def process_url(scheme, target, port, url, config, reporter):
155155
if result["manager_accessible"]:
156156
config.debug("Manager is accessible")
157157
# Test for default credentials
158-
credentials_found = try_default_credentials(url_manager, config)
158+
credentials_found = try_credentials(url_manager, config)
159159

160160
reporter.report_result(target, port, result, credentials_found)
161161

0 commit comments

Comments
 (0)