Skip to content

Commit

Permalink
WIP: add test for user failing to call p.run()
Browse files Browse the repository at this point in the history
  • Loading branch information
ndrewh committed Jul 8, 2024
1 parent 3989500 commit f6c7616
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/err_norun.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from pyda import *
from pwnlib.elf.elf import ELF
from pwnlib.util.packing import u64
import string
import sys, time

p = process()

e = ELF(p.exe_path)
e.address = p.maps[p.exe_path].base

plt_map = { e.plt[x]: x for x in e.plt }

counter = 0
def lib_hook(p):
global counter
name = plt_map[p.regs.rip]
print(f"[thread {p.tid}] {name}")

counter += 1
if counter == 1000:
jsdkfjdsaklfadska

def thread_entry(p):
print(f"thread_entry for {p.tid}")

p.set_thread_entry(thread_entry)

for x in e.plt:
p.hook(e.plt[x], lib_hook)
12 changes: 12 additions & 0 deletions tests/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,18 @@ def main():
)
)

# err_norun.py: user fails to call p.run()
res &= run_test(
"thread_1000.c", "err_norun.py",
ExpectedResult(
retcode=0,
checkers=[
output_checker,
lambda o, e: e.count(b"[Pyda] ERROR:") == 1,
]
)
)

if not res:
exit(1)

Expand Down

0 comments on commit f6c7616

Please sign in to comment.