[hacktheon2025] bridge

๐Ÿ‘‰๐Ÿป ๋ฌธ์ œ ๋ถ„์„

์ œ๊ณต๋œ bridge.apk ํŒŒ์ผ์„ ๋ถ„์„ํ•ด๋ณด๋ฉด MainActivity์—์„œ WebViewActivity๋ฅผ ํ˜ธ์ถœํ•˜๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

WebViewActivity์—์„œ๋Š” JsInterface๋ฅผ ์ด์šฉํ•˜์—ฌ Java์™€ Js๊ฐ€ ์ƒํ˜ธ์ž‘์šฉํ•˜๋„๋ก ํ•œ๋‹ค.

๋ฟ๋งŒ์•„๋‹ˆ๋ผ Js๋ฅผ enableํ•œ ๊ฒƒ์œผ๋กœ ๋ณด์•„ ์—‘ํ‹ฐ๋น„ํ‹ฐ ์ด๋ฆ„์ฒ˜๋Ÿผ ์›น๋ทฐ๋ฅผ ์˜ฌ๋ฆด ์ˆ˜ ์žˆ๋‹ค.

JsInterface๋ฅผ ์ข€ ๋” ๋ถ„์„ํ•ด๋ณด๋ฉด ๋‚ด๋ถ€์—์„œ๋Š” encode()์™€ decode()๊ฐ€ ์„ ์–ธ๋˜์–ด ์žˆ๋‹ค.

์—ฌ๊ธฐ์„œ encode์™€ decode๊ฐ€ jni๋กœ ์„ ์–ธ๋œ ์™ธ๋ถ€ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์ž„์„ ์•Œ๊ณ  ์žˆ๋‹ค๋ฉด ํ’€ ์ˆ˜ ์žˆ๋Š” ๋ฌธ์ œ์ด๋‹ค.

์ถ”๊ฐ€๋กœ JsInterface๋Š” WebViewActivity์—์„œ Bridge๋กœ ์ ‘๊ทผ ๊ฐ€๋Šฅํ•˜๊ฒŒ ์„ค์ •ํ•ด๋‘์—ˆ๊ธฐ ๋•Œ๋ฌธ์— Bridge.encode() ๋‚˜ Bridge.decode()๋กœ ์ ‘๊ทผ์ด ๊ฐ€๋Šฅํ•˜๋‹ค๋Š” ์ ์„ ํ™•์ธํ•ด๋‘์ž.

๐Ÿ‘‰๐Ÿป ๋ฌธ์ œ ํ’€์ด

payload ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>CTF Challenge Solution</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            max-width: 800px;
            margin: 0 auto;
            padding: 20px;
            background-color: #f5f5f5;
        }
        .container {
            background-color: white;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        }
        h1 {
            color: #333;
            border-bottom: 1px solid #eee;
            padding-bottom: 10px;
        }
        #result {
            margin-top: 20px;
            padding: 15px;
            background-color: #f9f9f9;
            border: 1px solid #ddd;
            border-radius: 4px;
            white-space: pre-wrap;
            word-break: break-all;
        }
        .status {
            color: #666;
            font-style: italic;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>CTF Challenge Decoder</h1>
        <p class="status" id="status">Initializing decoder...</p>

        <h2>Input:</h2>
        <p id="input">4658hg76&lt;h85eed73ihghidi8ehf&lt;78;</p>

        <h2>Decoded Result:</h2>
        <div id="result">Waiting for decoding...</div>
    </div>

    <script>
        function decodeString() {
            const inputString = '4658hg76<h85eed73ihghidi8ehf<78;';
            const resultElement = document.getElementById('result');
            const statusElement = document.getElementById('status');

            try {
                statusElement.textContent = "Decoding in progress...";

                if (typeof Bridge === 'undefined') {
                    statusElement.textContent = "Error: Bridge interface not found!";
                    resultElement.textContent = "Make sure the WebView has JavascriptInterface properly configured.";
                    return;
                }

                const decodedResult = Bridge.decode(inputString);

                resultElement.textContent = decodedResult;
                statusElement.textContent = "Decoding completed successfully!";

                console.log("Decoded successfully:", decodedResult);

            } catch (error) {
                statusElement.textContent = "Error occurred during decoding!";
                resultElement.textContent = "Error: " + error.message;
                console.error("Decoding failed:", error);
            }
        }

        window.addEventListener('load', function() {
            setTimeout(decodeString, 1000);
        });
    </script>
</body>
</html>

ํ•ด๋‹น ํŽ˜์ด๋กœ๋“œ๋ฅผ ์•ˆ๋“œ๋กœ์ด๋“œ ๋กœ์ปฌ ๋„คํŠธ์›Œํฌ์—์„œ ์ ‘๊ทผ ๊ฐ€๋Šฅํ•˜๋„๋ก ํ•˜์˜€๋‹ค.

adb reverse tcp:8080 tcp:8080

๊ทธ๋ฆฌ๊ณ  ์ž‘์„ฑํ•œ ํŽ˜์ด๋กœ๋“œ๋ฅผ python๋ฅผ ์ด์šฉํ•˜์—ฌ ์„œ๋ฒ„์— ์˜ฌ๋ ธ๋‹ค.

python3 -m http 8080

์ด์ œ payload.html์— ์ ‘๊ทผ์„ ํ•˜๊ฒŒ ๋˜๋ฉด flag๋ฅผ ์–ป์„ ์ˆ˜ ์žˆ๋‹ค.

Categories:

Updated:

Leave a comment