Skip to content

Instantly share code, notes, and snippets.

@osmanmakal
Created February 3, 2023 17:54
Show Gist options
  • Select an option

  • Save osmanmakal/84703c810b89f716d6ae98b5407ab461 to your computer and use it in GitHub Desktop.

Select an option

Save osmanmakal/84703c810b89f716d6ae98b5407ab461 to your computer and use it in GitHub Desktop.
esxi-scan.sh
#!/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
@osmanmakal
Copy link
Author

apt install expect
yum install expect

Eğer çalışmazsa hangi paket yöneticisini kullanıyorsanız expect kurulumu yapın

@burakyalti
Copy link

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
`

@ErhanERT
Copy link

ErhanERT commented Feb 5, 2023

İ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

@enesbakis
Copy link

İ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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment