Refactor tests (#3457)

* skip tests

* fix devshell

* rename .c -> .native.c

* rename .out -> .native.out

* rename crash_simple

* fixy

* fix rebase

* fix tests

* fix tests

* fix lint

* rewrite crash_simple to .C

* rewrite crash_simple to .C
pull/3459/merge
patryk4815 3 days ago committed by GitHub
parent 2d3e7775de
commit 82dc478359
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -62,7 +62,7 @@ import gdb
import pwndbg
import tests
BINARY = tests.get_binary("symbol_1600_and_752.out")
BINARY = tests.get_binary("symbol_1600_and_752.native.out")
```
Since these tests run inside GDB, we can import the `gdb` Python library. We also import the `tests` module,

@ -1,7 +0,0 @@
global _start
; This binary is there for tests that need a binary that crashes
; and is as simple as possible
_start:
mov dword [eax], 0

@ -0,0 +1,40 @@
__attribute__((naked))
void _start(void) {
#if defined(__x86_64__)
// x86_64: guaranteed illegal instruction
__asm__("ud2");
#elif defined(__i386__)
// x86 (i386): guaranteed illegal instruction
__asm__("ud2");
#elif defined(__aarch64__)
// AArch64: undefined instruction
__asm__("udf #0");
#elif defined(__arm__)
// ARM32 (A32): UDF undefined instruction
__asm__(".word 0xE7F000F0");
#elif defined(__riscv) || defined(__riscv__)
// RISC-V: opcode=0 is not a valid instruction (illegal)
__asm__(".word 0x00000000");
#elif defined(__powerpc64__) || defined(__ppc64__)
// PowerPC64: reserved/illegal instruction
__asm__(".long 0x00000000");
#elif defined(__powerpc__) || defined(__ppc__)
// PowerPC32: reserved/illegal instruction
__asm__(".long 0x00000000");
#elif defined(__mips__) && (__mips == 64)
// MIPS64: reserved/illegal instruction
__asm__(".word 0x00000000");
#elif defined(__mips__)
// MIPS32: reserved/illegal instruction
__asm__(".word 0x00000000");
#elif defined(__loongarch__) || defined(__loongarch64__)
// LoongArch64: guaranteed illegal instruction
__asm__(".word 0x002a0000");
#elif defined(__s390x__)
// IBM Z (s390x): illegal instruction
__asm__(".long 0x00000000");
#else
#error "Unsupported architecture: no illegal instruction defined"
#endif
}

@ -1,19 +1,30 @@
HOST_ARCH := $(shell uname -m)
HOST_ARCH_32 := empty
ifeq ($(HOST_ARCH),x86_64)
HOST_ARCH = x86-64
HOST_ARCH_32 := i386
else ifeq ($(HOST_ARCH),i686)
HOST_ARCH := i386
endif
ZIGCC = uv run python3 -m ziglang cc
CC = gcc
CXX = g++
MUSLCC = musl-gcc
DEBUG = 1
CFLAGS += -Wall
SOURCES_C = $(wildcard *.c)
SOURCES_C = $(wildcard *.native.c) $(wildcard *.$(HOST_ARCH).c) $(wildcard *.$(HOST_ARCH_32).c)
LINKED_C = $(SOURCES_C:.c=.out)
NASM = nasm -f elf64
LD = ld
SOURCES_ASM = $(wildcard *.asm)
SOURCES_ASM = $(wildcard *.$(HOST_ARCH).asm) $(wildcard *.$(HOST_ARCH_32).asm)
LINKED_ASM = $(SOURCES_ASM:.asm=.out)
LDFLAGS =
GO = go
SOURCES_GO = $(wildcard *.go)
SOURCES_GO = $(wildcard *.native.go) $(wildcard *.$(HOST_ARCH).go) $(wildcard *.$(HOST_ARCH_32).go)
LINKED_GO = $(SOURCES_GO:.go=.out)
ifeq ($(TARGET), x86)
@ -36,8 +47,10 @@ GLIBC_2_33=$(PWD)/glibcs/2.33
.PHONY : all clean
CUSTOM_TARGETS = reference_bin_pie.out reference_bin_nopie.out reference_bin_nopie.i386.out symbol_1600_and_752.out initialized_heap.x86-64.out initialized_heap_big.i386.out linked_lists.out onegadget.x86-64.out onegadget.i386.out heap_jemalloc_extent_info.out heap_jemalloc_heap.out heap_musl_dyn.out heap_musl_static.out gosample.i386.out gosample.x86-64.out
ALL_TARGETS := $(LINKED_C) $(LINKED_ASM) $(LINKED_GO) $(CUSTOM_TARGETS)
CUSTOM_TARGETS = reference_bin_pie.native.out reference_bin_nopie.native.out reference_bin_nopie.i386.out symbol_1600_and_752.native.out initialized_heap.x86-64.out initialized_heap_big.i386.out linked_lists.native.out onegadget.x86-64.out onegadget.i386.out heap_jemalloc_extent_info.native.out heap_jemalloc_heap.native.out heap_musl_dyn.native.out heap_musl_static.native.out gosample.i386.out gosample.x86-64.out
NATIVE_CUSTOM_TARGETS := $(filter %.native.out %.$(HOST_ARCH).out %.$(HOST_ARCH_32).out,$(CUSTOM_TARGETS))
ALL_TARGETS := $(LINKED_C) $(LINKED_ASM) $(LINKED_GO) $(NATIVE_CUSTOM_TARGETS)
all: $(ALL_TARGETS)
@ -46,7 +59,7 @@ all: $(ALL_TARGETS)
@$(CC) $(CFLAGS) -w -o $@ $? $(LDFLAGS)
%.out : %.asm
@echo "[+] Building and linking '$@'"
@echo "[+] Building '$@'"
@$(NASM) -o $@.o $?
@$(LD) -Ttext 0x400080 --section-start .note.gnu.property=0x8000000 -o $@ $@.o
@ -55,155 +68,159 @@ all: $(ALL_TARGETS)
@$(GO) build -gcflags "-N -l" -o $@ $?
@# Not stripped on purpose
gosample.i386.out : gosample.go
@echo "[+] Building gosample.i386.out"
crash_simple.native.out: crash_simple.native.c
@echo "[+] Building '$@'"
${ZIGCC} -O0 -nostdlib -ffreestanding -fno-stack-protector -fno-sanitize=all -o $@ $?
gosample.i386.out : gosample.native.go
@echo "[+] Building '$@'"
@GOARCH=386 $(GO) build -gcflags "-N -l" -o $@ $?
@# Not stripped on purpose
gosample.x86-64.out : gosample.go
@echo "[+] Building gosample.x86-64.out"
gosample.x86-64.out : gosample.native.go
@echo "[+] Building '$@'"
@GOARCH=amd64 $(GO) build -gcflags "-N -l" -o $@ $?
@# Not stripped on purpose
heap_bugs.x86-64.out: heap_bugs.x86-64.c
@echo "[+] Building heap_bugs.x86-64.out"
@echo "[+] Building '$@'"
${ZIGCC} \
${CFLAGS} \
-Wno-int-to-pointer-cast -Wno-int-conversion -Wno-unused-variable \
-target x86_64-linux-gnu.2.33 \
-Wl,-rpath=${GLIBC_2_33}:\
-Wl,--dynamic-linker=${GLIBC_2_33}/ld-linux-x86-64.so.2 \
-o heap_bugs.x86-64.out heap_bugs.x86-64.c
-o $@ $?
# TODO/FIXME: We should probably force this to 2.29? a version with tcache?
#heap_bins.out: heap_bins.c
# @echo "[+] Building heap_bins.out"
# @echo "[+] Building '$@'"
# ${ZIGCC} \
# -target x86_64-linux-gnu.2.33 \
# -Wl,-rpath=${GLIBC_2_33} \
# -Wl,--dynamic-linker=${GLIBC_2_33}/ld-linux-x86-64.so.2 \
# -g -O0 -o heap_bins.out heap_bins.c
# -g -O0 -o $@ $?
# Note: we use -pthread -lpthread because we hit this bug on CI builds:
# https://sourceware.org/bugzilla/show_bug.cgi?id=24548
heap_vis.out: heap_vis.c
@echo "[+] Building heap_vis.out"
${CC} -g -O0 -Wno-nonnull -o heap_vis.out heap_vis.c -pthread -lpthread
heap_malloc_chunk.out: heap_malloc_chunk.c
@echo "[+] Building heap_malloc_chunk.out"
${CC} -g -O0 -Wno-nonnull -Wno-unused-result -o heap_malloc_chunk.out heap_malloc_chunk.c -pthread -lpthread
heap_jemalloc_extent_info.out: heap_jemalloc_extent_info.c
@echo "[+] Building heap_jemalloc_extent_info.out"
${CC} -g -O0 -Wno-nonnull -Wno-unused-result \
-o heap_jemalloc_extent_info.out heap_jemalloc_extent_info.c \
heap_vis.native.out: heap_vis.native.c
@echo "[+] Building '$@'"
${CC} -g -O0 -Wno-nonnull -o $@ $? -pthread -lpthread
heap_malloc_chunk.native.out: heap_malloc_chunk.native.c
@echo "[+] Building '$@'"
${CC} -g -O0 -Wno-nonnull -Wno-unused-result -o $@ $? -pthread -lpthread
heap_jemalloc_extent_info.native.out: heap_jemalloc_extent_info.native.c
@echo "[+] Building '$@'"
${ZIGCC} -g -O0 -Wno-nonnull -Wno-unused-result \
-o $@ $? \
-Wl,-Bstatic -ljemalloc -Wl,-Bdynamic -lpthread -lm -lstdc++ -pthread -ldl
heap_jemalloc_heap.out: heap_jemalloc_heap.c
@echo "[+] Building heap_jemalloc_heap.out"
${CC} -g -O0 -Wno-nonnull -Wno-unused-result \
-o heap_jemalloc_heap.out heap_jemalloc_heap.c \
heap_jemalloc_heap.native.out: heap_jemalloc_heap.native.c
@echo "[+] Building '$@'"
${ZIGCC} -g -O0 -Wno-nonnull -Wno-unused-result \
-o $@ $? \
-Wl,-Bstatic -ljemalloc -Wl,-Bdynamic -lpthread -lm -lstdc++ -pthread -ldl
heap_musl_dyn.out: heap_musl.c
@echo "[+] Building heap_musl_dyn.out"
${MUSLCC} -g3 -O0 heap_musl.c -o heap_musl_dyn.out
heap_musl_dyn.native.out: heap_musl.native.c
@echo "[+] Building '$@'"
${MUSLCC} -g3 -O0 -o $@ $?
# Ideally I would do:
# strip heap_musl_static.out
# here because it would ensure mallocng commands are tested on
# a musl with no symbols. But that also makes it very hard to
# write the tests.
heap_musl_static.out: heap_musl.c
@echo "[+] Building heap_musl_static.out"
${MUSLCC} -g3 -O0 -static heap_musl.c -o heap_musl_static.out
heap_musl_static.native.out: heap_musl.native.c
@echo "[+] Building '$@'"
${MUSLCC} -g3 -O0 -static -o $@ $?
multiple_threads.out: multiple_threads.c
@echo "[+] Building multiple_threads.out"
${CC} -g -O0 -o multiple_threads.out multiple_threads.c -pthread -lpthread
multiple_threads.native.out: multiple_threads.native.c
@echo "[+] Building '$@'"
${CC} -g -O0 -o $@ $? -pthread -lpthread
tls.x86-64.out: tls.x86-64.c
@echo "[+] Building tls.x86-64.c"
@echo "[+] Building '$@'"
${ZIGCC} \
${CFLAGS} \
-target x86_64-linux-gnu \
-o tls.x86-64.out tls.x86-64.c
-o $@ $?
tls.i386.out: tls.i386.c
@echo "[+] Building tls.i386.c"
@echo "[+] Building '$@'"
${ZIGCC} \
${CFLAGS} \
-target x86-linux-gnu \
-o tls.i386.out tls.i386.c
-o $@ $?
issue_1565.out: issue_1565.c
@echo "[+] Building issue_1565.out"
${CC} -g -O0 -o issue_1565.out issue_1565.c -pthread -lpthread
issue_1565.native.out: issue_1565.native.c
@echo "[+] Building '$@'"
${CC} -g -O0 -o $@ $? -pthread -lpthread
# TODO: Link against a specific GLIBC version >= 2.26
initialized_heap_big.i386.out: initialized_heap.c
@echo "[+] Building initialized_heap_big.i386.out"
initialized_heap_big.i386.out: initialized_heap.native.c
@echo "[+] Building '$@'"
${ZIGCC} \
${CFLAGS} \
-target x86-linux-gnu \
-o initialized_heap_big.i386.out initialized_heap.c
-o $@ $?
# TODO: Link against a specific GLIBC version.
initialized_heap.x86-64.out: initialized_heap.c
@echo "[+] Building initialized_heap.x86-64.out"
initialized_heap.x86-64.out: initialized_heap.native.c
@echo "[+] Building '$@'"
${ZIGCC} \
${CFLAGS} \
-target x86_64-linux-gnu \
-o initialized_heap.x86-64.out initialized_heap.c
-o $@ $?
onegadget.x86-64.out: onegadget.c
@echo "[+] Building onegadget.x86-64.out"
onegadget.x86-64.out: onegadget.native.c
@echo "[+] Building '$@'"
${ZIGCC} \
${CFLAGS} \
-target x86_64-linux-gnu \
-o onegadget.x86-64.out onegadget.c
-o $@ $?
onegadget.i386.out: onegadget.c
@echo "[+] Building onegadget.i386.out"
onegadget.i386.out: onegadget.native.c
@echo "[+] Building '$@'"
${ZIGCC} \
${CFLAGS} \
-target x86-linux-gnu \
-o onegadget.i386.out onegadget.c
-o $@ $?
clean :
@echo "[+] Cleaning stuff"
@rm -f $(LINKED_C) $(LINKED_ASM) $(LINKED_GO) *.out *.o
linked_lists.out: linked-lists.c
@echo "[+] Building $<"
${ZIGCC} -fpie -g -o $@ $<
linked_lists.native.out: linked-lists.native.c
@echo "[+] Building '$@'"
${ZIGCC} -fpie -g -o $@ $?
reference_bin_pie.out: reference-binary.c
@echo "[+] Building reference_bin_pie.out"
${ZIGCC} -fpie -o reference_bin_pie.out reference-binary.c
reference_bin_pie.native.out: reference-binary.native.c
@echo "[+] Building '$@'"
${ZIGCC} -fpie -o $@ $?
reference_bin_nopie.out: reference-binary.c
@echo "[+] Building reference_bin_nopie.out"
${ZIGCC} -fno-pie -o reference_bin_nopie.out reference-binary.c
reference_bin_nopie.native.out: reference-binary.native.c
@echo "[+] Building '$@'"
${ZIGCC} -fno-pie -o $@ $?
reference_bin_nopie.i386.out: reference-binary.c
@echo "[+] Building reference_bin_nopie.i386.out"
${ZIGCC} -fno-pie -target x86-linux-gnu -o reference_bin_nopie.i386.out reference-binary.c
reference_bin_nopie.i386.out: reference-binary.native.c
@echo "[+] Building '$@'"
${ZIGCC} -fno-pie -target x86-linux-gnu -o $@ $?
symbol_1600_and_752.out: symbol_1600_and_752.cpp
${CXX} -O0 -ggdb -Wno-pmf-conversions symbol_1600_and_752.cpp -o symbol_1600_and_752.out
symbol_1600_and_752.native.out: symbol_1600_and_752.native.cpp
${CXX} -O0 -ggdb -Wno-pmf-conversions -o $@ $?
canary.x86-64.out: canary.x86-64.c
@echo "[+] Building canary.x86-64.out"
@echo "[+] Building '$@'"
${ZIGCC} \
${CFLAGS} \
-target x86_64-linux-gnu \
-o canary.x86-64.out canary.x86-64.c
-o $@ $?
canary.i386.out: canary.i386.c
@echo "[+] Building canary.i386.out"
@echo "[+] Building '$@'"
${ZIGCC} \
${CFLAGS} \
-target x86-linux-gnu \
-o canary.i386.out canary.i386.c
-o $@ $?

@ -26,6 +26,9 @@ class _GDBController(host.Controller):
GDB hides the asynchronous heavy lifting from us, so this call is
synchronous.
"""
if not os.path.exists(binary_path):
pytest.skip(f"{os.path.basename(binary_path)} does not exist. Platform not supported.")
os.environ["PWNDBG_IN_TEST"] = "1"
gdb.execute(f"file {binary_path}")
gdb.execute("set exception-verbose on")

@ -11,6 +11,8 @@ from typing import Coroutine
from typing import Dict
from typing import List
import pytest
async def _run(ctrl: Any, outer: Callable[..., Coroutine[Any, Any, None]]) -> None:
# We only import this here, as pwndbg-lldb is responsible for setting Pwndbg
@ -30,6 +32,9 @@ async def _run(ctrl: Any, outer: Callable[..., Coroutine[Any, Any, None]]) -> No
async def launch(
self, binary: Path, args: List[str] = [], env: Dict[str, str] = {}
) -> None:
if not os.path.exists(binary):
pytest.skip(f"{os.path.basename(binary)} does not exist. Platform not supported.")
await self.pc.execute("set context-reserve-lines never")
await self.pc.execute(f"target create {binary}")
env_args = " ".join((f"-E{k}={v}" for k, v in env.items()))

@ -7,7 +7,7 @@ from .. import get_binary
from .. import launch_to
from .. import pwndbg_test
HEAP_FIND_FAKE_FAST = get_binary("heap_find_fake_fast.out")
HEAP_FIND_FAKE_FAST = get_binary("heap_find_fake_fast.native.out")
target_address = None

@ -11,8 +11,8 @@ from .. import get_binary
from .. import launch_to
from .. import pwndbg_test
HEAP_MALLOC_CHUNK = get_binary("heap_malloc_chunk.out")
HEAP_MALLOC_CHUNK_DUMP = get_binary("heap_malloc_chunk_dump.out")
HEAP_MALLOC_CHUNK = get_binary("heap_malloc_chunk.native.out")
HEAP_MALLOC_CHUNK_DUMP = get_binary("heap_malloc_chunk_dump.native.out")
def generate_expected_malloc_chunk_output(chunks: Dict[str, ...]) -> Dict[str, ...]:
@ -559,8 +559,8 @@ async def test_heuristic_fail_gracefully(ctrl: Controller, is_multi_threaded: bo
##
# Jemalloc Tests
##
HEAP_JEMALLOC_EXTENT_INFO = get_binary("heap_jemalloc_extent_info.out")
HEAP_JEMALLOC_HEAP = get_binary("heap_jemalloc_heap.out")
HEAP_JEMALLOC_EXTENT_INFO = get_binary("heap_jemalloc_extent_info.native.out")
HEAP_JEMALLOC_HEAP = get_binary("heap_jemalloc_heap.native.out")
re_match_valid_address = r"0x7ffff[0-9a-fA-F]{6,9}"

@ -5,7 +5,7 @@ from .. import get_binary
from .. import launch_to
from .. import pwndbg_test
BINARY = get_binary("heap_bins.out")
BINARY = get_binary("heap_bins.native.out")
@pwndbg_test

@ -5,7 +5,7 @@ from .. import get_binary
from .. import launch_to
from .. import pwndbg_test
HEAP_VIS = get_binary("heap_vis.out")
HEAP_VIS = get_binary("heap_vis.native.out")
@pwndbg_test

@ -4,7 +4,7 @@ from ....host import Controller
from . import get_binary
from . import pwndbg_test
BINARY = get_binary("reference-binary.out")
BINARY = get_binary("reference-binary.native.out")
@pwndbg_test

@ -5,7 +5,7 @@ from . import get_binary
from . import launch_to
from . import pwndbg_test
REFERENCE_BINARY = get_binary("reference-binary.out")
REFERENCE_BINARY = get_binary("reference-binary.native.out")
@pwndbg_test

@ -5,7 +5,7 @@ import re
from . import get_binary
from . import pwndbg_test
REFERENCE_BINARY = get_binary("reference-binary.out")
REFERENCE_BINARY = get_binary("reference-binary.native.out")
@pwndbg_test

@ -3,7 +3,7 @@ from __future__ import annotations
from . import get_binary
from . import pwndbg_test
REFERENCE_BINARY = get_binary("reference-binary.out")
REFERENCE_BINARY = get_binary("reference-binary.native.out")
@pwndbg_test

@ -4,7 +4,7 @@ from ....host import Controller
from . import get_binary
from . import pwndbg_test
REFERENCE_BINARY = get_binary("reference-binary.out")
REFERENCE_BINARY = get_binary("reference-binary.native.out")
@pwndbg_test

@ -7,7 +7,7 @@ from . import get_binary
from . import launch_to
from . import pwndbg_test
HEAP_MALLOC_CHUNK = get_binary("heap_malloc_chunk.out")
HEAP_MALLOC_CHUNK = get_binary("heap_malloc_chunk.native.out")
@pwndbg_test

@ -6,7 +6,7 @@ from . import get_binary
from . import pwndbg_test
# We use the heap_vis binary as it enforces pthreads and so will have TLS on all distros
REFERENCE_BINARY = get_binary("heap_vis.out")
REFERENCE_BINARY = get_binary("heap_vis.native.out")
@pwndbg_test

@ -4,7 +4,7 @@ from ....host import Controller
from . import get_binary
from . import pwndbg_test
REFERENCE_BINARY = get_binary("reference-binary.out")
REFERENCE_BINARY = get_binary("reference-binary.native.out")
@pwndbg_test

@ -5,7 +5,7 @@ from . import break_at_sym
from . import get_binary
from . import pwndbg_test
REFERENCE_BINARY = get_binary("reference-binary.out")
REFERENCE_BINARY = get_binary("reference-binary.native.out")
@pwndbg_test

@ -7,7 +7,7 @@ from . import get_binary
from . import get_expr
from . import pwndbg_test
LINKED_LISTS_BINARY = get_binary("linked-lists.out")
LINKED_LISTS_BINARY = get_binary("linked-lists.native.out")
async def startup(ctrl: Controller):

@ -11,7 +11,7 @@ from . import break_at_sym
from . import get_binary
from . import pwndbg_test
REFERENCE_BINARY_NET = get_binary("reference-binary-net.out")
REFERENCE_BINARY_NET = get_binary("reference-binary-net.native.out")
class TCPServerThread(threading.Thread):

@ -7,7 +7,7 @@ from . import get_binary
from . import launch_to
from . import pwndbg_test
SEARCH_BINARY = get_binary("search_memory.out")
SEARCH_BINARY = get_binary("search_memory.native.out")
SEARCH_PATTERN = 0xD00DBEEF
SEARCH_PATTERN2 = 0xABCDEF1234567890

@ -8,7 +8,7 @@ from . import get_expr
from . import launch_to
from . import pwndbg_test
TELESCOPE_BINARY = get_binary("telescope_binary.out")
TELESCOPE_BINARY = get_binary("telescope_binary.native.out")
@pwndbg_test

@ -4,7 +4,7 @@ from ....host import Controller
from . import get_binary
from . import pwndbg_test
REFERENCE_BINARY = get_binary("reference-binary.out")
REFERENCE_BINARY = get_binary("reference-binary.native.out")
@pwndbg_test

@ -5,7 +5,7 @@ from . import break_at_sym
from . import get_binary
from . import pwndbg_test
MMAP_GAPS_BINARY = get_binary("mmap_gaps.out")
MMAP_GAPS_BINARY = get_binary("mmap_gaps.native.out")
@pwndbg_test

@ -9,8 +9,8 @@ from . import get_binary
from . import pwndbg_test
NO_SECTS_BINARY = get_binary("gosample.i386.out")
PIE_BINARY_WITH_PLT = "reference_bin_pie.out"
NOPIE_BINARY_WITH_PLT = "reference_bin_nopie.out"
PIE_BINARY_WITH_PLT = "reference_bin_pie.native.out"
NOPIE_BINARY_WITH_PLT = "reference_bin_nopie.native.out"
NOPIE_I386_BINARY_WITH_PLT = "reference_bin_nopie.i386.out"

@ -8,8 +8,8 @@ from . import get_binary
from . import launch_to
from . import pwndbg_test
REFERENCE_BINARY = get_binary("reference-binary.out")
CRASH_SIMPLE_BINARY = get_binary("crash_simple.out.hardcoded")
REFERENCE_BINARY = get_binary("reference-binary.native.out")
CRASH_SIMPLE_BINARY = get_binary("crash_simple.native.out")
NEXT_COMMANDS = (
"pc",

@ -10,11 +10,11 @@ from . import get_binary
from . import launch_to
from . import pwndbg_test
REFERENCE_BINARY = get_binary("reference-binary.out")
USE_FDS_BINARY = get_binary("use-fds.out")
TABSTOP_BINARY = get_binary("tabstop.out")
REFERENCE_BINARY = get_binary("reference-binary.native.out")
USE_FDS_BINARY = get_binary("use-fds.native.out")
TABSTOP_BINARY = get_binary("tabstop.native.out")
SYSCALLS_BINARY = get_binary("syscalls.x86-64.out")
MANGLING_BINARY = get_binary("symbol_1600_and_752.out")
MANGLING_BINARY = get_binary("symbol_1600_and_752.native.out")
@pwndbg_test
@ -75,7 +75,7 @@ async def test_context_disasm_show_fd_filepath(ctrl: Controller) -> None:
line_call_read, line_fd, line_buf, line_nbytes, *_rest = lines_after_call_read
line_fd = line_fd.strip()
assert re.match(r"fd:\s+3 \([a-z/]*pwndbg/tests/binaries/host/use-fds.out\)", line_fd)
assert re.match(r"fd:\s+3 \([a-z/]*pwndbg/tests/binaries/host/use-fds.native.out\)", line_fd)
line_buf = line_buf.strip()
assert re.match(r"buf:\s+0x[0-9a-f]+ ◂— 0", line_buf)
@ -112,7 +112,7 @@ async def test_source_code_tabstop(ctrl: Controller) -> None:
await ctrl.launch(TABSTOP_BINARY)
# Run until line 6
await ctrl.execute("b tabstop.c:6")
await ctrl.execute("b tabstop.native.c:6")
await ctrl.cont()
# Default context-code-tabstop = 8

@ -13,7 +13,7 @@ GOSAMPLE_X86 = get_binary("gosample.i386.out")
async def helper_test_dump(ctrl: Controller, target: str) -> None:
await ctrl.launch(target, env={"GOMAXPROCS": "1"})
await ctrl.execute("b gosample.go:6")
await ctrl.execute("b gosample.native.go:6")
await ctrl.cont()
dump = await ctrl.execute_and_capture("go-dump any &x")

@ -6,7 +6,7 @@ from ....host import Controller
from . import get_binary
from . import pwndbg_test
BINARY = get_binary("reference-binary.out")
BINARY = get_binary("reference-binary.native.out")
async def run_tests(ctrl: Controller, stack: int, use_big_endian: bool, expected: str) -> None:

@ -11,8 +11,8 @@ from . import get_binary
from . import launch_to
from . import pwndbg_test
HEAP_MALLOCNG_DYN = get_binary("heap_musl_dyn.out")
HEAP_MALLOCNG_STATIC = get_binary("heap_musl_static.out")
HEAP_MALLOCNG_DYN = get_binary("heap_musl_dyn.native.out")
HEAP_MALLOCNG_STATIC = get_binary("heap_musl_static.native.out")
# Userland only
re_addr = r"0x[0-9a-fA-F]{1,12}"

@ -5,8 +5,8 @@ from . import get_binary
from . import launch_to
from . import pwndbg_test
REFERENCE_BINARY = get_binary("reference-binary.out")
NESTED_STRUCTS_BINARY = get_binary("nested_structs.out")
REFERENCE_BINARY = get_binary("reference-binary.native.out")
NESTED_STRUCTS_BINARY = get_binary("nested_structs.native.out")
@pwndbg_test

@ -4,7 +4,7 @@ from ....host import Controller
from . import get_binary
from . import pwndbg_test
USE_FDS_BINARY = get_binary("use-fds.out")
USE_FDS_BINARY = get_binary("use-fds.native.out")
@pwndbg_test
@ -65,7 +65,7 @@ async def test_mmap_executes_properly(ctrl: Controller) -> None:
assert ptr == base_addr
# Continue the program until just before close(2) is called.
await ctrl.execute("b use-fds.c:16")
await ctrl.execute("b use-fds.native.c:16")
await ctrl.cont()
# Retrieve the file descriptor number and map it to memory.

@ -4,7 +4,7 @@ from ....host import Controller
from . import get_binary
from . import pwndbg_test
SMALL_BINARY = get_binary("crash_simple.out.hardcoded")
SMALL_BINARY = get_binary("crash_simple.native.out")
@pwndbg_test

@ -5,7 +5,7 @@ from . import break_at_sym
from . import get_binary
from . import pwndbg_test
MANGLING_BINARY = get_binary("symbol_1600_and_752.out")
MANGLING_BINARY = get_binary("symbol_1600_and_752.native.out")
@pwndbg_test

@ -7,7 +7,7 @@ from ....host import Controller
from . import get_binary
from . import pwndbg_test
REFERENCE_BINARY = get_binary("reference-binary.out")
REFERENCE_BINARY = get_binary("reference-binary.native.out")
async def set_param(ctrl: Controller, param_name: str, value: Any):

@ -12,7 +12,7 @@ import pwndbg.dbg
from .. import get_binary
HEAP_FIND_FAKE_FAST = get_binary("heap_find_fake_fast.out")
HEAP_FIND_FAKE_FAST = get_binary("heap_find_fake_fast.native.out")
target_address = None

@ -14,8 +14,8 @@ from pwndbg.aglib.heap.ptmalloc import SymbolUnresolvableError
from .. import get_binary
HEAP_MALLOC_CHUNK = get_binary("heap_malloc_chunk.out")
HEAP_MALLOC_CHUNK_DUMP = get_binary("heap_malloc_chunk_dump.out")
HEAP_MALLOC_CHUNK = get_binary("heap_malloc_chunk.native.out")
HEAP_MALLOC_CHUNK_DUMP = get_binary("heap_malloc_chunk_dump.native.out")
def generate_expected_malloc_chunk_output(chunks):
@ -510,8 +510,8 @@ def test_heuristic_fail_gracefully(start_binary, is_multi_threaded):
##
# Jemalloc Tests
##
HEAP_JEMALLOC_EXTENT_INFO = get_binary("heap_jemalloc_extent_info.out")
HEAP_JEMALLOC_HEAP = get_binary("heap_jemalloc_heap.out")
HEAP_JEMALLOC_EXTENT_INFO = get_binary("heap_jemalloc_extent_info.native.out")
HEAP_JEMALLOC_HEAP = get_binary("heap_jemalloc_heap.native.out")
# Relax address regex to accept different virtual address layouts (ASLR / jemalloc mappings).
# Old pattern assumed addresses starting with 0x7ffff and a limited digit count which fails on some hosts.
re_match_valid_address = r"0x[0-9a-fA-F]{6,16}"

@ -12,7 +12,7 @@ from pwndbg.aglib.heap.ptmalloc import BinType
from .. import get_binary
BINARY = get_binary("heap_bins.out")
BINARY = get_binary("heap_bins.native.out")
def test_heap_bins(start_binary):

@ -8,7 +8,7 @@ import pwndbg.aglib.vmmap
from .. import get_binary
HEAP_VIS = get_binary("heap_vis.out")
HEAP_VIS = get_binary("heap_vis.native.out")
def test_vis_heap_chunk_command(start_binary):

@ -6,7 +6,7 @@ from pwndbg.lib import cache
from . import get_binary
BINARY = get_binary("reference-binary.out")
BINARY = get_binary("reference-binary.native.out")
def test_cache_single_value(start_binary):

@ -7,7 +7,7 @@ import pwndbg.aglib.stack
from . import get_binary
REFERENCE_BINARY = get_binary("reference-binary.out")
REFERENCE_BINARY = get_binary("reference-binary.native.out")
def test_callstack_readable(start_binary):

@ -9,7 +9,7 @@ import pwndbg.aglib.regs
from . import get_binary
REFERENCE_BINARY = get_binary("reference-binary.out")
REFERENCE_BINARY = get_binary("reference-binary.native.out")
def test_command_cyclic_value(start_binary):

@ -6,7 +6,7 @@ import pwndbg.aglib.regs
from . import get_binary
REFERENCE_BINARY = get_binary("reference-binary.out")
REFERENCE_BINARY = get_binary("reference-binary.native.out")
def test_command_distance(start_binary):

@ -6,7 +6,7 @@ import gdb
from . import get_binary
HEAP_MALLOC_CHUNK = get_binary("heap_malloc_chunk.out")
HEAP_MALLOC_CHUNK = get_binary("heap_malloc_chunk.native.out")
def test_command_dt_works_with_address(start_binary):

@ -5,7 +5,7 @@ import gdb
from . import get_binary
# We use the heap_vis binary as it enforces pthreads and so will have TLS on all distros
REFERENCE_BINARY = get_binary("heap_vis.out")
REFERENCE_BINARY = get_binary("heap_vis.native.out")
def test_command_errno(start_binary):

@ -6,7 +6,7 @@ import pwndbg.aglib.regs
from . import get_binary
REFERENCE_BINARY = get_binary("reference-binary.out")
REFERENCE_BINARY = get_binary("reference-binary.native.out")
def test_flags_command(start_binary):

@ -11,8 +11,8 @@ import pytest
from . import get_binary
REFERENCE_BINARY = get_binary("reference-binary.out")
USE_FDS_BINARY = get_binary("use-fds.out")
REFERENCE_BINARY = get_binary("reference-binary.native.out")
USE_FDS_BINARY = get_binary("use-fds.native.out")
class TCPServerThread(threading.Thread):

@ -6,7 +6,7 @@ import pwndbg.aglib.proc
from . import get_binary
REFERENCE_BINARY = get_binary("reference-binary.out")
REFERENCE_BINARY = get_binary("reference-binary.native.out")
def test_command_ignore_no_breakpoint_set():

@ -8,7 +8,7 @@ import pwndbg.dbg
from . import get_binary
REFERENCE_BINARY_THREADS = get_binary("multiple_threads.out")
REFERENCE_BINARY_THREADS = get_binary("multiple_threads.native.out")
def wait_until(predicate: callable, timeout: int = 10):

@ -4,7 +4,7 @@ import gdb
from . import get_binary
REFERENCE_BINARY = get_binary("reference-binary.out")
REFERENCE_BINARY = get_binary("reference-binary.native.out")
def test_command_libcinfo(start_binary):

@ -6,7 +6,7 @@ import gdb
from . import get_binary
LINKED_LISTS_BINARY = get_binary("linked-lists.out")
LINKED_LISTS_BINARY = get_binary("linked-lists.native.out")
def startup(start_binary) -> None:

@ -11,7 +11,7 @@ import pwndbg.aglib.proc
from . import get_binary
REFERENCE_BINARY_NET = get_binary("reference-binary-net.out")
REFERENCE_BINARY_NET = get_binary("reference-binary-net.native.out")
class TCPServerThread(threading.Thread):

@ -6,7 +6,7 @@ import gdb
from . import get_binary
SEARCH_BINARY = get_binary("search_memory.out")
SEARCH_BINARY = get_binary("search_memory.native.out")
SEARCH_PATTERN = 0xD00DBEEF
SEARCH_PATTERN2 = 0xABCDEF1234567890

@ -11,7 +11,7 @@ import pwndbg.aglib.vmmap
from . import get_binary
TELESCOPE_BINARY = get_binary("telescope_binary.out")
TELESCOPE_BINARY = get_binary("telescope_binary.native.out")
def test_command_telescope(start_binary):

@ -9,9 +9,9 @@ import pwndbg.aglib.proc
from . import get_binary
GAPS_MAP_BINARY = get_binary("mmap_gaps.out")
CRASH_SIMPLE_BINARY = get_binary("crash_simple.out.hardcoded")
BINARY_ISSUE_1565 = get_binary("issue_1565.out")
GAPS_MAP_BINARY = get_binary("mmap_gaps.native.out")
CRASH_SIMPLE_BINARY = get_binary("crash_simple.native.out")
BINARY_ISSUE_1565 = get_binary("issue_1565.native.out")
def get_proc_maps():

@ -8,7 +8,7 @@ from pwndbg.commands.xor import memfrob
from . import get_binary
REFERENCE_BINARY = get_binary("reference-binary.out")
REFERENCE_BINARY = get_binary("reference-binary.native.out")
def test_command_xor_with_gdb_execute(start_binary):

@ -9,7 +9,7 @@ from pwndbg.commands import command_names
from . import get_binary
BINARY = get_binary("heap_bins.out")
BINARY = get_binary("heap_bins.native.out")
# TODO: See if we can reduce the number of commands we need to skip
disallowed_commands = {

@ -4,7 +4,7 @@ import gdb
from . import get_binary
MMAP_GAPS_BINARY = get_binary("mmap_gaps.out")
MMAP_GAPS_BINARY = get_binary("mmap_gaps.native.out")
def test_dump_mmap_args(start_binary):

@ -9,8 +9,8 @@ import pytest
from . import get_binary
NO_SECTS_BINARY = get_binary("gosample.i386.out")
PIE_BINARY_WITH_PLT = "reference_bin_pie.out"
NOPIE_BINARY_WITH_PLT = "reference_bin_nopie.out"
PIE_BINARY_WITH_PLT = "reference_bin_pie.native.out"
NOPIE_BINARY_WITH_PLT = "reference_bin_nopie.native.out"
NOPIE_I386_BINARY_WITH_PLT = "reference_bin_nopie.i386.out"

@ -9,8 +9,8 @@ import pwndbg.aglib.vmmap
from . import get_binary
REFERENCE_BINARY = get_binary("reference-binary.out")
CRASH_SIMPLE_BINARY = get_binary("crash_simple.out.hardcoded")
REFERENCE_BINARY = get_binary("reference-binary.native.out")
CRASH_SIMPLE_BINARY = get_binary("crash_simple.native.out")
NEXT_COMMANDS = (
"pc",

@ -13,11 +13,11 @@ import pwndbg.commands.context
from . import get_binary
REFERENCE_BINARY = get_binary("reference-binary.out")
USE_FDS_BINARY = get_binary("use-fds.out")
TABSTOP_BINARY = get_binary("tabstop.out")
REFERENCE_BINARY = get_binary("reference-binary.native.out")
USE_FDS_BINARY = get_binary("use-fds.native.out")
TABSTOP_BINARY = get_binary("tabstop.native.out")
SYSCALLS_BINARY = get_binary("syscalls.x86-64.out")
MANGLING_BINARY = get_binary("symbol_1600_and_752.out")
MANGLING_BINARY = get_binary("symbol_1600_and_752.native.out")
def test_context_disasm_show_fd_filepath(start_binary):
@ -71,7 +71,7 @@ def test_context_disasm_show_fd_filepath(start_binary):
line_call_read, line_fd, line_buf, line_nbytes, *_rest = lines_after_call_read
line_fd = line_fd.strip()
assert re.match(r"fd:\s+3 \([a-z/]*pwndbg/tests/binaries/host/use-fds.out\)", line_fd)
assert re.match(r"fd:\s+3 \([a-z/]*pwndbg/tests/binaries/host/use-fds.native.out\)", line_fd)
line_buf = line_buf.strip()
assert re.match(r"buf:\s+0x[0-9a-f]+ ◂— 0", line_buf)
@ -104,7 +104,7 @@ def test_source_code_tabstop(start_binary):
start_binary(TABSTOP_BINARY)
# Run until line 6
gdb.execute("break tabstop.c:6")
gdb.execute("break tabstop.native.c:6")
gdb.execute("continue")
# Default context-code-tabstop = 8

@ -10,7 +10,7 @@ if pwndbg.dbg.is_gdblib_available():
from . import get_binary
REFERENCE_BINARY = get_binary("reference-binary.out")
REFERENCE_BINARY = get_binary("reference-binary.native.out")
# Might be useful for future expansion of the test case

@ -4,7 +4,7 @@ import gdb
from . import get_binary
REFERENCE_BINARY = get_binary("reference-binary.out")
REFERENCE_BINARY = get_binary("reference-binary.native.out")
def test_function_base(start_binary):

@ -12,7 +12,7 @@ import pwndbg.glibc
from . import get_binary
# We used the same binary as heap tests since it will use libc, and many functions are mainly for debugging the heap
HEAP_MALLOC_CHUNK = get_binary("heap_malloc_chunk.out")
HEAP_MALLOC_CHUNK = get_binary("heap_malloc_chunk.native.out")
@pytest.mark.parametrize(

@ -33,7 +33,7 @@ def test_typeinfo_go_x86():
def helper_test_dump(start_binary, filename):
gdb.execute("set environment GOMAXPROCS=1")
start_binary(filename)
gdb.execute("break gosample.go:6", to_string=True)
gdb.execute("break gosample.native.go:6", to_string=True)
gdb.execute("continue")
dump = gdb.execute("go-dump any &x", to_string=True)

@ -11,7 +11,7 @@ import pwndbg.aglib.vmmap
from . import get_binary
BINARY = get_binary("reference-binary.out")
BINARY = get_binary("reference-binary.native.out")
def run_tests(stack, use_big_endian, expected):

@ -14,7 +14,7 @@ HELLO = [
" Type help function to see them.",
]
BINARY = get_binary("div_zero.out")
BINARY = get_binary("div_zero.native.out")
CORE = "/tmp/pwndbg-tests-div-zero-core"

@ -9,8 +9,8 @@ import pwndbg.dbg
from . import get_binary
REFERENCE_BINARY = get_binary("reference-binary.out")
NESTED_STRUCTS_BINARY = get_binary("nested_structs.out")
REFERENCE_BINARY = get_binary("reference-binary.native.out")
NESTED_STRUCTS_BINARY = get_binary("nested_structs.native.out")
def test_memory_read_write(start_binary):

@ -9,7 +9,7 @@ import pwndbg.lib.memory
from . import get_binary
USE_FDS_BINARY = get_binary("use-fds.out")
USE_FDS_BINARY = get_binary("use-fds.native.out")
def test_mmap_executes_properly(start_binary):
@ -64,7 +64,7 @@ def test_mmap_executes_properly(start_binary):
assert ptr == base_addr
# Continue the program until just before close(2) is called.
gdb.execute("break use-fds.c:16")
gdb.execute("break use-fds.native.c:16")
gdb.execute("continue")
# Retrieve the file descriptor number and map it to memory.

@ -7,7 +7,7 @@ import pwndbg.aglib.vmmap
from . import get_binary
SMALL_BINARY = get_binary("crash_simple.out.hardcoded")
SMALL_BINARY = get_binary("crash_simple.native.out")
def test_mprotect_executes_properly(start_binary):

@ -6,7 +6,7 @@ import pwndbg.color.message
from . import get_binary
BINARY = get_binary("reference-binary.out")
BINARY = get_binary("reference-binary.native.out")
def prepare_prompt(is_proc_alive):

@ -6,7 +6,7 @@ import pwndbg.dbg
from . import get_binary
MANGLING_BINARY = get_binary("symbol_1600_and_752.out")
MANGLING_BINARY = get_binary("symbol_1600_and_752.native.out")
def test_symbol_get(start_binary):

Loading…
Cancel
Save