From ad6277c0ee163eadef3b327e76d9600437644cb2 Mon Sep 17 00:00:00 2001 From: JoYo <> Date: Sun, 24 Feb 2019 06:34:26 +0000 Subject: [PATCH] capstone isn't disassembling the whole block, dumb heuristics for growth --- sins/mutation.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/sins/mutation.py b/sins/mutation.py index e5f15b4..22cf192 100644 --- a/sins/mutation.py +++ b/sins/mutation.py @@ -55,13 +55,18 @@ def generation(queue: Queue, shellcode: bytes): def growth(*, shellcode: bytes, length: int) -> bytes: - for mnemonic, op_str in disasm(shellcode): - if mnemonic == 'nop': - return bytes(shellcode) - if length <= len(shellcode): return bytes(shellcode) + opcodes = disasm(shellcode) + + if len(shellcode) > len(opcodes) * 8: + return bytes(shellcode) + + for mnemonic, op_str in opcodes: + if mnemonic == 'nop': + return bytes(shellcode) + shellcode = bytearray(shellcode) shellcode += b'\x90'