From 8ea7e400f51f9d59dee9352d3955171018f87782 Mon Sep 17 00:00:00 2001 From: perillamint Date: Sun, 2 Aug 2020 05:30:06 +0900 Subject: [PATCH] Implement padding for small payload --- fusee-launcher.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fusee-launcher.py b/fusee-launcher.py index 0c5e7ce..12c1cc9 100755 --- a/fusee-launcher.py +++ b/fusee-launcher.py @@ -642,6 +642,13 @@ with open(payload_path, "rb") as f: # Fit a collection of the payload before the stack spray... padding_size = STACK_SPRAY_START - PAYLOAD_START_ADDR + +if len(target_payload) < padding_size: + # Add NOP tail to correct heap spray location + tail_len = padding_size - len(target_payload) + print(f"Padding payload with {tail_len} byte of zeroes") + target_payload += bytearray(tail_len) + payload += target_payload[:padding_size] # ... insert the stack spray...