Lecture Security Removed
Lecture Security Removed
#include <stdio.h>
#define BUFFER SIZE 256
int main(int argc, char *argv[])
{
char buffer[BUFFER SIZE];
if (argc < 2)
return -1;
else {
strcpy(buffer,argv[1]); //should use strncpy(buffer, argv[1], sizeof(buffer)-1)
return 0;
}
}
Standard Layout of Typical Stack Frame
Modified Shell Code
#include <stdio.h>
int main(int argc, char *argv[])
{
execvp(‘‘\bin\sh’’,‘‘\bin \sh’’, NULL);// allows full
access to the directory depending on user privileges
return 0;
}
Hypothetical Stack Frame