문제의 소스코드를 보면 다음과 같다.


#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); }

}


getenv 를 통해 GREENIE라는 환경변수를 가져오고 있다.


그 이후는 기존에 했던 것들과 똑같으며 우리는 환경 변수를 설정해줘야 한다.



export 명령어를 통해 GREENIE라는 환경변수를 설정한 후 환경변수 속에 python으로 exploit code를 삽입한다.


그후 해당 파일을 실행하면 공격이 성공했음을 알 수 있다.





'pwnable > exploit-exercise' 카테고리의 다른 글

stack5  (0) 2017.02.24
stack4  (0) 2017.02.24
stack3  (0) 2017.02.24
stack1  (0) 2016.07.09
stack0  (0) 2016.07.09

+ Recent posts