---恢復內容開始---javascript
一、表單對於用戶而言是數據的錄入和提交的界面;
二、表單對於網站而言獲取用戶信息的途徑。
表單實質由2部分組成:
一、存儲表單控件的網頁文件;
二、處理表單提交數據的處理程序,該程序在服務器上運行
apt-get install apache2
配置apache的端口
netstat -aptnhtml
<html> <head> <meta charset="UTF-8"> <title>test</title> </head> <body> <table> <form method ="POST" action="x20151120.php" name="loginform" > <tr> <td>name:</td> <td><input type="text" name="username" value="Your name" size="20" maxlength="20" onfocus="if (this.value=='Your name') this.value='';" /></td> <td> </td> <td> </td> </tr> <tr> <td>password:</td> <td><input type="password" name="password" value="Your password" size="20" maxlength="20" onfocus="if (this.value=='Your password') this.value='';" /></td> <td> </td> <td> </td> </tr> <tr> <td><input type="checkbox" name="zlogin" value="1">reload</td> </tr> <table> <tr> <td><input type="submit" name="login" value="load" onClick="return validateLogin()"/></td> <td><input type="reset" name="rs" value="reset" /></td> </tr> </table> </form> </table> <script language="javascript"> function validateLogin(){ var sUserName = document.loginform.username.value ; var sPassword = document.loginform.password.value ; if ((sUserName =="") || (sUserName=="Your name")){ alert("please input your name!"); return false ; } if ((sPassword =="") || (sPassword=="Your password")){ alert("please input your password!"); return false ; } } </script> </body> </html>
web後端編程:前端
爲了可以儲存用戶名密碼,咱們須要創建一個帳號數據庫。html5
/etc/init.d/mysql startjava
打開Kali的mysql服務mysql
mysql -u root -pcss3
登陸mysql MariaDB [(none)]> use mysql Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed MariaDB [mysql]> update user set password=PASSWORD(" toor ") where user='root' MariaDB [mysql]> flush privileges; Query OK, 0 rows affected (0.00 sec) MariaDB [mysql]> quit
設置mysql MariaDB [mysql]> create database exp8_login_db; //建立一個數據庫 Query OK, 1 row affected (0.01 sec) MariaDB [mysql]> use exp8_login_db; Database changed MariaDB [exp8_login_db]> create table exp8_login_table (login_username VARCHAR(20),login_pwd VARCHAR(20)); Query OK, 0 rows affected (0.04 sec) //建立一個數據表並設置字段 MariaDB [exp8_login_db]> show tables;
<?php $uname=($_POST["username"]); $pwd=($_POST["password"]); echo "<br>$uname<br>"; echo "<br>$pwd<br>"; $query_str="SELECT * FROM exp8_login_table where login_username='{$uname}' and login_pwd='{$pwd}';"; $con = mysql_connect("localhost:1120","root","toor"); if (!$con) { die('Could not connect: ' . mysql_error()); } echo "connect ok!"; mysql_select_db("exp8_login_db", $con); /* Select queries return a resultset */ if ($result = mysql_query($query_str)) { if ($result->num_rows > 0 ){ echo "<br> Wellcome login Mr/Mrs:{$uname} <br> "; } else { echo "<br> login failed!!!! <br> " ; } /* free result set */ $result->close(); } mysql_close($con); ?>
經過sql注入繞過密碼驗證,web
只須要將
SELECT * FROM exp8_login_table where login_username='{$uname}' and login_pwd='{$pwd}';";
變成
SELECT * FROM exp8_login_table where login_username='' or 1=1;#' and login_pwd='{$pwd}';";
這樣隨便用戶名均可以繞過密碼驗證
跨站腳本攻擊(Cross Site Scripting),爲不和層疊樣式表(Cascading Style Sheets, CSS)的縮寫混淆。故將跨站腳本攻擊縮寫爲XSS。XSS是一種常常出如今web應用中的計算機安全漏洞,它容許惡意web用戶將代碼植入到提供給其它用戶使用的頁面中。好比這些代碼包括HTML代碼和客戶端腳本。攻擊者利用XSS漏洞旁路掉訪問控制——例如同源策略(same origin policy)。這種類型的漏洞因爲被駭客用來編寫危害性更大的phishing攻擊而變得廣爲人知
實驗體會:
web知識賊差,雖然以前自學過 html5+css3可是對於加上後端與數據庫來說,知識不夠用。。。。。就這樣吧。