LCG: hidden outputs and unknown modulus
The SamTicket gateway takes three outputs from the RidGen generator for each request: the first is written to the log as rid= (8 hex digits), and the other two are used for internal nonces and do not appear in the log. RidGen is a linear congruential generator of the form s' = a*s + c (mod m), m is an unknown 31-bit prime number (230 < m < 231), and a, c are also unknown. In the log, rid is present only in POST /api/ticket lines (in other lines -); the tid= field is from an external gateway generator and is unrelated to RidGen.
At the end of the log, sealed_backup are the bytes encrypting the service backup key. Encryption: the states AFTER the last rid in the log are taken (that is, consecutive outputs of RidGen, starting from the two internal nonces of that request, without skipping any), and the upper 8 bits of each state (s >> 23) are XORed with the corresponding byte of the flag: sealed[j] = flag[j] ^ (s_j >> 23).
Task: recover the generator parameters from gateway_access.log, decrypt the backup key, and find the flag: BAYROQ{LCG_QAYTA_TIKLASH_xxxxxxxxxxxxxxxx} (last 16 characters lowercase hex).