Skip to content
RCE Write-up Advanced

Got Overwrite

The report explains a GOT overwrite technique where the address of the puts function in the Global Offset Table is replaced with the address of system, so that when puts is called with a buffer containing /bin/sh, a shell is spawned. The attacker can achieve remote code execution if they can write to the GOT.

Monish Kumar Follow

Published on infosecwriteups.com

It is responsible for calling the dynamic linker during and after the program runtime to resolve the addresses of the requested functions

AidenPearce369, on infosecwriteups.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

The program allows writing to the Global Offset Table (GOT) without protection, enabling an attacker to redirect a function call to another function.

Impact

This could lead to remote code execution, allowing an attacker to spawn a shell.

What the attacker needed

Ability to write to the GOT; Knowledge of addresses (PLT, GOT, system)

How it was found

  1. Compile the provided source code.
  2. Disassemble the program using GDB-PEDA to find the PLT address of puts.
  3. From the PLT entry, find the GOT address of puts.
  4. Find the address of system.
  5. Overwrite the GOT entry of puts with the address of system.
  6. Pass /bin/sh as input to the buffer using gets, so that when puts is called, system executes with /bin/sh.

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.

Programs use a table to find the addresses of functions like puts. If an attacker can change the entry for puts to point to system instead, then calling puts will run system. This lets the attacker run commands on the computer.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.