{"id":21862820,"url":"https://github.com/sexfrance/v8-randomness-predictor","last_synced_at":"2026-04-13T16:35:29.221Z","repository":{"id":262099558,"uuid":"886214131","full_name":"sexfrance/v8-randomness-predictor","owner":"sexfrance","description":"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.","archived":false,"fork":false,"pushed_at":"2024-11-18T14:18:32.000Z","size":11,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-26T15:13:07.424Z","etag":null,"topics":["algorithm","javascript","math-random","nodejs","number-generation","predictor","python","randomness-prediction","reverse-algorithms","reverse-engineering","security-analysis","v8","v8-engine","xorshift","z3-solver"],"latest_commit_sha":null,"homepage":"https://discord.cyberious.xyz","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sexfrance.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-10T13:57:50.000Z","updated_at":"2024-12-16T16:22:16.000Z","dependencies_parsed_at":"2024-11-10T15:28:23.117Z","dependency_job_id":null,"html_url":"https://github.com/sexfrance/v8-randomness-predictor","commit_stats":null,"previous_names":["sexfrance/v8-randomness-predictor"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sexfrance%2Fv8-randomness-predictor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sexfrance%2Fv8-randomness-predictor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sexfrance%2Fv8-randomness-predictor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sexfrance%2Fv8-randomness-predictor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sexfrance","download_url":"https://codeload.github.com/sexfrance/v8-randomness-predictor/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244861800,"owners_count":20522662,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithm","javascript","math-random","nodejs","number-generation","predictor","python","randomness-prediction","reverse-algorithms","reverse-engineering","security-analysis","v8","v8-engine","xorshift","z3-solver"],"created_at":"2024-11-28T03:17:34.954Z","updated_at":"2026-04-13T16:35:24.199Z","avatar_url":"https://github.com/sexfrance.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n \n  \u003ch2 align=\"center\"\u003eV8 Randomness Predictor\u003c/h2\u003e\n  \u003cp align=\"center\"\u003e\n    A Python-based predictor using \u003ca href=\"https://github.com/Z3Prover/z3\"\u003ez3\u003c/a\u003e to reverse-engineer and predict random values generated by \u003ccode\u003eMath.random\u003c/code\u003e in \u003ca href=\"https://v8.dev\"\u003eV8\u003c/a\u003e with 100% accuracy. This script leverages a series of \u003ccode\u003eMath.random()\u003c/code\u003e values (min 5) to deduce future states.\n    \u003cbr /\u003e\n    \u003cbr /\u003e\n    \u003ca href=\"https://discord.cyberious.xyz\"\u003e💬 Discord\u003c/a\u003e\n    ·\n    \u003ca href=\"https://github.com/sexfrance/v8-randomness-predictor#-changelog\"\u003e📜 ChangeLog\u003c/a\u003e\n    ·\n    \u003ca href=\"https://github.com/sexfrance/v8-randomness-predictor/issues\"\u003e⚠️ Report Bug\u003c/a\u003e\n    ·\n    \u003ca href=\"https://github.com/sexfrance/v8-randomness-predictor/issues\"\u003e💡 Request Feature\u003c/a\u003e\n  \u003c/p\u003e\n\u003c/div\u003e\n\n---\n\n### ⚙️ Installation\n\n- Requires: `Python 3.8+`\n- Set up a virtual environment:\n  ```bash\n  python3 -m venv venv\n  ```\n- Activate the environment:\n  ```bash\n  # Windows\n  venv\\Scripts\\activate\n  # macOS/Linux\n  source venv/bin/activate\n  ```\n- Install requirements:\n  ```bash\n  pip install -r requirements.txt\n  ```\n- Install [nodejs](https://nodejs.org/) (optional)\n\n---\n\n### 🔥 Features\n\n- **Debug Logging**: Debug logging through `logmagix` that tracks each prediction stage.\n- **Z3 Integration**: Uses Z3 to reverse the XORSHIFT+128 algorithm behind `Math.random` in V8.\n- **Custom Sequence Input**: Optionally, input your own sequence of `Math.random()` values for testing.\n- **Automated Prediction**: Computes the next `Math.random()` output based on previous values.\n- **Error Handling**: Verifies the Z3 model's validity and provides detailed feedback.\n\n---\n\n### 🔍 Usage\n\n1. **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:\n\n   ```js\n   Array.from(Array(5), Math.random);\n   ```\n\n   Optionally, set a seed in Node.js to reproduce the same random sequence:\n\n   ```js\n   node --random_seed=1337\n   Array.from(Array(5), Math.random)\n   ```\n\n2. **Run the Predictor**: Input the random sequence into the script. For example:\n\n   ```bash\n   python main.py --sequence \"[0.9311600617849973, 0.3551442693830502, 0.7923158995678377, 0.787777942408997, 0.376372264303491]\"\n   ```\n\n   Or for testing purposes you can run the python code directly (requires NodeJS):\n\n   ```bash\n   python main.py\n   ```\n\n3. **Output Example**:\n\n   ```plaintext\n   Using Sequence: [0.376372264303491, 0.787777942408997, 0.7923158995678377, 0.3551442693830502, 0.9311600617849973]\n   States: {'se_state0': 4268050313212552111, 'se_state1': 6942842836049070467}\n   Successfully guessed result: 0.23137147109312428\n   ```\n\n---\n\n### 📹 Demo\n\n![Demo](https://i.imgur.com/85yw8di.gif)\n\n---\n\n### 📜 ChangeLog\n\n```diff\nv1.0.0 ⋮ 11/10/2024\n! Initial release with Math.random predictor\n```\n\n---\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://img.shields.io/github/license/sexfrance/v8-randomness-predictor.svg?style=for-the-badge\u0026labelColor=black\u0026color=f429ff\u0026logo=python\"/\u003e\n  \u003cimg src=\"https://img.shields.io/github/stars/sexfrance/v8-randomness-predictor.svg?style=for-the-badge\u0026labelColor=black\u0026color=f429ff\u0026logo=IOTA\"/\u003e\n  \u003cimg src=\"https://img.shields.io/github/languages/top/sexfrance/v8-randomness-predictor.svg?style=for-the-badge\u0026labelColor=black\u0026color=f429ff\u0026logo=python\"/\u003e\n\u003c/p\u003e\n\n**Inspired by**: [PwnFunction](https://github.com/PwnFunction/v8-randomness-predictor)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsexfrance%2Fv8-randomness-predictor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsexfrance%2Fv8-randomness-predictor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsexfrance%2Fv8-randomness-predictor/lists"}