Skip to content

Commit

Permalink
address flake8 issues
Browse files Browse the repository at this point in the history
ran autopep8 --in-place --aggressive --aggressive --max-line-length=80 --recursive .
  • Loading branch information
dgisser committed Oct 28, 2018
1 parent db3a23f commit 9023ddc
Show file tree
Hide file tree
Showing 9 changed files with 431 additions and 187 deletions.
153 changes: 86 additions & 67 deletions Reconnoitre/lib/core/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,34 +22,42 @@ 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(
"-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",
Expand All @@ -63,52 +71,63 @@ def setup_parser():
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(
"--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(
"--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",
Expand Down
42 changes: 33 additions & 9 deletions Reconnoitre/lib/file_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,14 @@ def expand_targets(target_hosts, output_directory):
if "-" in part:
iprange = part.split("-")
for i in range(int(iprange[0]), int(iprange[1])):
target_list.append(parts[0] + "." + parts[1] + "." + parts[2] + "." + str(i))
target_list.append(
parts[0] +
"." +
parts[1] +
"." +
parts[2] +
"." +
str(i))
with open(output_directory + "/targets.txt", "w") as targets:
for target in target_list:
targets.write("%s\n" % target)
Expand Down Expand Up @@ -89,32 +96,49 @@ def write_recommendations(results, ip_address, outputdir):

print("[+] Writing findings for %s" % (ip_address))

__location__ = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__)))
__location__ = os.path.realpath(
os.path.join(
os.getcwd(),
os.path.dirname(__file__)))
with open(os.path.join(__location__, "config.json"), "r") as config:
c = config.read()
j = json.loads(c.replace("$ip", "%(ip)s").replace("$port", "%(port)s").replace("$outputdir", "%(outputdir)s"))
j = json.loads(
c.replace(
"$ip",
"%(ip)s").replace(
"$port",
"%(port)s").replace(
"$outputdir",
"%(outputdir)s"))

f = open(recommendations_file, 'w')
for serv in serv_dict:
ports = serv_dict[serv]

for service in j["services"]:
if (serv in j["services"][service]["nmap-service-names"]) or (service in serv):
if (serv in j["services"][service]
["nmap-service-names"]) or (service in serv):
for port in ports:
port = port.split("/")[0]

description = "[*] " + j["services"][service]["description"]
description = "[*] "
+ j["services"][service]["description"]
print(description % {"ip": ip_address, "port": port})
f.write((description + "\n") % {"ip": ip_address, "port": port})
f.write((description + "\n") %
{"ip": ip_address, "port": port})

for entry in j["services"][service]["output"]:
f.write(" [*] " + entry["description"] + "\n")

for cmd in entry["commands"]:
f.write(
(" [=] " + cmd + "\n") % {"ip": ip_address, "port": port, "outputdir": outputdir})
f.write((" [=] " + cmd + "\n") %
{"ip": ip_address,
"port": port,
"outputdir": outputdir})

f.write("\n")

f.write("\n\n[*] Always remember to manually go over the portscan report and carefully read between the lines ;)")
f.write(
"\n\n[*] Always remember to manually go over the"
" portscan report and carefully read between the lines ;)")
f.close()
14 changes: 10 additions & 4 deletions Reconnoitre/lib/find_dns.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,18 @@ def find_dns(target_hosts, output_directory, quiet):
for line in lines:
line = line.strip()
line = line.rstrip()
if ("53/tcp" in line) and ("open" in line) and ("Discovered" not in line):
print(" [=] Found DNS service running on: %s" % (ip_address))
output_file.write("[*] Found DNS service running on: %s\n" % (ip_address))
if (("53/tcp" in line) and ("open" in line)
and ("Discovered" not in line)):
print(
" [=] Found DNS service running on: %s" %
(ip_address))
output_file.write(
"[*] Found DNS service running on: %s\n" %
(ip_address))
output_file.write(" [>] %s\n" % (line))
output_targets.write("%s" % (ip_address))
dnscount += 1
print("[*] Found %s DNS servers within %s hosts" % (str(dnscount), str(hostcount)))
print("[*] Found %s DNS servers within %s hosts" %
(str(dnscount), str(hostcount)))
output_file.close()
output_targets.close()
Loading

0 comments on commit 9023ddc

Please sign in to comment.