-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathwbh.py
109 lines (85 loc) · 3.22 KB
/
wbh.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
import sqlite3
import os
import sys
import argparse
import glob
from urllib.parse import urlparse
def parse_urls(urls, limit):
subs = set()
files = set()
params = set()
domains = set()
for u in urls:
url = urlparse(u)
domains.add(url.hostname)
for d in url.netloc.split(".")[:-2]:
if len(d) <= limit:
subs.add(d)
for f in url.path.split("/"):
if len(f) <= limit:
files.add(f)
for tp in url.query.split("&"):
if len(tp) <= limit:
params.add(tp.split("=")[0].split("[")[0])
return {"subdomains": subs, "files": files, "parameters": params, "domains": domains}
def get_chrome_urls():
if sys.platform == "win32":
history_chrome_files = glob.glob(os.path.expanduser(
"~")+"\\AppData\\Local\\Google\\Chrome\\User Data\\Default\\History")
else:
history_chrome_files = glob.glob(os.path.expanduser(
"~")+"/.config/*chrom*/*/History")
turls = []
for f in history_chrome_files:
conn = sqlite3.connect(f)
c = conn.cursor()
c.execute("select url from urls;")
for x in c.fetchall():
turls.append(x[0])
return turls
def get_firefox_urls():
if sys.platform == "win32":
history_firefox_files = glob.glob(os.path.expanduser(
"~")+"\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\*\\places.sqlite")
elif sys.platform == "darwin" :
history_firefox_files = glob.glob(os.path.expanduser(
"~")+"/Library/Application Support/Firefox/Profiles/*/places.sqlite")
else:
history_firefox_files = glob.glob(os.path.expanduser(
"~")+"/.mozilla/firefox/*/places.sqlite")
turls = []
for f in history_firefox_files:
conn = sqlite3.connect(f)
c = conn.cursor()
c.execute("select url from moz_places;")
for x in c.fetchall():
turls.append(x[0])
return turls
def main(args):
urls = set()
if args.chrome:
[urls.add(u) for u in get_chrome_urls()]
elif args.firefox:
[urls.add(u) for u in get_firefox_urls()]
else:
[urls.add(u) for u in get_chrome_urls()]
[urls.add(u) for u in get_firefox_urls()]
wordlists = parse_urls(urls, args.limit)
for key, result_list in wordlists.items():
print(f"{len(result_list)} {key} found!")
output = open(os.path.join(args.directory, f"{key}.txt"), "w")
output.writelines("%s\n" % sub for sub in result_list)
output.close()
if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="Create subdomains, files, parameters and domains wordlists from browser history")
parser.add_argument('-d', '--directory',
help='Directory to save the wordlists', default="./")
parser.add_argument(
'-l', '--limit', help="Limit of characters. Default: 40", type=int, default=40)
parser.add_argument(
'-c', '--chrome', help="Use Google Chrome to make the wordlists", action="store_true")
parser.add_argument(
'-f', '--firefox', help="Use Firefox to make the wordlists", action="store_true")
args = parser.parse_args()
main(args)