Skip to content
Memory corruption Write-up Intermediate

Exploiting Stack Buffer Overflow Step By Step Reverse Engineering

A stack buffer overflow in a Windows application allowed an attacker to overwrite the EIP register and redirect execution to shellcode, resulting in a remote shell. The author demonstrates the exploitation process step by step using a TryHackMe challenge.

Medusa Follow

Published on systemweakness.com

In this blog, we are going to see every step that is required to exploit Stack Buffer Overflow with the help of Immunity Debugger.

Medusa, on systemweakness.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the application copied user-supplied input into a fixed-size stack buffer without checking its length, allowing the return address to be overwritten.

Impact

An attacker could execute arbitrary code and obtain a remote shell on the target system.

What the attacker needed

Network access to the vulnerable service; ability to send data to the service

How it was found

  1. Send increasing amounts of data to the application until it crashes to find the minimum crash size.
  2. Generate a unique pattern and send it to determine which bytes overwrite the EIP register.
  3. Calculate the exact offset using the pattern offset tool.
  4. Confirm the offset by sending a buffer with a known marker at the offset and checking the EIP value.
  5. Find available space for shellcode in the ESP register.
  6. Identify bad characters by comparing memory with a generated byte array.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

A stack buffer overflow happens when a program writes more data into a fixed-size memory area than it can hold, spilling over into nearby memory. Here, the spilled data overwrote a special pointer that tells the program where to go next, letting the attacker point it at their own code and take control.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

More by Medusa

View all

10 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.