[Cryptanalysis] Encoding - ASCII
·
Wargame/Root me
아.... format string bug 3 풀어야되는데... 너무 안풀린다... ㅠㅠ 본 문제는 딱 보자마자 hex로 저장된 ascii 문자열이다. 파이썬을 이용해 해결. ┌──(kali㉿kali)-[~/Downloads] └─$ python Python 3.10.4 (main, Mar 24 2022, 13:07:27) [GCC 11.2.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> a='4C6520666C6167206465206365206368616C6C656E6765206573743A203261633337363438316165353436636436383964356239313237356433..
[Cracking] ELF x86 - 0 protection
·
Wargame/Root me
system, format string bug 3이 막혀 푸는 문제 2탄. 문제 파일을 다운받아보면 .bin 파일이고, 제목에서 보듯 elf x86 파일이다. 보통 크래킹 문제는 flag가 파일 내에 포함되어있는 경우가 많고, 그게 아니라면 flag를 암호화 & 복호화 하는 경우가 대부분인 것 같다. 1번 문제니 그냥 string을 뽑아봤고, 혹시나했던게 역시나 였다. ┌──(kali㉿kali)-[~/Downloads] └─$ strings ch1.bin /lib/ld-linux.so.2 __gmon_start__ libc.so.6 _IO_stdin_used puts realloc getchar __errno_location malloc stderr fprintf strcmp strerror __libc..
[App-Script] Bash - System 1
·
Wargame/Root me
1. intro 2. code 및 분석 2.1. code #include #include #include int main(void) { setreuid(geteuid(), geteuid()); system("ls /challenge/app-script/ch11/.passwd"); return 0; } 2.2. 분석 ㅁㄴㅇㄹ 3. 취약점 확인 및 공격 준비 3.1. 취약점 ㅁㄴㅇㄹ 3.2. 공격 준비 ㅁㄴㅇㄹ 4. exploit ㅁㄴㅇㄹ system 문제 풀다가 format string bug 3에서 막혀서 푸는 다른 문제... ㅠㅠ script 문제는 hackerschool의 ftz 느낌이 많이 난다. 코드에서 보듯이 ls로 .passwd 파일을 실행시키는데, 간단히 ls 명령어가 cat 명령어를 실행시..
[App-System] ELF x86 - Format String Bug Basic 3
·
Wargame/Root me
1. intro 2. code 및 분석 2.1. code #include #include #include #include int main(int argc, char ** argv) { // char log_file = "/var/log/bin_error.log"; char outbuf[512]; char buffer[512]; char user[12]; char *username = "root-me"; // FILE *fp_log = fopen(log_file, "a"); printf("Username: "); fgets(user, sizeof(user), stdin); user[strlen(user) - 1] = '\0'; if (strcmp(user, username)) { sprintf (buffe..
[App-System] ELF x86 - Stack buffer overflow basic 6
·
Wargame/Root me
1. intro 2. code 및 분석 2.1. code #include #include #include #include int main (int argc, char ** argv){ char message[20]; if (argc != 2){ printf ("Usage: %s \n", argv[0]); return -1; } setreuid(geteuid(), geteuid()); strcpy (message, argv[1]); printf ("Your message: %s\n", message); return 0; } 2.2. 분석 argv[1]을 message 변수에 복사하고 이를 출력한다. 3. 취약점 확인 및 공격 준비 3.1. 취약점 argv[1]의 크기를 체크하지 않아 overflow가 발생..
[App-System] ELF x86 - Stack buffer overflow basic 4
·
Wargame/Root me
1. intro 2. code 및 분석 2.1. code #include #include #include #include struct EnvInfo { char home[128]; char username[128]; char shell[128]; char path[128]; }; struct EnvInfo GetEnv(void) { struct EnvInfo env; char *ptr; if((ptr = getenv("HOME")) == NULL) { printf("[-] Can't find HOME.\n"); exit(0); } strcpy(env.home, ptr); if((ptr = getenv("USERNAME")) == NULL) { printf("[-] Can't find USERNAME.\n..
[App-System] ELF x64 - Double free
·
Wargame/Root me
1. intro 2. code 및 분석 2.1. code #include #include #include #include struct Zombie { int hp; void (*hurt)(); void (*eatBody)(); void (*attack)(); int living; }; struct Human { int hp; void (*fire)(int); void (*prayChuckToGiveAMiracle)(); void (*suicide)(); int living; }; struct Zombie *zombies[3]; struct Human *human = NULL; void fire(int zombieIndex) { struct Zombie *zombie = zombies[zombieIndex..
[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 x86 - BSS buffer overflow
·
Wargame/Root me
1. intro 2. code 및 분석 2.1. code #include #include char username[512] = {1}; void (*_atexit)(int) = exit; void cp_username(char *name, const char *arg) { while((*(name++) = *(arg++))); *name = 0; } int main(int argc, char **argv) { if(argc != 2) { printf("[-] Usage : %s \n", argv[0]); exit(0); } cp_username(username, argv[1]); printf("[+] Running program with username : %s\n", username); _atexit(..
[App-System] ELF x86 - Use After Free - basic
·
Wargame/Root me
1. intro 2. code 및 분석 2.1. code #include #include #include #include #define BUFLEN 64 struct Dog { char name[12]; void (*bark)(); void (*bringBackTheFlag)(); void (*death)(struct Dog*); }; struct DogHouse{ char address[16]; char name[8]; }; int eraseNl(char* line){ for(;*line != '\n'; line++); *line = 0; return 0; } void bark(){ int i; for(i = 3; i > 0; i--){ puts("UAF!!!"); sleep(1); } } void b..