Exemple #1
0
 def test_elf_symbols_elf_libelf_so(self):
     test_file = self.get_test_loc('elf/libelf.so')
     expected_file = self.get_test_loc('elf/libelf.so.expected_elf_symbols')
     with codecs.open(expected_file, encoding='utf-8') as expect:
         expected = json.load(expect)
     elf = Elf(test_file)
     for section, expected_values in expected.items():
         result = getattr(elf.symbols_section, section)
         for i, v in enumerate(sorted(expected_values)):
             assert tuple(v) == tuple(sorted(result)[i])
Exemple #2
0
 def test_elf_symbols_dwarf_arm_exec(self):
     test_file = self.get_test_loc('dwarf/arm_exec')
     expected_file = self.get_test_loc(
         'dwarf/arm_exec.expected_elf_symbols')
     with codecs.open(expected_file, encoding='utf-8') as expect:
         expected = json.load(expect)
     elf = Elf(test_file)
     for section, expected_values in expected.items():
         result = getattr(elf.symbols_section, section)
         for i, v in enumerate(sorted(expected_values)):
             assert v == sorted(result)[i]
Exemple #3
0
 def test_elf_symbols_misc_elfs_cpp_test_o(self):
     test_file = self.get_test_loc('misc_elfs/cpp-test.o')
     expected_file = self.get_test_loc(
         'misc_elfs/cpp-test.o.expected_elf_symbols')
     with codecs.open(expected_file, encoding='utf-8') as expect:
         expected = json.load(expect)
     elf = Elf(test_file)
     for section, expected_values in expected.items():
         result = getattr(elf.symbols_section, section)
         for i, v in enumerate(sorted(expected_values)):
             assert v == sorted(result)[i]
Exemple #4
0
 def test_corrupted_elf_compiled_with_gcc2(self):
     test_file = self.get_test_loc('elf-corrupted/corrupt.o')
     elf = Elf(test_file)
     assert elf.symbols_section
     sections_to_tests = [
         elf.symbols_section.files, elf.symbols_section.standard_files,
         elf.symbols_section.local_functions,
         elf.symbols_section.local_objects,
         elf.symbols_section.global_functions,
         elf.symbols_section.global_objects,
         elf.symbols_section.external_libs_functions,
         elf.symbols_section.external_libs_objects,
         elf.symbols_section.standard_functions,
         elf.symbols_section.standard_objects
     ]
     for section in sections_to_tests:
         assert not section
Exemple #5
0
 def test_needed_libraries_2(self):
     test_file = 'dwarf/amd64_exec'
     expected = ['libacl.so.1', 'libc.so.6', 'librt.so.1']
     test_loc = self.get_test_loc(test_file)
     elf = Elf(test_loc)
     assert set(expected) == set(elf.needed_libraries)
Exemple #6
0
 def test_needed_libraries_1(self):
     test_file = 'elf/libelf.so'
     expected = ['libc.so.6']
     test_loc = self.get_test_loc(test_file)
     elf = Elf(test_loc)
     assert set(expected) == set(elf.needed_libraries)
Exemple #7
0
 def test_needed_libraries_7(self):
     test_file = 'dwarf/ssdeep.x86_64'
     expected = ['libc.so.6']
     test_loc = self.get_test_loc(test_file)
     elf = Elf(test_loc)
     assert set(expected) == set(elf.needed_libraries)
Exemple #8
0
 def test_needed_libraries_5(self):
     test_file = 'dwarf/shash.i686'
     expected = ['libc.so.6']
     test_loc = self.get_test_loc(test_file)
     elf = Elf(test_loc)
     assert set(expected) == set(elf.needed_libraries)
Exemple #9
0
 def test_needed_libraries_3(self):
     test_file = 'dwarf/file_stripped'
     expected = ['libc.so.6', 'libmagic.so.1', 'libz.so.1']
     test_loc = self.get_test_loc(test_file)
     elf = Elf(test_loc)
     assert set(expected) == set(elf.needed_libraries)