mirror of
https://github.com/angr/angr
synced 2026-06-08 13:09:39 +00:00
563fb5f862
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/astral-sh/ruff-pre-commit: v0.14.11 → v0.14.13](https://github.com/astral-sh/ruff-pre-commit/compare/v0.14.11...v0.14.13) - [github.com/psf/black-pre-commit-mirror: 25.12.0 → 26.1.0](https://github.com/psf/black-pre-commit-mirror/compare/25.12.0...26.1.0) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
49 lines
1.4 KiB
Python
49 lines
1.4 KiB
Python
# pylint:disable=no-self-use,missing-class-docstring
|
|
from __future__ import annotations
|
|
from unittest import main, TestCase
|
|
import os.path
|
|
|
|
import angr
|
|
from angr.analyses.codecave import CodeCaveClassification
|
|
|
|
TEST_LOCATION = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", "..", "..", "binaries", "tests")
|
|
FAUXWARE = os.path.join(TEST_LOCATION, "x86_64", "fauxware")
|
|
|
|
|
|
class TestCodeCaveAnalysis(TestCase):
|
|
def test_function_aligments(self):
|
|
p = angr.Project(FAUXWARE, auto_load_libs=False)
|
|
p.analyses.CFGFast(normalize=True)
|
|
result = p.analyses.CodeCaves()
|
|
assert [
|
|
c for c in result.codecaves if c.addr == 0x400634 and c.classification == CodeCaveClassification.ALIGNMENT
|
|
]
|
|
|
|
def test_unreachable(self):
|
|
p = angr.load_shellcode(
|
|
"""
|
|
_start:
|
|
push rbp
|
|
mov rbp, rsp
|
|
call func_1
|
|
pop rbp
|
|
ret
|
|
|
|
func_0:
|
|
xor rax, rax
|
|
ret
|
|
|
|
func_1:
|
|
mov rax, 1
|
|
ret
|
|
""",
|
|
"amd64",
|
|
)
|
|
p.analyses.CFGFast()
|
|
result = p.analyses.CodeCaves()
|
|
assert len([c for c in result.codecaves if c.classification == CodeCaveClassification.UNREACHABLE]) == 1
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|