-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
executable file
·71 lines (61 loc) · 2.27 KB
/
run.py
File metadata and controls
executable file
·71 lines (61 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env python3
from netrecon import recon
import json
import os
import argparse
def main():
parser = argparse.ArgumentParser(description='Arguments for running NetRecon')
parser.add_argument('--write_output', action='store_true', default=False)
parser.add_argument('--host', type=str, action='store')
args = parser.parse_args()
if not args.host:
host = os.getenv('NETRECON_HOST')
else:
host = args.host
username = os.getenv('NETRECON_USERNAME')
password = os.environ.get('NETRECON_PASSWORD')
recon_output = recon.host_discovery(host, username, password)
if recon_output == 99:
recon_output = {'error': 99, 'msg': '%s timed out' % host}
# 98 = connection refused
elif recon_output == 98:
recon_output = {'error': 98, 'msg': '%s connection refused' % host}
# 97 = bad ssh key
elif recon_output == 97:
recon_output = {'error': 97, 'msg': '%s bad ssh key' % host}
# 96 = using ssh v1
elif recon_output == 96:
recon_output = {'error': 96, 'msg': '%s using ssh v1' % host}
# 95 = password denied
elif recon_output == 95:
recon_output = {'error': 95, 'msg': '%s password denied' % host}
# 94 = permission denied
elif recon_output == 94:
recon_output = {'error': 94, 'msg': '%s permission denied' % host}
# 93 = EOF
elif recon_output == 93:
recon_output = {'error': 93, 'msg': '%s EOF' % host}
# 92 = network unreachable
elif recon_output == 92:
recon_output = {'error': 92, 'msg': '%s network unreachable' % host}
# 91 = no route to host
elif recon_output == 91:
recon_output = {'error': 91, 'msg': '%s no route to host' % host}
# 1 = could not connect
elif recon_output == 1:
recon_output = {'error': 1, 'msg': '%s could not connect' % host}
if args.write_output:
if not recon_output:
print('no output from %s' % host)
exit()
with open("data/%s.json" % host, "w") as data_file:
json.dump(recon_output, data_file, indent=4)
else:
print(json.dumps(recon_output))
if __name__ == '__main__':
try:
main()
except (IOError, SystemExit):
raise
except KeyboardInterrupt:
print('Crtl+C Pressed. Shutting down.')