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 48 guests online
 
Advertisement

You are here: Home
EH-Net
May 25, 2013, 05:04:31 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Go back to The Ethical Hacker Network Online Magazine Home Page
 
  Home Help Calendar Login Register  
  Show Posts
Pages: [1]
1  Ethical Hacking Discussions and Related Certifications / Programming / Re: C Code Explanation on: August 05, 2010, 07:08:27 PM
Alright.. here it is.

Overflowing following program:
Code:
void return_input (void) {
char array[30];

gets (array);
printf("%s\n", array);
}

main () {
return_input();

return 0;

}

2. Disas main to get memory location where return_input is called.

Code:
Dump of assembler code for function main:
0x08048412 <main+0>:    push   %ebp
0x08048413 <main+1>:    mov    %esp,%ebp
[b]0x08048415[/b] <main+3>:    call   0x80483f4 <return_input>
0x0804841a <main+8>:    mov    $0x0,%eax
0x0804841f <main+13>:   pop    %ebp
0x08048420 <main+14>:   ret

As you can see, it is called at 0x0804841 I'm confused why you used the actual location of <return_input>

3. I then check to see how much space is reserved for return_input by disas return_input

Code:
Dump of assembler code for function return_input:
0x080483f4 <return_input+0>:    push   %ebp
0x080483f5 <return_input+1>:    mov    %esp,%ebp
0x080483f7 <return_input+3>:    sub    [b]$0x24[/b],%esp
0x080483fa <return_input+6>:    lea    -0x1e(%ebp),%eax
0x080483fd <return_input+9>:    mov    %eax,(%esp)
0x08048400 <return_input+12>:   call   0x8048308 <gets@plt>
0x08048405 <return_input+17>:   lea    -0x1e(%ebp),%eax
0x08048408 <return_input+20>:   mov    %eax,(%esp)
0x0804840b <return_input+23>:   call   0x8048328 <puts@plt>
0x08048410 <return_input+28>:   leave
0x08048411 <return_input+29>:   ret

As you can see.. it reserves 0x24 which in binary is 36. i don't understand why it reserves 36 but in the example in the book it only reserves 0x20 aka 32 .. its the same program.. with the same variable sizes..??

so then the example program used to overwrite the memory locations with the pointer to the <return_input> call is:

Code:
main(){
int i=0;
char stuffing[44];

for (i=0;i<=40;i+=4)
*(long *) &stuffing[i] = 0x80483f4;
puts(stuffing);
}

Since I have 4 bytes extra.. i changed both values to:

Code:
main(){
int i=0;
char stuffing[48];

for (i=0;i<=44;i+=4)
*(long *) &stuffing[i] = 0x08048415;
puts(stuffing);
}

Makes sense.. right?

BTW.. why is stuffing 4 bytes larger.. is there something appended to the end like in strings?

Anyways.. in the end when I feed the program into the overflow program.. it doesn't work.

Below.. i execute the command (./address_to_char;cat) | ./overflow and then it waits for input, i type in "input" and it exits. Completely different then what the book shows.. so it isn't working.. or is it? is the ./address_to_char the first input the program expects .. and my input "input" the second input because it goes back to return_addr?

Code:
(./address_to_char;cat) | ./overflow
input

The book shows something like this:

Code:
(./address_to_char;cat) | ./overflow
input
<<<<<<<<<<<<<a<u____,input
input
input

(page 22)

Lastly.. the command (./address_to_char;cat) | ./overflow .. what exactly is going on there..i thought to input the output of a program to another you would use the ">" command.

If anyone could help me out it would be awesome.. because I can't continue until I understand these basics Cheesy.

Thanks!


Edit: I also used the following options:

-fno-stack-protector

echo 0 > /proc/sys/kernel/randomize_va_space - disable virtual address randomization

gcc -mpreferred-stack-boundary=2 -ggdb
2  Ethical Hacking Discussions and Related Certifications / Cyber Warfare / Chinese on: July 22, 2010, 06:36:02 PM
Seeing as China may be our biggest cyber threat, do you think studying it along with computer security in college will increase the chances of getting a good government job?

Either way, I'm going to study it.. just because people say its very challenging.. and because I'm a big fan of the culture.. and tea.

Herro!
3  Ethical Hacking Discussions and Related Certifications / Programming / Re: C Code Explanation on: July 22, 2010, 06:33:49 PM
Thank you for the responses Cheesy. I'll get back to you with more details on my memory prob.
4  Ethical Hacking Discussions and Related Certifications / Programming / C Code Explanation on: July 20, 2010, 06:47:39 PM
Could someone please explain exactly what is going on in the following code... actually.. just that pointer line.. not exactly sure whats going on.
Code:
main(){
int i=0;
char stuffing[44];

for (i=0;i<=40;i=+4)
*(long *) &stuffing[i] = 0x08048415;
puts(stuffing);
}

Also, I'm going through the shell coders handbook and have a question..

So we are overflowing the following program:
Code:
main(){
int i=0;
char stuffing[44];

for (i=0;i<=40;i=+4)
*(long *) &stuffing[i] = 0x08048415;
puts(stuffing);
}

I compiled it with the mpreferred-stack-boundary=2 option.

Ran it in the same operating system and CPU type as the examples.. this applies to other examples from other sources as well.. so why is it that the amount of memory the cpu allocates on the stack always different.

In the book when this program is run through gdb and return_input is disassembled.. it shows sub $0x20, %esp a.k.a 32.. but on my computer it shows 0x24 or 36...

shouldn't the buffer be the same?

also, this was the same case when I was following along with the BoF series at securitytube.net ... the funny thing though.. was that the code he provided worked for me.. even though gdb showed that we had different memory sizes allocated...

 Huh

5  Resources / Career Central / Re: College time, I need to choose a career. Help? on: October 19, 2009, 09:39:43 AM
So for security, i would be going into the computer science major?
6  Resources / Career Central / Re: College time, I need to choose a career. Help? on: October 13, 2009, 05:02:18 PM
Thanks for all the responses.

One more thing...

Once I get into a college, I need to choose classes. To get into the nursing program, you have a bunch of prerequisite classes to take... to get into the pharmacy program.. same thing.. but how do I know what to take in college for a security career?

Do I take a bunch of related classes? or is there a specific program i take?

Thanks
7  Resources / Career Central / Re: Looking for some advice. on: October 12, 2009, 09:15:46 PM
No I'm not new to this stuff. I've done plenty of reading, I actually have a library of 40+ books just on the topic. I want to go all the way with computer security. So that's why I'm asking about Jobs, and what to look for in colleges.
8  Resources / Career Central / Re: College time, I need to choose a career. Help? on: October 12, 2009, 10:17:43 AM
Awesome, I'm actually on the east coast so I can definitely visit some of those.
9  Resources / Career Central / Re: College time, I need to choose a career. Help? on: October 12, 2009, 09:49:49 AM
Thanks for the suggestion, but military isn't an option for me.
10  Resources / Career Central / Re: College time, I need to choose a career. Help? on: October 12, 2009, 09:18:10 AM
Dale, Thanks for the response. It helped a bit  Smiley .
11  Resources / Career Central / College time, I need to choose a career. Help? on: October 11, 2009, 06:48:20 PM
Hey Everyone!

I need to choose a profession and college ASAP, as I am a senior in high school and it's that time of year. I always wanted to be a Software Engineer, but after some time of thinking, I decided I don't see myself doing that. Instead, I would like to follow career in what I'm most passionate about - Computer Security.

I've been searching the interwebs for jobs in the area, and it seems like they are all so similar, but have different names. For example, a couple job titles I came across were Computer Systems Security Analyst and IT Security Analyst along with a couple others, but they all seem to have the same job description.

I was hoping you experienced peoples could please help me out by naming some job titles in area and what their basic day looks like.

Also, what would I be taking in college? What courses should I be taking? What should I be looking for in a college?

And last but not least, what are some good colleges for computer security. I'm also thinking about minoring in business :-).

I've been learning about computer security/ethical hacking for a couple years now, and I really do enjoy it. I hope you guys/gals could help me out :-).

Cheers,
June
Pages: [1]
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines
Joomla Bridge by JoomlaHacks.com
Valid XHTML 1.0! Valid CSS!
Page created in 0.067 seconds with 22 queries.
 
Exclusive Deal

sansfire13_245x90_cw90.jpg
SANSFIRE 2013
June 15 - 22

5% Off w/ Code: EHN_5

SANS Deals 4 EH-Netters
5% OFF Any SANS Course in Any Format!
Coupon Code: EHN_5 Including SANS Rocky Mountain 2013 & SANS Boston 2013
Polls
Compared to this year, 2013 will be:
 
Recent Forum Topics
EH-Net News Feeds
Latest Additions
 
         
Advertisement

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