2018-2019-2 20165331《网络对抗技术》Exp 8 Web基础
实验收获与感想
通过本次实验,我学会了简单的网页制作,还算是简单。不过通过亲自操作我也发现了其安全性的不足,不过就目前已知的攻击方式的话,简单的限制输入就可以防范了。
什么是表单
表单在网页中主要负责数据采集功能。一个表单有三个基本组成部分:
- 表单标签:这里面包含了处理表单数据所用CGI程序的URL以及数据提交到服务器的方法。
- 表单域:包含了文本框、密码框、隐藏域、多行文本框、复选框、单选框、下拉选择框和文件上传框等。
- 表单按钮:包括提交按钮、复位按钮和一般按钮;用于将数据传送到服务器上的CGI脚本或者取消输入,还可以用表单按钮来控制其他定义了处理脚本的处理工作。
浏览器可以解析运行什么语言。
HTML、XML、Python、PHP、JavaScript、ASP等众多语言。
WebServer支持哪些动态语言
目前,最常用的三种动态网页语言有ASP,JSP,PHP。
实验流程
ⅠWeb前端HTML
(1)kali默认已安装Apache,直接使用 service apache2 start
命令打开Apache服务即可。如果没有任何错误提示,即表明成功开启。

(2)此时在浏览器输入127.0.0.1,如果可以打开Apache的默认网页,则开启成功



ⅡWeb前端:javascipt


ⅢWeb后端:MySQL基础
(1)输入 /etc/init.d/mysql start
开启MySQL服务,并输入mysql -u root -p
使用root权限进入,默认的密码是password


(2)分别用show databases;
查看数据库基本信息,use mysql;
选择使用mysql这个数据库,select user, password, host from user;
查看当前用户信息,update user set password=PASSWORD("新密码") where user='root';
修改密码,flush privileges;
更新权限





(3)退出数据库,使用新的密码登录

(4)分别使用create database <数据库名称>;
建立数据库,use <数据库名称>;
使用数据库,create table <表名> (字段设定列表);
建立数据库表,并设置字段基本信息,show tables;
查看表信息,insert into <表名> values('值1','值2','值3'...);
插入数据,grant select,insert,update,delete on 数据库.* to <用户名>@<登录主机>(可以是localhost,也可以是远程登录方式的IP) identified by "密码";
增加新用户,最后退出并使用新的用户名和密码进行登录







ⅣWeb后端:编写PHP网页
(1)在/var/www/html
目录下新建一个PHP测试文件phptest.php ,简单了解一下它的一些语法

(2)在浏览器网址栏中输入 localhost:80/phptest.php 可看到文件的内容

(3)利用PHP和MySQL,结合之前编写的登录网页进行登录身份认证,修改后的login.php如下

(4)修改login.html

(5)在浏览器输入127.0.0.1/login.html访问自己的登录界面,登陆后即可看到结果
Ⅴ最简单的SQL注入,XSS攻击测试
(1)SQL注入,在用户名输入框输入 ' or 1=1#
密码任意输入,可登陆成功

(2)XSS攻击测试,将一张图片放在/var/www/html
目录下,在用户名输入框输入<img src="huaji.jpg" />
,密码随意,就可以读取图片了
