Book Image

Practical Linux Security Cookbook

By : Michael A Lindner, Tajinder Kalsi
Book Image

Practical Linux Security Cookbook

By: Michael A Lindner, Tajinder Kalsi

Overview of this book

With the growing popularity of Linux, more and more administrators have started moving to the system to create networks or servers for any task. This also makes Linux the first choice for any attacker now. Due to the lack of information about security-related attacks, administrators now face issues in dealing with these attackers as quickly as possible. Learning about the different types of Linux security will help create a more secure Linux system. Whether you are new to Linux administration or experienced, this book will provide you with the skills to make systems more secure. With lots of step-by-step recipes, the book starts by introducing you to various threats to Linux systems. You then get to walk through customizing the Linux kernel and securing local files. Next you will move on to manage user authentication locally and remotely and also mitigate network attacks. Finally, you will learn to patch bash vulnerability and monitor system logs for security. With several screenshots in each example, the book will supply a great learning experience and help you create more secure Linux systems.
Table of Contents (17 chapters)
Practical Linux Security Cookbook
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Scanning hosts with Nmap


Nmap is one of the most popular tools included in Linux that can be used to scan a network. It has been in existence for many years, and to date, it is one of the most preferable tools to gather information about a network.

Nmap can be used by administrators on their networks to find any open ports and host systems.

When doing a vulnerability assessment, Nmap is surely a tool that can't be missed.

Getting ready

Most Linux versions have Nmap installed. The first step is to check whether you already have it using this command:

nmap –version

If Nmap exists, you should see an output similar to what is shown here:

If Nmap is not already installed, you can download and install it from https://nmap.org/download.html

How to do it…

Follow these steps to scan hosts using Nmap:

  1. The most common use of Nmap is to find all online hosts within a given IP range. The default command used to do this takes some time to scan the complete network, depending on the number of hosts present in the network. However, we can optimize the process in order to scan the range faster.

    The following screenshot shows you an example of this:

  2. In the preceding example, the time taken to complete the scan was 6.67 seconds when scanning 100 hosts. If the whole IP range for a particular network is to be scanned, it would take a lot more time.

  3. Now, let's try to speed up the process. The n switch tells Nmap not to perform the DNS resolution of the IP addresses, hence making the process faster. The T switch tells Nmap what speed to operate at. Here, T1 is the slowest and T5 is the fastest. The max-rtt-timeout option specifies the maximum time required to wait for the response.

    Now, the same command is shown in this example:

    This time, Nmap scanned the complete IP range in 1.97 seconds. Pretty good, right?

  4. Port scanning using Nmap helps us discover services that are online, such as finding FTP servers. To do this, use the following command:

    The preceding command of Nmap shall list out all the IP addresses that have port 21 open.

  5. Not only FTP, other services can also be discovered by matching the port numbers on which they run. For example, MySQL runs on port 3306. The command will now look like this:

How it works…

Nmap checks for services that are listening by testing the most common network communication ports. This information helps the network administrator to close down any unwanted or unused services. The preceding examples show you how to use port scanning and Nmap as powerful tools to study the network around us.

See also

Nmap also has scripting features using which we can write custom scripts. These scripts can be used with Nmap to automate and extend its scanning capabilities. You can find more information about Nmap on its official home page at https://nmap.org/