‹ BackHN Continuity

Thread

Reversing Factorio's RNG

255 points · 48 comments · jheitmann

  1. strstr · · focus · HN ↗
    I did an easier version of this in my college intro class. There was a class competition that involved rock paper scissors as a subcomponent, and ties were broken with randomness. You could rig Java’s prng so you would win all ties.

    The prng was seeded with usec time at first call. I called the rng a bunch of times to harvest entropy, and scanned the plausible usec times to find the seed. Then I primed the prng so I would win ties.

    Frankly, I assume I implemented this wrong, but the theory was there lol.

    1. rogueaine · · focus · HN ↗
      That’s not at all what the article proposed. The author constructed and transpose to the linear shift register coefficients and built a circuit network based on this to predict the next state (in the sandbox) and direct recipes.
      1. strstr · · focus · HN ↗
        From the article:

        > Sampling the current RNG through observations,

        > Computing the current internal RNG state,

        > Predicting the future internal states,

        > Calculating corresponding quality levels for each future call, and finally

        > Making use of the predicted levels with some adapters.

        The entropy->seeds (internal RNG state) step took more math of course. Frankly, I wouldn’t be surprised if they could have extracted the seeds without the math with a bit of RE and memory inspection.

        The version I did wasn’t predicting quality of course, it was predicting tie breakers

    2. 3eb7988a1663 · · focus · HN ↗
      I am failing to find the article, but some early online poker systems used the server time as the seed coupled with a weak PRNG. With the information of the hole cards + community cards, after a few hands, could quickly determine exactly what seed was being used and perfectly predict everyone's cards.
      1. e28eta · · focus · HN ↗
        I don&#x27;t think this was the original source, but this paper matches your (&amp; my) recollection: <a href="https:&#x2F;&#x2F;gwern.net&#x2F;doc&#x2F;cs&#x2F;cryptography&#x2F;2006-arkin.pdf" rel="nofollow">https:&#x2F;&#x2F;gwern.net&#x2F;doc&#x2F;cs&#x2F;cryptography&#x2F;2006-arkin.pdf

        google surfaces a couple of HN posts, but the source (cigital.com) seems to be a dead domain at this point:

        <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=288138">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=288138

        <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=9914607">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=9914607

        It&#x27;s a bad shuffle implementation + using time of day as seed (reducing search space). Using the player&#x27;s 2 cards and the 3 flop cards, it finds the RNG seed in real time, and then future hands (on the same server) are solved in &quot;under one second!&quot;

        1. 3eb7988a1663 · · focus · HN ↗
          Indeed this is not the article I originally read either, but very similar breakdown of the problem.
Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.