Protostar stack2
About
Stack2 looks at environment variables, and how they can be set.
This level is at /opt/protostar/bin/stack2
Source code
1#include <stdlib.h> 2#include <unistd.h> 3#include <stdio.h> 4#include <string.h> 5 6int main(int argc, char **argv) 7{ 8 volatile int modified; 9 char buffer[64]; 10 char *variable; 11 12 variable = getenv("GREENIE"); 13 14 if(variable == NULL) { 15 errx(1, "please set the GREENIE environment variable\n"); 16 } 17 18 modified = 0; 19 20 strcpy(buffer, variable); 21 22 if(modified == 0x0d0a0d0a) { 23 printf("you have correctly modified the variable\n"); 24 } else { 25 printf("Try again, you got 0x%08x\n", modified); 26 } 27 28}