Skip to content

Instantly share code, notes, and snippets.

@Baekalfen
Created January 3, 2017 09:27
Show Gist options
  • Save Baekalfen/5e6508bd3e05c9731b368d3a200bb7a7 to your computer and use it in GitHub Desktop.
Save Baekalfen/5e6508bd3e05c9731b368d3a200bb7a7 to your computer and use it in GitHub Desktop.
Small script to show a list of active WiFi devices on Asus routers
import subprocess
import sys
import time
des = sys.argv[1]
def call(cmd):
process = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
# wait for the process to terminate
out, err = process.communicate()
errcode = process.returncode
return (errcode, out)
mac_present = []
err, out = call("ssh %s wl -i eth2 assoclist" % des)
if err == 0:
for line in out.split('\n')[:-1]:
mac_present.append(line.split(' ')[1])
else:
print "Error", out
time.sleep(1) # Avoid SSH bruteforce detection
err, out = call("ssh %s arp" % des)
if err == 0:
for device_name in out.split('\n')[:-1]:
for mac in mac_present:
if mac in device_name:
print device_name
else:
print "Error", out
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment