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.
removing dependencies using ctypes (win32 and colorama) + some code r…
…eview
- Loading branch information
1 parent
6ea2322
commit e403156
Showing
36 changed files
with
604 additions
and
667 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
from ctypes.wintypes import * | ||
from ctypes import * | ||
|
||
LPBYTE = POINTER(BYTE) | ||
LPTSTR = LPSTR | ||
LPCTSTR = LPSTR | ||
|
||
# ------------------ Constants ------------------ | ||
|
||
# Credential Manager | ||
CRYPTPROTECT_UI_FORBIDDEN = 0x01 | ||
CRED_TYPE_GENERIC = 0x1 | ||
CRED_TYPE_DOMAIN_VISIBLE_PASSWORD = 0x4 | ||
|
||
# Regedit | ||
HKEY_CURRENT_USER = -2147483647 | ||
KEY_READ = 131097 | ||
KEY_ENUMERATE_SUB_KEYS = 8 | ||
KEY_QUERY_VALUE = 1 | ||
|
||
# custom key to read registry (not from msdn) | ||
ACCESS_READ = KEY_READ | KEY_ENUMERATE_SUB_KEYS | KEY_QUERY_VALUE | ||
|
||
# ------------------ Structures ------------------ | ||
|
||
class CREDENTIAL_ATTRIBUTE(Structure): | ||
_fields_ = [ | ||
('Keyword', LPSTR), | ||
('Flags', DWORD), | ||
('ValueSize', DWORD), | ||
('Value', LPBYTE) | ||
] | ||
PCREDENTIAL_ATTRIBUTE = POINTER(CREDENTIAL_ATTRIBUTE) | ||
|
||
class CREDENTIAL(Structure): | ||
_fields_ = [ | ||
('Flags', DWORD), | ||
('Type', DWORD), | ||
('TargetName', LPSTR), | ||
('Comment', LPSTR), | ||
('LastWritten', FILETIME), | ||
('CredentialBlobSize', DWORD), | ||
# ('CredentialBlob', POINTER(BYTE)), | ||
('CredentialBlob', POINTER(c_char)), | ||
('Persist', DWORD), | ||
('AttributeCount', DWORD), | ||
('Attributes', PCREDENTIAL_ATTRIBUTE), | ||
('TargetAlias', LPSTR), | ||
('UserName', LPSTR) | ||
] | ||
PCREDENTIAL = POINTER(CREDENTIAL) | ||
|
||
class DATA_BLOB(Structure): | ||
_fields_ = [ | ||
('cbData', DWORD), | ||
('pbData', POINTER(c_char)) | ||
] | ||
|
||
# ------------------ Functions ------------------ | ||
|
||
CredEnumerate = windll.advapi32.CredEnumerateA | ||
CredEnumerate.restype = BOOL | ||
CredEnumerate.argtypes = [LPCTSTR, DWORD, POINTER(DWORD), POINTER(POINTER(PCREDENTIAL))] | ||
|
||
CredFree = windll.advapi32.CredFree | ||
CredFree.restype = c_void_p | ||
CredFree.argtypes = [c_void_p] | ||
|
||
memcpy = cdll.msvcrt.memcpy | ||
LocalFree = windll.kernel32.LocalFree | ||
CryptUnprotectData = windll.crypt32.CryptUnprotectData | ||
|
||
|
||
# ------------------ Custom functions ------------------ | ||
|
||
def getData(blobOut): | ||
cbData = int(blobOut.cbData) | ||
pbData = blobOut.pbData | ||
buffer = c_buffer(cbData) | ||
|
||
memcpy(buffer, pbData, cbData) | ||
LocalFree(pbData); | ||
return buffer.raw | ||
|
||
def Win32CryptUnprotectData(cipherText, entropy=None): | ||
bufferIn = c_buffer(str(cipherText), len(cipherText)) | ||
blobIn = DATA_BLOB(len(cipherText), bufferIn) | ||
blobOut = DATA_BLOB() | ||
|
||
if entropy: | ||
bufferEntropy = c_buffer(entropy, len(entropy)) | ||
blobEntropy = DATA_BLOB(len(entropy), bufferEntropy) | ||
|
||
if CryptUnprotectData(byref(blobIn), None, byref(blobEntropy), None, None, 0, byref(blobOut)): | ||
return getData(blobOut) | ||
else: | ||
return False | ||
|
||
else: | ||
if CryptUnprotectData(byref(blobIn), None, None, None, None, 0, byref(blobOut)): | ||
return getData(blobOut) | ||
else: | ||
return False |
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,30 +1,55 @@ | ||
import logging | ||
from colorama import init, Fore, Back, Style | ||
import ctypes | ||
|
||
STD_OUTPUT_HANDLE = -11 | ||
std_out_handle = ctypes.windll.kernel32.GetStdHandle(STD_OUTPUT_HANDLE) | ||
|
||
def setColor(color='white', intensity=False): | ||
c = None | ||
if color == 'white': | ||
c = 0x07 | ||
elif color == 'red': | ||
c = 0x04 | ||
elif color == 'green': | ||
c = 0x02 | ||
elif color == 'cyan': | ||
c = 0x03 | ||
|
||
if intensity: | ||
c = c | 0x08 | ||
|
||
ctypes.windll.kernel32.SetConsoleTextAttribute(std_out_handle, c) | ||
|
||
class Header(): | ||
def __init__(self): | ||
init() # for colorama | ||
# init() # for colorama | ||
self.BRIGHT = '\x1b[31m' | ||
self.WHITE = '\x1b[37m' | ||
self.RESET_COLOR = '\x1b[0m' | ||
|
||
def first_title(self): | ||
init() | ||
print Style.BRIGHT + Fore.WHITE | ||
setColor(color='white', intensity=True) | ||
print '|====================================================================|' | ||
print '| |' | ||
print '| The LaZagne Project |' | ||
print '| |' | ||
print '| ! BANG BANG ! |' | ||
print '| |' | ||
print '|====================================================================|' | ||
print Style.RESET_ALL | ||
setColor() | ||
|
||
# info option for the logging | ||
def title(self, title): | ||
print Style.BRIGHT + Fore.WHITE + '------------------- ' + title + ' passwords -----------------\n' + Style.RESET_ALL | ||
setColor(color='white', intensity=True) | ||
print '------------------- ' + title + ' passwords -----------------\n' | ||
setColor() | ||
|
||
# Subtitle | ||
def title1(self, title1): | ||
print Style.BRIGHT + Fore.WHITE + '[*] ' + title1 + '\n' + Style.RESET_ALL | ||
# def title1(self, title1): | ||
# print self.BRIGHT + self.WHITE + '[*] ' + title1 + '\n' + self.RESET_COLOR | ||
|
||
# debug option for the logging | ||
def title_info(self, title): | ||
logging.info(Style.BRIGHT + Fore.WHITE + '------------------- ' + title + ' passwords -----------------\n' + Style.RESET_ALL) | ||
setColor(color='white', intensity=True) | ||
logging.info('------------------- ' + title + ' passwords -----------------\n') | ||
setColor() |
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
Oops, something went wrong.