Created
October 12, 2017 23:52
-
-
Save briankung/40ac8312baafe66c0b288b6722227c12 to your computer and use it in GitHub Desktop.
oi.js from PoC||GTFO
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function millis() { | |
return Date.now(); | |
} | |
function flip_coin() { | |
n = 0; | |
then = millis() + 1; | |
while (millis() <= then) { | |
n = !n; | |
} | |
return n; | |
} | |
function get_fair_bit() { | |
while (1) { | |
a = flip_coin(); | |
if (a != flip_coin()) { | |
return (a); | |
} | |
} | |
} | |
function get_random_byte() { | |
n = 0; | |
bits = 8; | |
while (bits--) { | |
n <<= 1; | |
n |= get_fair_bit(); | |
} | |
return n; | |
} | |
// Use it like this. | |
report_console = function() { | |
while(1) { | |
console.log(get_random_byte()); | |
} | |
} | |
report_console(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment