#!/bin/sh # poorly cobbled together script to scan cisco phones - by alex (at) trull (dot) org # use as you like but feel free to give credit and make it better and send it back ;) # can scan 1000 phones in 3 minutes on relatively poor hardware, with variable latency # todo: 7936 conference phones need to be authenticated with before handing out their # todo: serials, as such they are not currently handled. if [ -z $2 ]; then echo ERROR: insufficent arguments given echo syntax: $0 subnet/netmask filename.csv echo e.g.: $0 192.168.0.0/24 network1.csv echo note: requires lynx, nmap and awk to be in the path exit 1 fi RANGE=$1 CSVFILE=$2 # create the csv header for the file - make sure these match those at the bottom of this file in the awk - you can pick and mix since I have matched all arguments already! echo "hostname,macaddress,serial,model,hwrevision,version,apploadid,bootloadid" > $CSVFILE # scan for addresses by ping only #for IP in `nmap -sP -T Aggressive -n $RANGE | awk '/appears to be up./ { print $2 };'`; do # scan for addresses by http (preferred) for IP in `nmap -sP -T Aggressive -n -PS80 $RANGE | awk '/appears to be up./ { print $2 };'`; do lynx -dump -connect_timeout=1 $IP | awk '/Host Name/ { varhostname = $NF } ; /MAC Address/ { varmacaddress = $NF } ; /Phone DN/ { varphonedn = $NF } ; /App Load ID/ { varapploadid = $NF } ; /Boot Load ID/ { varbootloadid = $NF } ; /Version/ { varversion = $NF } ; /Hardware Revision/ { varhwrevision = $NF } ; /Serial Number/ { varserial = $NF } ; /Model Number/ { varmodel = $NF } ; /Time/ { vartime = $NF } ; /Date/ { vardate = $NF } ; /Time Zone/ { vartimezone = $NF } ; /Message Waiting/ { varmessagewaiting = $NF } ; END { print varhostname","varmacaddress","varserial","varmodel","varhwrevision","varversion","varapploadid","varbootloadid};' | grep -v ",,,,,,," >> $CSVFILE ; done exit 0