這個登錄頁面是否安全,正在研究 sql 注入,如果是的話,他們是否存在漏洞,我該如何管理它?我之前將用戶詳細信息加密到一個文件中并存儲在本地。我也用localhost,想著換個域。將用戶詳細信息存儲在文件中是否存在任何問題?請無視html<?phpsession_start();?><html> <body> <form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>"> <input type="text" name="Username"value=""> <?php if ($_SERVER["REQUEST_METHOD"] == "POST"){ $user = $_REQUEST['Username']; } ?> <form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>"> <input type="password" name="Password"value=""> <?php if ($_SERVER["REQUEST_METHOD"] == "POST"){ $password = $_REQUEST['Password']; } if (isset($_POST['submit'])) { $file = $user.".txt"; if (file_exists($file)){ $contents = file_get_contents($file); $ciphering = "AES-128-CTR"; $iv_length = openssl_cipher_iv_length($ciphering); $options = 0; $decryption_iv = '#secret#'; $decryption_key = "#key#"; $decryption= openssl_decrypt ($contents, $ciphering, $decryption_key, $options, $decryption_iv); if($decryption==$password){ echo("details match"); setcookie("username", $user,time()+2000); $_SESSION["logged_in"] = true; $_SESSION["username"] = $user; header("Location:/login/new folder/findchat.php?username"); exit(); } else{ echo('Complete im not a robot'); } } else{echo("pasword or username is not valid");} } ?> <input type="submit"value="submit"name="submit"> </body></html>抱歉我的拼寫錯誤,謝謝
1 回答

料青山看我應如是
TA貢獻1772條經(jīng)驗 獲得超8個贊
哇,這太可怕了。有很多漏洞。乍一看,這些是讓我眼前一亮的:
<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
這很容易受到 XSS 攻擊,就像這樣:http://example.com/badlogin.php/"><script>alert("xss")</script>
$file = $user.".txt";
if (file_exists($file)){
$contents = file_get_contents($file);
瑣碎的目錄遍歷。
$decryption= openssl_decrypt ($contents, $ciphering,
$decryption_key, $options, $decryption_iv);
if($decryption==$password){
您應該散列密碼,而不是加密它們。
您唯一沒有的漏洞是 SQL 注入,那是因為您沒有使用任何 SQL。
- 1 回答
- 0 關注
- 130 瀏覽
添加回答
舉報
0/150
提交
取消