본문 바로가기

시스템 해킹59

[HackCTF] Basic_BOF #2 int __cdecl main(int argc, const char **argv, const char **envp) { char buf[128]; // [esp+Ch] [ebp-8Ch] BYREF void (*v5)(void); // [esp+8Ch] [ebp-Ch] v5 = (void (*)(void))sup; fgets(buf, 133, stdin); v5(); return 0; } 32비트 elf 파일을 ida로 분석하면 위와 같습니다. gdb로 확인하면 buf의 위치는 ebp-0x8c 이고 v5 함수는 ebp-0xc 위치에 있습니다. 따라서 buf와 v5함수는 128만큼의 거리가 있고 fgets로 133까지 입력할 수 있으므로 버퍼오버플로우가 일어나게 된다. 이때 IDA에서 shell을 실행할 수.. 2021. 9. 12.
[HackCTF] Basic_BOF #1 int __cdecl main(int argc, const char **argv, const char **envp) { char s[40]; // [esp+4h] [ebp-34h] BYREF int v5; // [esp+2Ch] [ebp-Ch] v5 = 0x4030201; fgets(s, 45, stdin); printf("\n[buf]: %s\n", s); printf("[check] %p\n", (const void *)v5); if ( v5 != 0x4030201 && v5 != 0xDEADBEEF ) puts("\nYou are on the right way!"); if ( v5 == 0xDEADBEEF ) { puts("Yeah dude! You win!\nOpening your shell..... 2021. 9. 10.
[Square CTF] 6yte Name 6yte - You only get 6 of them Points 1000 points Type Exploit Description Our operatives found this site, which appears to control some of the androids’ infrastructure! There are only two problems. The robots love x86 assembly; the only thing easier for them to work with is binary. And they love terse command codes. Even 7 bytes was too many for this one. [DOCKER] docker run --rm -p 8080:80.. 2021. 9. 4.
[Square CTF] Bytes Name Bytes - You can use a lot of bytes. Points 50 points Type Exploit Description Our operatives found this site, which appears to control some of the androids’ infrastructure! The robots love x86 assembly; the only thing easier for them to work with is binary. 64 bytes should be enough for anyone. [DOCKER] docker run --rm -p 8080:8080 squarectf/bytes then visit http://localhost:8080/ [VMware] .. 2021. 9. 4.
[Pwnable.kr] ascii_easy #include #include #include #include #include #include #define BASE ((void*)0x5555e000) int is_ascii(int c){ if(c>=0x20 && c 2021. 8. 23.
[Pwnable.kr] otp #include int main(int argc, char* argv[]){ char fname[128]; unsigned long long otp[2]; if(argc!=2){ printf("usage : ./otp [passcode]\n"); return 0; } int fd = open("/dev/urandom", O_RDONLY); if(fd==-1) exit(-1); if(read(fd, otp, 16)!=16) exit(-1); // urandom 파일에서 16바이트만큼 읽어와서 otp에 저장 close(fd); sprintf(fname, "/tmp/%llu", otp[0]); // "tmp/otp[0]" 문자열 fname에 저장 FILE* fp = fopen(fname, "w"); // "t.. 2021. 8. 21.
[Pwnable.kr] brain fuck int __cdecl do_brainfuck(char a1) { int result; // eax _BYTE *v2; // ebx result = a1 - 43; switch ( a1 ) { case '+': result = p; ++*(_BYTE *)p; break; case ',': v2 = (_BYTE *)p; result = getchar(); *v2 = result; break; case '-': result = p; --*(_BYTE *)p; break; case '.': result = putchar(*(char *)p); break; case '': result = ++p; break; case '[': result = puts("[ and ] not supported."); break; .. 2021. 8. 21.
보호기법 정리 ASLR: 스택, 힙, 라이브러리, 등의 주소를 랜덤한 영역에 배치하여, 공격에 필요한 Target address를 예측하기 어렵게 만든다. 즉, 프로그램이 실행 될 때 마다 각 주소들이 변경됨 NX: NX특성으로 지정된 모든 메모리 구역은 데이터 저장을 위해서만 사용되며, 프로세스 명령어가 그 곳에 상주하지 않음으로써 실행되지 않도록 만들어 준다. Canary: 버퍼 오버플로가 발생하면 Canary 값이 손상되며, Canaries 데이터의 검증에 실패하여, 오버플로에 대한 경고가 출력되고, 손상된 데이터를 무효화 처리 출처: https://c0wb3ll.tistory.com/ 2021. 8. 20.
[Nebula] Level 03 LEVEL 03 Check the home directory of flag03 and take note of the files there. There is a crontab that is called every couple of minutes. To do this level, log in as the level03 account with the password level03. Files for this level can be found in /home/flag03. Source code There is no source code available for this level. flag02 디렉터리로 이동하면 writable.d 디렉토리와 writable.sh 스크립트 파일이 존재한다. 스크립트 파일의 내용.. 2021. 8. 19.