| |
Stack overflow exercise.
A code prompts for password, reads it from keyboard, and gives the root shell.
Any given password string, exceeding 11 letters, would corrupt the memory region, containing variable pass, therefore cause the code to
give the root shell.
Exercise
Download the source code and the Makefile:
Compile the source code, and assigne setuid root to the compiled executable:
Run the executable:
When prompted for password, type in a long string:
Notice, you got the root shell.
The way to fix it: use function fgets instead of gets,
for example:
|
|