forked from AlessandroZ/LaZagne
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
71ae178
commit b0a9599
Showing
4 changed files
with
113 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,85 +1,85 @@ | ||
import struct | ||
from ctypes import * | ||
from ctypes.wintypes import DWORD | ||
import win32cred | ||
from config.constant import * | ||
from config.write_output import print_output, print_debug | ||
from config.header import Header | ||
|
||
memcpy = cdll.msvcrt.memcpy | ||
LocalFree = windll.kernel32.LocalFree | ||
CryptUnprotectData = windll.crypt32.CryptUnprotectData | ||
CRYPTPROTECT_UI_FORBIDDEN = 0x01 | ||
|
||
class DATA_BLOB(Structure): | ||
_fields_ = [ | ||
('cbData', DWORD), | ||
('pbData', POINTER(c_char)) | ||
] | ||
|
||
class Dot_net(): | ||
def getData(self, blobOut): | ||
cbData = int(blobOut.cbData) | ||
pbData = blobOut.pbData | ||
buffer = c_buffer(cbData) | ||
memcpy(buffer, pbData, cbData) | ||
LocalFree(pbData); | ||
return buffer.raw | ||
|
||
def get_creds(self): | ||
try: | ||
creds = win32cred.CredEnumerate(None, 0) | ||
return creds | ||
except: | ||
return None | ||
|
||
def get_entropy(self): | ||
entropy = '82BD0E67-9FEA-4748-8672-D5EFE5B779B0\0' | ||
s = '' | ||
for c in entropy: | ||
s += struct.pack('<h', ord(c) << 2) | ||
entropy = s | ||
return s | ||
|
||
def Win32CryptUnprotectData(self, cipherText, entropy): | ||
bufferIn = c_buffer(cipherText, len(cipherText)) | ||
blobIn = DATA_BLOB(len(cipherText), bufferIn) | ||
bufferEntropy = c_buffer(entropy, len(entropy)) | ||
blobEntropy = DATA_BLOB(len(entropy), bufferEntropy) | ||
blobOut = DATA_BLOB() | ||
if CryptUnprotectData(byref(blobIn), None, byref(blobEntropy), None, None, CRYPTPROTECT_UI_FORBIDDEN, byref(blobOut)): | ||
return self.getData(blobOut) | ||
else: | ||
return 'failed' | ||
|
||
def retrieve_password(self): | ||
# print title | ||
Header().title_debug('Dot Net Passport') | ||
|
||
a = self.get_creds() | ||
pwd = '' | ||
pwdFound = [] | ||
if a: | ||
for i in a: | ||
values = {} | ||
if i['Type'] == win32cred.CRED_TYPE_DOMAIN_VISIBLE_PASSWORD: | ||
cipher_text = i['CredentialBlob'] | ||
pwd = self.Win32CryptUnprotectData(cipher_text, self.get_entropy()) | ||
if pwd != 'failed': | ||
values['TargetName'] = i['TargetName'] | ||
if i['UserName'] is not None: | ||
values['Username'] = i['UserName'] | ||
try: | ||
values['Password'] = pwd.decode('utf16') | ||
except: | ||
values['Password'] = 'Error decoding the password' | ||
|
||
pwdFound.append(values) | ||
|
||
# print the results | ||
print_output('Dot Net Passport', pwdFound) | ||
|
||
else: | ||
print_debug('INFO', 'No credentials listed with the enum cred function') | ||
|
||
import struct | ||
from ctypes import * | ||
from ctypes.wintypes import DWORD | ||
import win32cred | ||
from config.constant import * | ||
from config.write_output import print_output, print_debug | ||
from config.header import Header | ||
|
||
memcpy = cdll.msvcrt.memcpy | ||
LocalFree = windll.kernel32.LocalFree | ||
CryptUnprotectData = windll.crypt32.CryptUnprotectData | ||
CRYPTPROTECT_UI_FORBIDDEN = 0x01 | ||
|
||
class DATA_BLOB(Structure): | ||
_fields_ = [ | ||
('cbData', DWORD), | ||
('pbData', POINTER(c_char)) | ||
] | ||
|
||
class Dot_net(): | ||
def getData(self, blobOut): | ||
cbData = int(blobOut.cbData) | ||
pbData = blobOut.pbData | ||
buffer = c_buffer(cbData) | ||
memcpy(buffer, pbData, cbData) | ||
LocalFree(pbData); | ||
return buffer.raw | ||
|
||
def get_creds(self): | ||
try: | ||
creds = win32cred.CredEnumerate(None, 0) | ||
return creds | ||
except: | ||
return None | ||
|
||
def get_entropy(self): | ||
entropy = '82BD0E67-9FEA-4748-8672-D5EFE5B779B0\0' | ||
s = '' | ||
for c in entropy: | ||
s += struct.pack('<h', ord(c) << 2) | ||
entropy = s | ||
return s | ||
|
||
def Win32CryptUnprotectData(self, cipherText, entropy): | ||
bufferIn = c_buffer(cipherText, len(cipherText)) | ||
blobIn = DATA_BLOB(len(cipherText), bufferIn) | ||
bufferEntropy = c_buffer(entropy, len(entropy)) | ||
blobEntropy = DATA_BLOB(len(entropy), bufferEntropy) | ||
blobOut = DATA_BLOB() | ||
if CryptUnprotectData(byref(blobIn), None, byref(blobEntropy), None, None, CRYPTPROTECT_UI_FORBIDDEN, byref(blobOut)): | ||
return self.getData(blobOut) | ||
else: | ||
return 'failed' | ||
|
||
def retrieve_password(self): | ||
# print title | ||
Header().title_debug('Dot Net Passport') | ||
|
||
a = self.get_creds() | ||
pwd = '' | ||
pwdFound = [] | ||
if a: | ||
for i in a: | ||
values = {} | ||
if i['Type'] == win32cred.CRED_TYPE_DOMAIN_VISIBLE_PASSWORD: | ||
cipher_text = i['CredentialBlob'] | ||
pwd = self.Win32CryptUnprotectData(cipher_text, self.get_entropy()) | ||
if pwd != 'failed': | ||
values['TargetName'] = i['TargetName'] | ||
if i['UserName'] is not None: | ||
values['Username'] = i['UserName'] | ||
try: | ||
values['Password'] = pwd.decode('utf16') | ||
except: | ||
values['INFO'] = 'Error decoding the password' | ||
|
||
pwdFound.append(values) | ||
|
||
# print the results | ||
print_output('Dot Net Passport', pwdFound) | ||
|
||
else: | ||
print_debug('INFO', 'No credentials listed with the enum cred function') | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.