pwd
- It prints the current working directory
Is
- This command is used to list information or content in a particular
file/folder.
cd
- It is used to change the current working directory. Example: cd Desktop
mkdir
- Create a new folder
man
- Displays the help manual for a
particular command. Example: man Is
shutdown:
Shutdown or restart your system
rmdir:
Used to remove/delete a directory/folder
clear:
Clear the terminal
apt-get
update: Update kali Linux
apt-get
install: To install a new program.
Example: apt-get install leafpad
ifconfig:
It is similar to the windows command ipconfig. It shows basic network details
such as IP addresses, broadcast address, mac
address, and much more.
iwconfig:
It is similar to the ifconfig command. It is more focussed on only wireless
network
interfaces.
ping:
It is usually used as a simple way to verify that a computer can communicate
over the network with another computer or network device.
arp:
It is used to find IP to MAC address mappings. ARP, which stands for Address
Resolution Protocol, is a protocol used to map
a MAC address (or hardware address) to an IP address.
netstat:
It delivers basic statistics on all network activities and informs users on
which ports and addresses the corresponding connections (TCP, UDP) are running
and which ports are open for tasks.
route:
It fetches the routing table. It basically tells where all the network is
actually routed.
grep:
It is used to search a given file for patterns specified by the user. Basically
'grep' lets you enter a pattern of text and then it searches for this pattern
within the text that you provide it.
tr:
The tr command is used for translating or deleting characters.
cat:
cat command allows us to create single or multiple files, the view containing
the file, concatenate files, and redirect output in
terminal or files.
cut:
It is used to extract sections from each line of input – usually from a file.
echo:
It is used to print anything on the console.
If:
if [ expression
then
Statement(s) to be executed if expression is true
else
Statement(s) to be executed if expression is not true
fi
Sudo:
The Sudo command allows you to run programs with the security privileges of
another user (by default, as the superuser). It prompts you for your personal
password and confirms your request to execute a command by checking a file,
called sudoers, which the system administrator configures.
For
Loop: The for loop operates on lists of items. It repeats
a set of commands for
every item in a list. It is
used to iterate over
something.
Example:
for var in 0
123456789
do
echo $var
done
Output: It will
print numbers from 0 to 9
The
Script:
Below is the IP Sweeper script,
#!/bin/bash
for ip in seq 1 254 ; do
ping -c 1 $1.$ip I grep "64 bytes" | cut -d
""-f 4||
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.
Breaking
down
#!/bin/bash
It's basically a comment. We are telling the computer that,
it is a bash script.
for ip in seq 1 254 ; 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.$ip | grep "64 bytes" | cut -d
"" -f 4|
tr -d “:" &
• ping: To ping the ip address
• -c 1: 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 for loop. Example: If user input was 192.68.1 then in the first run
of for loop $ip will be 1. Thus $1.$ip will result in
192.68.1.1 and 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 -c 1 $1.$ip I grep "64 bytes" | cut -d
""-f 4||
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 given_ip' 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 “" -f 4:
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
I (pipe): It 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.
.lipsweep.sh [First
three ranges of your ip]
Example:
./ipsweep.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.
0 comments:
Post a Comment