Nytro Posted June 23, 2012 Report Posted June 23, 2012 [h=2]Script to Find All IP Addresses on a Internal Network[/h]Posted by purehate in Code Snippets at 12:56 PM I was working on a presentation this morning and as I was writing I realized I did not have a quick fast way to make a list of all the internal Ips on a LAN (Local Area network). Many of the tools I use including nmap, nessus and nexpose will accept a list of ips so I decided to whip up a quick dirty shell script to get the job done. I may clean it up in the future but for now it does its job. This is meant to work on Backtrack 4 but in its current state it will work on any Debian based distro. As always with any code found on the internet you use this at your own risk. Also I am sure this can be done better but like I said it was a 10 minute fix. Here is the script: Save it as ip_list.sh and give it execute permissions with chmod 75501 #!/bin/bash02 # Quick a dirty script to make a list of internal ips on a LAN03 # Questions, Comments or Death Threats can be sent to crackers@question-defense.com04 # This is made for Backtrack 4 so every one else is on their own05 06 #set some variables07 subnet=$(echo $2 | cut -f 1 -d .)08 outfile=$subnet"_ip.list"09 temp=ip.tmp10 11 #Check for the proper arguments12 if [ -z "$1" ]; then13 echo usage: $0 interface subnet14 echo "example: arp-scan eth0 192.168.1.0/24"15 exit16 fi17 18 if [ -z "$2" ]; then19 echo usage: $0 interface subnet20 echo "example: arp-scan eth0 192.168.1.0/24"21 exit22 fi23 24 #check for arp-scan25 echo "Checking for arp-scan"26 dpkg --status arp-scan | grep -q not-installed27 28 if [ $? -eq 0 ]; then29 echo "Downloading arp-scan...."30 sudo apt-get install arp-scan -y31 else32 echo "arp-scan found!"33 fi34 35 #running the scan36 /usr/bin/arp-scan $1 $2 > $temp 2>/dev/null37 cat ip.tmp | grep $subnet | awk {'print $1'} > $outfile38 rm -rf $temp39 40 count=$(wc -l $outfile | awk {'print $1'})41 echo $count "active ip's found"42 dir=$(pwd)43 echo "Your file is named" $outfile "and is located in the" $dir "directory"Sursa: Script to Find All IP Addresses on a Internal Network Quote