Re: [請益] php網頁會員登入問題

看板PHP作者 (隨便殺)時間16年前 (2008/08/11 23:47), 編輯推噓2(2018)
留言20則, 3人參與, 最新討論串6/7 (看更多)
以下是我目前的程式碼!! <!--範例程式:> <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

08/11 23:48, , 1F
你試幾種injection的方式,echo出你的$sql看看
08/11 23:48, 1F

08/11 23:48, , 2F
這樣應該比較好debug
08/11 23:48, 2F

08/11 23:52, , 3F
囧 他前面出\ 例如我輸入'OR''=' 他echo出來的變成
08/11 23:52, 3F

08/11 23:53, , 4F
WHERE ID='\'OR\'\'=\"
08/11 23:53, 4F

08/11 23:54, , 5F
是WHERE ID='".$ID."'的"的問題嗎?
08/11 23:54, 5F

08/12 00:14, , 6F
有試過把"刪掉 但是還是一樣會自動跑出\ 囧
08/12 00:14, 6F

08/12 00:15, , 7F
帳號: any
08/12 00:15, 7F

08/12 00:16, , 8F
樓上的意思是??
08/12 00:16, 8F

08/12 00:24, , 9F
帳號: any' OR 1=1; #
08/12 00:24, 9F

08/12 00:24, , 10F
echo 出來
08/12 00:24, 10F

08/12 00:25, , 11F
SELECT * FROM admin WHERE user='any' AND passwd='
08/12 00:25, 11F

08/12 00:25, , 12F
any' OR 1=1; #'
08/12 00:25, 12F

08/12 00:25, , 13F
mysql command line mode 可以執行
08/12 00:25, 13F

08/12 00:26, , 14F
但 mysql_query() 不能
08/12 00:26, 14F

08/12 00:26, , 15F
問一下,magic_quotes_gpc重新檢查一次
08/12 00:26, 15F

08/12 00:27, , 16F
php.ini那一行前面有沒有加上「;」 ?
08/12 00:27, 16F

08/12 00:30, , 17F
他整行是這樣
08/12 00:30, 17F

08/12 00:30, , 18F
; - magic_quotes_gpc = off [Performance]
08/12 00:30, 18F

08/12 00:36, , 19F
前面 ; - 要移除
08/12 00:36, 19F

08/12 00:43, , 20F
'any' OR 1=1; #'多一個\變成 'any\' OR 1=1; #'
08/12 00:43, 20F
文章代碼(AID): #18e5yCQt (PHP)
討論串 (同標題文章)
文章代碼(AID): #18e5yCQt (PHP)