LOS #05 wolfman

2020. 10. 28. 22:51
728x90
728x90
728x90
 

Lord of SQLInjection

 

los.rubiya.kr

Source code

http://www.wechall.net
<?php 
  include "./config.php"; 
  login_chk(); 
  $db = dbconnect(); 
  if(preg_match('/prob|_|\.|\(\)/i', $_GET[pw])) exit("No Hack ~_~"); 
  if(preg_match('/ /i', $_GET[pw])) exit("No whitespace ~_~"); 
  $query = "select id from prob_wolfman 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>"; 
  if($result['id'] == 'admin') solve("wolfman"); 
  highlight_file(__FILE__); 
?>

 

Query

select id from prob_wolfman where id='quest' and pw=''

 

Write-up

[사진 1]

위 사진에서 확인할 수 있는 정보는 다음과 같다.

  • 파라미터는 pw 1개가 사용될 수 있다.

  • pw 값에 whitespace(공백) 필터링을 하고 있다.

  • id 값은 "admin" 값을 요구하고 있다.

  • 쿼리문에서 id 값이 "guest" 값으로 고정되어 있다.

id 값으로 "admin" 값을 요구하기 때문에 pw 파라미터 뒤에 "or" 구문으로 새로운 id 값을 전달해주면 된다. 이 때 whitespace(공백)이 필터링되고 있으므로 다른 문자로 우회할 필요가 있다.

 

* SQL Injection Bypass 참고 사이트

 

SQL Injection Bypassing WAF Software Attack | OWASP Foundation

SQL Injection Bypassing WAF on the main website for The OWASP Foundation. OWASP is a nonprofit foundation that works to improve the security of software.

owasp.org

위 사이트에 따르면 whitespace(공백) 값을 "%0b" 문자로 우회할 수 있다고 한다.

 

Parameter

pw=1'or%0bid='admin

쿼리문은 다음과 같다.

select id from prob_wolfman where id='guest' and pw='1'or%0bid='admin'

 

Success

[사진 2]

728x90
728x90

'Wargame > LOS' 카테고리의 다른 글

LOS #07 orge  (0) 2020.10.28
LOS #06 darkelf  (0) 2020.10.28
LOS #04 orc  (0) 2020.10.28
LOS #03 goblin  (0) 2020.10.28
LOS #02 cobolt  (0) 2020.10.28

+ Recent posts