From 74f7c113441d0bff3f7adc06be8391415a978c55 Mon Sep 17 00:00:00 2001 From: Caleb Stewart Date: Tue, 2 Jun 2020 21:27:17 -0400 Subject: [PATCH] Correctly catch errors while probing init system. Should fix #16 --- pwncat/remote/victim.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pwncat/remote/victim.py b/pwncat/remote/victim.py index dfba384..ac0a1ef 100644 --- a/pwncat/remote/victim.py +++ b/pwncat/remote/victim.py @@ -512,8 +512,11 @@ class Victim: """ util.progress("identifying init system") - with self.open("/proc/1/comm", "r") as filp: - init = filp.read() + try: + with self.open("/proc/1/comm", "r") as filp: + init = filp.read() + except (FileNotFoundError, PermissionError): + init = None if "systemd" in init: self.host.init = util.Init.SYSTEMD @@ -521,6 +524,8 @@ class Victim: self.host.init = util.Init.UPSTART elif "sysv" in init: self.host.init = util.Init.SYSV + else: + self.host.init = util.Init.UNKNOWN util.progress("identifying remote kernel version") try: