Skip to content

Code cleanup and automated PEP8 code style check (flake8) #62

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

Merged
merged 1 commit into from
Oct 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[flake8]
max-line-length = 120
exclude = __pycache__,.virtualenv,.venv,build,dist
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ language: python
python: 3.6

install:
- pip install flake8
# - pip install -r ./requirements.txt

# command to run tests
script: nosetests
script:
- nosetests
- flake8
4 changes: 0 additions & 4 deletions lib/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +0,0 @@
#!/usr/bin/env python

pass

4 changes: 0 additions & 4 deletions lib/core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +0,0 @@
#!/usr/bin/env python

pass

192 changes: 98 additions & 94 deletions lib/core/input.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
from argparse import ArgumentParser
import os.path

class cli_helper(object):

class CliHelper(object):
@staticmethod
def readable_file(parser, arg):
if not os.path.exists(arg):
parser.error("The file %s does not exist!" % arg)
else:
return open(arg, 'r') # return an open file handle
return open(arg, 'r') # return an open file handle


class cli_argument_parser(object):
class CliArgumentParser(object):
def __init__(self):
self._parser = self.setup_parser()

Expand All @@ -21,94 +22,97 @@ def parse(self, argv):
def setup_parser():
parser = ArgumentParser()

parser.add_argument("-t",
dest="target_hosts",
required=True,
help="Set a target range of addresses to target. Ex 10.11.1.1-255")

parser.add_argument("-o",
dest="output_directory",
required=True,
help="Set the output directory. Ex /root/Documents/labs/")

parser.add_argument("-w",
dest="wordlist",
required=False,
help="Set the wordlist to use for generated commands. Ex /usr/share/wordlist.txt",
default=False)

parser.add_argument("-p",
dest="port",
required=False,
help="Set the port to use. Leave blank to use discovered ports. Useful to force virtual host scanning on non-standard webserver ports.",
default=80)

parser.add_argument("--pingsweep",
dest="ping_sweep",
action="store_true",
help="Write a new target.txt by performing a ping sweep and discovering live hosts.",
default=False)

parser.add_argument("--dns","--dnssweep",
dest="find_dns_servers",
action="store_true",
help="Find DNS servers from a list of targets.",
default=False)

parser.add_argument("--services",
dest="perform_service_scan",
action="store_true",
help="Perform service scan over targets.",
default=False)

parser.add_argument("--hostnames",
dest="hostname_scan",
action="store_true",
help="Attempt to discover target hostnames and write to 0-name.txt and hostnames.txt.",
default=False)

parser.add_argument("--snmp",
dest="perform_snmp_walk",
action="store_true",
help="Perform service scan over targets.",
default=False)

parser.add_argument("--quick",
dest="quick",
action="store_true",
required=False,
help="Move to the next target after performing a quick scan and writing first-round recommendations.",
default=False)

parser.add_argument("--virtualhosts",
dest="virtualhosts",
action="store_true",
required=False,
help="Attempt to discover virtual hosts using the specified wordlist.",
default=False)

parser.add_argument('--ignore-http-codes',
dest='ignore_http_codes',
type=str,
help='Comma separated list of http codes to ignore with virtual host scans.',
default='404')

parser.add_argument('--ignore-content-length',
dest='ignore_content_length',
type=int,
help='Ignore content lengths of specificed amount. This may become useful when a server returns a static page on every virtual host guess.',
default=0)

parser.add_argument("--quiet",
dest="quiet",
action="store_true",
help="Supress banner and headers to limit to comma dilimeted results only.",
default=False)

parser.add_argument("--no-udp",
dest="no_udp_service_scan",
action="store_true",
help="Disable UDP services scan over targets.",
default=False)
return parser

parser.add_argument("-t",
dest="target_hosts",
required=True,
help="Set a target range of addresses to target. Ex 10.11.1.1-255")

parser.add_argument("-o",
dest="output_directory",
required=True,
help="Set the output directory. Ex /root/Documents/labs/")

parser.add_argument("-w",
dest="wordlist",
required=False,
help="Set the wordlist to use for generated commands. Ex /usr/share/wordlist.txt",
default=False)

parser.add_argument("-p",
dest="port",
required=False,
help="Set the port to use. Leave blank to use discovered ports. "
"Useful to force virtual host scanning on non-standard webserver ports.",
default=80)

parser.add_argument("--pingsweep",
dest="ping_sweep",
action="store_true",
help="Write a new target.txt by performing a ping sweep and discovering live hosts.",
default=False)

parser.add_argument("--dns", "--dnssweep",
dest="find_dns_servers",
action="store_true",
help="Find DNS servers from a list of targets.",
default=False)

parser.add_argument("--services",
dest="perform_service_scan",
action="store_true",
help="Perform service scan over targets.",
default=False)

parser.add_argument("--hostnames",
dest="hostname_scan",
action="store_true",
help="Attempt to discover target hostnames and write to 0-name.txt and hostnames.txt.",
default=False)

parser.add_argument("--snmp",
dest="perform_snmp_walk",
action="store_true",
help="Perform service scan over targets.",
default=False)

parser.add_argument("--quick",
dest="quick",
action="store_true",
required=False,
help="Move to the next target after performing a quick scan and writing "
"first-round recommendations.",
default=False)

parser.add_argument("--virtualhosts",
dest="virtualhosts",
action="store_true",
required=False,
help="Attempt to discover virtual hosts using the specified wordlist.",
default=False)

parser.add_argument('--ignore-http-codes',
dest='ignore_http_codes',
type=str,
help='Comma separated list of http codes to ignore with virtual host scans.',
default='404')

parser.add_argument('--ignore-content-length',
dest='ignore_content_length',
type=int,
help='Ignore content lengths of specificed amount. '
'This may become useful when a server returns a static page on '
'every virtual host guess.',
default=0)

parser.add_argument("--quiet",
dest="quiet",
action="store_true",
help="Supress banner and headers to limit to comma dilimeted results only.",
default=False)

parser.add_argument("--no-udp",
dest="no_udp_service_scan",
action="store_true",
help="Disable UDP services scan over targets.",
default=False)
return parser
Loading