#!/bin/bash if [[ "$(nc -h 2>&1 | grep -wo zero)" != "zero" ]]; then echo "You need to install netcat for this shell script to work, go to http://netcat.sourceforge.net" >&2; exit 1; fi if [[ "$(bc -h | egrep "version" | awk '{print $1}')" != "-v" ]]; then echo "You need Bison (bc) for this shell script to work. http://www.google.com/search?hl=en&q=bc+linux+download&aq=f&aqi=&oq=" >&2; exit 1; fi nmap >& /dev/null; if [[ "${?}" -ne "255" ]]; then echo "You need to install nmap for this shell script to work, go to http://www.insecure.org" >&2; exit 1; fi python -h >& /dev/null || echo "You need python for the Iphone Jail Break test via ssh. http://www.python.org/download/linux/" >&2; jail="no"; if [ ! -e jailbreaktest.py ]; then echo "I need the jailbreaktest.py script to do the jail break authentication test." >&2; jail="no"; fi ipaddress="$(netstat -rn | awk '{print $1}' | egrep -m1 '[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}'| sed 's/0$//g')"; rangeEnd="$(netstat -rn | awk '{print $3}' | egrep -m1 255 | cut -d. -f4)"; if [[ "${rangeEnd}" -ne "0" ]]; then rangeEnd=${rangeEnd}; else rangeEnd="254" fi ScanRange="$(echo ${ipaddress}1-${rangeEnd})"; MACcomputers=($(sudo nmap -sP -n -T4 ${ScanRange} | egrep --before-context=2 'Apple' | egrep -wo '[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}')); if [[ "${MACcomputers[@]}" ]] then true; else echo "No Apple computers on this LAN.."; echo "Range Scanned: ${ScanRange}"; exit 1; fi echo "=======NameThatApple results for `date`========"; for ip in ${MACcomputers[@]}; do nc -z -w1 -vv ${ip} 1 2>&1 | egrep -w "*local|[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}" | awk '{print $1 $2}' | sed 's/\[/\n&/g'; arp ${ip} | egrep 'ether' | awk '{print $3}'; ##Port scan test#### ###SSH test######### nc -z -w1 -vv ${ip} 22 &> /dev/null; if [[ "${?}" -eq "0" ]]; then echo "SSH must be running on this computer"; ###Jail Break test### if [[ "${jail}" == "no" ]]; then echo "Performing jail break test.."; python jailbreaktest.py ${ip}; if [[ "${?}" -eq "0" ]]; then echo "Jail Break test was a success!"; else echo "Jail Break test failed."; fi fi ####################### fi ##################### ########Samba test################## nc -z -w1 -vv ${ip} 137 &> /dev/null; port137="${?}"; nc -z -w1 -vv ${ip} 138 &> /dev/null; port138="${?}"; nc -z -w1 -vv ${ip} 139 &> /dev/null; port139="${?}"; netBiosResult="$(echo ${port137} + ${port138} + ${port139} | bc -l)"; if [[ ${netBiosResult} -eq "0" ]]; then echo "Samba must be running on this computer"; fi #################################### nc -z -w1 -vv ${ip} 548 &> /dev/null; if [[ "${?}" -eq "0" ]]; then echo "AFP must be running on this computer"; fi nc -z -w1 -vv ${ip} 631 &> /dev/null; if [[ "${?}" -eq "0" ]]; then echo "CUPS must be running on this computer"; fi nc -z -w1 -vv ${ip} 3689 &> /dev/null; if [[ "${?}" -eq "0" ]]; then echo "Itunes must be running on this computer"; fi ############### printf "\n"; done exit 0; #do a check on tcp port 62078 #also automate your python script to do a login on possibly jail broken iphones and set an exit code based up #on success of entry or not