コード例 #1
0
    def test_set(self):

        s = '01 20 40 E2 02 20 61 E0 01 30 D1 E4 00 00 53 E3 02 30 C1 E7 FB FF FF 1A 1E FF 2F E1'

        odb = OdbFile(BinaryString(s, 'arm'))
        odb.execute(LoadOperation())

        modify = ModifySettingsFactory.set_architecture('i386')
        odb.execute(modify)
        binary = odb.get_binary()
        options = binary.options
        self.assertEquals("i386", options.architecture)

        modify = ModifySettingsFactory.set_base_address('1000')
        odb.execute(modify)
        binary = odb.get_binary()
        options = binary.options
        self.assertEquals("1000", options.base_address)

        modify = ModifySettingsFactory.set_endian('BIG')
        odb.execute(modify)
        binary = odb.get_binary()
        options = binary.options
        self.assertEquals("BIG", options.endian)

        modify = ModifySettingsFactory.set_values(
            {'selected_opts': ["intel-mnemonic"]})
        odb.execute(modify)
        binary = odb.get_binary()
        options = binary.options
        self.assertEquals(1, len(options.get_extra_options()))
        self.assertEquals('intel-mnemonic', options.get_extra_options()[0])
コード例 #2
0
    def test_hash(self):
        s = '55 31 D2 89 E5 8B 45 08 56 8B 75 0C 53 8D 58 FF 0F B6 0C 16 88 4C 13 01 83 C2 01 84 C9 75 F1 5B 5E 5D C3'

        odb_file = OdbFile(BinaryString(s, 'i386'))
        self.assertEqual('d41d8cd98f00b204e9800998ecf8427e',
                         odb_file.get_binary().md5())
        self.assertEqual('da39a3ee5e6b4b0d3255bfef95601890afd80709',
                         odb_file.get_binary().sha1())
コード例 #3
0
    def test_size(self):
        odb_file = OdbFile(
            BinaryFile(self.get_test_bin_path('ls'), 'elf64-x86-64',
                       'i386:x86-64'))
        self.assertEqual(114032, odb_file.get_binary().size)

        s = '01 20 40 E2 02 20 61 E0 01 30 D1 E4 00 00 53 E3 02 30 C1 E7 FB FF FF 1A 1E FF 2F E1'
        odb_file = OdbFile(BinaryString(s, 'arm'))
        self.assertEqual(28, odb_file.get_binary().size)
コード例 #4
0
    def test_load_and_get(self):

        s = '01 20 40 E2 02 20 61 E0 01 30 D1 E4 00 00 53 E3 02 30 C1 E7 FB FF FF 1A 1E FF 2F E1'

        odb = OdbFile(BinaryString(s, 'arm'))
        odb.execute(LoadOperation())

        binary = odb.get_binary()
        options = binary.options

        self.assertEquals("arm", options.architecture)
        self.assertEquals(0, options.base_address)
        self.assertEquals('binary', options.target)
コード例 #5
0
 def test_desc(self):
     odb_file = OdbFile(
         BinaryFile(self.get_test_bin_path('ls'), 'elf64-x86-64',
                    'i386:x86-64'))
     self.assertEqual(8, len(odb_file.get_binary().desc()))