ii4gsp
wargame.kr 4번 [login filtering] 본문
계정이있는데 차단되었다고한다.
필터링을 우회하는 문제인것 같다.
id입력칸과 pw입력칸이 있다.
get source를 눌러 소스코드를 보자.
<?php
if (isset($_GET['view-source'])) {
show_source(__FILE__);
exit();
}
/*
create table user(
idx int auto_increment primary key,
id char(32),
ps char(32)
);
*/
if(isset($_POST['id']) && isset($_POST['ps'])){
include("../lib.php"); # include for auth_code function.
mysql_connect("localhost","login_filtering","login_filtering_pz");
mysql_select_db ("login_filtering");
mysql_query("set names utf8");
$key = auth_code("login filtering");
$id = mysql_real_escape_string(trim($_POST['id']));
$ps = mysql_real_escape_string(trim($_POST['ps']));
$row=mysql_fetch_array(mysql_query("select * from user where id='$id' and ps=md5('$ps')"));
if(isset($row['id'])){
if($id=='guest' || $id=='blueh4g'){
echo "your account is blocked";
}else{
echo "login ok"."<br />";
echo "Password : ".$key;
}
}else{
echo "wrong..";
}
}
?>
<!DOCTYPE html>
<style>
* {margin:0; padding:0;}
body {background-color:#ddd;}
#mdiv {width:200px; text-align:center; margin:50px auto;}
input[type=text],input[type=[password] {width:100px;}
td {text-align:center;}
</style>
<body>
<form method="post" action="./">
<div id="mdiv">
<table>
<tr><td>ID</td><td><input type="text" name="id" /></td></tr>
<tr><td>PW</td><td><input type="password" name="ps" /></td></tr>
<tr><td colspan="2"><input type="submit" value="login" /></td></tr>
</table>
<div><a href='?view-source'>get source</a></div>
</form>
</div>
</body>
<!--
you have blocked accounts.
guest / guest
blueh4g / blueh4g1234ps
-->
php 소스코드와 아래 주석이 있다.
guest / guest
blueh4g / blueh4g1234ps
두개의 차단당한 계정을 가지고있다.
mysql_connect("localhost","login_filtering","login_filtering_pz");
mysql_select_db ("login_filtering");
mysql_query("set names utf8");
쿼리를 연결 시키는 코드이다.
$key = auth_code("login filtering");
$id = mysql_real_escape_string(trim($_POST['id']));
$ps = mysql_real_escape_string(trim($_POST['ps']));
$row=mysql_fetch_array(mysql_query("select * from user where id='$id' and ps=md5('$ps')"));
post로 전송한 id와 ps를 escape하고 $id, $ps에 넣고 $row에 실행결과를 넣는다.
if(isset($row['id'])){
if($id=='guest' || $id=='blueh4g'){
echo "your account is blocked";
}else{
echo "login ok"."<br />";
echo "Password : ".$key;
}
}else{
echo "wrong..";
}
}
$row에 id값이 존재할경우 그것이 guest나 blueh4g이라면 "your account is blocked"
이라는 문자를 출력하고 아니라면 "login ok"문자와 key값을 보여준다.
$row에 id값이 존재하지않으면 "worng.."이란 문자를 출력한다.
php는 대소문자를 구분하고 쿼리에는 대소문자의 구분이 없고
필터링은 php에서 하기때문에 id=Guest, pw=guest를 넣어주면 쿼리에서는 Guest가 guest와 같은 값 인줄 알기때문에 key를 내준다.
'웹 해킹 > wargame.kr' 카테고리의 다른 글
wargame.kr 6번 [fly me to the moon] (0) | 2020.01.14 |
---|---|
wargame.kr 5번 [WTF_CODE] (0) | 2020.01.14 |
wargame.kr 3번 [QR CODE PUZZLE] (0) | 2020.01.14 |
wargame.kr 2번 [flee button] (2) | 2020.01.14 |
wargame.kr 1번 [already got] (0) | 2020.01.14 |
Comments