New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make import as module easier and define "main" #34
Open
aronmolnar
wants to merge
1
commit into
hannob:master
Choose a base branch
from
aronmolnar:patch-1
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hartwork
suggested changes
Nov 28, 2019
Comment on lines
+652
to
+732
sys.excepthook = new_excepthook | ||
|
||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument("hosts", nargs='*', help="hostname to scan") | ||
parser.add_argument("-t", "--tests", nargs=1, | ||
help="Comma-separated tests to run.") | ||
parser.add_argument("--useragent", nargs=1, | ||
help="User agent to send") | ||
parser.add_argument("--nowww", action="store_true", | ||
help="Skip scanning www.[host]") | ||
parser.add_argument("--nohttp", action="store_true", | ||
help="Don't scan http") | ||
parser.add_argument("--nohttps", action="store_true", | ||
help="Don't scan https") | ||
parser.add_argument("-i", "--info", action="store_true", | ||
help="Enable all info tests (no bugs/security vulnerabilities)") | ||
parser.add_argument("-n", "--noisy", action="store_true", | ||
help="Show noisy messages that indicate boring bugs, but no security issue") | ||
parser.add_argument("-p", "--path", default='', action="store", type=str, | ||
help="Base path on server (scans root dir by default)") | ||
parser.add_argument("-j", "--json", action="store_true", | ||
help="Produce JSON output") | ||
parser.add_argument("-d", "--debug", action="store_true", | ||
help="Show detailed debugging info") | ||
args = parser.parse_args() | ||
|
||
# Initializing global pool manager | ||
user_agent = {'user-agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:53.0) Gecko/20100101 Firefox/53.0'} | ||
if args.useragent: | ||
user_agent = {'user-agent': args.useragent[0]} | ||
poolmanager = urllib3.PoolManager(10, headers=user_agent) | ||
|
||
|
||
if args.tests is None: | ||
tests = [g for f, g in locals().items() if hasattr(g, '_is_default_test')] | ||
else: | ||
tests = [] | ||
try: | ||
for x in args.tests[0].split(','): | ||
tests.append(locals()["test_" + x]) | ||
except KeyError: | ||
print("Test %s does not exist" % x) | ||
sys.exit(1) | ||
|
||
if args.info: | ||
tests += [g for f, g in locals().items() if hasattr(g, '_is_info_test')] | ||
|
||
path = args.path.rstrip("/") | ||
if len(path) > 0 and path[0] != "/": | ||
path = "/" + path | ||
if path != "": | ||
pdebug("Path: %s" % path) | ||
|
||
hosts = list(args.hosts) | ||
if not args.nowww: | ||
for h in args.hosts: | ||
hosts.append("www." + h) | ||
|
||
for i, h in enumerate(hosts): | ||
hosts[i] = h.encode("idna").decode("ascii") | ||
if h != hosts[i]: | ||
pdebug("Converted %s to %s" % (h, hosts[i])) | ||
|
||
pdebug("All hosts: %s" % ",".join(hosts)) | ||
|
||
|
||
json_out = [] | ||
for host in hosts: | ||
pdebug("Scanning %s" % host) | ||
for test in tests: | ||
pdebug("Running %s test" % test.__name__) | ||
if hasattr(test, '_is_hostname_test'): | ||
test(host) | ||
else: | ||
if not args.nohttp: | ||
test("http://" + host + path) | ||
if not args.nohttps: | ||
test("https://" + host + path) | ||
if args.json: | ||
print(json.dumps(json_out)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation is off here and the pull request is not adding a function main
as implied by its title. Should be an easy fix if you're still interested in this feature.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.