Skip to content

Commit 52bd4b6

Browse files
Merge pull request #2 from 0xricksanchez/cplugin
2 parents b5fc8ab + d675df4 commit 52bd4b6

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed

__init__.py

+11-5
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ class DisassemblerError(Exception):
3232

3333

3434
class 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)

plugin.json

+13-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
11
{
2-
"api": ["python3"],
2+
"api": [
3+
"python3"
4+
],
35
"author": "434b",
4-
"description": "Instruction assembler",
6+
"description": "Interactive shellcode disassembler/assembler",
57
"license": {
68
"name": "Apache 2.0",
7-
"text": "Copyright 2024 0x434b <[email protected]>"
9+
"text": "Copyright 2024 0x434b <[email protected]> Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License."
810
},
911
"longdescription": "",
1012
"minimumbinaryninjaversion": 4526,
1113
"name": "Shellcoder",
12-
"platforms": ["Darwin", "Linux", "Windows"],
14+
"platforms": [
15+
"Darwin",
16+
"Linux",
17+
"Windows"
18+
],
1319
"pluginmetadataversion": 2,
14-
"type": ["helper"],
20+
"type": [
21+
"helper"
22+
],
1523
"version": "1.0.0"
1624
}

0 commit comments

Comments
 (0)