2020-05-19 19:14:55 -04:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
from libwifi import *
|
|
|
|
import argparse, time
|
|
|
|
|
|
|
|
def main():
|
|
|
|
parser = argparse.ArgumentParser(description="Test packet injection properties of a device.")
|
|
|
|
parser.add_argument('inject', help="Interface to use to inject frames.")
|
2020-05-22 09:46:51 -04:00
|
|
|
parser.add_argument('monitor', nargs='?', help="Interface to use to monitor for frames.")
|
2020-05-19 19:14:55 -04:00
|
|
|
options = parser.parse_args()
|
|
|
|
|
2020-06-26 01:59:18 -04:00
|
|
|
peermac = "00:11:22:33:44:55"
|
|
|
|
|
2020-06-27 09:27:46 -04:00
|
|
|
# TODO: Add a --debug parameter similar to fragattack
|
|
|
|
|
2020-05-19 19:14:55 -04:00
|
|
|
subprocess.check_output(["rfkill", "unblock", "wifi"])
|
|
|
|
|
|
|
|
set_monitor_mode(options.inject)
|
2020-05-22 09:46:51 -04:00
|
|
|
if options.monitor:
|
|
|
|
set_monitor_mode(options.monitor)
|
2020-06-26 01:59:18 -04:00
|
|
|
chan_inject = get_channel(options.inject)
|
|
|
|
chan_monitor = get_channel(options.monitor)
|
|
|
|
if chan_inject == None or chan_monitor == None:
|
|
|
|
log(WARNING, "Unable to verify if both devices are on the same channel")
|
|
|
|
elif chan_inject != chan_monitor:
|
2020-05-22 09:46:51 -04:00
|
|
|
log(ERROR, "Both devices are not on the same channel")
|
|
|
|
quit(1)
|
2020-06-26 01:59:18 -04:00
|
|
|
peermac = get_mac_address(options.monitor)
|
2020-05-22 09:46:51 -04:00
|
|
|
else:
|
|
|
|
log(WARNING, "Only performing selftest. This can detect only injection issues caused by")
|
2020-06-26 01:59:18 -04:00
|
|
|
log(WARNING, "the kernel. Many other issues cannot be detected in this self-test, so you")
|
2020-05-22 09:46:51 -04:00
|
|
|
log(WARNING, "should not trust the output of the tests unless you know what you're doing.")
|
2020-05-19 19:14:55 -04:00
|
|
|
|
|
|
|
log(STATUS, "Performing injection tests ...")
|
2020-06-26 01:59:18 -04:00
|
|
|
try:
|
|
|
|
test_injection(options.inject, options.monitor, peermac)
|
|
|
|
except OSError as ex:
|
|
|
|
log(ERROR, str(ex))
|
2020-05-19 19:14:55 -04:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|
|
|
|
|