You are on page 1of 12
Ft 19:29 > sas X GD Here are a few Linux commands that you might daily interact with, pwd - It prints the current working directory ls - This command is used to list e information or content in a particular file/ folder. cd - It is used to change the current working directory. Example: cd Desktop e mkdir - Create a new folder man - Displays the help manual for a particular command. Example: man ls b> am fw 19:32 > 325 wD X GD Some more commands shutdown: Shutdown or restart your system rmdir: Used to remove/delete a directory/ folder e clear: Clear the terminal © apt-get update: Update kali Linux apt-get install: To install a new program. Example: apt-get install leafpad For more commands and detailed content, click here b> am Fat 20:31 X ED Some commands you should know ifconfig: |t 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. b> am Fiat 20:34 saa < GD more commanas arp: It is used to find IP to MAC address mappings. ARP, which stands for Address e Resolution Protocol, is a protocol used to map a MAC address (or hardware address) to an IP address. netstat: |t 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. b> am Fat 20:09 © Ihe Or < GD 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: |t is used to print anything on the console. b> am Tad cay @ github.com/T TCM-Course-Resources / actical-Ethical-Hacking-Resources 12 Code 4 Pullrequests © Actions [il] Projects. © Security [vIn P master ~ _ Practical-Ethical-Hacking-Resources / bash / ipsweep.sh BD. Grimmie Rename ipsweep.sh to bash/ipsweep.sh 31 contributor 12 Lines (10 sloc) | 222 Bytes if cst 1 then echo “You forgot an IP address!" echo “Syntax: ./ipsweep.sh 192,168.1" else for ip in “seq 1 254; do ping -c 1 $1.Sip | grep "64 bytes” | cut -d"" fi fa [ted 2021 GitHub,Inc. Tens Privacy Security Sti Contact GitHub Pricing API Training Blog Ft 15:40 55 as X Below is the IP Sweeper script, #!/bin/bash for ip in seq 1254; do ping -c 1 $1.Sip | grep “64 bytes” | cut -d“” f4|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. b> am Ft 15:53 as X GD 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 ina range for 1-254 that is, the number of ip addresses in a particular network. b> am Fiat 16:00 < GD Breaking down ping -c 1$1.Sip | grep “64 bytes” | cut -d“” -f4|tr-d“:" & e 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 Sip will be 1. Thus $1.Sip 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. b> am Breaking down p | grep “64 bytes” | cut -d“” & ping-c1$1 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 A) from it, that will be the ip. Tap to Continue Ft 16:09 @ ee 5 » 8 < GD Breaking down 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 b> am ‘ut 16:11 @ 322 wD < GD How to run? we Now save the file and hit the below command on the terminal to run the script. .[ipsweep.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. b> am

You might also like