Responsive Advertisement

The Script

Below is the IP Sweeper script,


#1/bin/bash

for ip in seq 1 254; do

ping-c1 $1.sip Igrep "64 bytes" | cut -d ""

t4 tr-d ":" &

done


This script will execute and return the ip address in the specified domain range that had responded to the ping. Write the above script in ipsweep.sh file. Now, let's break it down and try to understand the code.

Breaking down

#!/bin/bash


It's basically a comment. We are telling the computer that, it is a bash script.

for ip in seq 1254; do

This is for loop. We want to execute the command for every ip in the given network range. Thus, we write a for loop and execute it in a range for 1-254 that is, the number of ip addresses in a particular network


ping-c 1$1.Sip I grep "64 bytes" | cut -d"

-f4 tr-d "" &

ping: To ping the ip address

-c1: Ping one ip at a time

$1.$ip: $1 will be the user input. We will input the first three ranges of the IP and the last range will be taken from the tor 

loop. Example: If user input was 192.68.1 then in the first run of for loop $Sip will be

1. Thus $1.$ip will result in 192.68.1.1 and

2. it will ping this ip.

grep "64 bytes": Try running a ping command to an ip. If the ip responds, the result will be "64 bytes from (given_ip)" Thus, if the ip is active, it will respond and the response will contain the term "64 bytes". Thus, grep "64 bytes" will simply filter out the ip's that responded from a total of 254 ip addresses.

ping-c1$1.Sip Igrep "64 bytes" | cut -d * "

-f4 tr -d":" &

    We know that if the ip is active it will respond. The demo of responding will be something like this, '64 bytes from givenip where given_ip will be the ip pinged too. Thus, from the whole response now, we will need only the ip address of the responded ip.

cut-d f4: This command basically does the same thing. It cuts the whole response with the delimiter(-d) whitespace(" ") and picks the 4th term(-f 4) from it, that will be the ip.



The cut command will basically produce output like 192.68.1.1 Here, we don't need the colon(:). We just need the ip, thus we run the tr command.

tr-d "": Here we pass colon(:) as a delimiter and tr command deletes it.

&: This basically allows the thread to work simultaneously

|(pipe): lt basically joins all the above commands as a single command


How to run?


Now save the file and hit the below command on the terminal to run the script.


./fipsweep.sh [First three ranges of your ip ]

Example:./lipsweep.sh 192.186.1 This will run the file and sweep all the active ip's in the given range in the text file. Later we can perform many network-related hacking operations on these IPs

Post a Comment

Technology

Responsive Advertisement
Responsive Advertisement