-
-
Save WGH-/3b017c820ee069346a7a432293b04586 to your computer and use it in GitHub Desktop.
This file contains 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
#include <iostream> | |
#include <cstdlib> | |
#include <vector> | |
auto type(uint32_t res) | |
{ | |
if (res >= 0xFD70) | |
res = 3; | |
else if (res >= 0xF0A3) | |
res = 2; | |
else if (res >= 0xBAE0) | |
res = 1; | |
else | |
res = 0; | |
return res; | |
} | |
int main(int argc, char **argv) | |
{ | |
// fill in the values you see here: | |
// | |
// 0 - empty | |
// 1 - bar | |
// 2 - lemon | |
// 3 - "7" | |
// | |
// order is top-bottom, left-to-right (column-major) | |
std::vector<uint8_t> info = {1,0,0,1,0,0,0,1,0, 0,1,0,0,1,0,0,0,0, 0,1,2,0,0,0,0,0,1, 0,0,0,0,0,0,1,0,0, 0,0,0,0,0,0,0,1,0}; | |
std::vector<uint32_t> good_shit; | |
// find PRNG states that give triple "7" | |
for (size_t i = 0; i < 0x100000000; ++i) | |
{ | |
if ((i & 0xFFFFFF) == 0) | |
{ | |
std::cout << '\r' << std::hex << i; | |
std::cout.flush(); | |
} | |
uint32_t state = i; | |
state = state * 0x41C64E6D + 31337; | |
state = state * 0x41C64E6D + 31337; | |
auto a1 = type((state >> 16) ^ (state & 0xFFFF)); | |
state = state * 0x41C64E6D + 31337; | |
state = state * 0x41C64E6D + 31337; | |
state = state * 0x41C64E6D + 31337; | |
auto b1 = type((state >> 16) ^ (state & 0xFFFF)); | |
state = state * 0x41C64E6D + 31337; | |
state = state * 0x41C64E6D + 31337; | |
state = state * 0x41C64E6D + 31337; | |
auto c1 = type((state >> 16) ^ (state & 0xFFFF)); | |
if (a1 == 3 && b1 == 3 && c1 == 3) | |
good_shit.emplace_back(i); | |
} | |
std::cout << " total " << std::dec << good_shit.size() << " good shits found" << std::endl; | |
// brute-force current state | |
for (size_t i = 0; i < 0x100000000; ++i) | |
{ | |
if ((i & 0xFFFFFF) == 0) | |
{ | |
std::cout << '\r' << std::hex << i; | |
std::cout.flush(); | |
} | |
bool ok = true; | |
int total_ok = 0; | |
uint32_t state = i; | |
for (auto x : info) | |
{ | |
state = state * 0x41C64E6D + 31337; | |
auto res = (state >> 16) ^ (state & 0xFFFF); | |
res = type(res); | |
ok &= (res == x); | |
if (!ok) | |
break; | |
} | |
if (ok) | |
{ | |
// entering secret combination for the developer menu | |
// will play game 2 times (because it has button "1" twice in the sequence) | |
// take that into account: | |
for (int j = 0; j < 18; ++j) | |
state = state * 0x41C64E6D + 31337; | |
uint32_t benis = -1; | |
for (auto x : good_shit) | |
{ | |
if (x >= state) | |
{ | |
benis = x; | |
break; | |
} | |
} | |
if (benis == -1) | |
benis = good_shit[0]; | |
std::cout << "\r[!] " << i << ' ' << std::dec << benis - state; | |
std::cout << std::endl; | |
std::cout.flush(); | |
} | |
} | |
std::cout << std::endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment