Image
 
linkedin_logo.png rss_logo.jpg
twitter_logo.png youtube_logo.jpg
Latest Additions
 
EH-Net Login
Welcome Guest.






Lost Password?
No account yet? Register
Who's Online
We have 49 guests and 7 members online
EH-Net News Feeds
Latest Additions
 
Advertisement

You are here: Home arrow Forum arrow Ethical Hacking Discussions and Related Certificationsarrow Network Pen Testingarrow Trying to understand i686 architecture
EH-Net
May 25, 2012, 01:18:48 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Advertise on EH-Net!! - Reasonable Rates, Highly Targeted Audience.
 
   Home   Help Calendar Login Register  
Pages: 1 [2]   Go Down
  Print  
Author Topic: Trying to understand i686 architecture  (Read 8611 times)
0 Members and 1 Guest are viewing this topic.
jacksmash
Newbie
*
Offline Offline

Posts: 14


View Profile
« Reply #15 on: February 25, 2010, 11:34:40 AM »

Skip the 2nd question... I should have been using "x/8x", duh. This is the output I get...

(gdb) x/8x buffer1
0xbffff467:   0x04846000   0xfff48808   0xfff488bf   0x04842bbf
0xbffff477:   0x00000108   0x00000200   0x00000300   0x00000000

And then main:

(gdb) disas main
Dump of assembler code for function main:
0x08048402 <main+0>:   push   %ebp
0x08048403 <main+1>:   mov    %esp,%ebp
0x08048405 <main+3>:   sub    $0x10,%esp
0x08048408 <main+6>:   movl   $0x0,-0x4(%ebp)
0x0804840f <main+13>:   movl   $0x3,0x8(%esp)
0x08048417 <main+21>:   movl   $0x2,0x4(%esp)
0x0804841f <main+29>:   movl   $0x1,(%esp)
0x08048426 <main+36>:   call   0x80483e4 <function>
0x0804842b <main+41>:   movl   $0x1,-0x4(%ebp)
0x08048432 <main+48>:   mov    $0x8048510,%eax
0x08048437 <main+53>:   mov    -0x4(%ebp),%edx
0x0804843a <main+56>:   mov    %edx,0x4(%esp)
0x0804843e <main+60>:   mov    %eax,(%esp)
0x08048441 <main+63>:   call   0x804831c <printf@plt>
0x08048446 <main+68>:   leave 
0x08048447 <main+69>:   ret   
End of assembler dump.


Something definitely isn't right if you look at the last address for buffer1
Logged
zeroflaw
Full Member
***
Offline Offline

Posts: 184



View Profile
« Reply #16 on: February 25, 2010, 11:39:37 AM »

Doh! Yea x/8 doesn't work on every system. Maybe you should try "x/16x" to show more of the stack.

ZF
Logged

ZF
jacksmash
Newbie
*
Offline Offline

Posts: 14


View Profile
« Reply #17 on: February 25, 2010, 12:51:51 PM »

Ok, so I got this all figured out.

In case anyone else ever reads this, I was using gcc version 4.. and Ubuntu 9.04... so there's clearly some things I don't understand there. Going back to Ubuntu 7.10, I was able to get this working using zeroflaw's directions.

Thanks!!
Logged
jacksmash
Newbie
*
Offline Offline

Posts: 14


View Profile
« Reply #18 on: February 25, 2010, 01:32:30 PM »

I'm getting a little closer on Ubuntu 9.04.

If you compile as follows:
Code:
gcc -g -mpreferred-stack-boundary=2 -o e3 example3.c

and then do the following with gdb:

(gdb) b 2
Breakpoint 1 at 0x804844a: file example3.c, line 2.
(gdb) run
Starting program: /home/joel/hacking/stacksmash/e3

Breakpoint 1, function (a=1, b=2, c=3) at example3.c:2
2   void function(int a, int b, int c) {
(gdb) x/8x buffer1
0xbffff457:   0xfff48808   0x0484f9bf   0x6fe30408   0x6fdff400
0xbffff467:   0x0484e000   0xfff48808   0xfff488bf     0x0484a7bf
(gdb) disas main
Dump of assembler code for function main:
0x0804847e <main+0>:   push   %ebp
0x0804847f <main+1>:   mov    %esp,%ebp
0x08048481 <main+3>:   sub    $0x10,%esp
0x08048484 <main+6>:   movl   $0x0,-0x4(%ebp)
0x0804848b <main+13>:   movl   $0x3,0x8(%esp)
0x08048493 <main+21>:   movl   $0x2,0x4(%esp)
0x0804849b <main+29>:   movl   $0x1,(%esp)
0x080484a2 <main+36>:   call   0x8048444 <function>
0x080484a7 <main+41>:   movl   $0x1,-0x4(%ebp)
0x080484ae <main+48>:   mov    $0x8048590,%eax
0x080484b3 <main+53>:   mov    -0x4(%ebp),%edx
0x080484b6 <main+56>:   mov    %edx,0x4(%esp)
0x080484ba <main+60>:   mov    %eax,(%esp)
0x080484bd <main+63>:   call   0x8048364 <printf@plt>
0x080484c2 <main+68>:   leave 
0x080484c3 <main+69>:   ret   
End of assembler dump.


.... you will see that you can find most of the return address... but something is a bit weird since it is offset a bit. It is almost 28 bytes away from the start of buffer1... but not quite. Almost seems like it's 27 bytes away... but that doesn't seem to make much sense to me!

Not sure if this helps any...
Logged
zeroflaw
Full Member
***
Offline Offline

Posts: 184



View Profile
« Reply #19 on: February 25, 2010, 03:47:33 PM »

I'm not getting it to work on 9.* either. The funny thing is that I tried to compile it on a Ubuntu 9.10 x64 virtual machine. Used the same methods to find the distance between buffer1 and the return address etc. It actually worked!

It has something to do with the alignment on the stack. It just has to be some option or maybe a bug  Huh Huh Huh

ZF
Logged

ZF
jacksmash
Newbie
*
Offline Offline

Posts: 14


View Profile
« Reply #20 on: February 25, 2010, 04:04:26 PM »

Did you type that wrong? Do you mean you tried it on Ubuntu 7.10 x64 and it really worked?
Logged
zeroflaw
Full Member
***
Offline Offline

Posts: 184



View Profile
« Reply #21 on: February 25, 2010, 04:56:17 PM »

Lol I did mean 9.10. I recently upgraded Tongue Still confused about 32 bit version and stack alignment.

ZF
Logged

ZF
jacksmash
Newbie
*
Offline Offline

Posts: 14


View Profile
« Reply #22 on: February 25, 2010, 05:06:57 PM »

Oh... wow, my apologies! I didn't think it was reasonable to not work on 9.04, but work on 9.10!! Maybe it is a bug then. Weird.

I'll give it a shot as well.

Joel
Logged
jacksmash
Newbie
*
Offline Offline

Posts: 14


View Profile
« Reply #23 on: February 26, 2010, 08:01:01 AM »

Ok, the problem I posted in "Reply #18" equally applies to 9.10 for me:
Code:
uname -a
Linux my-ubuntu 2.6.31-14-generic #48-Ubuntu SMP Fri Oct 16 14:04:26 UTC 2009 i686 GNU/Linux
Logged
Pages: 1 [2]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines
Joomla Bridge by JoomlaHacks.com
Valid XHTML 1.0! Valid CSS!
Page created in 0.322 seconds with 23 queries.
 

gk_static-ad_feb2012.jpg
Global Knowledge: Build Security Skills to Protect & Defend

els_130x200fixed2.gif
eLearnSecurity Student Course Now Live!
5% Off with Code
ELS-EH-5

SANS Deals 4 EH-Netters
$150 OFF Any SANS Course in Any Format!
Coupon Code: EHN_Connect Including SANS Security West 2012 & SANSFIRE 2012
Recent Forum Topics

cbtnuggets_logo_125.jpg
Try CBT Nuggets Free!

Vote For EH-Net

Add to Technorati Favorites
technorati fave

 
         
Advertisement

© 2012 The Ethical Hacker Network
Joomla! is Free Software released under the GNU/GPL License.