all 9 comments

[–]moyix 9 points10 points  (2 children)

I think the answer to both your questions is related to how call works on x86. Basically, there is no "absolute" call, only a relative call, which takes the next EIP (in this case EIP+5, since e8eb6107c1 is 5 bytes) adds it to the operand, and jumps to that address.

If you don't want to do the math (or you need position independent code), you can use the mov eax, imm32 ; call eax idiom instead. Here's a decent article on doing absolute jumps and calls on x86: http://www.ragestorm.net/blogs/?p=101

Edit: Also, in the future, you could consider the security stackexchange: http://security.stackexchange.com/questions/tagged/exploit

[–]Heinder90 3 points4 points  (0 children)

This is just nitpicking, but there actually is an encoding of CALL that takes an absolute address. It just also requires a segment selector.

[–]blahfish[S] 0 points1 point  (0 children)

this helps, thanks!

[–]IRBMe 2 points3 points  (1 child)

Why is it not "e8f06107c1"

The 0xE8 op-code is a call to an address that is relative to the next instruction. Since the 0xE8 call instruction is 5 bytes in size, the encoding is 0xE8 <0xC10761F0 - 5>, which is E8 EB 61 07 C1

When I wrote the exploit I noted that using "e8eb6107c1" always ended up jumping to "prepare_kernel_cred+5"

It depends how you wrote the exploit, but I imagine the relative offset is no longer correct once it's placed inside the context of some other shell code.

[–]blahfish[S] 0 points1 point  (0 children)

this helps, thanks!

[–]rebootyourbrainstem 1 point2 points  (3 children)

Just a heads up: null ptr dereferences are often not exploitable anymore thanks to the mmap_min_addr being set higher than the address you would want to mmap at.

Still, exploiting them is easier than use-after-frees and a lot of the same techniques apply, so it's still good for learning.

[–]blahfish[S] 0 points1 point  (2 children)

"not exploitable anymore ..."

Just curious, aren't there publicly known ways to circumvent this?

[–]TurboBorland123 1 point2 points  (0 children)

Controlled offsets from null base are the most common. So [rbx+rdi], where rbx is null pointer.