作者sosokill (随便杀)
看板PHP
标题Re: [请益] php网页会员登入问题
时间Mon Aug 11 23:47:23 2008
以下是我目前的程式码!!
<!--范例程式:>
<html>
<head><title>login</title></head>
<body>
<center>
<h2>ID&&PassWord</h2>
<hr><small><font color="red">
<?
session_start();
session_register("login_session");
$ID="";
$Password="";
if(isset($_POST["ID"]))
$ID=$_POST["ID"];
if(isset($_POST["Password"]))
$Password=$_POST["Password"];
if($ID!="")
{
$link=mysql_connect("localhost","sosokill","sosokill");
mysql_select_db("member");
$sql="SELECT * FROM membertest WHERE ID='".$ID."' AND
Password='".$Password."'";
$result=mysql_query($sql);
if(mysql_num_rows($result)>=1){
$_SESSION["login_session"]=true;
header("location:hello.php");
}else
echo "<br>Password error<br>";
mysql_close($link);
}
?>
</font></small></center>
<form action="check.php" method="post">
<table align="center" bgcolor="#FFCC99">
<tr><td>username:</td>
<td><input type="text" name="ID" size="15" maxlength="20"></td></tr>
<tr><td>password:</td>
<td><input type="password" name="Password" size="15" maxlength="20"></td></tr>
<tr><td colspan="2" align="center">
<input type="submit" value="login"></td></tr>
</table>
</form>
</body>
</html>
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.129.39.100
1F:→ ybite :你试几种injection的方式,echo出你的$sql看看 08/11 23:48
2F:→ ybite :这样应该比较好debug 08/11 23:48
3F:→ sosokill :囧 他前面出\ 例如我输入'OR''=' 他echo出来的变成 08/11 23:52
4F:→ sosokill :WHERE ID='\'OR\'\'=\" 08/11 23:53
5F:→ sosokill :是WHERE ID='".$ID."'的"的问题吗? 08/11 23:54
6F:→ sosokill :有试过把"删掉 但是还是一样会自动跑出\ 囧 08/12 00:14
7F:推 PHP5 :帐号: any 08/12 00:15
8F:→ sosokill :楼上的意思是?? 08/12 00:16
9F:→ PHP5 :帐号: any' OR 1=1; # 08/12 00:24
10F:→ PHP5 :echo 出来 08/12 00:24
11F:→ PHP5 :SELECT * FROM admin WHERE user='any' AND passwd=' 08/12 00:25
12F:→ PHP5 :any' OR 1=1; #' 08/12 00:25
13F:→ PHP5 :mysql command line mode 可以执行 08/12 00:25
14F:→ PHP5 :但 mysql_query() 不能 08/12 00:26
15F:推 ybite :问一下,magic_quotes_gpc重新检查一次 08/12 00:26
16F:→ ybite :php.ini那一行前面有没有加上「;」 ? 08/12 00:27
17F:→ sosokill :他整行是这样 08/12 00:30
18F:→ sosokill :; - magic_quotes_gpc = off [Performance] 08/12 00:30
19F:→ PHP5 :前面 ; - 要移除 08/12 00:36
20F:→ sosokill :'any' OR 1=1; #'多一个\变成 'any\' OR 1=1; #' 08/12 00:43