Fix test command procinfo (#1706)

* Updated canary.py for better display

* Updated test_command_procinfo.py

* Revert "Updated canary.py for better display"

This reverts commit 802e243183.

* Fix lint issue

* Update test_command_procinfo.py

---------

Co-authored-by: Unknown6334 <63234449+Unknown1934-del@users.noreply.github.com>
Co-authored-by: Disconnect3d <dominik.b.czarnota@gmail.com>
pull/1717/head
Unknown Sentinel 3 years ago committed by GitHub
parent f402732a33
commit 14bb546efe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,5 +1,7 @@
import os
import shutil
import signal
import subprocess
import gdb
@ -11,9 +13,18 @@ REFERENCE_BINARY_NET = tests.binaries.get("reference-binary-net.out")
def test_command_procinfo(start_binary):
start_binary(REFERENCE_BINARY_NET)
# Sanity check, netcat must exist at this point
assert shutil.which("nc") is not None
os.system("nc -l -p 31337 2>/dev/null 1>&2 &")
# Check if netcat exists
nc_path = shutil.which("nc")
assert nc_path is not None, "netcat is not installed"
# Spawn netcat
netcat_process = subprocess.Popen(
[nc_path, "-l", "-p", "31337"],
stdin=subprocess.DEVNULL,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
start_new_session=True,
)
bin_path = gdb.execute("pi pwndbg.gdblib.proc.exe", to_string=True).strip("\n")
pid = gdb.execute("pi pwndbg.gdblib.proc.pid", to_string=True).strip("\n")
@ -28,6 +39,9 @@ def test_command_procinfo(start_binary):
assert pid in res_list[1]
assert "127.0.0.1:31337" in result
# Close netcat
os.killpg(os.getpgid(netcat_process.pid), signal.SIGTERM)
def test_command_procinfo_before_binary_start():
result = gdb.execute("procinfo", to_string=True)

Loading…
Cancel
Save