Websec - level 22

 

 

 

 

 


 

 

14번문제를 풀면서 고민했던 방법 중 $blacklist{} 방법을 사용하여 쉽게 풀었다.

 

$blacklist{input} input값을 1씩 늘려가면서 결과 값으로

var_dump, serialize, print_r 등의 원하는 값을 찾은 후 이를 이용하여 $a를 출력하여 문제를 해결하였다.

 

 

https://seummm.tistory.com/27

 

Websec - level 14

Websec - level 14 input은 25글자로 제한되어 있으며, 내부함수와 설정된 문자, 문자열들이 블랙리스트로 등록되어 Input에 해당 문자가 있으면 Insecure code detected!을 출력하게 된다. 1. 처음에는 $blackli..

seummm.tistory.com

 

 


문제를 풀면서...

 

1. serialize를 사용했을 때 *, A는 갑자기 어디서 나타난건가

O:1:"A":3:{s:3:"pub";s:17:"-";s:6:"*pro";s:18:"-";s:6:"Apri";s:22:"-";}
object(A)#1 (3) {
  ["pub"]=>
  string(17) "-"
  ["pro":protected]=>
  string(18) "-"
  ["pri":"A":private]=>
  string(22) "-}"
}

var_dump에서도 A를 발견할 수 있었다.

 

 

 

 

 

->

 

object를 배열로 cast할 때 property에 따라 property names/new array keys가 앞에 붙는다.

 

 

protected'(space-padded)*'

private : '(space-padded)class이름'

 

 

class test
{
    public $var1 = 1;
    protected $var2 = 2;
    private $var3 = 3;
    static $var4 = 4;
   
    public function toArray()
    {
        return (array) $this;
    }
}

$t = new test;
print_r($t->toArray());

/* outputs:

Array
(
    [var1] => 1
    [ * var2] => 2
    [ test var3] => 3
)

 

 

 

 


 

 

2. Serialize를 이용하여 출력하였을 때 왜 *pro, Apri로 출력된 각각의 문자열이 serialize에서 표시된 길이와 같지않을까?

 

O:1:"A":3:{s:3:"pub";s:17:"-";s:6:"*pro";s:18:"-";s:6:"Apri";s:22:"-";}

 

 

 

 

 

->protect와 private의 *와 A사이에 \0이 생략되어있어 보이는 숫자보다 +2하면 된다.

   serialize할 때 addslashes(serialize($a))하면 숨겨진 %00를 확인할 수 있다.!

 

 


 

 

추가적으로 공부한 내용을 토대로 새로운 풀이를 얻을 수 있었따.

 

((array)$a){'pub'}

((array)$a){'%00*%00pro'}

((array)$a){'%00A%00pri'} 

'Web hacking > Websec' 카테고리의 다른 글

websec - level 19  (0) 2020.03.05
websec - level 24  (0) 2020.02.25
Websec - level 14  (0) 2020.02.19
Websec - level 17  (0) 2020.01.05
Websec - level 4  (0) 2020.01.05

+ Recent posts