def get_keys(player_id): multiplier = incr = None while multiplier is None or incr is None: first_state = make_bet('Lcg', player_id, 10, 10)['realNumber'] second_state = make_bet('Lcg', player_id, 10, 10)['realNumber'] states = [first_state, second_state] if modinv(states[1] - states[0], M): third_state = make_bet('Lcg', player_id, 10, 10)['realNumber'] states.append(third_state) return crack_unknown_multiplier(states), states[-1]
def crack_better_mt(account_id): state = [] for i in range(624): print(i) response = make_bet('BetterMt', account_id, 1, 0) state.append(response['realNumber']) recovered_state = recover_state_mt(state) generator = MersenneRng() generator.state = recovered_state money = 0 while money < 1_000_000: response = make_bet('BetterMt', account_id, 1, generator.get_random_number()) money = response['account']['money'] print(money)
def get_mt_generator(account_id, first_timestamp, second_timestamp): response = make_bet('Mt', account_id, 1, 0) seed = first_timestamp while True: generator = MersenneRng(seed) new_generated_value = generator.get_random_number() seed += 1 if new_generated_value == response[ 'realNumber'] or seed > second_timestamp + 1: break return generator
def crack_mt(): first_timestamp = int(time()) - 1 account = create_account() second_timestamp = int(time()) generator = get_mt_generator(account['id'], first_timestamp, second_timestamp) money = 0 while money < 1_000_000: response = make_bet('Mt', account['id'], 10, generator.get_random_number()) money = response['account']['money']
third_state = make_bet('Lcg', player_id, 10, 10)['realNumber'] states.append(third_state) return crack_unknown_multiplier(states), states[-1] def calculate_next_value(a, number, c): result = (a * number + c) % M if abs(result) <= 2**31: return result return result - M if result > 0 else result + M def mod(a, b): return ((a % b) + b) % b if __name__ == "__main__": account = create_account() ((m, mult, increment), last_value) = get_keys(account['id']) next_value = calculate_next_value(mult, last_value, increment) bet = make_bet('Lcg', account['id'], 1, str(next_value)) print(bet) money = 0 while money < 1_000_000: next_value = calculate_next_value(mult, next_value, increment) bet = make_bet('Lcg', account['id'], 10, str(next_value)) money = bet['account']['money'] print(bet['account']['money'])