def generate_counter_sync_token(self):
     return OPAYGOEncoder.generate_standard_token(
         starting_code=self.starting_code,
         key=self.key,
         value=OPAYGOShared.COUNTER_SYNC_VALUE,
         count=self.count,
         restricted_digit_set=self.restricted_digit_set)
 def generate_counter_sync_token(self):
     self.count, token = OPAYGOEncoder.generate_standard_token(
         starting_code=self.starting_code,
         key=self.key,
         value=OPAYGOShared.COUNTER_SYNC_VALUE,
         count=self.count,
         restricted_digit_set=self.restricted_digit_set)
     return SingleDeviceServerSimulator._format_token(token)
 def generate_payg_disable_token(self):
     self.count, token = OPAYGOEncoder.generate_standard_token(
         starting_code=self.starting_code,
         key=self.key,
         value=OPAYGOShared.PAYG_DISABLE_VALUE,
         count=self.count,
         restricted_digit_set=self.restricted_digit_set)
     return SingleDeviceServerSimulator._format_token(token)
 def generate_payg_disable_token(self):
     self.count += 1
     return OPAYGOEncoder.generate_standard_token(
         starting_code=self.starting_code,
         key=self.key,
         value=OPAYGOShared.PAYG_DISABLE_VALUE,
         count=self.count,
         restricted_digit_set=self.restricted_digit_set)
 def _generate_token_from_value(self, value, mode):
     self.count, token = OPAYGOEncoder.generate_standard_token(
         starting_code=self.starting_code,
         key=self.key,
         value=value,
         count=self.count,
         mode=mode,
         restricted_digit_set=self.restricted_digit_set)
     return SingleDeviceServerSimulator._format_token(token)
 def _generate_token_from_value(self, value, mode):
     self.count += 1
     return OPAYGOEncoder.generate_standard_token(
         starting_code=self.starting_code,
         key=self.key,
         value=value,
         count=self.count,
         mode=mode,
         restricted_digit_set=self.restricted_digit_set)
Exemple #7
0
def generate_from_device_data(device_data,
                              token_type,
                              value_raw=None,
                              value_days=None,
                              token_count=None):
    assert (value_days is not None) or (value_raw is not None)
    if value_raw is None:
        value_raw = value_days * device_data['time_divider']
    device_data['token_count'], token = OPAYGOEncoder.generate_standard_token(
        starting_code=device_data['starting_code'],
        key=codecs.decode(device_data['key'], 'hex'),
        value=value_raw,
        count=token_count or device_data['token_count'],
        restricted_digit_set=device_data['restricted_digit_set'],
        mode=token_type)
    token = str(token).rjust(9, '0')
    token = ' '.join([token[i:i + 3] for i in range(0, len(token), 3)])
    return device_data, token
Exemple #8
0
if __name__ == '__main__':
    print('Trying to bruteforce the starting code...')

    token_base = OPAYGOShared.get_token_base(code_count_1) - known_value

    for i in range(2**64):
        if i % 10000 == 0:
            print(str(round((i / (2**64)) * 100, 10)) + '%')

        device_key = i.to_bytes(16, 'big')
        #print(device_key)

        activation_code = OPAYGOEncoder.generate_standard_token(
            starting_code=starting_code,
            key=device_key,
            value=known_value,
            count=1 + 1)

        if activation_code == code_count_1:
            print('Level 1 Match found!')
            print(device_key)

            activation_code_2 = OPAYGOEncoder.generate_standard_token(
                starting_code=starting_code,
                key=device_key,
                value=known_value,
                count=2 + 1)

            if activation_code_2 == code_count_2:
                print('Level 2 Match found!')
Exemple #9
0
if __name__ == '__main__':
    print('Trying to bruteforce the starting code...')

    token_base = OPAYGOShared.get_token_base(code_count_1) - known_value

    for i in range(999999):
        if i % 10000 == 0:
            print(str(int((i/999999)*100))+'%')

        starting_code = OPAYGOShared.put_base_in_token(i*1000, token_base)

        count, activation_code = OPAYGOEncoder.generate_standard_token(
            starting_code=starting_code,
            key=device_key,
            value=known_value,
            count=1,
            mode=OPAYGOShared.TOKEN_TYPE_ADD_TIME
        )

        if activation_code == code_count_1:

            count, activation_code_2 = OPAYGOEncoder.generate_standard_token(
                starting_code=starting_code,
                key=device_key,
                value=known_value,
                count=count,
                mode=OPAYGOShared.TOKEN_TYPE_ADD_TIME
            )

            if activation_code_2 == code_count_2:
device_key_hex = 'a29ab82edc5fbbc41ec9530f6dac86b1'
device_starting_code = 123456789
raise Exception("Please change the key and starting code and remove this exception. ")
device_last_count = 4
days_to_activate = 7


if __name__ == '__main__':
    print('Generating code for device with key '+device_key_hex+' and starting code '+str(device_starting_code)+'. ')
    print('The code will have the count (number of codes generated before) of '+str(device_last_count)+'. ')
    print('The code will contain ' + str(days_to_activate) + ' days of activation. ')

    new_count, token = OPAYGOEncoder.generate_standard_token(
        starting_code=device_starting_code,
        key=codecs.decode(device_key_hex, 'hex'),
        value=days_to_activate,
        count=device_last_count,
        restricted_digit_set=False,
        mode=OPAYGOShared.TOKEN_TYPE_ADD_TIME
    )

    print(token)

    value, count, type = OPAYGODecoder.get_activation_value_count_and_type_from_token(
        starting_code=device_starting_code,
        key=codecs.decode(device_key_hex, 'hex'),
        token=token,
        last_count=device_last_count
    )
    print(value, count, type)

from decode_token import OPAYGODecoder
import codecs

# Inputs for the code to be generated
# ------ IMPORTANT WARNING --------
# DO NOT USE THIS KEY IN PRODUCTION
# IT IS JUST AN EXAMPLE
# ---------------------------------
device_key_hex = 'a29ab82edc5fbbc41ec9530f6dac86b1'
device_starting_code = 123456789
device_last_count = 2
days_to_activate = 7

if __name__ == '__main__':
    print('Generating code for device with key ' + device_key_hex +
          ' and starting code ' + str(device_starting_code) + '. ')
    print(
        'The code will have the count (number of codes generated before) of ' +
        str(device_last_count) + '. ')
    print('The code will contain ' + str(days_to_activate) +
          ' days of activation. ')

    activation_code = OPAYGOEncoder.generate_standard_token(
        starting_code=device_starting_code,
        key=codecs.decode(device_key_hex, 'hex'),
        value=days_to_activate,
        count=device_last_count + 1,
        restricted_digit_set=False)

    print(str(activation_code))