Home Forums Gamescan Chat42 About
* Login   * Register * FAQ    * Search
It is currently Sun 02-01-2026 2:56AM

All times are UTC - 6 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Hex help
PostPosted: Tue 10-12-2004 2:49PM 
Offline
Cookie Monster
Cookie Monster
User avatar

Joined: Mon 05-12-2003 6:27PM
Posts: 423
Location: Rolla

Source: TJ Hall
Hey, I am having a problem converting ascii hex into actual hex in C.

This is what I am trying to do:
a.out -h 080483c4

I want to turn that hex number that is getting input in ASCII format to be converted into hex format in a character array like this:

myarray[4] : [0xc4][0x83][0x04][0x08] <= little indian

Does anyone know how to do this? I have looked all over and can't find out how. If anyone has a quick answer that would like to share... I appreciate it.

Thanks,
Brandon


Top
 Profile  
    
 Post subject:
PostPosted: Tue 10-12-2004 3:25PM 
Offline
Captain
User avatar

Joined: Tue 01-28-2003 8:22AM
Posts: 161

Source: Off Campus
First off, it's little endian, not indian.

Second, read it in to a char array as a temp, then use sscanf on it. You can use that to parse out hex numbers (I believe the format is %2x to indicate 2 characters as hex). So it would look something like this (btw, this may not work 100%, this is going off the top of my head without testing it):

argv[2] is assumed to be the 080483c4 read from the command line, since you are passing in variables to main.

char myarray[4];
sscanf(argv[2], "%2x%2x%2x%2x", &myarray[3], &myarray[2], &myarray[1], &myarray[0]);


Top
 Profile E-mail  
    
 Post subject:
PostPosted: Tue 10-12-2004 6:59PM 
Offline
Cookie Monster
Cookie Monster
User avatar

Joined: Mon 05-12-2003 6:27PM
Posts: 423
Location: Rolla

Source: MST-PSK Wireless
Thanks Cecil,

You were right on about the sscanf() command and the arguments. I was building a small/simple tool to allow me to easily exploit code vulnerable to stack overflows. I have uploaded the source code for it to my website.

http://web.umr.edu/~bmpfg8/add_of.c

I know you can do some tricks with python at the command line, but I like sticking to good old C and ASM. One thing to note if you are going to test out the code: You need to enter your Hex Address without 0x or 0X. That is something sscanf is suppose to handle... but doesn't (at least it doesn't appear to work for me). It can handle up to a 32bit address.

Thanks again,
Brandon


Top
 Profile  
    
 Post subject:
PostPosted: Wed 10-13-2004 7:16AM 
Offline
Major
User avatar

Joined: Fri 01-25-2002 12:35PM
Posts: 316
Location: Your Mom

Source: CSF Building
Brandito wrote:
Thanks Cecil,

You were right on about the sscanf() command and the arguments. I was building a small/simple tool to allow me to easily exploit code vulnerable to stack overflows. I have uploaded the source code for it to my website.

http://web.umr.edu/~bmpfg8/add_of.c

I know you can do some tricks with python at the command line, but I like sticking to good old C and ASM. One thing to note if you are going to test out the code: You need to enter your Hex Address without 0x or 0X. That is something sscanf is suppose to handle... but doesn't (at least it doesn't appear to work for me). It can handle up to a 32bit address.

Thanks again,
Brandon


Well my my, aren't you a l33t h4x0r. :roll:

_________________
All right, they're on our left, they're on our right, they're in front of us, they're behind us...they can't get away this time
-Lieutenant General Lewis B. Puller, USMC

Don't Be Gay


Top
 Profile  
    
 Post subject:
PostPosted: Wed 10-13-2004 11:43AM 


Source: Somewhere
Gay Mother Fucker,

rr... the code I wrote really isn't that "l33t". It is pretty basic.... but anyways... your sarcasm is duely noted.

Thanks,
Brandito


Top
  
    
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group