Question: in C++ please Do the following exercises in the sequence indicated. Get as much done as you can within the given lab time. When you

in C++ please

Do the following exercises in the sequence indicated. Get as much done as you can within the given lab time. When you are done with each exercise, demonstrate your running programs to the lab instructor, print your programs and hand them in with your name on them.

When you seem to have gotten stuck with a task, try to locate your error. If you still cannot locate your error ask the lab instructor for help.

Click here to copy a very bad program (compliments to Dr. Botting).

1- First, run the program with name 'botting' and try passwords 'x', 'xx', 'xxxx', 'xxxxxx', and so on.... what happens with each? Any unexpected logins? Explain what is happening. (Hint look at the memory addresses of the character arrays.)

2- Rewrite the program. Get rid of those nasty arrays and replace them with string data types.

3- After you show the instructor your work, use the extra time to finish the homework assignment.

-----------------

/* Simple buffer overflow example RJBotting 9/27/2004 Warning this is an example with many pieces of insecure code and information. Inspired by INSIDE THE BUFFER OVERFLOW ATTACK: MECHANISM, METHOD, & PREVENTION Mark E. Donaldson, SANS Corporation. April 3, 2002 GSEC Version 1.3 */ #include  #include  #include  #include  #include  using namespace std; void get(char* askfor, int numchars, char* input); void get_password(char* name, char* pwd); int main() { // Change these character arrays to strings. char name[8]; char pwd[8]; char passwd[8]; cout << "Address of name =" << &name <<" "; cout << "Address of pwd =" << &pwd <<" "; cout << "Address of passwd =" << &passwd <<" "; char Name[5]="Name"; char Password[9]="Password"; bool authenticated=false; while(! authenticated) { // input the name here get(Name, 7, name); // get the password pwd for the name get_password(name, pwd); // input a password passwd get(Password, 7, passwd); // cout <>input; return; } void get_password(char* name, char* pwd) { // Yuch! This returns pwd depending on the variable name // Rewrite so it accepts a string name and returns a string if(!strcmp(name,"botting")) strcpy(pwd, "123456"); else if(!strcmp(name,"ernesto")) strcpy(pwd, "765432"); else if(!strcmp(name,"tong")) strcpy(pwd, "234567"); else strcpy(pwd, "qwert"); return; } 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!