-
-
Notifications
You must be signed in to change notification settings - Fork 590
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2daaf38
commit 7a87f74
Showing
3 changed files
with
64 additions
and
126 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
|
||
import lief | ||
from utils import get_sample | ||
|
||
lief.logging.set_level(lief.logging.LOGGING_LEVEL.INFO) | ||
|
||
def test_endianness(): | ||
binary = lief.parse(get_sample('ELF/ELF32_x86_binary_ls.bin')).abstract | ||
header = binary.header | ||
|
||
assert header.endianness == lief.ENDIANNESS.LITTLE | ||
|
||
binary = lief.parse(get_sample('MachO/MachO64_x86-64_binary_id.bin')).abstract | ||
header = binary.header | ||
|
||
header.endianness == lief.ENDIANNESS.LITTLE | ||
|
||
binary = lief.parse(get_sample('PE/PE64_x86-64_binary_ConsoleApplication1.exe')).abstract | ||
header = binary.header | ||
|
||
header.endianness == lief.ENDIANNESS.LITTLE | ||
|
||
|
||
def test_format(): | ||
binary = lief.parse(get_sample('ELF/ELF32_x86_binary_ls.bin')).abstract | ||
binary.format == lief.EXE_FORMATS.ELF | ||
|
||
binary = lief.parse(get_sample('MachO/MachO64_x86-64_binary_id.bin')).abstract | ||
binary.format == lief.EXE_FORMATS.MACHO | ||
|
||
binary = lief.parse(get_sample('PE/PE64_x86-64_binary_ConsoleApplication1.exe')).abstract | ||
binary.format == lief.EXE_FORMATS.PE | ||
|
||
def test_pie(): | ||
binary = lief.parse(get_sample('ELF/ELF32_ARM_binary-pie_ls.bin')).abstract | ||
assert binary.is_pie | ||
|
||
binary = lief.parse(get_sample('MachO/MachO64_x86-64_binary_nm.bin')).abstract | ||
assert binary.is_pie | ||
|
||
binary = lief.parse(get_sample('PE/PE32_x86_binary_cmd.exe')).abstract | ||
assert binary.is_pie | ||
|
||
binary = lief.parse(get_sample('ELF/ELF64_x86-64_binary_ls.bin')).abstract | ||
assert not binary.is_pie | ||
|
||
|
||
def test_ctor(): | ||
binary = lief.parse(get_sample('PE/PE32_x86_binary_winhello-mingw.exe')).abstract | ||
assert [f.address for f in binary.ctor_functions] == [0x4018e0, 0x401890] | ||
assert binary.imagebase == 0x400000 | ||
|
||
binary = lief.parse(get_sample('MachO/MachO64_x86-64_binary_all.bin')).abstract | ||
assert [f.address for f in binary.ctor_functions] == [0x100000dd0] | ||
assert binary.imagebase == 0x100000000 | ||
|
||
binary = lief.parse(get_sample('ELF/ELF64_x86-64_binary_gcc.bin')).abstract | ||
assert [f.address for f in binary.ctor_functions] == [4206768, 4206416, 4203936] | ||
assert binary.imagebase == 0x400000 | ||
assert binary.offset_to_virtual_address(0xd4f38) == 0x6d4f38 | ||
|
||
binary = lief.parse(get_sample('MachO/MachO64_x86-64_binary_sshd.bin')).abstract | ||
assert binary.offset_to_virtual_address(0x18f001) == 0x10019a001 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,6 @@ | |
(CWD / "dex"), | ||
(CWD / "art"), | ||
(CWD / "api"), | ||
#(CWD / "abstract"), | ||
(CWD / "abstract"), | ||
"--verbose" | ||
]) |