-
Notifications
You must be signed in to change notification settings - Fork 122
/
Copy pathbotshot.py
142 lines (113 loc) · 3.5 KB
/
botshot.py
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/usr/bin/env python3
"""
botshot.py 0.2 - Mass Web Screenshot Command Line Script
Copyright (c) 2017-2020 Marco Ivaldi <[email protected]>
"The Other Way to Pen-Test" --HD Moore & Valsmith
Botshot is a Python script that captures screenshots of
websites from the command line. It is useful to automate
mapping of the web attack surface of large networks.
Based on previous work by @federicodotta and @0-duke.
Requirements:
Python 3 (https://pythonclock.org/ is ticking...)
Selenium (https://pypi.python.org/pypi/selenium)
ChromeDriver (https://chromedriver.chromium.org/)
Example usage:
$ ./botshot.py -f urls
TODO:
Implement import from Nmap's XML output files
Add the ability to save output in HTML format
Add the ability to perform nikto/dirb scans
Migrate to Electron (https://electron.atom.io/)?
Get the latest version at:
https://github.com/0xdea/tactical-exploitation/
"""
VERSION = "0.1"
BANNER = """
botshot.py {0} - Mass Web Screenshot Command Line Script
Copyright (c) 2017 Marco Ivaldi <[email protected]>
""".format(VERSION)
import sys
import argparse
import time
import os
import re
from selenium import webdriver
def webshot(args):
"""
Mass web screenshot function
"""
targets = [url.rstrip() for url in args.f]
timeout = args.t
# chrome webdriver options
options = webdriver.ChromeOptions()
options.add_argument("--headless")
options.add_argument("--ignore-certificate-errors")
options.add_argument("--no-sandbox")
#options.add_argument("--disable-dev-shm-usage")
# set up headless browser
try:
browser = webdriver.Chrome(options=options)
browser.set_page_load_timeout(timeout)
browser.set_window_size(1920, 1080)
except Exception as err:
print("// error: {0}".format(err))
browser.quit()
sys.exit(1)
# create output directory
outdir = "webshots-" + time.strftime("%Y%m%d-%H%M%S", time.localtime())
try:
os.mkdir(outdir, mode=0o755)
except Exception as err:
print("// error: {0}".format(err))
browser.quit()
sys.exit(1)
for url in targets:
print("*** Grabbing screenshot of {0} ***\n".format(url))
p = re.compile("[:/]+")
outfile = outdir + "/" + p.sub("_", url) + ".png"
try:
browser.get("about:blank")
browser.get(url)
time.sleep(1) # workaround for some targets
browser.save_screenshot(outfile)
except (KeyboardInterrupt, SystemExit):
browser.quit()
sys.exit(1)
except Exception as err:
print("// error: {0}".format(err))
browser.quit()
return
def get_args():
"""
Get command line arguments
"""
parser = argparse.ArgumentParser()
parser.set_defaults(func=webshot)
parser.add_argument(
"-f",
metavar="FILE",
type=argparse.FileType("r"),
required=True,
help="specify file containing a list of URLs")
parser.add_argument(
"-t",
metavar="TIMEOUT",
type=int,
default=30,
help="specify timeout in seconds (default: 30)")
if len(sys.argv) == 1:
parser.print_help()
sys.exit(0)
return parser.parse_args()
def main():
"""
Main function
"""
print(BANNER)
if sys.version_info[0] != 3:
print("// error: this script requires python 3")
sys.exit(1)
args = get_args()
args.func(args)
if __name__ == "__main__":
main()