• XSS.stack #1 – первый литературный журнал от юзеров форума

BASH Port Scanner + support IP range

basileusapoleiaoff

HDD-drive
Пользователь
Регистрация
02.08.2023
Сообщения
40
Реакции
21
I was bored so i made this :)

How to use:

first input: you need to give an IP like 192.168.10.1
and the second input: you give the range like 255
and the third input the Port you want to scan for like 80


and of course don't forget chmod 755 script



Bash:
#!/bin/bash

echo "Entering the IP Address:"
read FirstIP

echo "Entering the last octet of IP Address to make a range:"
read range

echo "Enter the port you want to scan for:"
read Port

nmap -sT $FirstIP-$range -p $Port >/dev/null -oG MyScan

cat MyScan | grep open > MyScan2
cat MyScan2
 
Just in case you dont have nmap on your box.

scan a port range :

Bash:
#!/bin/bash

IP="REMOTE_IP_ADDRESS"

for port in {1..65535}; do
    nc -zv $IP $port >> open_ports.txt 2>&1
done

Scan a port range in a subnet
Bash:
#!/bin/bash

IP="SUBNET_IP_ADDRESS"
SUBNET_MASK="SUBNET_MASK"

IFS=. read -r i1 i2 i3 i4 <<< "$IP"
IFS=. read -r m1 m2 m3 m4 <<< "$SUBNET_MASK"

start_ip=$(( (i1 & m1) ))
start_ip+="."
start_ip=$(( (i2 & m2) ))
start_ip+="."
start_ip=$(( (i3 & m3) ))
start_ip+="."
start_ip=$(( (i4 & m4) ))

IFS=. read -r _ _ _ end_ip <<< "$SUBNET_MASK"

for ((i=i4; i<=end_ip; i++)); do
    nc -zv $start_ip$i $port >> open_ports.txt 2>&1
done
 


Напишите ответ...
  • Вставить:
Прикрепить файлы
Верх