Current location: Hot Scripts Forums » Programming Languages » C/C++ » Example of Buffer Overrun and Overcoming it


Example of Buffer Overrun and Overcoming it

Reply
  #1 (permalink)  
Old 11-12-06, 08:43 PM
ashali19 ashali19 is offline
New Member
 
Join Date: Nov 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Example of Buffer Overrun and Overcoming it

Dear Experts,


I have to demonstrate my understanding on buffer overrun by writing a code that has buffer overrun.I also have to choose a C++ function other than strcpy.I have to write a C++ program that prints out the balance of deposits of a customer( 3 cutomers).Their balances are hard coded in the program.Each customer has a password and associated salt code which is also hard coded.The program checks only the first eight characters of a password input; namely, check the following equality for access control:

StoredSalt||StoredPassword = StoredSalt||EnteredPassword

The intended usage and output are as follows:



bank Customer_Name Password



A sample run (not real):



C:\> bank Alice Alice123

The balance for Alice is $1234



Address of update = 00401328



77C5ACA0

77C3E6AD

77F944A8

00000007

003D2BC8

. . .


There is a function named “update” in the program. It adds $2000 to the balance so that the printout can be the sum of the balance: $2000 + the-hard-coded-balance. The buffer problem in the code allows a customer to illegally invoke this function.Can someone help me on this?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 11-13-06, 04:46 PM
King Coder King Coder is offline
Community VIP
 
Join Date: Jan 2006
Posts: 703
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Can someone help me on this?
Please show effort when posting homework problems. I nor anyone here will do your homework for you. SHOW EFFORT!
__________________
my site
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 11-15-06, 11:53 PM
ashali19 ashali19 is offline
New Member
 
Join Date: Nov 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Smile Help on buffer overrun

Dear expert,


i am sorry for the help i have asked.i have put in effort and was able to do the program in c.However i need to use c++ to do the functions.

Right now i am printing the address in C such that:

printf("\nMy stack looks like:\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\ n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n% p\n%p\n%p\n");

The above will print the addresses.I need to use C++ to do display the addresses.

cout<<"address arguments";

i have used #include<iostream> but it does not work???is there some other sytax i should use??

rgds
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 11-17-06, 03:52 PM
King Coder King Coder is offline
Community VIP
 
Join Date: Jan 2006
Posts: 703
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by ashali19
Dear expert,


i am sorry for the help i have asked.i have put in effort and was able to do the program in c.However i need to use c++ to do the functions.

Right now i am printing the address in C such that:

printf("\nMy stack looks like:\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\ n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n% p\n%p\n%p\n");

The above will print the addresses.I need to use C++ to do display the addresses.

cout<<"address arguments";

i have used #include<iostream> but it does not work???is there some other sytax i should use??

rgds
cout is right, but I'm not sure what you're wanting with this portion of code:

Code:
printf("\nMy stack looks like:\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n");
Are you just wanting to print the address of the stack? If so, the '&' can give you the address. For instance:

Code:
int b = 5;
cout << &b << endl;
Will print the address of b

printf will work just as good.
__________________
my site
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -5. The time now is 07:33 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.