-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathnmap_web_screenshot.py
More file actions
executable file
·75 lines (59 loc) · 2.06 KB
/
nmap_web_screenshot.py
File metadata and controls
executable file
·75 lines (59 loc) · 2.06 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
72
73
74
75
#!/usr/bin/env python2.7
###########
# IMPORTS #
###########
from __future__ import print_function
import sys
import argparse
import os
from subprocess import check_output
import modules.nmap as nmap
from tqdm import tqdm
#############
# FUNCTIONS #
#############
def error(*objects):
print("[!]", *objects, file=sys.stderr)
def info(*objects):
print("[+]", *objects, file=sys.stdout)
def take_screenshot(urls, path):
binary = 'CutyCapt'
for url in tqdm(urls):
filename = "{0}.png".format(
url.replace('//', '_').replace('/', '_').replace(':', ''))
check_output(["{0}".format(binary), "--insecure", "--max-wait=15000",
"--out-format=png", "--url={0}".format(url),
"--out={0}/{1}".format(path, filename)])
########
# MAIN #
########
if __name__ == '__main__':
desc = 'Parse nmap xml output and take a screenshot of all web servers.'
parser = argparse.ArgumentParser(description=desc)
required = parser.add_argument_group('required arguments')
required.add_argument('-o', '--output',
action='store',
help='directory to output results',
metavar='PATH',
required=True)
parser.add_argument('files',
action='store',
nargs='+',
help='nmap xml file(s) to parse',
metavar='INPUT')
args = parser.parse_args()
for xml in args.files:
if not os.path.isfile(xml):
error("File '%s' does not exist!" % xml)
exit()
if not os.access(xml, os.R_OK):
error("File '%s' is not readable!" % xml)
exit()
if not os.path.exists(args.output):
error("Directory '%s' does not exist!" % args.output)
exit()
if not os.access(args.output, os.W_OK):
error("Directory '%s' is not writable!" % args.output)
exit()
web_servers = nmap.parse_web_servers(args.files)
take_screenshot(web_servers, args.output)