Hackappatoi CTF 2022 - [PWN] Sanity drink
·
CTF/Solved
1. intro 2. code 및 분석 2.1. code int __cdecl main(int argc, const char **argv, const char **envp) { char user_password[32]; // [rsp+0h] [rbp-50h] BYREF char otp_password[32]; // [rsp+20h] [rbp-30h] BYREF unsigned __int64 v7; // [rsp+48h] [rbp-8h] v7 = __readfsqword(0x28u); puts("------------------------------------------------------------"); puts("---------------[ Pwners Secret Club Access ]-----..
[App system] ELF x86 - Stack buffer overflow basic 5
·
Wargame/Root me
1. intro 2. code 및 분석 2.1. code #include #include #include #include #include #include #define BUFFER 512 struct Init { char username[128]; uid_t uid; pid_t pid; }; void cpstr(char *dst, const char *src) { for(; *src; src++, dst++) { *dst = *src; } *dst = 0; } void chomp(char *buff) { for(; *buff; buff++) { if(*buff == '\n' || *buff == '\r' || *buff == '\t') { *buff = 0; break; } } } struct Init ..
basic_exploitation_001
·
Wargame/Dreamhack
#include #include #include #include void alarm_handler() { puts("TIME OUT"); exit(-1); } void initialize() { setvbuf(stdin, NULL, _IONBF, 0); setvbuf(stdout, NULL, _IONBF, 0); signal(SIGALRM, alarm_handler); alarm(30); } void read_flag() { system("cat /flag"); } int main(int argc, char *argv[]) { char buf[0x80]; initialize(); gets(buf); return 0; } 앞선 문제와 다르게 이번에는 gets로 문자열을 입력받는다. 또한 read_flag ..
basic_exploitation_000
·
Wargame/Dreamhack
서버에 접속해서 실제로 값을 넣어보면 접속 시마다 buf의 주소가 변경되는 것을 보아 ASLR 즉, 랜덤 스택 보호 기법이 걸려있음을 알 수 있다. ┌──(kali㉿kali)-[~/Downloads/1] └─$ nc host3.dreamhack.games 13445 buf = (0xfff4d778) a ┌──(kali㉿kali)-[~/Downloads/1] └─$ nc host3.dreamhack.games 13445 buf = (0xffa4f748) a 코드를 보면 #include #include #include #include void alarm_handler() { puts("TIME OUT"); exit(-1); } void initialize() { setvbuf(stdin, NULL, _ION..
[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..