An Analyzation to Stream-games

  • Question:

The key file is here:

  • The core function is here:

This function is used to create the key bit by bit. At the beginning of everything, the flag versus the mask, which selects special bits in the flags. Then, these special bits XOR among themselves, The result of the XOR operation is something like counting if the number of 1 in these special bits is odd or even. After we get the XOR result, it is given to the last bit of the flag after the flag is moved to the left by 1 bit. The XOR result is also given to the key which is write to file. And that keeps the flag at a fixed length.

  • The whole operation is like the follow figure:

It is likely that the flag was pushed far away by a stream of 1/0 bit. And we cannot get any bit of it. However, fortunately, we can get the bits after the flag, which were written to file. And the point is the first bit of the mask. Let’s have a look at the operation to create these bits. And assume that the last bit of the flag, named A-bit, is pushed to the first place of the flag. At this moment, A-bit is going to take part in next XOR operation with the rest selected bits, named R-bits. According to the nature of XOR operation, when we get the last bit by:

LastBit = Abit \ XOR\ Rbits

We can easily get the A-bit by:

Abit=LastBit \ XOR\ Rbits

So we can get the former bit by the XOR operation among the following mask-length bits. After we get A-bit, we can get the bit before A-bit through the same way. Thus we can get the whole flag. What we only need is the mask and first several bits in the key at the number of length of the mask. We don’t need violent ***** any more. ^_^

  • The solution is here:

(The length of the mask is 4 bytes, so we only need the first 8 hex number in the key file)

  • The result is here:

Not so hard!

  • 参考文章

Streamgame系列总结https://blog.csdn.net/qq_39153247/article/details/80144695