CTF/바이너리 (7) 썸네일형 리스트형 dreamhack CTF ROUND#10 : Times file명령으로 확인 스트립된 64bit ELF파일임 readelf -h 옵션으로 elf헤더 분석 entry point 가 0x1220인것을 확인 strings명령으로 파일 내부 문자열 전부 추출 함수 이름들, 사용하는 문자열등이 보임 아마 내부적으로 조건을 맞추면 나머지 쓰레기 문자열들을 처리해서 디코딩 후 출력해주는 로직일듯? 메모리 보호기법 확인 checksec.sh https://www.trapkit.de/tools/checksec/ RELRO, NX, PIE가 적용된걸 확인 Full RELRO : bss영역을 제외한 모든 부분에서 write권한이 사라짐 NX : Non eXecute. 데이터 영역(스택, 힙)에서 코드 실행권한을 삭제하는것 (윈도우에선 DEP라 부른다) PIE : 위치 독립 실행.. python 쓸만한 함수들 format 함수 reddb.tistory.com/71 int 바이트오더 변경 import binascii n = 0x12345678 b = bytearray.fromhex(format(n, 'x')) b.reverse() print(hex(int(binascii.hexlify(b), 16))) 정리필요 import binascii local_38 = 0x743f3d3f3d6a6c6c local_30 = 0x62507c66506e6b66 local_28 = 0x6b616a667d695076 local_20 = 0x72 res_s="" n = local_38 b = bytearray.fromhex(format(n, 'x')) b.reverse() #print(hex(int(binascii.hexlify(b.. picoCTF 2019 : CanaRy https://ctf101.org/binary-exploitation/stack-canaries/ Stack Canaries - CTF 101 From here you can search these documents. Enter your search terms below. ctf101.org https://j3rrry.tistory.com/54 picoCTF 2018 buffer overflow 3 Binary Exploitation 요약 4바이트 길이의 canary 값이 고정되어 있기 때문에 1바이트씩 '\x00' 부터 '\xff' 까지 넣어봐서 "stack smash" 가 뜨는지 확인하면 "4xV," 가 canary 임을 알 수 있고 이제 RET에 flag를 출력해주는 함수 el.. j3rrry.ti.. picoCTF 2019 : rop32 https://kblab.tistory.com/223 ROP 기법은 가젯이라는 작은 코드조각들을 모아 원하는 코드를 실행하도록 조립하는 기법이다. #include #include #include #include #include #define BUFSIZE 16 void vuln() { char buf[16]; printf("Can you ROP your way out of this one?\n"); return gets(buf); } int main(int argc, char **argv){ setvbuf(stdout, NULL, _IONBF, 0); // Set the gid to the effective gid // this prevents /bin/sh from dropping the privile.. picoCTF 2019 : OverFlow 1 주어진 소스코드 #include #include #include #include #include #include "asm.h" #define BUFFSIZE 64 #define FLAGSIZE 64 void flag() { char buf[FLAGSIZE]; FILE *f = fopen("flag.txt","r"); if (f == NULL) { printf("Flag File is Missing. please contact an Admin if you are running this on the shell server.\n"); exit(0); } fgets(buf,FLAGSIZE,f); printf(buf); } void vuln(){ char buf[BUFFSIZE]; gets(buf); printf.. picoCTF 2019 : slippery-shellcode 소스코드 #include #include #include #include #include #define BUFSIZE 512 #define FLAGSIZE 128 void vuln(char *buf){ gets(buf); puts(buf); } int main(int argc, char **argv){ setvbuf(stdout, NULL, _IONBF, 0); // Set the gid to the effective gid // this prevents /bin/sh from dropping the privileges gid_t gid = getegid(); setresgid(gid, gid, gid); char buf[BUFSIZE]; puts("Enter your shellcode:"); vuln(.. picoCTF 2019 : handy-shellcode 주어진 소스코드 #include #include #include #include #include #define BUFSIZE 148 #define FLAGSIZE 128 void vuln(char *buf){ gets(buf); puts(buf); } int main(int argc, char **argv){ setvbuf(stdout, NULL, _IONBF, 0); // Set the gid to the effective gid // this prevents /bin/sh from dropping the privileges gid_t gid = getegid(); setresgid(gid, gid, gid); char buf[BUFSIZE]; puts("Enter your shellcode:"); v.. 이전 1 다음