Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sexfrance/v8-randomness-predictor
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.
https://github.com/sexfrance/v8-randomness-predictor
algorithm javascript math-random nodejs number-generation predictor python randomness-prediction reverse-algorithms reverse-engineering security-analysis v8 v8-engine xorshift z3-solver
Last synced: about 2 months ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/sexfrance/v8-randomness-predictor
- Owner: sexfrance
- License: mit
- Created: 2024-11-10T13:57:50.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-11-18T14:18:32.000Z (2 months ago)
- Last Synced: 2024-11-18T15:45:11.493Z (2 months ago)
- Topics: algorithm, javascript, math-random, nodejs, number-generation, predictor, python, randomness-prediction, reverse-algorithms, reverse-engineering, security-analysis, v8, v8-engine, xorshift, z3-solver
- Language: Python
- Homepage: https://discord.cyberious.xyz
- Size: 10.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
V8 Randomness Predictor
A Python-based predictor using z3 to reverse-engineer and predict random values generated byMath.random
in V8 with 100% accuracy. This script leverages a series ofMath.random()
values (min 5) to deduce future states.
๐ฌ Discord
ยท
๐ ChangeLog
ยท
โ ๏ธ Report Bug
ยท
๐ก Request Feature
---
### โ๏ธ Installation
- Requires: `Python 3.8+`
- Set up a virtual environment:
```bash
python3 -m venv venv
```
- Activate the environment:
```bash
# Windows
venv\Scripts\activate
# macOS/Linux
source venv/bin/activate
```
- Install requirements:
```bash
pip install -r requirements.txt
```
- Install [nodejs](https://nodejs.org/) (optional)---
### ๐ฅ Features
- **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.---
### ๐ Usage
1. **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:
```js
Array.from(Array(5), Math.random);
```Optionally, set a seed in Node.js to reproduce the same random sequence:
```js
node --random_seed=1337
Array.from(Array(5), Math.random)
```2. **Run the Predictor**: Input the random sequence into the script. For example:
```bash
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):
```bash
python main.py
```3. **Output Example**:
```plaintext
Using Sequence: [0.376372264303491, 0.787777942408997, 0.7923158995678377, 0.3551442693830502, 0.9311600617849973]
States: {'se_state0': 4268050313212552111, 'se_state1': 6942842836049070467}
Successfully guessed result: 0.23137147109312428
```---
### ๐น Demo
![Demo](https://i.imgur.com/85yw8di.gif)
---
### ๐ ChangeLog
```diff
v1.0.0 โฎ 11/10/2024
! Initial release with Math.random predictor
```---
**Inspired by**: [PwnFunction](https://github.com/PwnFunction/v8-randomness-predictor)