Post

Webhacking.kr - web59

web59

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
<?php
  include "../../config.php";
  if($_GET['view_source']) view_source();
  $db = dbconnect();
  if($_POST['lid'] && isset($_POST['lphone'])){
    $_POST['lid'] = addslashes($_POST['lid']);
    $_POST['lphone'] = addslashes($_POST['lphone']);
    $result = mysqli_fetch_array(mysqli_query($db,"select id,lv from chall59 where id='{$_POST['lid']}' and phone='{$_POST['lphone']}'"));
    if($result['id']){
      echo "id : {$result['id']}<br>lv : {$result['lv']}<br><br>";
      if($result['lv'] == "admin"){
      mysqli_query($db,"delete from chall59");
      solve(59);
    }
    echo "<br><a href=./?view_source=1>view-source</a>";
    exit();
    }
  }
  if($_POST['id'] && isset($_POST['phone'])){
    $_POST['id'] = addslashes($_POST['id']);
    $_POST['phone'] = addslashes($_POST['phone']);
    if(strlen($_POST['phone'])>=20) exit("Access Denied");
    if(preg_match("/admin/i",$_POST['id'])) exit("Access Denied");
    if(preg_match("/admin|0x|#|hex|char|ascii|ord|select/i",$_POST['phone'])) exit("Access Denied");
    mysqli_query($db,"insert into chall59 values('{$_POST['id']}',{$_POST['phone']},'guest')");
  }
?>

Solution

1
2
3
4
5
6
7
8
9
10
11
column에는 id, lv, phone이 있는 것 같고 lv 값이 admin이여야 함.
join시 들어가는 값은 values(id, phone, lv)이며 lv은 현재 guest로 고정되어있음.
phone 입력 값은 최대 19글자까지임.

id : test, phone : 1234로 join 한 결과 
id : test, lv : guest가 나옴.

phone=1,reverse('nimda')로 해보았으나 길이가 걸림.
여기서 id 값을 nimda로 하고 reverse(id)로 하면 됨.

id=nimda&phone=1,reverse(id))--%20
This post is licensed under CC BY 4.0 by the author.