Is there a better way to find the unknown with loops in python?

I am trying to “discover” what was the value of a variable UNKNOWNwhen it was created hash_res.

The only information that was provided to me was that the following lines were used:

random.seed(UNKNOWN+hash(CONST_VAR))
hash_res = random.randint(1<<32, 1<<40)

Plus value CONST_VARis the set value 113092. The value is RESULT_VARalso given which 75284812356.

So far this is what I came up with, but I'm not sure if this is the right way or there is a faster and better way.

import random
from hashlib import md5

UNKNOWN = 0
CONST_VAR = 113092
RESULT_VAR = 75284812356
hash_res = 0

while hash_res != RESULT_VAR:
    UNKNOWN = UNKNOWN+1
    random.seed(UNKNOWN+hash(CONST_VAR))
    hash_res = random.randint(1<<32, 1<<40)

print UNKNOWN

, UNKNOWN , hash_res RESULT_VAR. UNKNOWN, (a.k.a. hash_res RESULT_VAR)

, , ?

#, - :)

+4
3

, , ?

, /, .

"" , , .. - .

( , ..), , , MD5 (: , C/++, python), .

+4

, , ?

, , .

, hash(CONST_VAR), 1<<32 1<<40 .

( @tobias_k), , UNKNOWN (, random.getstate() , random.randint(1<<32, 1<<40))

UNKOWN, .


Edit

, parallelism , ( 4 , 4 * n, 4 * n + 1 ..)

+3

According to @tobias_k's suggestion, to look at the source, I think this question comes down to UNKNOWN's solution to:

a = UNKNOWN+113092
a, x = divmod(a, 30268)
a, y = divmod(a, 30306)
a, z = divmod(a, 30322)
x, y, z = int(x)+1, int(y)+1, int(z)+1
x = (171 * x) % 30269
y = (172 * y) % 30307
z = (170 * z) % 30323
random = (x/30269.0 + y/30307.0 + z/30323.0) % 1.0

4294967296 + int(random * 2361183241434822606848) == 75284812356

Unfortunately, you lose information at every step of this algorithm, which makes reverse engineering virtually impossible.

+1
source

Source: https://habr.com/ru/post/1610900/


All Articles