Byte Bandits CTF 2023

5 篇文章 2 订阅

Improper Error Handling

打开靶机是这样的

看源码

<html>
  <head>
    <title>Top Secret Project</title>
    <style>
      body {
        font-family: Arial, sans-serif;
        margin: 40px;
      }
      form {
        display: flex;
        flex-direction: column;
        align-items: center;
      }
      label {
        font-size: 1.2em;
        margin-bottom: 10px;
      }
      input[type="password"] {
        font-size: 1.2em;
        padding: 5px;
        width: 400px;
        margin-bottom: 20px;
      }
      button {
        font-size: 1.2em;
        padding: 5px 10px;
        background-color: #4CAF50;
        color: white;
        border-radius: 5px;
        cursor: pointer;
      }
      pre {
        background-color: #eee;
        padding: 20px;
        white-space: pre-wrap;
        margin-top: 20px;
        display: none;
      }
      .error {
        color: red;
      }
    </style>
  </head>
  <body>
    <h1>Top Secret Project</h1>
    <form>
      <label for="input">Enter the password:</label>
      <input type="password" id="input">
      <button type="button" onclick="sendRequest()">Submit</button>
    </form>
    <p class="error" id="error-message"></p>
    <pre id="debug-message"></pre>
  </body>
  <script>
    function sendRequest() {
      let length = document.getElementById("input").value;
      fetch("/api/error?length=" + length)
        .then(response => response.text())
        .then(text => {
          if (text.startsWith("Error")) {
            document.getElementById("error-message").textContent = text;
            document.getElementById("error-message").style.display = "block";
            document.getElementById("debug-message").style.display = "none";
          } else {
            document.getElementById("debug-message").textContent = text;
            document.getElementById("debug-message").style.display = "block";
            document.getElementById("error-message").style.display = "none";
          }
        });
    }
  </script>
  
</html> 

定义了一个sendRequest()请求函数

访问:

/api/error?length=

试试传参

一步一步加长看看

当传任意参数到32位时,爆出了flag

Hi-Score

一秒点一百下就能拿flag

这种题,大概率跟js有关

先看看js

调试器打开,找到一个函数

function _0x59a2() {
	var _0x78411b = [
		"\x20cps",
		"clicks",
		"\x20Your\x20Reward\x20:\x20<a\x20href=\x22" +
			"2f2e736563726574696f6e2f666c6167"
				.match(/[\da-f]{2}/gi)
				.map((h) => String.fromCharCode(parseInt(h, 16)))
				.join("") +
			"\x22\x20download=\x22flag\x22>Reward</a>",
		"3526ccMajJ",
		"innerHTML",
		"4263236HVNRoh",
		"3656895VkgrIX",
		"503210VEeXpc",
		"toFixed",
		"5NfzyuJ",
		"8399912tBbEFu",
		"SCORE:\x20",
		"6379703kdfIqT",
		"getElementById",
		"getTime",
		"48bKPhCj",
		"14Xmxuhh",
		"reward",
		"9wOTYQU",
		"597OMUzhx",
		"2046510XnQiaG",
	];
	_0x59a2 = function () {
		return _0x78411b;
	};
	return _0x59a2();
}

看起来

"\x20Your\x20Reward\x20:\x20<a\x20href=\x22" +

"2f2e736563726574696f6e2f666c6167"

这段是回显reward,也就是flag的

一开始以为要解这个 2f2e736563726574696f6e2f666c6167

发现不行

_0x59a2 = function () {
		return _0x78411b;
	};
	return _0x59a2();
}

看到这,可以运行_0x59a2()这个函数,返回函数值

得到flag的地址/.secretion/flag

访问下载打开

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值