I am kind of new to Python and trying to learn how to write an SSID Scanner that will do the following:
- Ask user for length of time to scan
- Enable Monitor Mode through Airmon-NG using a wlan
- Check to see if Mon0 is infact enabled, then goes to the next step
- After checking for Mon0, start Airmon-NG using Mon0 and scan for 5 minutes
- Have the program see that once the 5 minute mark is hit, print out "SSID Scan Complete"
- Close program
I'd like to eventually grab the scan output after 5 minutes and dump it into a text file for later viewing, but I'm not there yet, so excuse the Python ignorance as I continue to learn. All I have so far is after research, but I feel stuck and some parts I know are wrong and I cant figure them out, such as:
- actually verifing Mon0 is on before starting airodump-NG
- Waiting for the inputted time length before finishing
Here is what I have so far:
#!/usr/bin/env python
import os
import subprocess
from datetime import datetime
#Clear the screen
subprocess.call("clear")
#Ask for the length of time in Minutes to scan for SSIDs
scan_ssid = raw_input("How many minutes would you like to scan for: ")
scan_length = scan_ssid
#Print banner
print "Scanning for SSIDs for " + scan_ssid " minutes."
#Start and verify airmon-ng in monitor mode
print "Placing wlan iface in Monitor Mode"
os.system("airmon-ng start wlan2")
monitor = mon0
if monitor == True:
print "Monitor Mode: Enabled"
#Start airodump-ng with monitor enabled
print "Starting SSID scan with Monitor Mode"
os.system("airodump-ng mon0")
#Scan for the user requested timefame
scan_length = time.time()
while True:
scan_length = 0
if scan_length == 5 or time.time() > scan_length:
break
scan_length = scan_length - 1
print "SSID Scan Complete!"
sys.exit(0)