source.php


<html>
<head>
<title>In My Dreams</title>
</head>
<body>
<p>Here is the <a href='index2.html'>source</a>!</p>
</body>
</html>
<?php
//hi all! you may ask what to do here? its simple, just have a nice walk through these lines, then just call w_() 
//and its done 
$_k = @$_GET['magic']; //put the magic byte here :)
$_u=create_function('$_a_','foreach($_a_ as $_=>$__){$a[$_]=$__;}return @array_splice($a,1);'); 
$_u=@call_user_func($_u,@$_GET['argv']);function w_(){print'Good job! flag: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';}$_f=chr(112).chr(114).__CLASS__."\x65"."\x67"."_"
$_function=create_function('$___,$_,$__','return(strcmp((($_^$__)|$___),123)==0)?1:0;'); 
((int)
$_function((int)$_u[0],(int)$_u[1],(int)$_u[2])>0)?0:printf("%s",die()); 
$__=cosh;$___=$__[asinh(_)];$_t="\x31";$___.=$__[$_t+$_t+$_t];$___.=$__[$_t];$___++;$___++;$___++; 
$_f.=substr(str_repeat("\x72",11),-3,1)."e";$_f_=metaphone(crc32(__DIR__).preg_replace("%^=(\?):*?[\sa-z*]*{\$}*?.[^\D]{1,}(\w|\s)$%sUi","${2}1,$1",crc32(__FILE__))); 
@
$_a.=__METHOD__."\x25".$___(@0+"@${$_t}"+~$_k+1*(5*20))."\x0";$_f.="pl";
$_f.="ac"."\x65";@$_f("%.".$_a."%ixs","(string)$_u[3]()",' ');


인풋으로 magic이랑 argv 두개를 받는다. 

일단 먼저 argv[1],argv[2],argv[3] 값으로 return(strcmp((($_^$__)|$___),123)==0)?1:0; 요부분 리턴 1나오게 값 세팅해 주면 된다.


그다음 argv[4]는 @$_f("%.".$_a."%ixs","(string)$_u[3]()",' '); 요기 두번째 인자 영역에 들어가는데 $_f은 preg_replace 문자열이기때문에 argv[4]에 w_를 세팅해주고 패턴영역에 e modifier를 insert해주면 php code 실행을 통해 w_함수를 사용할 수 있다.


그럼 이제 $_a 요 값이 어떤식으로 세팅되는지 보면 되는데 __METHOD__."\x25".$___(@0+"@${$_t}"+~$_k+1*(5*20))."\x0";$_f.="pl";

요 코드를 통해 "%".연산결과."\x0" 이런식으로 세팅되는걸 볼 수 있다. 연산결과는 magic 파라미터 값을 통해 특정 연산들을 거쳐서 세팅되는데 이 값이 만약 e가되면 %e\x00꼴로되서 php code가 실행될 거라 생각했다.


주석 중에 //put the magic byte here :) 요런게 있어서 그냥 magic값에 00~ff까지 브포 돌리니까 플래그를 뿌려주는 byte가 존재했다.

블로그 이미지

JeonYoungSin

메모 기록용 공간

,