Wednesday, November 24, 2021

kali linux 6 bash scripting

sudo apt-get update && apt-get upgrade 
sudo apt-get install git    

$ ping 192.168.37.1 -c 1
PING 192.168.37.1 (192.168.37.1) 56(84) bytes of data.
64 bytes from 192.168.37.1: icmp_seq=1 ttl=128 time=0.751 ms

$ ping 192.168.37.1 -c 1 > ip.txt

$ cat ip.txt | grep "64 bytes"
64 bytes from 192.168.37.1: icmp_seq=1 ttl=128 time=1.07 ms

$ cat ip.txt | grep "64 bytes" | cut -d " " -f 4
192.168.37.1:

$ cat ip.txt | grep "64 bytes" | cut -d " " -f 4 | tr -d ":"
192.168.37.1

ipsweep.sh
$ chmod +x ipsweep.sh   

$./ipsweep.sh 192.168.37
192.168.37.2
192.168.37.1
192.168.37.129

$ ./ipsweep.sh 192.168.37 > ip.txt

$ cat ip.txt                                                
192.168.37.1
192.168.37.2
192.168.37.129

$ for ip in $(cat ip.txt); do sudo nmap -sS -p 80 -T4 $ip & done   

[2] 11572
[3] 11573
[4] 11574
                                                                             
Starting Nmap 7.91 ( https://nmap.org ) at 2021-11-24 16:45 EST
Starting Nmap 7.91 ( https://nmap.org ) at 2021-11-24 16:45 EST
Starting Nmap 7.91 ( https://nmap.org ) at 2021-11-24 16:45 EST
┌──(kali㉿kali)-[~/Documents]
└─$ Nmap scan report for 192.168.37.129                                  3 ⚙
Host is up (0.000039s latency).

PORT   STATE  SERVICE
80/tcp closed http

Nmap done: 1 IP address (1 host up) scanned in 0.16 seconds

[4]  + done       sudo nmap -sS -p 80 -T4 $ip
┌──(kali㉿kali)-[~/Documents]
└─$ Nmap scan report for 192.168.37.2                                    2 ⚙
Host is up (0.00043s latency).

PORT   STATE  SERVICE
80/tcp closed http
MAC Address: 00:50:56:E4:7E:27 (VMware)

Nmap done: 1 IP address (1 host up) scanned in 0.26 seconds

[3]  + done       sudo nmap -sS -p 80 -T4 $ip
┌──(kali㉿kali)-[~/Documents]
└─$ Nmap scan report for 192.168.37.1                                    1 ⚙
Host is up (0.00045s latency).

PORT   STATE    SERVICE
80/tcp filtered http
MAC Address: 00:50:56:C0:00:08 (VMware)

Nmap done: 1 IP address (1 host up) scanned in 0.50 seconds

[2]  + done       sudo nmap -sS -p 80 -T4 $ip

-------------------------
$ for ip in $(cat ip.txt); do sudo nmap -sS -p 80 -T4 $ip; done

Starting Nmap 7.91 ( https://nmap.org ) at 2021-11-24 16:42 EST
Nmap scan report for 192.168.37.1
Host is up (0.0012s latency).

PORT   STATE    SERVICE
80/tcp filtered http
MAC Address: 00:50:56:C0:00:08 (VMware)

Nmap done: 1 IP address (1 host up) scanned in 0.49 seconds
Starting Nmap 7.91 ( https://nmap.org ) at 2021-11-24 16:42 EST
Nmap scan report for 192.168.37.2
Host is up (0.00051s latency).

PORT   STATE  SERVICE
80/tcp closed http
MAC Address: 00:50:56:E4:7E:27 (VMware)

Nmap done: 1 IP address (1 host up) scanned in 0.24 seconds
Starting Nmap 7.91 ( https://nmap.org ) at 2021-11-24 16:42 EST
Nmap scan report for 192.168.37.129
Host is up (0.000061s latency).

PORT   STATE  SERVICE
80/tcp closed http

Nmap done: 1 IP address (1 host up) scanned in 0.15 seconds

reference:

No comments:

Post a Comment