Skip to content

Commit

Permalink
add openrc support for --kill
Browse files Browse the repository at this point in the history
  • Loading branch information
NastyaGrifon committed Jan 2, 2024
1 parent ab698d5 commit 9eeb19f
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions wifite/tools/airmon.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []

Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 9eeb19f

Please sign in to comment.