Skip to content

whokilleddb/v8-randomness-predictor

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

8 Commits
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

v8-randomness-predictor

Using z3 to predict Math.random in v8

YouTube video

PwnFunction YouTube Video

Watch the โœจ YouTube Video

Run Instructions

Get a few Random numbers from v8, run to following code in d8, nodejs or chrome.

Array.from(Array(5), Math.random)

Optionally you can set the random seed in nodejs so you'd get the same numbers as shown below.

/*
* Run nodejs with `--random_seed` flag like
* node --random_seed=1337
*/
Array.from(Array(5), Math.random)
// [0.9311600617849973, 0.3551442693830502, 0.7923158995678377, 0.787777942408997, 0.376372264303491]

Next we feed these random numbers into the python script (line 12).

SEQUENCE = [
  0.9311600617849973,
  0.3551442693830502,
  0.7923158995678377,
  0.787777942408997,
  0.376372264303491,
][::-1]

or, feeding them to the script with the -s/--seeds flag

$ python3 v8-randomness-breaker.py -s 0.9311600617849973,0.3551442693830502,0.7923158995678377,0.787777942408997,0.376372264303491

Run the script.

$ python3 main.py
๐Ÿ‘จโ€๐Ÿ’ป Break that v8 Math.random()!
๐ŸŒฑ   Using 5 seeds
๐Ÿ‘‰   0.376372264303491
๐Ÿ‘‰   0.787777942408997
๐Ÿ‘‰   0.7923158995678377
๐Ÿ‘‰   0.3551442693830502
๐Ÿ‘‰   0.9311600617849973
๐Ÿš€   Next Random Number: 0.23137147109312428 
๐Ÿ’พ   State Values:
+--------+---------------------+
| state  |        value        |
+--------+---------------------+
| state0 | 4268050313212552111 |
| state1 | 6942842836049070467 |
+--------+---------------------+

Resources

About

Using z3 to predict `Math.random` in v8

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%