[App-System] ELF x64 - Stack buffer overflow - PIE
·
Wargame/Root me
1. intro 2. code 및 분석 2.1. code #include #include // Instructions // // gcc -o chall chall.c -Wl,-z,norelro -fno-stack-protector (on the app-systeme-ch61 server for instance, but the goal is to enable NX and PIE) void Winner() { printf("Access granted!\n"); FILE *fp; int c; fp = fopen(".passwd", "r"); if (fp == NULL) { perror("Error while opening the file.\n"); exit(EXIT_FAILURE); } else { print..
[App-System] ELF x64 - Stack buffer overflow - basic
·
Wargame/Root me
1. intro 2. code 및 분석 2.1. code #include #include #include #include #include /* gcc -o ch35 ch35.c -fno-stack-protector -no-pie -Wl,-z,relro,-z,now,-z,noexecstack */ void callMeMaybe(){ char *argv[] = { "/bin/bash", "-p", NULL }; execve(argv[0], argv, NULL); } int main(int argc, char **argv){ char buffer[256]; int len, i; scanf("%s", buffer); len = strlen(buffer); printf("Hello %s\n", buffer); r..
[App-System] ELF x86 - Stack buffer overflow basic 2
·
Wargame/Root me
1. intro 2. code & 분석 #include #include #include #include void shell() { setreuid(geteuid(), geteuid()); system("/bin/bash"); } void sup() { printf("Hey dude ! Waaaaazzaaaaaaaa ?!\n"); } void main() { int var; void (*func)()=sup; char buf[128]; fgets(buf,133,stdin); func(); } 우선 envi. config.에 NX, Heap exec가 걸려있다. 추후에 이에 대해서 다시 한번 정리하기로하고, 간단히 이야기하자면 buffer 내에 의미 있는 코드가 입력되더라도 실행되지는 않게 막아주는 보호 기..
[App-System] ELF x86 - Stack buffer overflow basic 1
·
Wargame/Root me
1. intro 2. code & 분석 #include #include int main() { int var; int check = 0x04030201; char buf[40]; fgets(buf,45,stdin); printf("\n[buf]: %s\n", buf); printf("[check] %p\n", check); if ((check != 0x04030201) && (check != 0xdeadbeef)) printf ("\nYou are on the right way!\n"); if (check == 0xdeadbeef) { printf("Yeah dude! You win!\nOpening your shell...\n"); setreuid(geteuid(), geteuid()); system(..