Question: The following program takes a password as input but always refuses to generate lottery numbers: lottery.cpp Luckily, the program is vulnerable to a buffer overrun
The following program takes a password as input but always refuses to generate lottery numbers:
lottery.cpp
Luckily, the program is vulnerable to a buffer overrun in the goodPassword procedure. The goal is to take advantage of the vulnerability so that it can generate lucky numbers for us
a Draw a diagram showing how the stack is arranged when this program runs.
b Figure out a password that can make the program output a lucky number. Hint: no need to overwrite the return address; there is an easier target to overwrite in this program.Explain how your password works.
c Rewrite the program so that it no longer has a buffer vulnerability.
#include
using namespace std;
char goodPassword
int good N;
char Password; Memory storage for the password
cinPassword; Get input from keyboard
return chargood;
int main
cout"Enter your password:"
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
