[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<h85eed73ihghidi8ehf<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๋ฅผ ์ป์ ์ ์๋ค.
Leave a comment