---恢复内容开始---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可是对于加上后端与数据库来说,知识不够用。。。。。就这样吧。