Skip to content

Instantly share code, notes, and snippets.

@chr15m
Created December 12, 2016 08:01
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save chr15m/8a79b891c680af3bff7704d3d3860fb4 to your computer and use it in GitHub Desktop.
Find Raspberry Pi devices on your local networks.
#!/bin/sh
# get broadcast addresses for each network
net=`ifconfig | grep -o -E "Bcast:(.*?) " | cut -f2 -d":"`
# loop over networks running the scan
for n in $net;
do
# first find SSH machines silently to prime the arp table
nmap -T4 -n -p 22 --open --min-parallelism 100 "$n/24" | grep -e "scan report for" -e "ssh" > /dev/null
done
# then run arp to show machines pi MACs
arp -na | grep b8:27:eb | grep -Eo '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment