@@ -32,8 +32,8 @@ class DisassemblerError(Exception):
3232
3333
3434class Assembler :
35- def __init__ (self ):
36- self .arch = None
35+ def __init__ (self ) -> None :
36+ self .arch : Architecture = None
3737
3838 def set_architecture (self , arch_name : str ) -> None :
3939 try :
@@ -98,7 +98,7 @@ def format_output(
9898 assembled_instructions : List [Dict ],
9999 output_format : str ,
100100 total_bytes : int ,
101- mnemonic_options : Dict = None ,
101+ mnemonic_options : Dict = {} ,
102102 ) -> str :
103103 if total_bytes == 0 :
104104 return "No instructions to assemble"
@@ -133,7 +133,7 @@ def format_output(
133133 else :
134134 lines .append (f' b"{ instr ["bytes" ].hex ()} ", # { instr ["asm" ]} ' )
135135 return (
136- f "shellcode = [\n "
136+ "shellcode = [\n "
137137 + "\n " .join (lines )
138138 + f"\n ]\n \n # Total length: { total_bytes } bytes\n "
139139 f"shellcode_length = { total_bytes } \n "
@@ -151,7 +151,7 @@ def format_output(
151151 hex_bytes = [f"0x{ b :02x} " for b in instr ["bytes" ]]
152152 lines .append (f" { ', ' .join (hex_bytes )} , // { instr ['asm' ]} " )
153153 return (
154- f "unsigned char shellcode[] = {{\n "
154+ "unsigned char shellcode[] = {{\n "
155155 + "\n " .join (lines )
156156 + f"\n }};\n \n // Total length: { total_bytes } bytes\n "
157157 f"const size_t shellcode_length = { total_bytes } ;"
@@ -563,6 +563,8 @@ def highlight_bad_patterns(
563563 highlight_format = QTextCharFormat ()
564564 highlight_format .setBackground (QColor (255 , 200 , 200 )) # Light red background
565565 highlight_format .setForeground (QColor (0 , 0 , 0 )) # Black text
566+ start = 0
567+ length = 0
566568
567569 for result in found_bad_patterns :
568570 offset , pattern = result ["offset" ], result ["pattern" ]
@@ -592,6 +594,10 @@ def highlight_bad_patterns(
592594 start = offset * 3
593595 length = pattern_length * 3 - 1
594596
597+ if not start :
598+ self .show_error ("Could not find the start position for highlighting" )
599+ if not length :
600+ self .show_error ("Could not find the length for highlighting" )
595601 cursor .setPosition (start )
596602 cursor .movePosition (QTextCursor .Right , QTextCursor .KeepAnchor , length )
597603 cursor .mergeCharFormat (highlight_format )
0 commit comments