CTF
[DamCTF 2020] write up
[DamCTF 2020] write up
2020.10.12WEB / finger-warmup 문제 사이트에 접속하면 아래 사진 처럼 클릭하는 링크가 나온다. 클릭하면 똑같은 페이지 이지만, 주소 뒤에 랜덤한 값이 따라 붙는다. 문제 힌트에 `requests` 모듈과 `beautifulsoup` 모듈을 사용하라고 되어 있어, `a` 태그를 크롤링해 계속 클릭하면 flag를 획득 할 수 있을 거라고 생각했다. import requests import bs4 import time url = "https://finger-warmup.chals.damctf.xyz/" s = requests.session() res = s.get(url) while True: html = bs4.BeautifulSoup(res.text, "html.parser") href = html...
[b01lers 2020 CTF] write up
[b01lers 2020 CTF] write up
2020.10.07There is no Spoon keyword: `Heap overflow` #include #include #include #include char * xor(char * src, char * dest, int len) { for(int i = 0; i < len - 1; i++) { dest[i] = src[i] ^ dest[i]; } dest[len-1] = 0; return dest; } int main() { setvbuf(stdout, 0, 2, 0); setvbuf(stderr, 0, 2, 0); char buffer[256]; int len = 256; printf("Neo, enter your matrix: "); len = read(0, buffer, len); char * buffer..
[DreamhackCTF 2020] validator write up
[DreamhackCTF 2020] validator write up
2020.09.29pwnable 분야의 validator 문제이다. 해당 문제는 바이너리만 주워줬고, 바이너리 파일을 c 나타내면 다음과 같다. void validate(void *input_data, int arg2){ for (int i = 0; i
[DreamhackCTF 2020] Mango write up
[DreamhackCTF 2020] Mango write up
2020.09.29web 분야의 Mango 문제이다. 해당 문제는 코드가 주워줬고, `mongodb injection` 으로 admin 의 pw를 알아내는 문제이다. const express = require('express'); const app = express(); const mongoose = require('mongoose'); mongoose.connect('mongodb://localhost/main', { useNewUrlParser: true, useUnifiedTopology: true }); const db = mongoose.connection; // flag is in db, {'uid': 'admin', 'upw': 'DH{32alphanumeric}'} const BAN = ['admin', '..
[DarkCTF 2020] web write up
[DarkCTF 2020] web write up
2020.09.271. Source php의 `auto type casting` 문제 인거 같다.
[DarkCTF 2020] newPaX write up
[DarkCTF 2020] newPaX write up
2020.09.27pwnable 분야의 두번째 문제 newPaX 이다. Checksec Analyze 이번 바이너리에는 `main()` 과 `vuln()` 이렇게 2개가 있는데, `main()` 함수에는 별거 없고 `vuln()` 함수에서 `BOF` 공격이 가능하다. 이전 문제와 다른점은 `32bit` 라는 점이다. `32bit rop` 공격은 `64bit` 와 다르기 때문에, 아래 코드 처럼 `stack` 에 데이터를 overwrite 했다. 필자는 `read()` 함수의 `GOT`를 leak 했고, libc database 사이트에서 라이브러리를 다운 받아 `libc_base` 를 구했다. from pwn import * p = remote("newpax.darkarmy.xyz", "5001") e = ELF("./n..
[DarkCTF 2020] rop write up
[DarkCTF 2020] rop write up
2020.09.27pwnable 분야의 첫번째 문제 roprop 이다. (write up을 작성하는 시점에서 서버가 닫혀있어 설명하는데 지장이...) Checksec ubuntu:~/environment/ctf/DarkCTF/pwn/01_rop $ checksec roprop [*] '/home/ubuntu/environment/ctf/DarkCTF/pwn/01_rop/roprop' Arch: amd64-64-little RELRO: Partial RELRO Stack: No canary found NX: NX enabled PIE: No PIE (0x400000) Analyze 바이러니는 `main` 함수만 정의 되어 있다. `gets()` 함수에서 `BOF` 공격이 가능한 것을 볼 수 있다. 우선 `libc addre..
[Google CTF 2020] log-me-in write up
[Google CTF 2020] log-me-in write up
2020.08.27google ctf web 문제의 log me in 이다. 해당 문제 write up은 다른 사람의 롸업을 보고 작성한 것이다. 문제 페이지에 접속하면 아래와 같은 페이지가 나온다. 이번 문제는 코드를 올려 줬는데, 문제의 코드는 아래와 같다. /** * @fileoverview Description of this file. */ const mysql = require('mysql'); const express = require('express'); const cookieSession = require('cookie-session'); const cookieParser = require('cookie-parser'); const bodyParser = require('body-parser'); const..
[Google CTF 2020] pasteurize write up
[Google CTF 2020] pasteurize write up
2020.08.27Google CTF 2020 문제중 web 문제 `pasteurize` 이다. 해당 write up은 외국인의 풀이를 바탕으로 작성되었다. 문제 사이트에 접속하면 입력과 제출을 할 수 있는 기능이 있다. 개발자 모드로 보면 `/source` 링크가 있는데 해당 링크로 들어가면 `nodejs`로 코딩된 코드를 볼 수 있다. 아래는 문제의 코드이다. const express = require('express'); const bodyParser = require('body-parser'); const utils = require('./utils'); const Recaptcha = require('express-recaptcha').RecaptchaV3; const uuidv4 = require('uuid')..
[pwnable.xyz] door write up
[pwnable.xyz] door write up
2020.08.10Analytic 이번 문제는 `main()` 함수와 `win()` 함수 2개만 있다. `main()` 함수를 보면 사용자가 입력한 값을 write 하는 것만 있다. int main(){ setup() puts("Door To Other RealmS") int32_t var_14 = 0 int32_t var_10 = 0 *door = rand():0.d while (true) print_menu() uint64_t rax_2 = zx.q(read_int32():0.d) if (rax_2:0.d != 2) if (rax_2:0.d s> 2) if (rax_2:0.d != 3) if (rax_2:0.d == 4) return 0 // rax_2 == 3 else if (*door == 0) continue e..
[pwnable.xyz] child write up
[pwnable.xyz] child write up
2020.08.09Analytic checksec으로 검사 해보니 처음보는 것이 있는데 `fortify: enabled` 이다. 이건 처음봐서 뭔지 모르겠다... 문제 푸는데는 지장 없는듯..? `create_child()` 함수를 보면 18세 이하만 조건을 통과 할 수 있는데, 조건을 통과하면 `child`의 구조체가 만들어진다. void create_child(){ __printf_chk(1, "Age: ") int64_t rax_1 = read_int32() uint64_t rax_7 if (rax_1:0.d u> 0x12) rax_7 = puts("Not a child.") else void* rax_2 = malloc(0x20) *(rax_2 + 0x18) = sx.q(rax_1:0.d) *(rax_2 + 8) ..
[pwnable.xyz] car shop write up
[pwnable.xyz] car shop write up
2020.08.09Analytic `Full RELRO` 이기 때문에 GOT overwrite를 할 수 없다. `buy()` 함수를 보면 사용자가 선택한 자동차가 메모리 공간에 저장된다. 이때의 메모리 구조를 보면 아래와 같다. `0x603260` ~ `0x6032af`: 사용자가 `buy()` 함수를 호출하면 `car`라는 구조체의 chunk가 만들어짐 `0x603260`: 자동차 이름을 저장한 주소 `0x603268`: 자동차 이름의 크기 `0x603270`: 다음 청크(`car`)의 주소 `0x603278`: 이전 청크(`car`)의 주소 `0x603290`: 자동차의 이름 gdb-peda$ x/10gx 0x603260 0x603260: 0x0000000000603290 0x0000000000000003 0x6032..