Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #
- # Hocam subnet hesaplamasinda hata var ama vakit yetmedi malesef :(
- # Baslangic ip ve toplam ip blogunu hesaplayamadim, uzerinde biraz daha ugrasmam lazim
- # fping ile daha kolay yapilabiliyor aslinda ama dediginiz gibi zor yolu tercih ettim biraz..
- if [[ $# -eq 0 ]] ; then
- echo "[*] Kullanimi: $0 <interface>"
- exit 1
- fi
- IF=$1
- IP=$(ifconfig $IF | grep Mask | cut -d ':' -f2 | cut -d " " -f1)
- Mask=$(ifconfig $IF | grep Mask | cut -d ':' -f4 | cut -d " " -f1)
- IFS=.
- IPArray=($IP)
- MaskArray=($Mask)
- NetArray=()
- Start=0
- Max=$(( 255 * 255 * 255 * 255 ))
- for ara in "${!IPArray[@]}";
- do
- NetArray[$ara]=$(( ${IPArray[$ara]} & ${MaskArray[$ara]} ))
- Start=$(( $Start + (${NetArray[$ara]} << (3-$ara)*8) ))
- done
- IFS=
- echo "IP Adresiniz : $IP"
- echo "Subnet Maskiniz : $Mask"
- echo "Network : ${NetArray[@]}"
- for ((IPs=$Start; IPs <= $Max; IPs++))
- do
- IP=$(( IPs >> 24 ))
- IP="$IP.$(( (IPs >> 16) & 255 ))"
- IP="$IP.$(( (IPs >> 8) & 255 ))"
- IP="$IP.$(( IPs & 255 ))"
- $(ping -c 1 -w 1 $IP >& /dev/null)
- if [[ $? -eq 0 ]]; then
- echo "[+] $IP aktif."
- AKTIF=$AKTIF+1
- else
- PASIF=$PASIF+1
- echo "[-] $IP pasif."
- fi
- done
- echo "\n[*] Tarama tamamlandi:"
- echo "[-] $AKFIT aktif cihaz"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement