Skip to content

Commit

Permalink
Merge pull request #189 from NastyaGrifon/master
Browse files Browse the repository at this point in the history
add openrc support for --kill switch
  • Loading branch information
kimocoder authored Jan 5, 2024
2 parents ab698d5 + ac9c989 commit 0118912
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

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 0118912

Please sign in to comment.