From 9eeb19fe2c454cc3a904b56c37d5d403a46e972a Mon Sep 17 00:00:00 2001 From: nastyagrifon Date: Wed, 3 Jan 2024 00:36:35 +0600 Subject: [PATCH 1/2] add openrc support for --kill --- wifite/tools/airmon.py | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/wifite/tools/airmon.py b/wifite/tools/airmon.py index 48239637b..58893c8e9 100755 --- a/wifite/tools/airmon.py +++ b/wifite/tools/airmon.py @@ -339,6 +339,14 @@ def terminate_conflicting_processes(): """ Deletes conflicting processes reported by airmon-ng """ airmon_output = Process(['airmon-ng', 'check']).stdout() + # Checking for systemd, otherwise assume openrc + try: + if os.path.exists('/usr/lib/systemd/systemd'): + init_system = 'systemd' + else: + init_system = 'openrc' + # TODO: add support for other unorthodox init systems (maybe?) + # Conflicting process IDs and names pid_pnames = [] @@ -369,17 +377,33 @@ def terminate_conflicting_processes(): if pname == 'NetworkManager' and Process.exists('systemctl'): Color.pl('{!} {O}stopping NetworkManager ({R}systemctl stop NetworkManager{O})') # Can't just pkill NetworkManager; it's a service - Process(['systemctl', 'stop', 'NetworkManager']).wait() + if init_system == 'systemd': + Process(['systemctl', 'stop', 'NetworkManager']).wait() + elif init_system == 'openrc': + Process(['rc-service', 'NetworkManager', 'stop']).wait() + else: + print(('Unsupported init system, cannot kill the process')) Airmon.killed_network_manager = True elif pname == 'network-manager' and Process.exists('service'): Color.pl('{!} {O}stopping network-manager ({R}service network-manager stop{O})') # Can't just pkill network manager; it's a service - Process(['service', 'network-manager', 'stop']).wait() + if init_system == 'systemd': + Process(['service', 'network-manager', 'stop']).wait() + elif init_system == 'openrc': + Process(['rc-service', 'network-manager', 'stop']).wait() + else: + print(('Unsupported init system, cannot kill the process')) Airmon.killed_network_manager = True elif pname == 'avahi-daemon' and Process.exists('service'): Color.pl('{!} {O}stopping avahi-daemon ({R}service avahi-daemon stop{O})') # Can't just pkill avahi-daemon; it's a service - Process(['service', 'avahi-daemon', 'stop']).wait() + if init_system == 'systemd': + Process(['service', 'avahi-daemon', 'stop']).wait() + elif init_system == 'openrc': + Process(['rc-service', 'avahi-daemon', 'stop']).wait() + else: + print(('Unsupported init system, cannot kill the process')) + else: Color.pl('{!} {R}Terminating {O}conflicting process {R}%s{O} (PID {R}%s{O})' % (pname, pid)) with contextlib.suppress(Exception): From ac9c989815eba570516e4bd1a0dce367ded88bb9 Mon Sep 17 00:00:00 2001 From: nastyagrifon Date: Wed, 3 Jan 2024 02:38:32 +0600 Subject: [PATCH 2/2] removed try --- wifite/tools/airmon.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/wifite/tools/airmon.py b/wifite/tools/airmon.py index 58893c8e9..8dfa1dbc1 100755 --- a/wifite/tools/airmon.py +++ b/wifite/tools/airmon.py @@ -340,11 +340,11 @@ def terminate_conflicting_processes(): airmon_output = Process(['airmon-ng', 'check']).stdout() # Checking for systemd, otherwise assume openrc - try: - if os.path.exists('/usr/lib/systemd/systemd'): - init_system = 'systemd' - else: - init_system = 'openrc' + + if os.path.exists('/usr/lib/systemd/systemd'): + init_system = 'systemd' + else: + init_system = 'openrc' # TODO: add support for other unorthodox init systems (maybe?) # Conflicting process IDs and names