Skip to content

Commit f3d79a6

Browse files
authored
Merge pull request #82 from dgisser/master
Address flake8 issues (#81 PEP8 refactor)
2 parents db3a23f + 9023ddc commit f3d79a6

File tree

9 files changed

+431
-187
lines changed

9 files changed

+431
-187
lines changed

Reconnoitre/lib/core/input.py

Lines changed: 86 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -22,34 +22,42 @@ def parse(self, argv):
2222
def setup_parser():
2323
parser = ArgumentParser()
2424

25-
parser.add_argument("-t",
26-
dest="target_hosts",
27-
required=True,
28-
help="Set a target range of addresses to target. Ex 10.11.1.1-255")
29-
30-
parser.add_argument("-o",
31-
dest="output_directory",
32-
required=True,
33-
help="Set the output directory. Ex /root/Documents/labs/")
34-
35-
parser.add_argument("-w",
36-
dest="wordlist",
37-
required=False,
38-
help="Set the wordlist to use for generated commands. Ex /usr/share/wordlist.txt",
39-
default=False)
40-
41-
parser.add_argument("-p",
42-
dest="port",
43-
required=False,
44-
help="Set the port to use. Leave blank to use discovered ports. "
45-
"Useful to force virtual host scanning on non-standard webserver ports.",
46-
default=80)
47-
48-
parser.add_argument("--pingsweep",
49-
dest="ping_sweep",
50-
action="store_true",
51-
help="Write a new target.txt by performing a ping sweep and discovering live hosts.",
52-
default=False)
25+
parser.add_argument(
26+
"-t",
27+
dest="target_hosts",
28+
required=True,
29+
help="Set a target range of addresses to target. Ex 10.11.1.1-255")
30+
31+
parser.add_argument(
32+
"-o",
33+
dest="output_directory",
34+
required=True,
35+
help="Set the output directory. Ex /root/Documents/labs/")
36+
37+
parser.add_argument(
38+
"-w",
39+
dest="wordlist",
40+
required=False,
41+
help="Set the wordlist to use for generated commands."
42+
" Ex /usr/share/wordlist.txt",
43+
default=False)
44+
45+
parser.add_argument(
46+
"-p",
47+
dest="port",
48+
required=False,
49+
help="Set the port to use. Leave blank to use discovered ports. "
50+
"Useful to force virtual host "
51+
"scanning on non-standard webserver ports.",
52+
default=80)
53+
54+
parser.add_argument(
55+
"--pingsweep",
56+
dest="ping_sweep",
57+
action="store_true",
58+
help="Write a new target.txt by performing "
59+
"a ping sweep and discovering live hosts.",
60+
default=False)
5361

5462
parser.add_argument("--dns", "--dnssweep",
5563
dest="find_dns_servers",
@@ -63,52 +71,63 @@ def setup_parser():
6371
help="Perform service scan over targets.",
6472
default=False)
6573

66-
parser.add_argument("--hostnames",
67-
dest="hostname_scan",
68-
action="store_true",
69-
help="Attempt to discover target hostnames and write to 0-name.txt and hostnames.txt.",
70-
default=False)
74+
parser.add_argument(
75+
"--hostnames",
76+
dest="hostname_scan",
77+
action="store_true",
78+
help="Attempt to discover target hostnames and "
79+
"write to 0-name.txt and hostnames.txt.",
80+
default=False)
7181

7282
parser.add_argument("--snmp",
7383
dest="perform_snmp_walk",
7484
action="store_true",
7585
help="Perform service scan over targets.",
7686
default=False)
7787

78-
parser.add_argument("--quick",
79-
dest="quick",
80-
action="store_true",
81-
required=False,
82-
help="Move to the next target after performing a quick scan and writing "
83-
"first-round recommendations.",
84-
default=False)
85-
86-
parser.add_argument("--virtualhosts",
87-
dest="virtualhosts",
88-
action="store_true",
89-
required=False,
90-
help="Attempt to discover virtual hosts using the specified wordlist.",
91-
default=False)
92-
93-
parser.add_argument('--ignore-http-codes',
94-
dest='ignore_http_codes',
95-
type=str,
96-
help='Comma separated list of http codes to ignore with virtual host scans.',
97-
default='404')
98-
99-
parser.add_argument('--ignore-content-length',
100-
dest='ignore_content_length',
101-
type=int,
102-
help='Ignore content lengths of specificed amount. '
103-
'This may become useful when a server returns a static page on '
104-
'every virtual host guess.',
105-
default=0)
106-
107-
parser.add_argument("--quiet",
108-
dest="quiet",
109-
action="store_true",
110-
help="Supress banner and headers to limit to comma dilimeted results only.",
111-
default=False)
88+
parser.add_argument(
89+
"--quick",
90+
dest="quick",
91+
action="store_true",
92+
required=False,
93+
help="Move to the next target after "
94+
"performing a quick scan and writing "
95+
"first-round recommendations.",
96+
default=False)
97+
98+
parser.add_argument(
99+
"--virtualhosts",
100+
dest="virtualhosts",
101+
action="store_true",
102+
required=False,
103+
help="Attempt to discover virtual hosts "
104+
"using the specified wordlist.",
105+
default=False)
106+
107+
parser.add_argument(
108+
'--ignore-http-codes',
109+
dest='ignore_http_codes',
110+
type=str,
111+
help='Comma separated list of http '
112+
'codes to ignore with virtual host scans.',
113+
default='404')
114+
115+
parser.add_argument(
116+
'--ignore-content-length',
117+
dest='ignore_content_length',
118+
type=int,
119+
help='Ignore content lengths of specificed amount. '
120+
'This may become useful when a server returns a static page on '
121+
'every virtual host guess.',
122+
default=0)
123+
124+
parser.add_argument(
125+
"--quiet",
126+
dest="quiet",
127+
action="store_true",
128+
help="Supress banner and headers to limit "
129+
"to comma dilimeted results only.",
130+
default=False)
112131

113132
parser.add_argument("--no-udp",
114133
dest="no_udp_service_scan",

Reconnoitre/lib/file_helper.py

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,14 @@ def expand_targets(target_hosts, output_directory):
2727
if "-" in part:
2828
iprange = part.split("-")
2929
for i in range(int(iprange[0]), int(iprange[1])):
30-
target_list.append(parts[0] + "." + parts[1] + "." + parts[2] + "." + str(i))
30+
target_list.append(
31+
parts[0] +
32+
"." +
33+
parts[1] +
34+
"." +
35+
parts[2] +
36+
"." +
37+
str(i))
3138
with open(output_directory + "/targets.txt", "w") as targets:
3239
for target in target_list:
3340
targets.write("%s\n" % target)
@@ -89,32 +96,49 @@ def write_recommendations(results, ip_address, outputdir):
8996

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

92-
__location__ = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__)))
99+
__location__ = os.path.realpath(
100+
os.path.join(
101+
os.getcwd(),
102+
os.path.dirname(__file__)))
93103
with open(os.path.join(__location__, "config.json"), "r") as config:
94104
c = config.read()
95-
j = json.loads(c.replace("$ip", "%(ip)s").replace("$port", "%(port)s").replace("$outputdir", "%(outputdir)s"))
105+
j = json.loads(
106+
c.replace(
107+
"$ip",
108+
"%(ip)s").replace(
109+
"$port",
110+
"%(port)s").replace(
111+
"$outputdir",
112+
"%(outputdir)s"))
96113

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

101118
for service in j["services"]:
102-
if (serv in j["services"][service]["nmap-service-names"]) or (service in serv):
119+
if (serv in j["services"][service]
120+
["nmap-service-names"]) or (service in serv):
103121
for port in ports:
104122
port = port.split("/")[0]
105123

106-
description = "[*] " + j["services"][service]["description"]
124+
description = "[*] "
125+
+ j["services"][service]["description"]
107126
print(description % {"ip": ip_address, "port": port})
108-
f.write((description + "\n") % {"ip": ip_address, "port": port})
127+
f.write((description + "\n") %
128+
{"ip": ip_address, "port": port})
109129

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

113133
for cmd in entry["commands"]:
114-
f.write(
115-
(" [=] " + cmd + "\n") % {"ip": ip_address, "port": port, "outputdir": outputdir})
134+
f.write((" [=] " + cmd + "\n") %
135+
{"ip": ip_address,
136+
"port": port,
137+
"outputdir": outputdir})
116138

117139
f.write("\n")
118140

119-
f.write("\n\n[*] Always remember to manually go over the portscan report and carefully read between the lines ;)")
141+
f.write(
142+
"\n\n[*] Always remember to manually go over the"
143+
" portscan report and carefully read between the lines ;)")
120144
f.close()

Reconnoitre/lib/find_dns.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,18 @@ def find_dns(target_hosts, output_directory, quiet):
3232
for line in lines:
3333
line = line.strip()
3434
line = line.rstrip()
35-
if ("53/tcp" in line) and ("open" in line) and ("Discovered" not in line):
36-
print(" [=] Found DNS service running on: %s" % (ip_address))
37-
output_file.write("[*] Found DNS service running on: %s\n" % (ip_address))
35+
if (("53/tcp" in line) and ("open" in line)
36+
and ("Discovered" not in line)):
37+
print(
38+
" [=] Found DNS service running on: %s" %
39+
(ip_address))
40+
output_file.write(
41+
"[*] Found DNS service running on: %s\n" %
42+
(ip_address))
3843
output_file.write(" [>] %s\n" % (line))
3944
output_targets.write("%s" % (ip_address))
4045
dnscount += 1
41-
print("[*] Found %s DNS servers within %s hosts" % (str(dnscount), str(hostcount)))
46+
print("[*] Found %s DNS servers within %s hosts" %
47+
(str(dnscount), str(hostcount)))
4248
output_file.close()
4349
output_targets.close()

0 commit comments

Comments
 (0)