LINUX FOR HACKERS: LEARN CYBERSECURITY PRINCIPLES WITH SHELL,PYTHON,BASH PROGRAMMING USING KALI LINUX TOOLS. A COMPLETE GUIDE FOR BEGINNERS by TYE DARWIN

LINUX FOR HACKERS: LEARN CYBERSECURITY PRINCIPLES WITH SHELL,PYTHON,BASH PROGRAMMING USING KALI LINUX TOOLS. A COMPLETE GUIDE FOR BEGINNERS by TYE DARWIN

Author:TYE DARWIN [DARWIN, TYE]
Language: eng
Format: azw3, mobi, epub
Publisher: GVS PUBLICATIONS
Published: 2020-12-04T16:00:00+00:00


#! /bin/bash

# This program creates a scanner that scans a specified port number to check whether they are open or not in a local network

Nmap -sT 191.123.111.32 -p 2378

-oG resultsfile1

Cat resultsfile1 | grep open > resultsfile2

Cat resultsfile2

# End of the bash script file

Explanation:

The above program may seem complex for beginners bu believe us it is simple and does what it is entitled to.

I) Life every time, we start the script file with a #! Command with the location of bash interpreter. And in the next line we follow with a comment that explains the role of the scanner that we are trying to create.

ii) In the third line, we actually get into some business by invoking a TCP scan using the nmap command. Here carefully follow what each of the command does while scanning.

A) nmap - This starts the scanning program. It is essential to scan the open ports

B) -sT - This command informs to the Nmap hat it needs to perform a TCP scan

C) 191.123.111.32 - This is the address of the local network we are trying to attack with nMap

D) -p - This says that nmap is searching for the open ports. Nmap also provides other options such as -T, -V to know about other details of the target system. Also, make sure that you are using a TOR network or other relay network with a lot of proxies to not being stopped by efficient intrusion detection systems.

E)2378 - This is the number of the port that we are trying to scan in all the network addresses in Local area network

The bash script automatically scans all the network addresses in the given network and will look out for any ports with 2378 and if they are open will print a log with ‘open’ modifier.

iii) By now, the shell terminal reaches the next line of the code a result will be generated by the nmap on command line. You can even stop displaying the output if you want to. After the scanning completes we reach the next line of the script file where it says to export all the output into a text file with GREP format enabled.

The file name that the script asks to be created is ‘resultsfile1’. If you wonder what a GREP format is let us explain you. Usually shell terminal prints a lot of code while performing actions. GREP allows us to extract a part of the output for easy reading or analyzing purposes. It is a handy tool that is often used by hackers and system administrators to search and filter things. You will learn about it in detail in the next module of this book.

iv) The next line of the bash script separates the file content that is preceded using the ‘cat’ command. After that it asks all the extracted lines to be exported to ‘resultsfile2’.

V) That’s it. Now a new file will be created with all the network addresses with open ports 2378.

Now, enter the directory and execute it with root permissions in the manner we have learnt before.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.