26.07.2018 Views

hacking-the-art-of-exploitation

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

This section consists <strong>of</strong> many jump instructions, each one corresponding to<br />

<strong>the</strong> address <strong>of</strong> a function. It works like a springboard—each time a shared<br />

function needs to be called, control will pass through <strong>the</strong> PLT.<br />

An object dump disassembling <strong>the</strong> PLT section in <strong>the</strong> vulnerable format<br />

string program (fmt_vuln.c) shows <strong>the</strong>se jump instructions:<br />

reader@<strong>hacking</strong>:~/booksrc $ objdump -d -j .plt ./fmt_vuln<br />

./fmt_vuln:<br />

file format elf32-i386<br />

Disassembly <strong>of</strong> section .plt:<br />

080482b8 :<br />

80482b8: ff 35 6c 97 04 08 pushl 0x804976c<br />

80482be: ff 25 70 97 04 08 jmp *0x8049770<br />

80482c4: 00 00 add %al,(%eax)<br />

...<br />

080482c8 :<br />

80482c8: ff 25 74 97 04 08 jmp *0x8049774<br />

80482ce: 68 00 00 00 00 push $0x0<br />

80482d3: e9 e0 ff ff ff jmp 80482b8 <br />

080482d8 :<br />

80482d8: ff 25 78 97 04 08 jmp *0x8049778<br />

80482de: 68 08 00 00 00 push $0x8<br />

80482e3: e9 d0 ff ff ff jmp 80482b8 <br />

080482e8 :<br />

80482e8: ff 25 7c 97 04 08 jmp *0x804977c<br />

80482ee: 68 10 00 00 00 push $0x10<br />

80482f3: e9 c0 ff ff ff jmp 80482b8 <br />

080482f8 :<br />

80482f8: ff 25 80 97 04 08 jmp *0x8049780<br />

80482fe: 68 18 00 00 00 push $0x18<br />

8048303: e9 b0 ff ff ff jmp 80482b8 <br />

08048308 :<br />

8048308: ff 25 84 97 04 08 jmp *0x8049784<br />

804830e: 68 20 00 00 00 push $0x20<br />

8048313: e9 a0 ff ff ff jmp 80482b8 <br />

reader@<strong>hacking</strong>:~/booksrc $<br />

One <strong>of</strong> <strong>the</strong>se jump instructions is associated with <strong>the</strong> exit() function,<br />

which is called at <strong>the</strong> end <strong>of</strong> <strong>the</strong> program. If <strong>the</strong> jump instruction used for<br />

<strong>the</strong> exit() function can be manipulated to direct <strong>the</strong> execution flow into<br />

shellcode instead <strong>of</strong> <strong>the</strong> exit() function, a root shell will be spawned. Below,<br />

<strong>the</strong> procedure linking table is shown to be read only.<br />

Exploitation 191

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!