-
-
Save osmanmakal/84703c810b89f716d6ae98b5407ab461 to your computer and use it in GitHub Desktop.
| #!/bin/bash | |
| # KULLANIM | |
| # bash esxi-scan.sh 195.175.33.0/24 | |
| # | |
| input=$1 | |
| net=$(echo $input | cut -d '/' -f 1) | |
| prefix=$(echo $input | cut -d '/' -f 2) | |
| if (($prefix != 24)) | |
| then | |
| echo "sadece /24" | |
| exit 1 | |
| fi | |
| cut=$(echo $net | cut -d. -f1,2,3). | |
| for i in $(seq 255); do | |
| echo | timeout 0.2 unbuffer nc -nvw1 $cut$i 902 | if grep -iq "VMware" | |
| then | |
| echo "$cut$i ESXi VAR KONTROL ET" | |
| else | |
| echo "$cut$i esxi yok" | |
| fi | |
| done |
Kod için teşekkürler
Çok fazla /24 varsa, bunları subnets.txt ye altalta yazıp aşağıdaki gibi de taratabilirsiniz.
`while read subnets; do
cut=$(echo $subnets | cut -d. -f1,2,3).
for i in $(seq 255); do
echo | timeout 0.2 nc -nw1 $cut$i 902 | if grep -iq "VMware"
then
echo "$cut$i ESXi VAR KONTROL ET"
fi
done
done <subnets.txt
`
İlgili .sh dosyası çalıştırılması halinde çok uzun bir cevap alacaksınız ve terminal ekranı size bu uzun çıktıyı gösteremeyecektir.
İlgili cevabı " bash esxscan.sh 0.0.0.0/24 > output.txt " şeklinde aynı dizinde bulunan bir .txt dosyasına atarsanız tüm sonuçları o .txt dosyasında aşağıdaki gibi görebilirsiniz.
0.0.0.0 esxi yok
0.0.0.1 esxi yok
0.0.0.2 esxi yok
İlgili .sh dosyası çalıştırılması halinde çok uzun bir cevap alacaksınız ve terminal ekranı size bu uzun çıktıyı gösteremeyecektir.
İlgili cevabı " bash esxscan.sh 0.0.0.0/24 > output.txt " şeklinde aynı dizinde bulunan bir .txt dosyasına atarsanız tüm sonuçları o .txt dosyasında aşağıdaki gibi görebilirsiniz.
0.0.0.0 esxi yok 0.0.0.1 esxi yok 0.0.0.2 esxi yok
Eğer 18 ve 19. satırları kaldırırsanız gereksiz printleri, output kirliliğini ve dolayısı ile oluşacak geciklmeyi önleyebilirsiniz.
apt install expect
yum install expect
Eğer çalışmazsa hangi paket yöneticisini kullanıyorsanız expect kurulumu yapın