webhackingkr 8번

Webhackingkr 2015. 3. 5. 20:37

8번 문제에 들어가니 다짜고짜 거절당해버린다.


이제는 익숙하지만 아무것도 안했는데 거절이라니...

당황스럽지만 클릭할 것도 없고 소스부터 확인해 본다.


<html>
<head>
<title>Challenge 8</title>
<style type="text/css">
body { background:black; color:white; font-size:10pt; }
</style>
</head>
<body>
<br><br>
<center>USER-AGENT
Access Denied!


소스도 특이점이 없다.
진입점이 보이지 않아, 컴퓨터에서 놀고있던 fiddler를 이용해 대체 뭔놈인지 확인해본다.



생각없이 보다가 index.php 지점에서 이 페이지가 php로 구성된다는 것을 착안, 다짜고짜 URL에 index.php를 쳐본다. 빙고, 동일하게 작동하는것을 보니 특별한 조작 없는 php페이지라는 것을 확인할 수 있었다.
소스를 봐야하니 가장 쉬운 방법인 index.phps로 접근해 본다.(phps는 php의 소스보기 확장자. 옵션을 설정하지 않았을 시 쉽게 소스를 볼 수 있다.)


<html>
<head>
<title>Challenge 8</title>
<style type="text/css">
body { background:black; color:white; font-size:10pt; }
</style>
</head>
<body>
<br><br>
<center>USER-AGENT

<?

$agent
=getenv("HTTP_USER_AGENT");
$ip=$_SERVER[REMOTE_ADDR];

$agent=trim($agent);

$agent=str_replace(".","_",$agent);
$agent=str_replace("/","_",$agent);

$pat="/\/|\*|union|char|ascii|select|out|infor|schema|columns|sub|-|\+|\||!|update|del|drop|from|where|order|by|asc|desc|lv|board|\([0-9]|sys|pass|\.|like|and|\'\'|sub/";

$agent=strtolower($agent);

if(
preg_match($pat,$agent)) exit("Access Denied!");

$_SERVER[HTTP_USER_AGENT]=str_replace("'","",$_SERVER[HTTP_USER_AGENT]);
$_SERVER[HTTP_USER_AGENT]=str_replace("\"","",$_SERVER[HTTP_USER_AGENT]);

$count_ck=@mysql_fetch_array(mysql_query("select count(id) from lv0"));
if(
$count_ck[0]>=70) { @mysql_query("delete from lv0"); }


$q=@mysql_query("select id from lv0 where agent='$_SERVER[HTTP_USER_AGENT]'");

$ck=@mysql_fetch_array($q);

if(
$ck)

echo(
"hi <b>$ck[0]</b><p>");
if(
$ck[0]=="admin")

{
@
solve();
@
mysql_query("delete from lv0");
}


}

if(!
$ck)
{
$q=@mysql_query("insert into lv0(agent,ip,id) values('$agent','$ip','guest')") or die("query error");
echo(
"<br><br>done!  ($count_ck[0]/70)");
}


?>

<!--

index.phps

-->

</body>
</html>












'Webhackingkr' 카테고리의 다른 글

webhackingkr 7번  (0) 2015.03.05
webhackingkr 6번  (0) 2015.03.04
Posted by 튼튼한노예
,