Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ class DisassemblerError(Exception):


class Assembler:
def __init__(self):
self.arch = None
def __init__(self) -> None:
self.arch: Architecture = None

def set_architecture(self, arch_name: str) -> None:
try:
Expand Down Expand Up @@ -98,7 +98,7 @@ def format_output(
assembled_instructions: List[Dict],
output_format: str,
total_bytes: int,
mnemonic_options: Dict = None,
mnemonic_options: Dict = {},
) -> str:
if total_bytes == 0:
return "No instructions to assemble"
Expand Down Expand Up @@ -133,7 +133,7 @@ def format_output(
else:
lines.append(f' b"{instr["bytes"].hex()}", # {instr["asm"]}')
return (
f"shellcode = [\n"
"shellcode = [\n"
+ "\n".join(lines)
+ f"\n]\n\n# Total length: {total_bytes} bytes\n"
f"shellcode_length = {total_bytes}\n"
Expand All @@ -151,7 +151,7 @@ def format_output(
hex_bytes = [f"0x{b:02x}" for b in instr["bytes"]]
lines.append(f" {', '.join(hex_bytes)}, // {instr['asm']}")
return (
f"unsigned char shellcode[] = {{\n"
"unsigned char shellcode[] = {{\n"
+ "\n".join(lines)
+ f"\n}};\n\n// Total length: {total_bytes} bytes\n"
f"const size_t shellcode_length = {total_bytes};"
Expand Down Expand Up @@ -563,6 +563,8 @@ def highlight_bad_patterns(
highlight_format = QTextCharFormat()
highlight_format.setBackground(QColor(255, 200, 200)) # Light red background
highlight_format.setForeground(QColor(0, 0, 0)) # Black text
start = 0
length = 0

for result in found_bad_patterns:
offset, pattern = result["offset"], result["pattern"]
Expand Down Expand Up @@ -592,6 +594,10 @@ def highlight_bad_patterns(
start = offset * 3
length = pattern_length * 3 - 1

if not start:
self.show_error("Could not find the start position for highlighting")
if not length:
self.show_error("Could not find the length for highlighting")
cursor.setPosition(start)
cursor.movePosition(QTextCursor.Right, QTextCursor.KeepAnchor, length)
cursor.mergeCharFormat(highlight_format)
Expand Down
18 changes: 13 additions & 5 deletions plugin.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
{
"api": ["python3"],
"api": [
"python3"
],
"author": "434b",
"description": "Instruction assembler",
"description": "Interactive shellcode disassembler/assembler",
"license": {
"name": "Apache 2.0",
"text": "Copyright 2024 0x434b <admin@0x434b.dev>"
"text": "Copyright 2024 0x434b <admin@0x434b.dev> 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."
},
"longdescription": "",
"minimumbinaryninjaversion": 4526,
"name": "Shellcoder",
"platforms": ["Darwin", "Linux", "Windows"],
"platforms": [
"Darwin",
"Linux",
"Windows"
],
"pluginmetadataversion": 2,
"type": ["helper"],
"type": [
"helper"
],
"version": "1.0.0"
}