示例#1
0
def main():
    # Set Input Options
    hash_type = "HMAC-SHA1"  # valid type: "HMAC-SHA1", "HMAC-SHA256"

    # set complete path, e.g.: """G:\OLGR-TECHSERV\BINIMAGE\AGT\GDQL163A_1I6A_003.bnk"""
    bnk_or_bin_file = "bnkfiles/5D81F_W4QLQ05M.BNK"
    #bnk_or_bin_file = 'G:/OLGR-TECHSERV/BINIMAGE/KONAMI/1645GDXX_393_004.BNK'
    bad_contents_bnk_file = 'G:/OLGR-TECHSERV/BINIMAGE/KONAMI/1985GCXX_393_002.BNK'
    #bnk_or_bin_file = 'G:/OLGR-TECHSERV/BINIMAGE/IGT/000A_B1010_0_004.bnk'
    seed = "0000000000000000000000000000000000000000000000000000000000000000"  # set appropriate seed, script will adjust size of seed

    # Set Output Options
    options_d = dict()
    options_d[
        'cache_file_f'] = False  # False / True - uses cache_file - just use False here.
    options_d[
        'uppercase'] = False  # False / True - output in uppercase characters
    options_d[
        'eightchar'] = False  # False / True - output hash with eight char spaces
    options_d['reverse'] = False  # False / True - reverse byte output
    options_d[
        'usr_cache_file'] = False  # False / True - user cache file - just use False here

    cache_d = dict()

    my_seed = Seed(seed, hash_type)
    options_d['selectedHashtype'] = hash_type

    # generate the hash
    verify_with_epsigexe = True  # True: use epsig.exe to verify bnk file format
    # False: use builtin function to verify BNK format

    myp = epsig2(my_seed.seed, bnk_or_bin_file, options_d, cache_d, hash_type,
                 verify_with_epsigexe)
    if myp.filepath != None:  # if filepath = None, then error in file/filename format
        myp.processfile()

        # format based on output options
        xor_result = epsig2.format_output(None, myp.xor_result, options_d)
        p_seed = epsig2.format_output(None, my_seed.seed, options_d)

        print(p_seed + "\t" + xor_result)

    else:
        print("invalid file - error in file/filename format: " +
              bnk_or_bin_file)
示例#2
0
    def test_format_output_uppercase(self): 
        inputstr = '92971beb3f6d486bdb86402e8e9e2c726d1173d7999f3f7188f3884663181ff0'

        self.options_d['cache_file_f'] = False
        self.options_d['uppercase'] = True
        self.options_d['eightchar'] = False
        self.options_d['reverse'] = False
        self.options_d['usr_cache_file'] = False
        self.selectedHashtype = 'HMAC-SHA256'
        self.options_d['selectedHashtype'] = self.selectedHashtype        
        output_str = epsig2.format_output(self, inputstr, self.options_d)
        self.assertEqual(output_str, '92971BEB3F6D486BDB86402E8E9E2C726D1173D7999F3F7188F3884663181FF0')
示例#3
0
    def test_format_output(self): 
        inputstr = '0x94C5809DEA787F1584A5CA6CFDF4210A9E831018'

        self.options_d['cache_file_f'] = False
        self.options_d['uppercase'] = True
        self.options_d['eightchar'] = False
        self.options_d['reverse'] = False
        self.options_d['usr_cache_file'] = False
        self.selectedHashtype = 'HMAC-SHA1'
        self.options_d['selectedHashtype'] = self.selectedHashtype        
        output_str = epsig2.format_output(self, inputstr, self.options_d)
        self.assertEqual(output_str, '94C5809DEA787F1584A5CA6CFDF4210A9E831018')
示例#4
0
    def test_dobnk_SHA1(self):
        expected_result = 'FC1FE2617F2B5EF0C0652FB8D1345738782E6468'
        seed = "0000000000000000000000000000000000000000000000000000000000000000"
        hash_type = "HMAC-SHA1"
        my_seed = Seed(seed, hash_type)
        self.options_d['selectedHashtype'] = hash_type

        myp = epsig2(my_seed.seed, self.bnkfile, self.options_d,
                     self.cache_dict, hash_type)
        myp.processfile()
        self.assertEqual(
            epsig2.format_output(self, myp.xor_result, self.options_d),
            expected_result)
示例#5
0
    def test_dobin_SHA1(self):
        expected_result = '0E2DAD2DE1D15EB13CD8553E0A2BBA7127AF4796'
        seed = "0000000000000000000000000000000000000000000000000000000000000000"
        hash_type = "HMAC-SHA1"
        my_seed = Seed(seed, hash_type)
        self.options_d['selectedHashtype'] = hash_type

        myp = epsig2(my_seed.seed, self.binfile, self.options_d,
                     self.cache_dict, hash_type)
        myp.processfile()
        self.assertEqual(
            epsig2.format_output(self, myp.xor_result, self.options_d),
            expected_result)
示例#6
0
    def test_dobin_HMAC_SHA256(self):
        seed = "0000000000000000000000000000000000000000000000000000000000000000"
        hash_type = "HMAC-SHA256"
        my_seed = Seed(seed, hash_type)
        self.options_d['selectedHashtype'] = hash_type

        myp = epsig2(my_seed.seed, self.binfile, self.options_d,
                     self.cache_dict, hash_type)
        myp.processfile()

        expected_result = '92971BEB3F6D486BDB86402E8E9E2C726D1173D7999F3F7188F3884663181FF0'
        self.assertEqual(
            epsig2.format_output(self, myp.xor_result, self.options_d),
            expected_result)
示例#7
0
    def test_dobnk_SHA256(self): 
        self.bnkfile = 'bnkfiles/5D81F_W4QLQ05M.BNK'
        self.mandir = os.path.dirname(self.bnkfile)
        self.options_d['cache_file_f'] = False 
        self.LogOutput = list() 
        self.selectedHashtype = 'HMAC-SHA256'    
        self.options_d['selectedHashtype'] = self.selectedHashtype        
        self.seed = Seed('0000000000000000000000000000000000000000000000000000000000000000', self.selectedHashtype).seed

        expected_result = '000000000000000000000000FC1FE2617F2B5EF0C0652FB8D1345738782E6468'

        h = epsig2.dobnk(self, self.bnkfile, blocksize=8192)
        formatted_h = epsig2.format_output(self, str(h), self.options_d) 

        self.assertEqual(formatted_h, expected_result)