看板 PHP 關於我們 聯絡資訊
以下是我目前的程式碼!! <!--範例程式:> <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
ybite :你試幾種injection的方式,echo出你的$sql看看 08/11 23:48
ybite :這樣應該比較好debug 08/11 23:48
sosokill :囧 他前面出\ 例如我輸入'OR''=' 他echo出來的變成 08/11 23:52
sosokill :WHERE ID='\'OR\'\'=\" 08/11 23:53
sosokill :是WHERE ID='".$ID."'的"的問題嗎? 08/11 23:54
sosokill :有試過把"刪掉 但是還是一樣會自動跑出\ 囧 08/12 00:14
PHP5 :帳號: any 08/12 00:15
sosokill :樓上的意思是?? 08/12 00:16
PHP5 :帳號: any' OR 1=1; # 08/12 00:24
PHP5 :echo 出來 08/12 00:24
PHP5 :SELECT * FROM admin WHERE user='any' AND passwd=' 08/12 00:25
PHP5 :any' OR 1=1; #' 08/12 00:25
PHP5 :mysql command line mode 可以執行 08/12 00:25
PHP5 :但 mysql_query() 不能 08/12 00:26
ybite :問一下,magic_quotes_gpc重新檢查一次 08/12 00:26
ybite :php.ini那一行前面有沒有加上「;」 ? 08/12 00:27
sosokill :他整行是這樣 08/12 00:30
sosokill :; - magic_quotes_gpc = off [Performance] 08/12 00:30
PHP5 :前面 ; - 要移除 08/12 00:36
sosokill :'any' OR 1=1; #'多一個\變成 'any\' OR 1=1; #' 08/12 00:43