A Python-based predictor using z3 to reverse-engineer and predict random values generated by Math.random
in V8 with 100% accuracy. This script leverages a series of Math.random()
values (min 5) to deduce future states.
💬 Discord
·
📜 ChangeLog
·
- Requires:
Python 3.8+
- Set up a virtual environment:
python3 -m venv venv
- Activate the environment:
# Windows venv\Scripts\activate # macOS/Linux source venv/bin/activate
- Install requirements:
pip install -r requirements.txt
- Install nodejs (optional)
- Debug Logging: Debug logging through
logmagix
that tracks each prediction stage. - Z3 Integration: Uses Z3 to reverse the XORSHIFT+128 algorithm behind
Math.random
in V8. - Custom Sequence Input: Optionally, input your own sequence of
Math.random()
values for testing. - Automated Prediction: Computes the next
Math.random()
output based on previous values. - Error Handling: Verifies the Z3 model's validity and provides detailed feedback.
-
Generate Random Numbers: Use V8 (Node.js, Chrome, etc.) to produce a sequence of random values with
Math.random()
. An example sequence can be generated by running:Array.from(Array(5), Math.random);
Optionally, set a seed in Node.js to reproduce the same random sequence:
node --random_seed=1337 Array.from(Array(5), Math.random)
-
Run the Predictor: Input the random sequence into the script. For example:
python main.py --sequence "[0.9311600617849973, 0.3551442693830502, 0.7923158995678377, 0.787777942408997, 0.376372264303491]"
Or for testing purposes you can run the python code directly (requires NodeJS):
python main.py
-
Output Example:
Using Sequence: [0.376372264303491, 0.787777942408997, 0.7923158995678377, 0.3551442693830502, 0.9311600617849973] States: {'se_state0': 4268050313212552111, 'se_state1': 6942842836049070467} Successfully guessed result: 0.23137147109312428
v1.0.0 ⋮ 11/10/2024
! Initial release with Math.random predictor
Inspired by: PwnFunction