XSS扫描系统原理
那個broken web application 后續會慢慢研究的。。。先把工作任務完成。。
工作任務1:搜索類似演示網站
http://code.google.com/p/websecurify/wiki/DemoSites工作任務2:檢索XSS自動化掃描工具,開源,了解檢測原理
=================================================================
(一 )工作任務1:搜索類似演示網站
示例網站:http://code.google.com/p/websecurify/wiki/DemoSites
Details
The following websites may be used to compare Websecurify with other automated web application security testing tools:
- http://demo.testfire.net
- http://testphp.vulnweb.com
- http://testasp.vulnweb.com
- http://testaspnet.vulnweb.com
- http://zero.webappsecurity.com
- http://crackme.cenzic.com
- http://www.webscantest.com
| S.No. | Vulnerable Application | Platform | Remark |
| 1 | SPI Dynamics (live) | ASP | 漏掃廠商的缺陷demo站點,想學習還是可以玩的。有新花樣最好本地玩吧,除非你是活雷鋒。 |
| 2 | Cenzic (live) | PHP | 同1 |
| 3 | Watchfire (live) | ASPX | 同1 |
| 4 | Acunetix 1 (live) | PHP | 同1 |
| 5 | Acunetix 2 (live) | ASP | 同1 |
| 6 | Acunetix 3 (live) | ASP.Net | 同1 |
| 7 | PCTechtips Challenge (live) | online hack challenge, just for fun | |
| 8 | Damn Vulnerable Web Application | PHP/MySQL | 有提供Live CD版,適合懶人 |
| 9 | Mutillidae | PHP | 針對OWASP的Top 10名單設置針對性的缺陷供你耍,必須推薦 |
| 10 | The Butterfly Security Project | PHP | ? |
| 11 | Hacme Casino | Ruby on Rails | Hacme系列is copyright by McAfee, but toooooooooooold! take it as you will and at your own risk. |
| 12 | Hacme Bank 2.0 | ASP.NET (2.0) | 同上,不解釋。 |
| 13 | Updated HackmeBank | ASP.NET (2.0) | 鏈接失效?我沒用過。 |
| 14 | Hacme Books | J2EE | 還是Hacme。。。 |
| 15 | Hacme Travel | C++ (application client-server) | 又是Hacme。。。不過這個是C++的,比較少見。也許有價值,我沒用過 |
| 16 | Hacme Shipping | ColdFusion MX 7, MySQL | ColdFusion平臺的,有針對性的可以搭建一下試試,我沒用過 |
| 17 | OWASP WebGoat | JAVA | 適合教學 |
| 18 | OWASP Vicnum | PHP, Perl | ? |
| 19 | OWASP InsecureWebApp | JAVA | ? |
| 20 | OWASP SiteGenerator | ASP.NET | ? |
| 21 | Moth | ? | |
| 22 | Stanford SecuriBench | JAVA | ? |
| 23 | SecuriBench Micro | JAVA | ? |
| 24 | BadStore | Perl(CGI) | ? |
| 25 | WebMaven/Buggy Bank?(very old) | ? | ? |
| 26 | EnigmaGroup?(live) | ? | ? |
| 27 | XSS Encoding Skillsx5s (Casaba Watcher) | ? | Fiddler的擴展,輔助XSS漏洞挖掘(多種字符編碼轉換支持) |
| 28 | Google Gruyere(live) (previously Jarlsberg) | ? | 可以在線玩,GAE supported. So, if you are in CH1N4, you may need?a VPN or proxy?to access it. |
| 29 | Exploit- DB | Multi-platform | 最真實的Web App漏洞資料庫,totally damn real!看上哪個,直接官網下載對應缺陷版本,本地想怎么玩就怎么玩。 |
| 30 | exploit-kb-vulnerable-web-app | PHP/MySQL | 文檔清晰,易部署,有Vmware Image版,適合懶人 |
“豬在笑”推薦幾個手工的輔助工具,個人感覺挺好~
| Tool | Category | Remark | Similar |
| paros | HTTP代理/HTTP協議調試/spider | 最新開源版3.2.13更新于2006年,后續版本已經完全商業化。但工具的易用性、功能在今天來看都是值得推薦的。支持HTTP協議雙向數據查看/修改/過濾是其亮點。 | burp proxy?,Fiddler,?live http headers (Firefox addon),Firebug (Many browsers’ addon) |
| HackBar | 手工SQL注入輔助 | 方便轉碼、編碼、填充垃圾字符,繞過濾必備 | |
| TamperData | HTTP請求參數控制 | 攔截HTTP/HTTPS請求,允許手工修改HTTP請求參數(GET參數、POST字段、cookie等)后再提交 | |
| Groundspeed | 客戶端安全措施半自動化解除 | 自動檢測隱藏表單字段、去除表單驗證等,免去自己通過Firebug修改html代碼的麻煩 | |
| BuiltWith (Chrome擴展) | 網站架構自動分析 | 自動檢測和識別當前瀏覽網站所采用的技術架構,腳本小子的最愛 | |
Google 檢索到一份整理好的滲透測試學習資源列表
by?http://www.pulog.org/Resources/2242/Pentesting-Vulnerable/
Web Pentesting
| Application Name | Company/Developer | URL |
| OWASP WebGoat | OWASP | http://www.owasp.org/index.php/OWASP_WebGoat_Project |
| OWASP Vicnum | OWASP | http://www.owasp.org/index.php/Category:OWASP_Vicnum_Project |
| OWASP InsecureWebApp | OWASP | http://www.owasp.org/index.php/Category:OWASP_Insecure_Web_App_Project |
| Web Security DOJO | Maven Security Consulting | http://www.mavensecurity.com/web_security_dojo/ |
| Gruyere (antigo Codelab / Jalsberg) | http://google-gruyere.appspot.com/ | |
| Hacme Game | NTNU | http://hacmegame.org/ |
| SPI Dynamics | SPI Dynamics | http://zero.webappsecurity.com/ |
| Acunetix 1 | Acunetix | http://testphp.vulnweb.com/ |
| Acunetix 2 | Acunetix | http://testasp.vulnweb.com/ |
| Acunetix 3 | Acunetix | http://testaspnet.vulnweb.com/ |
| PCTechtips Challenge | PC Tech Tips | http://pctechtips.org/hacker-challenge-pwn3d-the-login-form/ |
| Damn Vulnerable Web Application | DVWA | http://dvwa.co.uk/ |
| Mutillidae | Iron Geek | http://www.irongeek.com/i.php?page=security/mutillidae-deliberately-vulnerable-php-owasp-top-10 |
| The Butterfly Security Project | The Butterfly Security | http://sourceforge.net/projects/thebutterflytmp/ |
| Hacme Casino | McAfee | http://www.mcafee.com/us/downloads/free-tools/hacme-casino.aspx |
| Hacme Bank 2.0 | McAfee | http://www.mcafee.com/us/downloads/free-tools/hacme-bank.aspx |
| Updated HackmeBank | McAfee | http://www.o2-ounceopen.com/technical-info/2008/12/8/updated-version-of-hacmebank.html |
| Hacme Books | McAfee | http://www.mcafee.com/us/downloads/free-tools/hacmebooks.aspx |
| Hacme Travel | McAfee | http://www.mcafee.com/us/downloads/free-tools/hacmetravel.aspx |
| Hacme Shipping | McAfee | http://www.mcafee.com/us/downloads/free-tools/hacmeshipping.aspx |
| Moth | Bonsai Sec | http://www.bonsai-sec.com/en/research/moth.php |
| Stanford SecuriBench | Standford | http://suif.stanford.edu/%7Elivshits/securibench/ |
| SecuriBench Micro | Standford | http://suif.stanford.edu/%7Elivshits/work/securibench-micro/ |
| BadStore | BadStore | http://www.badstore.net/ |
| WebMaven/Buggy Bank | Maven Security | http://www.mavensecurity.com/webmaven |
| EnigmaGroup | Enigma Group | http://enigmagroup.org/ |
| XSS Encoding Skills – x5s (Casaba Watcher) | X5S | http://www.nottrusted.com/x5s/ |
| Exploit- DB | Exploit DB | http://www.exploit-db.com/webapps |
| The Bodgeit Store | The Bodgeit Store | http://code.google.com/p/bodgeit/ |
| LampSecurity | MadIrish | http://sourceforge.net/projects/lampsecurity/ |
| hackxor | Hackxor | http://hackxor.sourceforge.net/cgi-bin/index.pl |
| WackoPicko | WackoPicko | https://github.com/adamdoupe/WackoPicko |
| RSnake’s Vulnerability Lab | RSnake | http://ha.ckers.org/weird/ |
?
War Games
| Application Name | Company / Developer | URL |
| Hell Bound Hackers | Hell Bound Hackers | http://hellboundhackers.org/ |
| Vulnerability Assessment | Kevin Orrey | http://www.vulnerabilityassessment.co.uk/ |
| Smash the Stack | Smash the Stack | http://www.smashthestack.org/ |
| Over?the Wire | Over the?Wire | http://www.overthewire.org/wargames/ |
| Hack This Site | Hack This Site | http://www.hackthissite.org/ |
| Hacking Lab | Hacking Lab | https://www.hacking-lab.com/ |
| We Chall | We Chall | https://www.wechall.net/ |
| REMnux | REMnux | http://zeltser.com/remnux/ |
?
Insecure Distributions
| Application Name | Company / Developer | URL |
| Damm Vulnerable Linux | DVL | http://www.damnvulnerablelinux.org/ |
| Metasploitable | Offensive Security | http://blog.metasploit.com/2010/05/introducing-metasploitable.html |
| de-ICE | Hacker Junkie | http://www.de-ice.net/ |
| Moth | Bonsai SecuritySoftware | http://www.bonsai-sec.com/en/research/moth.php |
| PwnOS | Niel Dickson | http://www.neildickson.com/os/ |
| Holynix | Pynstrom | http://pynstrom.net/holynix.php |
(二)工作任務2:XSS自動化掃描器系統原理
1.Google到一個關于xss的掃描器,sourceforge的xsser,以下是它的簡介:Cross Site "Scripter" is an automatic -framework- to detect, exploit and report XSS vulnerabilities in web-based applications.
大概就是說它是個自動掃描利用漏洞并且報告之的東東,和我要找的符合。 下載地址:http://sourceforge.net/projects/xsser/files/latest/download 源碼checkout地址:svn://svn.code.sf.net/p/xsser/code 這個是XSSer的用法:http://blog.csdn.net/xihuanqiqi/article/details/8072323
2.Google把自己的內部審計XSS的工具開源了?ratproxy
?Google 推出一套免費的 Web 安全評估工具,叫做 RatProxy,這套工具可以檢測、分析您的網站是否有安全性漏洞或網頁是否有被入侵,目前可支援 Linux, FreeBSD, MacOS X, 與 Windows (Cygwin) 等執行環境(反正就是 Unix-like 的環境啦)。
RatProxy 可偵測到的漏洞包括 Cross-site Scripting (XSS, 跨網站指令碼)、指令碼惡意置入(script inclusion issues), 惡意網頁內容(content serving problems), insufficient XSRF 以及 XSS 防護(XSS defenses) 等。 ratproxy地址:http://code.google.com/p/ratproxy/#ratproxy
以下是Google到的Ratproxy用法: Ratproxy 工作流程:
- 1) 運行腳本后,會在本地啟動一個代理服務器,默認端口是 8080 ;
- 2) 瀏覽器設置這個地址 ([url]http://localhost:8080[/url])為 代理地址 ;
- 3) 瀏覽要測試的 Web 頁面,進行實際登錄,填寫表單等操作(這些動作會被代理服務器捕捉并做點"手腳"發給待檢測的頁面),ratproxy 會在后臺記錄相關的 Log ;
- 4) 用 ratproxy 提供的工具解析 Log 并輸出?<acronym title="HyperText" markup="" language "="" style="padding: 0px; margin: 0px; ">HTML?進行分析;
- 5) 修正比較嚴重的問題后,跳回到第一步,直到評估通過為止。
$ sudo apt-get install libssl-dev openssl
$ cd ratproxy ; make 然后就可以提交類似: $ ./ratproxy -v . -w foo.log -d foo.com -lfscm
3.Google到?XSSDetect?是一款微軟公司為開發人員提供針對跨站腳本攻擊的靜態分析工具
XSSDetect是精簡版的.NET代碼分析工具,原本供微軟內部人員尋找應用軟件的安全漏洞之用,大概是受開源思想影響,現在已經可以免費下載了。
下載地址:http://tel1.hackol.com/2010/hackol.com-4910-XSSDetectSetup.rar 下完就能傻瓜化安裝了 這是XSSDetect的用法:
Sample Usage
(三)研究XSSer系統運行原理
1.先在虛擬機上安裝好相關軟件如Ihttp://xsser.sourceforge.net/所說的: InstallationXSSer runs on many platforms. It requires Python and the following libraries:
- python-pycurl - Python bindings to libcurl
- python-beautifulsoup - error-tolerant HTML parser for Python
- python-libxml2 - Python bindings for the GNOME XML library
- python-geoip - Python bindings for the GeoIP IP-to-country resolver library
On Debian-based systems (ex: Ubuntu), run:
sudo apt-get install python-pycurl python-beautifulsoup python-libxml2 python-geoip?
Ps:如果有些安裝不了,那是因為有些軟件包需要升級。具體怎么升級可以看看: Ubuntu 更新源 源地址和相關操作
Ubuntu apt-get 詳解
?Ps:如果你下載了XSSer的包,里面有個 /doc/INSTALL,別看了,里面的信息太老了,竟然要用到Python-xml,哎。
2.熟悉用法,看看:??
XSSer(超強XSS攻擊利器)使用說明中文版?
VMware安裝虛擬機Ubuntu的時候,安裝完畢后是命令行模式,得重啟后才能進入圖形界面。
=======================================================================
XSSer 安裝與測試
教程入口:http://xsser.sourceforge.net/
1. Installation 安裝python相關組件
XSSer runs on many platforms. It requires Python and the following libraries:- python-pycurl - Python bindings to libcurl
- python-beautifulsoup - error-tolerant HTML parser for Python
- python-libxml2 - Python bindings for the GNOME XML library
- python-geoip - Python bindings for the GeoIP IP-to-country resolver library
在Ubuntu下用這個指令就能夠安裝后所有的要用到python模塊:
[plain]?view plaincopy
2.下載XSSer相應的包并且安裝
下載地址:http://sourceforge.net/projects/xsser/files/xsser_1.6-1.tar.gz/download
下載后用以下指令:
安裝:
[plain]?view plaincopy
以GTK模式(也就是圖形化模式運行)(GTK mode):
[plain]?view plaincopy
3.XSSer語法的掌握 (官網寫的是 python xsser.py -u "http://www.baidu.com",我用的xsser -u "http://www.baidu.com",都行)
(1)最簡單的注入
[plain]?view plaincopy(2)從文件中讀取URL,帶有代理和HTTP REFERER的注入
[plain]?view plaincopy(3)使用Cem(Character Encoding Mutations 字符編碼基因突變),使用user-agent,設置超時時間,設置線程數
[plain]?view plaincopyPs1:Cem就是先用Hex編碼,再轉為Str編碼,然后再轉為Hex編碼!
(first, change payload to hexadecimal; second, change to StringFromCharCode the first encoding; third, reencode to Hexadecimal the second encoding)
Ps2:user-agent 也就是用戶代理,這個域放置了一些信息如OS版本,CPU類型,瀏覽器版本,瀏覽器渲染引擎,瀏覽器語言,瀏覽器語言等,可以被web服務器獲取,這里我們不想被web服務器獲取,所以就設置了下“XSSer!!!”就好啦~~
(4)從文件讀取(-i "urls.txt"),裝載自己的代碼(--payload ' ' ),并且用JS中的Unescape()函數解碼(--Une)
[plain]?view plaincopy
2)SWF文件或者包含該文件的web頁面被包含在本地受信任的沙箱中
滿足上述條件就能夠用:
[plain]?view plaincopy
思考2:--Une為什么要用到這里?Unescape()函數對escape()函數編碼過后的字符串進行解碼,如果字符串不是編碼后的字符串,則會把字符串原封不動的返回。也就是說,字符串被瀏覽器編碼后送到web服務器嗎?escape()一般用于腳本向某個頁面如a.php這個URL傳遞參數時編碼,可是我用的是XSSer,它在傳遞參數的時候會編碼嗎?
這兩個問題等我以后深入了解再回來回答。
(5)指定引擎并且從引擎的返回結果作為target URL--XSSer Storm
[plain]?view plaincopy
Ps1: duckduckgo是一個網站,搞搜索引擎的 "duck"。
Ps2: ?-d DORK ? ? ? 把搜索結果作為攻擊的目標URL ( Process search engine dork results as target urls)
Ps3: ?--De=DORK_ENGINE ?指定用到的引擎 for dorking 有這么多:(bing, altavista,?yahoo, baidu, yandex, youdao, webcrawler, google, etc.)
? ? ? ? ? ? ? ? ? ??
(6)指定抓取URL的深度和數量
? ? --Cw=CRAWLER_WIDTH ?Deeping level of crawler: 1-5
? ? --Cl ? ? ? ? ? ? ? ?Crawl only local target(s) urls (default TRUE)
[plain]?view plaincopy
(7)Post數據(Simple injection from URL, using POST, with statistics results)
[plain]?view plaincopy
思考:這個-s到底有什么用呢?統計數據?Post數據一般就是把數據封裝到表單中然后發到web服務器請求。
回答:這個-s其實和post沒關系,就是把數據給統計了:
===========================================================================
[*] Statistic:
===========================================================================
--------------------------------------------------
Test Time Duration: ?0:00:05.929196
--------------------------------------------------
Total Connections: 2
-------------------------
200-OK: 1 | 404: 0 | 503: 0 | Others: 1
Connec: 50 %
--------------------------------------------------
Total Payloads: 1
-------------------------
Checker: 0 | Manual: 0 | Auto: 1 | DCP: 0 | DOM: 0 | Induced: 0 | XSR: 0 | XSA: 0 | COO: 0
--------------------------------------------------
Total Injections: 1
-------------------------
Failed: 1 | Sucessfull: 0
Accur : 0 %
-------------------------
Total Discovered: 0
-------------------------
Checker: 0 | Manual: 0 | Auto: 0 | DCP: 0 | DOM: 0 | Induced: 0 | XSR: 0 | XSA: 0 | COO: 0
--------------------------------------------------
False positives: 0 | Vulnerables: 0
-------------------------
Mana: 0
--------------------------------------------------
[I] Could not find any vulnerability!. Try another combination or hack it -manually- :)
===========================================================================
(8)Get請求 八進制編碼(--Doo) 結果以簡短URL形式(--short tinyurl)
[plain]?view plaincopy
(9)Shadow DOM XSS攻擊,跨站Cookie注入,最終代碼FinalRemote(--Fr)
[plain]?view plaincopy
Ps2:DOM XSS 攻擊原理
Ps3:DOM shadow space (no server logging!) 這個DOM陰影空間貌似在哪里聽過?可是就是找不到相關資料。。。終于google到了這篇文章,它講的是Shadow DOM
什么是Shadow Dom?可能會給你帶來點幫助。。。
(10) Dos(拒絕服務攻擊) ? 網址壓縮is.gd
[plain]?view plaincopy
Ps:根據官方介紹,Is.gd 至今已處理了近 900 萬個網址。首頁非常簡潔,輸入需要壓縮的網址提交即可。生成縮略網址后系統會計算壓縮前后的字符串長度,并給出壓縮率。
如果想要讓用戶預覽網頁,而不是直接發送縮略網址(有助于用戶了解所鏈接到的網址,防止被釣魚),只需在縮略網址后添加連接字符 “-” 來開啟網頁預覽功能。
例如,芒果的網址?http://www.mangguo.org?經過壓縮后為?http://is.gd/Aqdn,網頁預覽地址為?http://is.gd/Aqdn-。
注意:縮略網址 URL 中字母區分大小寫。
XSSer結果會多了這么一行:
[plain]?view plaincopy
(11) 在這些地方注入參數變量:?HTTP USer-Agent,HTTP Referer , ?Cookie parameters
[plain]?view plaincopyPs1: ? --Xsa ? ? ? ? ? ? ? XSA - Cross Site Agent Scripting
Ps2: ? --Xsr ? ? ? ? ? ? ? XSR - Cross Site Referer Scripting
(12)? 創建一個假的XSS代碼嵌入圖像(create a false image with XSS code embedded)
[plain]?view plaincopy(13)把積極的結果輸出到指定的XML文件中(Report output 'positives' injections of a dorking search (using "ask" dorker) directly to a XML file).
[plain]?view plaincopy(14)把我們的掃描結果上傳到某些網站上(twitter)這個功能真的是有愛啊~,不吐槽了。。
[plain]?view plaincopy-http://twitter.com/xsserbot01
(15)創建一個swf電影注入XSS代碼(Create a .swf movie with XSS code injected)
這個和那個圖片的嵌入惡意代碼差不多 [plain]?view plaincopy(16)?發送一個hash值,預先看看目標URL是否重復全部內容(send an unique hash, without vectors, to pre-check if?target(s) repeats all content recieved)
[plain]?view plaincopy思考:這個hash它是怎么去pre-check呢?如果要確認是否重復,首先我的有這個網頁的URL的hash,然后我發給它,那么這個hash哪里來呢?難道是有文件存儲著?第一次的話沒有hash怎么辦?
回答:不懂~真心不懂~等以后的我深入了解了再研究吧~
(17) Data Control Protocal(DCP) 數據控制協議 注入,這個好偏門的感覺
[plain]?view plaincopy(18)META標簽中的Base64編碼(RFC2397),也是很偏門的感覺
[plain]?view plaincopy(19)啟動瀏覽器,結束時發現的每個XSS(launch a browser at the end with each XSS discovered)
[plain]?view plaincopy總結
- 上一篇: SM3密码杂凑算法原理
- 下一篇: 广数928te_广数928TE系统说明书