[LOS] 6. Darkelf

고둑·2021년 7월 11일
0

LoS

목록 보기
6/21
post-thumbnail

힌트

  • 비교 연산자는 문자열로 사용할 수도 있지만, 기호로도 사용할 수 있다.

풀이

코드 해석

<?php 
  include "./config.php"; 
  login_chk(); 
  $db = dbconnect();  
  if(preg_match('/prob|_|\.|\(\)/i', $_GET[pw])) exit("No Hack ~_~"); 
  if(preg_match('/or|and/i', $_GET[pw])) exit("HeHe"); 
  $query = "select id from prob_darkelf 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("darkelf"); 
  highlight_file(__FILE__); 
?>

이번 문제는 orand, 즉 비교 연산자의 문자열 형태를 필터링한다고 볼 수 있다.

문제 풀이

비교 연산자 기호 사용하기

간단하게 or의 기호 형태 ||를 이용하면 쉽게 풀 수 있다.

https://los.rubiya.kr/chall/darkelf_c6a5ed64c4f6a7a5595c24977376136b.php?pw=%27||id=%27admin

profile
문워킹은 하지말자

0개의 댓글