Kali Linux 3 in 1 Beginners Guide
Kali Linux 3 in 1 Beginners Guide
The contents of this book may not be reproduced, duplicated or transmitted without direct written
permission from the author.
Under no circumstances will any legal responsibility or blame be held against the publisher for any
reparation, damages, or monetary loss due to the information herein, either directly or indirectly.
Legal Notice:
This book is copyright protected. This is only for personal use. You cannot amend, distribute, sell,
use, quote or paraphrase any part of the content within this book without the consent of the author.
Disclaimer Notice:
Please note the information contained within this document is for educational and entertainment
purposes only. Every attempt has been made to provide accurate, up to date and reliable information.
No warranties of any kind are expressed or implied. Readers acknowledge that the author is not
engaging in the rendering of legal, financial, medical or professional advice. The content of this book
has been derived from various sources. Please consult a licensed professional before attempting any
techniques outlined in this book.
By reading this document, the reader agrees that under no circumstances are is the author responsible
for any losses, direct or indirect, which are incurred as a result of the use of information contained
within this document, including, but not limited to, —errors, omissions, or inaccuracies.
Table of Contents
Kali Linux:
Comprehensive Beginners Guide To Learn Kali Linux Step By Step
Chapter 1: An Introduction to Kali Linux
Features of Kali Linux
What’s Different about Kali Linux?
Is Kali Linux Right For You?
Chapter 2: Installing and Downloading Kali Linux
Where to Get Official Kali Linux Images
Verifying Your Downloaded Kali Image
Kali Linux Default root Password is toor
Chapter 3: Making a Kali Bootable USB Drive
Advantages of a Bootable USB Drive
Requirements to create a Kali Linux USB
Kali Linux Live USB Install Procedure
Chapter 4: Installing Kali Linux
Kali Linux Hard Disk Install
Dual Boot Kali with Windows
Dual Boot Kali on Mac Hardware
Single Boot Kali on Mac Hardware
Kali Linux Encrypted Disk Install
Kali Linux Network PXE Install
Kali Linux on ARM
Kali on ASUS Chromebook Flip – Developer Instructions
Chapter 5: ARM Devices
Kali Linux – MiniX
Kali Linux – Cubietruck
Kali Linux – Raspberry Pi2
Kali Linux – Trimslice
Kali Linux – Cubieboard2
Kali Linux – RIoTboard
Kali Linux – NanoPi2
Kali Linux – Utilite Pro
Kali Linux – ODROID-C1
Kali Linux on USB Armory
Kali Linux on Acer Tegra Chromebook 13″
Kali Linux on ODROID-XU3
Kali Linux – CuBox-i4Pro
Kali Linux – Samsung Chromebook 2
Kali Linux – Raspberry Pi
Kali Linux – BeagleBone Black
Kali Linux – HP Chromebook
Kali Linux – CuBox
Kali Linux – ODROID U2
Chapter 6: Troubleshooting Installations
Kali Linux installation failures
How should the debug logs be saved or transferred?
Troubleshooting Wireless Drivers
Chapter 7: Real World Applications for Kali Linux
Commands in Kali Linux
Keyboard Shortcuts
Other Useful Commands
Searching Commands
File Permissions
File Commands
Compression Commands
Printing Commands
Network Commands
SSH commands
User Administration Commands
Process Management Commands
Installation from Source Commands
Stopping and Starting Commands
Chapter 8: Tools in Kali Linux
Exploitation Tools
Forensics Tools
Information Gathering Tools
Reverse Engineering tools
Wireless Attack Tools
Reporting Tools
Stress Testing Tools
Maintaining Access Tools
Sniffing and Spoofing Tools
Conclusion
References
Kali Linux:
Simple and Effective Approach to Learn Kali Linux
Introduction
Chapter 1: Getting Started With Kali Linux
What is Kali Linux?
Installing and Preparing Kali Linux
Installing Kali Linux Using USB-Method
Dual Boot Kali Linux Installation
Installing Kali Linux on Hyper-V
Starting Installation Process
ARM Installations
Kali Linux Features
Is Kali Linux For You?
Things We Learned in This Chapter
Chapter 2: Getting Started With Hacking
What is Hacking?
Learning About Types of Hackers
Hacking Consequences
Things We Learned in This Chapter
Chapter 3: The Hacking Process
Information Gathering(Reconnaissance)
Types of Reconnaissance
Scanning
Gaining Access
Maintaining Access
Clearing the Tracks
Things We Learned in This Chapter
Chapter 4: Learning About Cyber Security
Why Cyber Security is Important
Learning About the CIA Triad
What Challenges Does the CIA Triad Bring?
Different Types of Cyber Threats
Why is Cyber Security Important?
Things We Learned in This Chapter
Chapter 5: Learning about Debian Connection
How Packages Flow From Debian to Kali Linux
How is The Debian Difference Managed?
Things We Learned in This Chapter
Chapter 6: Linux Fundamentals Refresh
Understanding Linux
Kernel Powering Hardware
A Working File System
Process Management
Command Line: Interface To Talk To Your System
Command Line Basics
Filesystem Hierarchy Standard
Home Directory
Learning More Useful Commands
Things We Learned in This Chapter
Chapter 7: Kali Linux Configuration
Network Configuration
Configuring Network Using Command Line
Using systemd-networkd
Unix Groups and Users Management
Getent Command
Changing or Modifying an Account
Account Disabling
Use Groups Management
Configuring Services
PostgreSQL Database Configuration
Apache Configuration
Managing Services
Things We Learned in This Chapter
Chapter 8: Understanding Kali Linux Community and Documentation
Documentation Sources
Learning About Info Documentation
Community-Driven Kali Linux
Become Part of the Community: Do Bug Reports
Things We Learned in This Chapter
Chapter 9: Kali Linux Monitoring and Security
Security Policy For The Rescue
Data Confidentiality
Extreme Cases
Approach
Security Measures
How To Secure Network Services
Getting Your Firewall To Work: Packet Filtering
Logging and Monitoring
How to Detect Changes
Things We Learned in This Chapter
Chapter 10: Debian Package Management
APT Introduction
Different Package Licenses
Kali Repositories
Basic Package Interaction
Using dkpg to Install Package
Meet APT - an Overall Better Solution
Kali Linux Upgrade
Purging and Removing Packages
Learning About Package Contents
Troubleshooting Packages
Bug Reports
Downgrading
Things We Learned in This Chapter
Chapter 11: Kali Linux And Security Assessment
Preparing Kali Linux for Security Assessment
The Different Types of Security Assessments
Vulnerability Assessment
Compliance Penetration Test
Traditional Penetration Test
Application Assessment
Things we Learned in This Chapter
Chapter 12: Server And Network Scanning - How To Find And Secure
Network Vulnerabilities
Asking the Right Questions
Thinking Like A Hacker
Create A Map Of Publicly Available Information
Reinforcing All The Weak Links and Vulnerabilities
Things We Learned in This Chapter
Chapter 13: Kali Linux Tools
Nmap - The World’s Most Famous Network Mapper Tool
Fierce - Network Mapping & Port Scanning Tool
Unicornscan - Information Gathering & Data Correlation Tool
Wireshark - Network Analyzer
Aircrack-ng - Wireless Security Software Suite
Kismet Wireless - Wireless LAN Analyzer, Sniffer, and IDS
John The Ripper - Cryptography Testing Tool
BeEF - Browser Exploitation Framework
Yersinia - L2 Attacks
DHCPig - DHCP Exhaustion Application
THC Hydra - For Brute Force Crack Remote Authentication Services
Metasploit Framework - Penetration Testing Suite
FunkLoad - Web-Stress Tool
SlowHTTPTest - Web-Stress Application For HTTP Servers
Inundator - Multi-Thread IDS Evasion Security Tool
Social Engineering Toolkit
OpenVAS - Vulnerability Scanning Tool
Nikto - Helps In Full Web Server Scans
WPScan - Auditing Tool For WordPress Security
CMSMap - A Centralized Security Solution For All Popular CMS
Choose The Right Tool And Reinforce Your Network Security
Things We Learned in This Chapter
Conclusion
Kali Linux:
Advanced Methods and Strategies to Learn Kali Linux
Introduction
Chapter 1: Firewalls in Kali Linux
Behavior of Netfilter
Understanding ICMP
iptables and ip6tables syntax
Configuring the Script to Run at Every Boot
Chapter 2: The Lifecycle of a Penetration Test
Introduction
Reconnaissance
Scanning
Exploitation
Maintaining Access
Reporting
Chapter 3: Reconnaissance
Introduction
Trusted Agents
Google Search
Google Hacking
Chapter 4: Scanning
Introduction
Network Traffic
Ports and Firewalls
IP Protocols
TCP
UDP
ICMP
PING
Traceroute
NMAP: The Scanning King
Nmap Scripting Engine
Nessus
Chapter 5: Exploitation
Introduction
Attack Vectors and Attack Types
Local Exploits
Remote Exploits
Metasploit Framework
Compliance and Nexpose
Overt Vs. Covert
Metasploit: Basic Framework
Accessing Metasploit
Metasploit Scanning
Meterpreter Session Management
Access File System
Exploiting Web Servers and Web Applications
Web Application Testing
Chapter 6: Maintaining Access
Introduction
Terminology
Backdoors
Chapter 7: Reporting
Parts of the Penetration Test Report
Reporting Tools
Conclusion
Sources
KALI
LINUX
Ethan Thorpe
Chapter 1
An Introduction to Kali Linux
Let’s go through the features of Kali Linux in brief before we deep dive into
this book.
Free to use
BackTrack Linux was completely free of cost to use, and this has been
continued with Kali Linux as well. As a Kali Linux user, you will never
have to pay for the operating system or the tools it comes equipped with.
Open Source
Kali Linus is committed to the model of Open Source, and therefore the
Kali Linux development tree is available to everyone on the Internet. The
source code for Kali Linux is available on gitlab and is available to anyone
who wants to make customizations to it and rebuild the packages to suit
their specific needs.
Custom kernel
Kali Linux kernel comes equipped with the latest injection patches. As
penetration testers, this helps the development team to conduct wireless
assessments with ease.
They are developed in a secure environment. The development team of Kali
Linux includes a very small group of individuals, and they are trusted to
make commits to the repositories and packages for Kali Linux, all of which
is achieved using secure protocols via multiple channels.
GPG signed
Every developer who has worked on packages for Kali Linux signs it and
subsequently, the repositories sign the package as well.
Language support
Penetration tools are usually written in English. However, Kali Linux
developers have ensured that Kali includes language support for users from
around the world so that more users can work in their native language and
find tools on Kali that they can use to complete their tasks.
Customizable
Kali developers understand enough to know that not all users can accept
their interface design. Therefore, they have made it very easy for the
adventurous users to customize the system as per their requirement right
from the top till the kernel.
Customized kernel
Kali Linux comes equipped with a kernel that is completely customized and
patched for wireless injection.
Minimal repositories
Kali Linux has minimal and trusted repositories only. Given the motive
with which Kali Linux was developed, it makes absolute sense to maintain
the integrity of the system. Therefore, third-party applications for Kali are
kept at a bare minimum to achieve the goal of security. While many users
are tempted to add third-party repositories to their sources and lists, doing
so increases the risk of breaking your Kali installation.
Kali Linux can pose as a challenge even for veteran users in the Linux
domain. Kali, unlike other open source Linux projects, is not a wide-open
source project, mainly because of security concerns. The development team
consists of a very small number of users, and the packages that are
developed for Kali Linux and committed to repositories are signed by the
individual developer first and then by the entire team. Also the upstream or
third party repository from which the packages are updated or new
packages are pulled is very small. Adding software from repositories to
your Kali operating system from third party sources that are not tested and
verified by the Kali Linux team can cause harm to your system.
Over and above, the misuse of penetration testing tools and security within
a computer network, without any authorization, may result in irreversible
damage and the consequences of such damage may get you into personal or
legal trouble. The excuse that “You did not know what you were doing”
will not work in such cases.
Never download an image of Kali Linux from any other source than the
official source. After downloading the image, always make sure to verify
the SHA256 checksum value of your downloaded file with the official
value of the file. It would be very easy for a third party intruder to modify
the installation file such that it includes malware which will end up being
hosted on your system.
You can download all official images for Kali Linux installations from the
following link:
- https://www.kali.org/downloads/
- https://www.offensive-security.com/kali-linux-vmware-arm-image-
download/
If you are unsure about what architecture of your current system, you can
run the following command on the terminal in Linux or Apple OS X to
know the architecture.
uname -m
You will find the architecture mentioned under the “Device Type” header in
system properties on your computer.
You will find Kali Linux ISO images available for download from the
website as both as a direct download file and as a torrent file.
VMware Images
If you are using VMware and want to use Kali Linux as a “guest,” Kali
Linux is available as a pre-built VMware machine with VMware tools
already pre-installed. The image for VMware is available in 64-bit, 32-bit,
32-bit PAE formats.
ARM Images
The hardware and architecture vary considerably on ARM-based devices.
Therefore, it is not possible to maintain a single image for installation
across various ARM-based devices. There are a varied set of pre-built
images available for Kali Linux installation across a wide set of devices.
If you want to build your ARM images, scripts for building your custom
ISO are available in the Kali GitHub repository.
These pages are encrypted with an SSL connection, and one would not be
able to access these via plain HTTPS protocol. Since this is an encrypted
connection, it makes it difficult for an attacker to intercept the connection
between you and the website, thus making it impossible to modify the
download file.
After downloading the image file, make sure you validate that it is what you
expect it to be and not a malicious file. Verifying the checksum after
downloading is always a great way to ensure you have a genuine file.
There are many methods for verifying the file you have downloaded. Each
provides some level of assurance and expects a particular level of effort on
your part.
You can download the Kali Linux installation ISO from the “Downloads”
section of the official Kali Linux website and then calculate the SHA256
checksum of the download file and compare it with the checksum listed on
the website for the corresponding download file. This is a very easy method
to verify the download but is sometimes susceptible to DNS poisoning.
DNS poisoning implies that you are trying to resolve an official Kali Linux
website, but an attacker somehow redirects you to a website they wish you
to be on where the SHA checksum would show up us something else, and
then you end up downloaded an infected ISO from their website.
You can also download the Kali Linux ISO via torrents. And this will also
download an ISO file that will contain a SHA256 checksum. So this way
you will have 2 files, one that was directly downloaded, while the other that
was downloaded via torrents. You can then crosscheck if both have the
same checksum using tools on Windows, Linux or Mac.
To be sure that the Kali Linux installation ISO you have downloaded is a
genuine ISO and is the real thing, you can download the following files: a
cleartext signature file and a version of the same file that has a signature by
the official Kali Linux key and then continue to perform the following
actions:
2. Validate that the signature in the file that has the SHA256 hash has
been signed correctly with the official key.
If you are comfortable with using this complicated process to validate your
downloaded ISO, you can proceed without any fear that you have got the
official image of the installation for Kali Linux and that it has not been
tampered with. While this is the most complex method to validate your
download, it has the advantage that you have complete assurance of the
integrity of your downloaded image file.
The easiest way to run Kali Linux is to run it “live” from a USB drive. The
method also has a lot of advantages.
Portability
You can carry the Kali Linux operating system on any USB drive in your
pocket and have it running on any machine that is available to you.
Customizable
As discussed in the previous chapter, you can use scripts from the Kali
Linux GitHub repository to build your custom Kali Linux installation ISO
image and load it onto a USB drive as well.
Persistency
With a little bit of customization, you can make your Kali Linux Live USB
drive store persistent data that will be retained across reboots.
For this purpose, we will first need to use the ISO image of Kali Linux to
set up a bootable USB drive.
2. If you are using Windows, you will require the Win32 Disk Imager
software to create the Kali Linux USB drive. On Linux or OS X,
you can use the dd command on the terminal, which is pre-installed
for creation of bootable USB drives.
2. Choose the ISO file for Kali Linux installation and ensure that you
have selected the correct USB drive to be written it to. Click on
Write.
3. Once the writing to the USB drive is complete, you can eject the
drive and use it as a bootable USB drive to boot Kali Linux Live or
install Kali Linux on your machine.
Warning: If you are unsure as to how to use the dd command, you may end
up writing the Kali Linux image to a disk drive that you did not intend to.
Therefore, it is important that you are alert while you are using the dd
command.
Step One
You will need to know the device path to be used for writing the Kali Linux
image to the USB drive. Without having the USB drive inserted in the USB
slot, execute the following command in the command prompt in the
terminal window.
sudo fdisk -l
You will get an output that shows you all the devices mounted on your
system, which will show the partitions as
/dev/sda1
/dev/sda2
Step Two
Now, plugin the USB drive and run the same command “sudo fdisk -l”
again. You will see an additional device this time, which is your USB drive.
It will show up as something like
/dev/sdb
The size of your USB drive will be written against it.
Step Three
Proceed to write the image carefully on the USB drive using the command
shown below. In the above example, we are assuming that the name of your
Kali Linux ISO file is “kali-linux-2019.1-amd64.iso” and it is in your
present working directory. The block size parameter bs can be increased,
but the ideal value would be “bs=512k”.
The writing to the USB drive will take a few minutes, and it is not abnormal
for it to take a little more than 10 minutes to finish writing.
The dd command will not show any output until the process is completed. If
your USB drive has an LED, you will see it blinking which is an indicator
of the disk being written on. Once the dd command has been completed, the
output would be something like this.
5823+1 records in
5823+1 records out
This will end the processing of the equations. You can now use the USB
drive to boot into Kali Linux Live or start and installation of Kali Linux on
a machine.
You can use the following steps to write the ISO to your USB drive.
Step One
Without plugging in your USB drive to your MAC desktop or laptop, type
the following command on the command prompt of the terminal window.
diskutil list
Step Two
A list of device paths showing all the disks mounted on your system will be
displayed along with the data of the partition.
/dev/disk1
/dev/disk2
Step Three
Now plug in the USB and run the diskutil list command again. You will see
that the list now shows your USB drive as well. It will be the one that did
not show up for the first time. Let us assume that it is
/dev/disk6
Step Four
You can unmount the USB disk from the system using the following
command:
/dev/disk6
The writing to the USB drive will take a few minutes, and it is not abnormal
for it to take a little more than 10 minutes to finish writing.
The dd command will not show any output until the process is completed. If
your USB drive has an LED, you will see it blinking which is an indicator
of the disk being written on. Once the dd command has been completed, the
output would be something like this.
5823+1 records in
That will be the end of the processing of the equation. You can now use the
USB drive to boot into Kali Linux Live or start and installation of Kali
Linux on a machine.
3. A DVD drive or USB boot support to help with the Kali Linux
installation.
2. Write The Kali Linux ISO to DVD or a USB drive using the tools
mentioned in the previous chapter.
3. You must ensure that your system is already set to allow a boot from
a USB drive.
2. Select the language that you require for the operating system
followed by the country location. You will be prompted to choose
the keyboard layout of your preference.
4. The installer will then copy all installation files to the hard drive of
your computer, probe all the network devices and interfaces, and
then ask you to enter a hostname for your system. You can enter the
hostname of your choice, and that will be the name your system
will be identified with.
5. You can also enter a default domain name for your system, and this
is an optional feature.
6. Enter the full name for a user who will be non-root on the system.
7. A default userid is created for the name that you have provided.
You can change the username as per your choice as well if you
want.
9. Next, you will get a list of the disk on which the operating system is
to be installed. You can select the entire disk otr you can use the
Logical Volume Manager to create partitions if you are experienced
with creating granular configurations.
10. Select the disk that you want to create partitions for.
11. You can either keep all the files on a single partition that is the
default or create new partitions for a few directories of your choice
depending on what you will be using the software for. If you are
not sure with what you want, you can go with the default choice,
which is “All files in one partition”.
12. On this screen, you have one last chance where you can have a look
at all the disk configurations that you selected post which the
installer will start making irreversible changes. When you click on
Continue here, the installer will start with the Kali Linux
installation and you will get an almost completed installation.
13. The next step is to configure the network mirrors for your system.
Kali uses a central repository through which it distributes
applications. If you are using a proxy server, you will need to enter
that information here.
Note: If you select NO on this screen, you will not be able to use any Kali
repositories for software installations in the future.
14. On this screen, you will install GRUB. Grand Unified Bootloader
or GRUB is a bootloader application, which is used in case you
have multiple operating systems to boot from. Given that this is a
fresh installation, you can install GRUB on the master boot record
and make it the primary bootloader for your system.
15. That’s it. You can now click on the continue button which will
reboot your system and your Kali Linux installation is now
complete.
Dual Boot Kali with Windows
Kali Linux Dual Boot with Windows
Having Kali Linux installed alongside Windows on the same system can be
very beneficial. Although, you need to be very patient and cautious while
setting up a dual operating system installation. Firstly, make sure that all the
important data from your Windows installation is backed up. Also, since
this exercise will result in modification of your hard drive, it is advisable to
back up everything of importance on an external media.
In the example that we are going to look at, we are using a system, which
has Windows 7 already installed on it and is taking 100% of the disk space.
So we will first resize the Windows partition such that it occupies less space
and then proceed with installing Kali Linux on a new and empty partition.
You can prepare for the installation by having the following checklist ready.
2. Write The Kali Linux ISO to DVD or a USB drive using the tools
mentioned in the previous chapter.
3. You must ensure that your computer is ready to allow a boot from a
USB drive.
3. A DVD drive or USB boot support to help with the Kali Linux
installation.
Dual Boot Installation Procedure
1. To begin with the installation, boot the system using the installation
media on which you have loaded the Kali Linux ISO. You will be
prompted with the Kali Linux boot screen. Click on Live, which
will boot you into the Kali Linux desktop.
2. Once you are on the Kali Linux desktop, launch the gparted
application. We will be using gparted to compress the existing
Windows partition, which will help us create sufficient space for the
Kali Linux installation.
This particular chapter will guide you to dual boot an OS X with Kali Linux
alongside use rEFInd, optionally allowing you to encrypt your Kali Linux
installation.
Your experience with using Kali Linux is dependent on the make, model
and the year when your device was manufactured. Newer devices will work
better with Kali Linux. If you have an older system, it is advised that you
install rEFInd to improve the chances of success.
When we use a 3rd party software rEFInd, it helps us open up the boot
menu for OS X, which is apt for dual booting. It also helps older Apple
devices boot from USB, which otherwise could not. Once you have
installed Kali Linux, you can customize rEFInd to hide it or remove it
completely.
Installation Prerequisites
1. Minimum disk space of 20GB for the Kali Linux installation.
2. A minimum of 1GB RAM. However, it is recommended to have
2GB or higher.
3. USB boot may or may not work on devices older than 2012 without
rEFInd. Therefore a blank DVD is advisable.
4. A blank DVD or a USB with 4GB or higher space for a device
which is newer than 2012.
Step Two
Once you see the boot menu, insert the installation medium which is the
DVD or USB drive. If everything works fine, you will see two volumes.
Step Three
Although Kali Linux is a Debian based system, rEFInd detects it as a
Windows system.
If you are using a DVD for installation, you may need to press ESC and
refresh the menu once the disk is fully spinning.
If you still end up seeing only one volume, it indicates that the installation
medium is not supported for your Apple device. Re-installing rEFInd and
trying again would be a good option at this point just to be sure.
If you select the EFI volume, the system will hang and the boot will not
continue at this time.
Step Four
If everything is fine, you can select the Windows – Legacy OS from FAT
volume option, which will boot you into the Kali Linux boot screen. Here
you can select Live and you will be directed to the Kali Linux desktop.
Step Five
We can now use gparted like we have read previously to compress the OS X
partition and create a 20GB partition for the Kali Linux installation.
Gparted can be found in Kali under:
Step Six
Once you have gparted on, select the OS X partition. It will usually be the
larger partition. Resize it and leave 20GB to create a new partition for the
Kali Linux installation.
2. Once you see the boot menu, insert the installation medium which
is the DVD or USB drive. If everything works fine, you will see
two volumes.
5. The installation will begin and copy all installation files to your
system’s hard disk. You will then be asked to enter a hostname for
your system which can be anything as per your choice. You can also
enter a domain name if you have one.
9. The installer will now list down the disk choices to install Kali
Linux on. We have already created a partition in the previous steps
to use for the Kali installation. Select‘Guided – use the largest
continuous free space’.
If you are an experienced user, you can always use the ‘Manual’
option to make granular configurations. On this screen, you can
also set up an encrypted LVM if you want your Kali installation to
be completely encrypted.
You will be prompted for a password now. Enter the same
password that you set up during step 7 of this process. When you
want to boot Kali Linux, you will need to use the same password.
The installer will now wipe your disk securely before asking for the
password. This will take some time or a few hours depending upon
the size and speed of the disk.
On this screen, you will have one last chance to review the disk
configuration you have selected for your installation post which the
changes would be irreversible. Click Continue and the installation
will begin and you are almost done.
10. The next step is to configure the network mirrors for your system.
Kali uses a central repository through which it distributes
applications. If you are using a proxy server, you will need to enter
that information here.
Note: If you select NO on this screen, you will not be able to use any Kali
repositories for software installations in the future.
11. On this screen, you will install GRUB. Grand Unified Bootloader
or GRUB is a bootloader application, which is used in case you
have multiple operating systems to boot from. You can install
GRUB on the master boot record and make it the primary
bootloader for your system.
apt-get update
This process will help us convert the Master Boot Record of the system to a
hybrid such that Apple’s boot manager EFI will be able to detect entries in
GRUB and boot from it.
just hit the Enter key at the below prompt and your MBR partition table will
be untouched.
Place EFI GPT (0xEE) partition first in MBR (good for GRUB)? (Y/N): y
Unused partition space(s) found. Use one to protect more partitions? (Y/N):
n
root@kali:~#
18. We can now use both OS X and Kali Linux and we will get a choice to
select which one to boot into at start up.
rEFInd Configuration
Alternatively, if you wish, you can make modifications to the rEFInd in
multiple ways, which include:
1. The default Operating System selection which by default is set to
OS X.
2. The Boot screen timeout value, which is 20 seconds by default.
3. Boot directly into the default Operating System selection (You can
press Options during boot if you want to use a different operating
system. This will open the boot menu.)
4. Remove rEFInd which implies enabling the good old Apple menu.
This will still allow booting to both Apple and Kali Linux.
To make any of these modifications, just boot into OS X and modify the
following file. From the terminal.
osx:~ mbp$ sudo nano /EFI/refind/refind.conf
To change how many seconds you get on the boot menu to select an
Operating System, you can alter the ‘timeout’ value. If you set it to ‘-1’, it
will boot into the default operating system which is OS X in this case.
timeout -1
To set the default Operating System which is selected on the boot menu,
modify the ‘default_selection’ value. OS X has the value 1 and Kali Linux
has the value 2The ‘default_selection’ value sets the default selection on
startup. OSX will be at position ‘1’ and Kali will be at ‘2’. Let’s use OS X
as a default in this scenario.
default _value 1
Now if we save the changes we have made by modifying this file, when we
reboot the system, it will feel like nothing has changed. However, if you
press the Options key during boot up, the Apple boot menu will pop up and
the following options will show up.
Apple’s boot menu does not let us change the values of the names of the
operating systems. If you want to customize these values, you will have to
go for rEFInd
Installation Prerequisites
1. Minimum disk space of 20GB for the Kali Linux installation.
3. USB boot may or may not work on devices older than 2012 without
rEFInd. Therefore a blank DVD is advisable.
2. Write The Kali Linux ISO to DVD or a USB drive using the tools
mentioned in the previous chapter.
3. Make sure that your computer is already set to allow a boot from a
USB drive.
2. Insert the media you have created for the Kali Linux installation,
that it the USB drive or DVD depending on your system. If
everything is in place, you will see two options, EFI and Windows.
Despite Kali Linux being a Debian based operating system it shows
up at Windows on Apple.
Your system does not support the installation media if it does not
see the Windows option. In such an event, you can install rEFInd
and try the process again. Selecting the EFI volume will result in
the boot process getting hung.
4. When you select Windows, the Kali boot screen will appear on your
system. You can now choose either The Live ‘Graphical Install’ or
‘Text-mode’ installation method. In this book we will follow the
‘Graphical Install’ method.
6. The installation will begin and copy all installation files to your
system’s hard disk. You will then be asked to enter a hostname for
your system, which can be anything as per your choice. You can
also enter a domain name if you have one.
If you are an experienced user, you can always use the ‘Manual’
option to make granular configurations. On this screen, you can
also set up an encrypted LVM if you want your Kali installation to
be completely encrypted.
11. You will be prompted for a password now. Enter the same
password that you set up during step 8 of this process. Note that
you will have to use the same password every time you boot Kali
Linux.
12. The installer will now wipe your disk securely before asking for the
password. This will take some time or a few hours depending upon
the size and speed of the disk.
13. On this screen, you will have one last chance to review the disk
configuration you have selected for your installation post which the
changes would be irreversible. Click Continue and the installation
will begin and you are almost done.
14. The next step is to configure the network mirrors for your system.
Kali uses a central repository through which it distributes
applications. If you are using a proxy server, you will need to enter
that information here.
Note: If you select NO on this screen, you will not be able to use any Kali
repositories for software installations in the future.
15. On this screen, you will install GRUB. Grand Unified Bootloader
or GRUB is a bootloader application, which is used in case you
have multiple operating systems to boot from. You can install
GRUB on the master boot record and make it the primary
bootloader for your system.
17. If your Kali Linux ISO does not include the gdisk package, it will
need to be installed first.
apt-get update
We must now ensure that the EFI from Apple can detect and boot the
GRUB. To do this, we will need to convert the MBR into a hybrid.
19. root@kali:~# gdisk /dev/sda
3. USB boot may or may not work on devices older than 2012 without
rEFInd. Therefore a blank DVD is advisable.
2. Write The Kali Linux ISO to DVD or a USB drive using the tools
mentioned in the previous chapter.
3. Make sure that your computer is already set to allow a boot from a
USB drive.
6. The installer will now list down the disk choices to install Kali
Linux on. We have already created a partition in the previous steps
to use for the Kali installation. Select‘Guided – use the entire disk
and set up encrypted LVM’.
8. Enter your preference for the partitioning scheme. For the purpose
of encryption, you will need to enter a password for encryption.
Note that you will have to use the same password every time you
boot Kali Linux.
9. The next step is to configure the network mirrors for your system.
Kali uses a central repository through which it distributes
applications. If you are using a proxy server, you will need to enter
that information here.
Note: If you select NO on this screen, you will not be able to use any Kali
repositories for software installations in the future.
10. On this screen, you will install GRUB. Grand Unified Bootloader
or GRUB is a bootloader application which is used in case you
have multiple operating systems to boot from. You can install
GRUB on the master boot record and make it the primary
bootloader for your system.
cd /tftpboot
# for 64 bit systems:
wget http://http.kali.org/kali/dists/kali-rolling/main/installer-
amd64/current/images/netboot/netboot.tar.gz
# for 32 bit systems:
wget http://http.kali.org/kali/dists/kali-rolling/main/installer-
i386/current/images/netboot/netboot.tar.gz
Tar zxpf netboot.tar.gz
Rm netboot.tar.gz
Once you have configured everything as mentioned, you can now boot a
target system on the network and configure it to boot from the network.
Your PXE server will allocate an IP address to the target system and the
target system will boot Kali Linux.
Kali Linux on ARM
Kali Linux – ASUS Chromebook Flip
The ASUS Chromebook Flip is a Chromebook ARM device with the
following configuration.
4. You can now write this image to the SD card or USB drive by using
the dd utility. In the example shown by us, we will be installing
Kali Linux on the SD card which has the path /dev/sdb. This can be
changed as per your requirement.
Note: This will erase all content on your SD card or USB drive. Choosing
the wrong disk device can also result in the hard disk of the device getting
wiped out.
After the dd operation completes, you can boot up the ASUS Chromebook
Flip keeping the SD card or USB drive plugged in. You can log in to the
Kali desktop using the ‘root’ username and password ’toor’.
2. 1GB of RAM.
1. You will need an 8GB or higher SD card to install Kali Linux on.
3. You can now write this image to the SD card by using the dd utility.
In the example shown by us, we will be installing Kali Linux on the
SD card which has the path /dev/sdb. You can change this as per
your requirement.
Note: This will erase all content on your SD card. Choosing the wrong disk
device can also result into the hard disk of the device getting wiped out.
After the dd operation completes, you can boot up the Mini-X keeping the
SD card plugged in. You can login to the Kali desktop using the ‘root’
username and password ’toor’.
2. 2GB of RAM
1. You will need an 8GB or higher SD card to install Kali Linux on.
Note: This will erase all content on your SD card. Choosing the wrong disk
device can also result into the hard disk of the device getting wiped out.
This process can take a while depending on your device speed and image
size.
The time taken to complete the Kali Linux installation depends on the speed
of the SD card and the size of the Kali Linux image.
After the dd operation completes, you can boot up the Cubietruck keeping
the SD card plugged in. You can login to the Kali desktop using the ‘root’
username and password ’toor’.
2. 1GB of RAM
Kali Linux installation can be performed using an external SD card for
Raspberry Pi2.
3. You can now write this image to the SD card by using the dd utility.
In the example shown by us, we will be installing Kali Linux on the
SD card which has the path /dev/sdb. You can change this as per
your requirement.
Note: This will erase all content on your SD card. Choosing the wrong disk
device can also result into the hard disk of the device getting wiped out.
This process can take a while depending on your device speed and image
size.
The time taken to complete the Kali Linux installation depends on the speed
of the SD card and the size of the Kali Linux image.
After the dd operation completes, you can boot up the Raspberry Pi2
keeping the SD card plugged in. You can login to the Kali desktop using the
‘root’ username and password ’toor’.
2. 1GB of RAM
3. You can now write this image to the SD card by using the dd utility.
In the example shown by us, we will be installing Kali Linux on the
SD card which has the path /dev/sdb. You can change this as per
your requirement.
Note: This will erase all content on your SD card. Choosing the wrong disk
device can also result into the hard disk of the device getting wiped out.
The time taken to complete the Kali Linux installation depends on the speed
of the SD card and the size of the Kali Linux image.
After the dd operation completes, you can boot up the Trimslice keeping the
SD card plugged in. You can login to the Kali desktop using the ‘root’
username and password ’toor’.
2. 1GB of RAM
3. You can now write this image to the SD card by using the dd utility.
In the example shown by us, we will be installing Kali Linux on the
SD card which has the path /dev/sdb. You can change this as per
your requirement.
Note: This will erase all content on your SD card. Choosing the wrong disk
device can also result into the hard disk of the device getting wiped out.
This process can take a while depending on your device speed and image
size.
The time taken to complete the Kali Linux installation depends on the speed
of the SD card and the size of the Kali Linux image.
After the dd operation completes, you can boot up the Cubieboard2 keeping
the SD card plugged in. You can login to the Kali desktop using the ‘root’
username and password ’toor’.
2. 1GB of RAM
Kali Linux installation can be performed using an external SD card for the
RIotboard.
Note: This will erase all content on your SD card. Choosing the wrong disk
device can also result into the hard disk of the device getting wiped out.
This process can take a while depending on your device speed and image
size.
The time taken to complete the Kali Linux installation depends on the speed
of the SD card and the size of the Kali Linux image.
After the dd operation completes, you can boot up the RIoTboard keeping
the SD card plugged in. You can login to the Kali desktop using the ‘root’
username and password ’toor’.
Kali on RIoTboard – Developer Instructions
If you are someone who is adventurous and likes to play around the
development of a software and want to make some customizations to the
Kali Linux image for RIoTboard like making changes to the configuration
of the kernel, you can check out the Kali scripts for ARM devices on
https://gitlab.com/kalilinux/build-scripts/kali-arm. The script to be used is
riot.sh
2. 1GB of RAM
Kali Linux installation can be performed using an external SD card for the
NanoPi2
3. You can now write this image to the SD card by using the dd utility.
In the example shown by us, we will be installing Kali Linux on the
SD card which has the path /dev/sdb. You can change this as per
your requirement.
Note: This will erase all content on your SD card. Choosing the wrong disk
device can also result into the hard disk of the device getting wiped out.
This process can take a while depending on your device speed and image
size.
The time taken to complete the Kali Linux installation depends on the speed
of the SD card and the size of the Kali Linux image.
After the dd operation completes, you can boot up the NanoPi2 keeping the
SD card plugged in. You can login to the Kali desktop using the ‘root’
username and password ’toor’.
2. 2GB of RAM
Kali Linux installation can be performed using an external SD card for the
Utilite Pro.
3. You can now write this image to the SD card by using the dd utility.
In the example shown by us, we will be installing Kali Linux on the
SD card which has the path /dev/sdb. You can change this as per
your requirement.
Note: This will erase all content on your SD card. Choosing the wrong disk
device can also result into the hard disk of the device getting wiped out.
This process can take a while depending on your device speed and image
size.
The time taken to complete the Kali Linux installation depends on the speed
of the SD card and the size of the Kali Linux image.
After the dd operation completes, you can boot up the Utilite Pro keeping
the SD card plugged in. You can login to the Kali desktop using the ‘root’
username and password ’toor’.
2. 1GB of RAM
Kali Linux installation can be performed using an external SD card for the
ODROID-C1.
3. You can now write this image to the SD card by using the dd utility.
In the example shown by us, we will be installing Kali Linux on the
SD card which has the path /dev/sdb. You can change this as per
your requirement.
Note: This will erase all content on your SD card. Choosing the wrong disk
device can also result into the hard disk of the device getting wiped out.
This process can take a while depending on your device speed and image
size.
The time taken to complete the Kali Linux installation depends on the speed
of the SD card and the size of the Kali Linux image.
After the dd operation completes, you can boot up the ODROID-C1
keeping the SD card plugged in. You can login to the Kali desktop using the
‘root’ username and password ’toor’.
Kali Linux installation can be performed using an external SD card for the
USB Armory.
1. You will need an 8GB or higher SD card to install Kali Linux on.
3. You can now write this image to the SD card by using the dd utility.
In the example shown by us, we will be installing Kali Linux on the
SD card which has the path /dev/sdb. You can change this as per
your requirement.
Note: This will erase all content on your SD card. Choosing the wrong disk
device can also result into the hard disk of the device getting wiped out.
This process can take a while depending on your device speed and image
size.
The time taken to complete the Kali Linux installation depends on the speed
of the SD card and the size of the Kali Linux image.
After the dd operation completes, you can boot up the USB Armory
keeping the SD card plugged in. You can login to the Kali desktop using the
‘root’ username and password ’toor’.
2. 4GB of RAM.
Kali Linux installation can be performed using an external SD card for the
Acer Tegra Chromebook keeping the internal hard disk completely safe and
untouched.
1. You will need an 8GB or higher SD card to install Kali Linux on.
2. Enable USB boot and put the Acer Tegra Chromebook in developer
mode.
4. You can now write this image to the SD card by using the dd utility.
In the example shown by us, we will be installing Kali Linux on the
SD card which has the path /dev/sdb. You can change this as per
your requirement.
Note: This will erase all content on your SD card. Choosing the wrong disk
device can also result into the hard disk of the device getting wiped out.
This process can take a while depending on your device speed and image
size.
The time taken to complete the Kali Linux installation depends on the speed
of the SD card and the size of the Kali Linux image.
After the dd operation completes, you can boot up the Acer Tegra
Chromebook keeping the SD card plugged in. You can login to the Kali
desktop using the ‘root’ username and password ’toor’.
Kali Linux installation can be performed using an external SD card for the
ODROID-XU3.
3. You can now write this image to the SD card by using the dd utility.
In the example shown by us, we will be installing Kali Linux on the
SD card which has the path /dev/sdb. You can change this as per
your requirement.
Note: This will erase all content on your SD card. Choosing the wrong disk
device can also result into the hard disk of the device getting wiped out.
xzcat kali-$version-odroidxu3.img.xz | dd of=/dev/sdb bs=512k
This process can take a while depending on your device speed and image
size.
The time taken to complete the Kali Linux installation depends on the speed
of the SD card and the size of the Kali Linux image.
2. 2GB of RAM
3. You can now write this image to the SD card by using the dd utility.
In the example shown by us, we will be installing Kali Linux on the
SD card which has the path /dev/sdb. You can change this as per
your requirement.
Note: This will erase all content on your SD card. Choosing the wrong disk
device can also result into the hard disk of the device getting wiped out.
This process can take a while depending on your device speed and image
size.
The time taken to complete the Kali Linux installation depends on the speed
of the SD card and the size of the Kali Linux image.
4. You can now write this image to the SD card by using the dd utility.
In the example shown by us, we will be installing Kali Linux on the
SD card which has the path /dev/sdb. You can change this as per
your requirement.
Note: This will erase all content on your SD card. Choosing the wrong disk
device can also result into the hard disk of the device getting wiped out.
This process can take a while depending on your device speed and image
size.
The time taken to complete the Kali Linux installation depends on the speed
of the SD card and the size of the Kali Linux image.
After the dd operation completes, you can boot up the Samsung ARM
Chromebook 2 keeping the SD card plugged in. You can login to the Kali
desktop using the ‘root’ username and password ’toor’.
The Raspberry Pi is powered with an SD card and will boot from the SD
card when the board is switched on.
The Kali Linux image for Raspberry Pi has been loaded with minimum
tools which is as per standards maintained for other ARM devices. You can,
however, install the full desktop package through an upgrade using the kali-
linux-fullmeta package.
3. You can now write this image to the SD card by using the dd utility.
In the example shown by us, we will be installing Kali Linux on the
SD card which has the path /dev/sdb. You can change this as per
your requirement.!
Note: This will erase all content on your SD card. Choosing the wrong disk
device can also result into the hard disk of the device getting wiped out.
This process can take a while depending on your device speed and image
size.
The time taken to complete the Kali Linux installation depends on the speed
of the SD card and the size of the Kali Linux image.
After the dd operation completes, you can boot up the Raspberry Pi keeping
the SD card plugged in. You can login to the Kali desktop using the ‘root’
username and password ’toor’.
Note: All ARM images of Kali Linux are pre-configured with the same
public key. So it is advisable to change the public key as soon as the
installation is complete. You can do so using the following commands.
root@kali:~ rm /etc/ssh/ssh_host_*
root@kali:~ dpkg-reconfigure openssh-server
root@kali:~ service ssh restart
3. You can now write this image to the SD card by using the dd utility.
In the example shown by us, we will be installing Kali Linux on the
SD card which has the path /dev/sdb. You can change this as per
your requirement.
Note: This will erase all content on your SD card. Choosing the wrong disk
device can also result into the hard disk of the device getting wiped out.
Note: This will erase all content on your SD card. Choosing the wrong disk
device can also result into the hard disk of the device getting wiped out.
After the dd operation completes, you can boot up the BeagleBone Black
keeping the SD card plugged in. You can login to the Kali desktop using the
‘root’ username and password ’toor’.
Note: All ARM images of Kali Linux are pre-configured with the same
public key. So it is advisable to change the public key as soon as the
installation is complete. You can do so using the following commands.
root@kali:~ rm /etc/ssh/ssh_host_*
root@kali:~ dpkg-reconfigure openssh-server
root@kali:~ service ssh restart
Kali Linux installation can be performed using an external SD card for the
HP Chromebook leaving the internal disk safe and untouched.
Note: This will erase all content on your SD card. Choosing the wrong disk
device can also result into the hard disk of the device getting wiped out.
This process can take a while depending on your device speed and image
size.
The time taken to complete the Kali Linux installation depends on the speed
of the SD card and the size of the Kali Linux image.
After the dd operation completes, you can boot the HP Chromebook with
the USB stick plugged in. When you reach the developer boot prompt, press
CTRL+U, and you will boot into Kali Linux.
Kali on HP ARM Chromebook – Developer Instructions
If you are someone who is adventurous and likes to play around the
development of a software and want to make some customizations to the
Kali Linux image for HP Chromebook like making changes to the
configuration of the kernel, you can check out the Kali scripts for ARM
devices on https://gitlab.com/kalilinux/build-scripts/kali-arm. The script to
be used is chromebook-arm-hp.sh
3. You can now write this image to the SD card by using the dd utility.
In the example shown by us, we will be installing Kali Linux on the
SD card which has the path /dev/sdb. You can change this as per
your requirement.
Note: This will erase all content on your SD card. Choosing the wrong disk
device can also result into the hard disk of the device getting wiped out.
dd if=kali-$vers-odroid.img of=/dev/sdb bs=1M
This process can take a while depending on your device speed and image
size.
The time taken to complete the Kali Linux installation depends on the speed
of the SD card and the size of the Kali Linux image.
“An installation step failed. You can try to run the failing item again from
the menu, or skip it and choose something else. The failing step is:
<description of the failing item>”
If you click on continue, you will be redirected to the Debian installer main
menu. On the main menu, navigate to “save debug logs”:
Hitting the continue button should take you to the Debian installer main
menu. From that main menu, browse to the “save debug logs“.
Here, there are several methods through which you can transfer the
installation log files to another system or disk. The easiest way is to start a
web server on the source machine where the installation is ongoing.
You will be prompted with a screen, which has the following question with
3 options.
Selecting the ‘web’ option will start a web server from which you can
download or view the installation logs.
A simple web server will be started and the screen will let you know the
URL from which you can access the logs.
On choosing this option, a web server is created and you can view the logs
or download the logs from the URL.
Aug 19 23:45:05 base-installer: error: The tar process copying the live
system failed (only 152937 out of 286496 files have been copied, last file
was ).
Aug 19 23:45:05 main-menu[927]: (process:7553): tar: write error: No
space left on device
http://www.aircrack-ng.org/documentation.htm
The error messages for wireless devices usually tell you what is going
wrong and how it can be fixed. If not, you can then proceed toward Google.
Chapter 7
Real World Applications for Kali Linux
There are a diverse number of applications for Kali Linux in the real world.
Including them in a sales pitch is critical if you want to form a business
model that will generate revenue for your company, which has specialists
who work in the security domain using Kali Linux.
Data security is an integral part of your business if you are just beginning to
work with clients. If you look up the Internet, you will easily find articles
about data breaches that have been happening in small businesses in and
around your area or even a college database for that matter. A little fear can
be a healthy thing. Fear sells and it sells more especially today, since we are
living in the digital era.
Most people who run small businesses today run their websites using
Wordpress. Travel writers, photographers, etc. use Wordpress for blogging
and showcasing their photography too. Activities like these require
investment of time from the website owner, and all this can be lost just
because of one faulty line of code in their Wordpress website. The business
owner may not only lose the time that they have invested but also their
customers if there is a loss of data.
There is a Kali Linux tool called ‘wpscan’, which we will talk about in
detail later. This application scans a Wordpress code for vulnerabilities and
allows you to report them to the website owner.
Another well-known Kali tool is ‘nmap’. This tool helps to scan open ports
on Wi-Fi connections. Open ports can be deemed to be open doors, which
can be accessed by anyone with the right amount of knowledge. The open
ports can be used to access data, which is critical to a business such as
customer details or even credit card details.
These tools usually run via the terminal in Kali Linux. Whenever you
launch one of these tools using the dropdown menu in the graphical
interface, it will always redirect you to the terminal, which launches in a
preconfigured root access mode in Kali. The terminal is used to run a lot of
commands while using tools in Kali and you will spend most of your time
on the terminal in Kali.
If you are booting Kali as a live disk and not a full install, it is
recommended that the first thing you do is open up the terminal and then
type the following command to update all the software.
apt-get update
You can also lookup for upgraded software using the following command.
apt-get upgrade
We will now go through all the regular commands that are used on your
Kali system while you’re at work.
Keyboard Shortcuts
- Enter Runs the current command that you have typed
- Ctrl + R Lets you partially type a command and finds the rest
- Ctrl + Z Stops the current command and you can resume it with bg
in the background or fg in the foreground
- Ctrl + E Go to the end of the command line that you are typing
- Ctrl + U Erases the line before the cursor and copies it to special
clipboard
- Ctrl + K Erases the line after the cursor and copies it to special
clipboard
- Ctrl + Y Paste from the special clipboard that has data copied from
the Ctrl + U and Ctrl + K
- Ctrl + T Used to swap the two characters just before the cursor
- man -t man | ps2pdf -> man.pdf Saves the man page to a PDF file
- which command Displays the full path of the command
- whereis app shows all possible locations where the app is installed
- which app Shows the full path of the app that is run by default
Searching Commands
- grep pattern files Lets you search for the desired pattern in files
- locate file To find the file in all possible locations on the system
- find / -name filename Look for the file called filename right from
the root directory
- find / -name “*filename*” Look for the file containing the string
called filename right from the root directory
- locate filename Assuming that you have already used the command
updatedb, search for a file called filename using the locate
command
- updatedb This command updates the database of all files on all file
systems that exist on your root directory
File Permissions
- chmod octal file Change the file permissions to octal. This can be
found separately for user, group and world by adding 4 for read(r),
2 for write(w), 1 for execute(x)
Example:
chmod 777 Assigns read, write and execute for user, group and
world
chmod 755 Assigns read, write and execute for user, read and
execute for group and world
File Commands
- ls Lists down content of a directory
- rm -rf dir Forcefully deletes the dir called dir along with all its
directories and subdirectories
- more file Displays the content of the file called file page by page,
and you can proceed to the next page using the spacebar
- head -20 file Outputs the first 20 lines of the file called file
- tail -20 file Outputs the last 20 lines of the file called file
- tail -f file Outputs the content of the file called file on a real time
update basis as it grows showing the latest 10 lines
Compression Commands
- tar cf file.tar files Creates an archive called file.tar which contains
the files
- tar xf file.tar Extract the content from the file names file.tar
- tar czf file.tar.gz files Creates an archive called file.tar.gz which
contains the files using the GZip compression
- tar czf file.tar.gz Extract the content from the file names file.tar.gz
using GZip
- tar xjf file.tar.bz2 Extract the content from the file names
file.tar.bz2 using BZip2
Printing Commands
- /etc/rc.d/init.d/lpd start Print daemon is started
- man -t subject| lpr Print the content of the manual page for the
subject in postscript format
Network Commands
- ifconfig Print down the IP addresses for all the devices on the local
machine
SSH commands
- ssh user@host Connect to a particular host as a particular user
- killall proc Kill all processes which have the name proc
make
make install
In this section we will go through the various tools available in Kali Linux
for security and penetration testing. There are a number of tools in Kali
which are classified as per the task that they are used for. They are as
follows.
1. Exploitation Tools
2. Forensics Tools
6. Reporting Tools
We will go through tools available on Kali Linux for all the categories one
by one and understand the purpose of each tool and how it will help us in
the security domain.
Exploitation Tools
On a network of computers, usually over the Internet, there are several web
applications, which leave a system vulnerable due to bad code or open ports
on the server which are publicly accessible. Exploitation tools help you to
target a system and exploit the vulnerabilities in that system, thus helping
you to patch a vulnerability. Let’s go through all the Exploitation Tools
available in Kali Linux one at a time.
Armitage
Armitage was developed by Raphael Mudge to be used with the Metasploit
framework as its GUI frontend. Armitage is a tool that recommends
exploits and is fairly simple to use as cyber-attack management tool which
is available in the graphical form. It is open source and available for free
security tool and is mostly known for the data it provides on shared sessions
and the communication it provides through a single instance of Metasploit.
Armitage helps a user to launch exploits and scans, get recommendations of
exploits and explore the advanced features that are available in the
Metasploit framework.
You can install this tool on your Kali Linux system using the following
commands on the terminal.
apt-getupdate
apt-getinstallbackdoor-factory
Commix
Providing use cases for penetration tester, web developers, and researchers,
Commix (short for COMMand Injection eXploiter) works in a simple
environment to test web applications. It basically allows a user to find the
errors, bugs or vulnerabilities with respect to command injections in web
applications. This tool easily allows you to identify and exploit a
vulnerability of command injection. The Commix tool has been developed
using the Python language.
Crackle
The Crackle tool in Kali Linux is a brute force utility used for cracking and
intercepting traffic between bluetooth devices. Most bluetooth devices have
a 4-6 digit pairing code, which is in an encrypted format. Using Crackle,
these codes can be decrypted if the pairing process between 2 devices is
intercepted and thus allowing you to listen to all communication happening
between the 2 devices.
jboss-autopwn
The script uses the uname -r command to find the kernel version of the
Linux operating system. Additionally it will also provide the -k parameter
through which user can manually enter the version for the kernel of the
Linux operating system.
Maltego Teeth
Maltego is a tool that is used for data mining and is interactive. It provides
an interactive interface that outputs graphs which help in link analysis.
Since it allows link analysis, Maltego is used for investigations on the
Internet to find the relationship between information that is scattered over
various web pages on the Internet. Maltego Teeth was developed later with
an added functionality that gives penetration testers the ability to do
password breaking, SQL injections and vulnerability detection, all using a
graphical interface.
sqlmap
sqlmap is a Kali tool that is open source and is used for penetration testing.
It allows automating the detection of SQL injection vulnerabilities and
exploiting it to take over database servers. It comes equipped with a very
powerful detection engine, a range of tools which will help an extreme
penetration tester and switches that help fetch information like database
fingerprinting, retrieving data from databases, access to the file system of
the operating system and execute commands on the operating system.
Yersinia
Yersinia is a tool that detects exploits weaknesses in network protocols and
takes advantage of it. It is a tool which is a solid framework for testing and
analyzing deployment of networks and systems. It comprises of layer-2
attacks which exploit the weaknesses in various layer-2 protocols in a given
network thus allowing a penetration tester to detect flaws in a layer-2
network. Yersinia is used during penetration tests to start attacks on network
devices such as DHCP servers,switches, etc which use the spanning tree
protocol.
Cisco-global-exploiter
The Cisco Global Exploiter (CGE) tool is a security testing exploit
engine/tool, which is simple yet fast and advanced. Cisco switches and
routers have 14 vulnerabilities which can be exploited using the Cisco
Global Exploiter tool. The Cisco Global Exploiter is basically a perl script,
which is driven using the command line and has a front-end that is simple
and easy to use.
Cisco-torch
The Cisco Torch is an exploitation tool which varies from the regular
scanners in the sense that it can be used to launch multiple and
simultaneous scans at a given point in time which results in tasks getting
done faster and more efficiently. In addition to the network layer, it also
helps in fingerprinting systems in the application layer of the OSI model.
This is something that even a tool like NMAP doesn’t provide.
Forensics Tools
We will now list down and learn tools available in Kali Linux which are
used in the Forensics domain.
Binwalk
The Binwalk tool is useful while working on binary image file. It lets you
scan through the image file for executable code that may be embedded in
the image file. It is a very powerful and useful tool for users who know
what they are doing as it can be used to detect coveted information that is
hidden in images of firmware. This can help in uncovering a loophole or a
hack that is hidden in the image file, which is used with the intention to
exploit the system.
The Binwalk tool is developed in python and makes use of the libmagic
library from python, therefore making it an apt tool for magic signatures
that are created for the Unix file system. To make it even more comfortable
for testers in the investigation domain, it contains a database of signatures
that are commonly found in firmware around the world. This makes it a
convenient tool to detect anomalies.
Bulk-extractor
The bulk-extractor tool is an interesting tool used by investigators who want
to fetch specific data from a digital file. The tools helps retrieve URLs,
email addresses, credit/debit card numbers, etc. The tools can be used to
scan through files, directories and even images of disks. The best part is that
even if the data is corrupted partially or in a compressed format, the tool
will still reach its depth to find the data.
Another interesting feature of this tool is that if there is data that you keep
finding repeatedly, such as email addresses, URLs, you can create a search
pattern for them, which can be displayed in the form of a histogram. It also
ends up creating a list of words that are found in a given set of data that
may be used to crack a password for files that have been encrypted.
Chkrootkit
The chkrootkit tool is usually used in a live boot scenario. It is used locally
to check the host machine for any rootkits that may be installed on the host.
It therefore helps in the hardening of a system, thus ensuring that the system
is not compromised and vulnerable to a hacker.
The chkrootkit tool also has the ability to scan through system binaries for
any modifications made to the rootkit, temporary deletion, string
replacements, and latest log deletions made. These are just a few of the
things that this little tool can do. It looks like a fairly simple tool but the
power it possesses can be invaluable to a forensic investigator.
p0f
The p0f tool can help the user know the operating system of a host that is
being targeted just by intercepting the transmitted packages and examining
them and it does this irrespective of whether the targeted host is behind a
firewall or not. The use of p0f does not lead to any increase in network
traffic, no lookup of names, and no probes that may be found to be
mysterious. Given all these features, p0f in the hands of an advanced user,
can help detect presence of firewalls, use of NAT devices, and presence of
load balancers as well.
pdf-parser
The pdf-parser tool is used in parsing PDF files to classify elements that are
used in the file. The output of the tool on a PDF file will not be a PDF file.
One may not recommend it for textbook cases of PDF parsers but it does
help to get the job done. Mostly, its use case is PDF files, which you may
suspect of being embedded with scripts in them.
Dumpzilla
The Dumpzilla tool is a tool that is developed in python. The purpose of
this tool is to extract all information that may be of interest to forensics
from web browsers like Seamonkey, Mozilla Firefox and Iceweasel.
ddrescue
The ddrescue tool is a savior of a tool. It helps in copying data from one
block device such as a hard disc or a CD ROM to another block device. But
the reason it is a savior is because it copies the good parts first to avoid any
read errors on the source.
The ddrescue tool’s basic operation is completely automatic which means
that once you have started it, you do not need to wait for any prompts like
an error, wherein you will need to stop the program or restart it.
Foremost
Have you ever deleted files on purpose or by mistake and realized that you
needed them later? The Foremost tool is there to your rescue. This tool is an
open source package which is easy to use and helps you retrieve data off of
disks that may have been formatted. It may not help recover the filename
but the will recover the data it held. A magical feature is that even of the
directory information is lost, it can help retrieve data by referencing to the
header or footer of the file, making it a fast and reliable tool for data
recovery.
Galleta
The Galleta tool helps you parse a cookie trail that you have been following
and convert it into a spreadsheet format, which can be exported for future
reference.
Volatility
When it comes to memory forensics, Volatility is a very popular tool.
Developed in the python language, this tool facilitates the extraction of data
from volatile memory such as RAM. It is compatible with 32 bit and 64 bit
architectures of almost all Windows variants and limited flavors of Linux
and Android. The tool accepts memory dumps in various formats such as
crash dumps, raw memory dumps, hibernation files, virtual snapshots, etc.
The tool allows you to get an idea of the run-time state of the host machine
and is independent of the investigation of the host.
Password that are decrypted during run-time are stored in the RAM. Thus
by retrieving the details of a password, Volatility comes as a savior for
investigation of files that lie on the hard disk and may be encrypted with a
password. This helps in decreasing the overall time that may be required for
a particular case to be investigated.
Autopsy
Sleuth Kit is a digital forensics toolkit which is open source and can be used
with a wide range of file systems such as FAT, NTFS, EXT2, EXT3(and
raw images) to perform analysis that can be in depth. The graphical
interface developed for Sleuth Kit (which is a command line tool) is called
Autopsy. Autopsy brags of features such as Hash Filtering, Timeline
analysis, File System analysis and searching for keywords. It is also very
versatile as it lets you add other modules to the existing set for extended
functionality.
You get the option to launch a fresh new case or use one which already
exists when you launch the Autopsy tool.
Xplico
Xplico is a forensic tool, which is open source and is used for network
forensics. If you wish to extract data from applications that use the network
protocols or Internet, Xplico is the tool for you. All popular network
protocols such as HTTPS, POP, SMTP, IMAP, SIP, UDP, TCP and others
are supported by Xplico. It supports both IPv4 and IPv6. An SQLite
database is used to store the output data from the tool.
5. Querying specific service that will help fetch useful data such as
usernames
The NMap tool which is for security auditing and discovery of network is a
free tool. Apart from penetration testers, it is also used by system
administrators and network administrators for daily tasks such as
monitoring the uptime of the server or a service and managing schedules for
service upgrades.
Stealth Scan
The Stealth scan is also popularly known as the hal open scan or SYN. It is
called the half open scan because it refrains from completing the usual
three-way handshake of TCP. So how it works is a SYN packet is sent by an
attacker to the target host. The target host will acknowledge the SYN and
sent a SYN/ACK in return. If a SYN/ACK is received, it can be safely
assumed that the connection to the target host will complete and the port is
open and listening on the target host. If the response received is RST
instead, it is safe to assume that the port is close or not active on the target
host.
acccheck
The acccheck tool was developed has an attack tool consisting of a
password dictionary to target Windows Authentication processes which use
the SMB protocol. The accccheck is basically a wrapper script which is
injected in the binary of ‘smbclient’ and therefore depends on the smbclient
binary for execution.
Amap
Amap is a scanning too of the next generation that allows a good number of
options and flags in its command line syntax making it possible to identify
applications and processes even if the ports that they are running on are
different.
For example, a web server by default accepts connections on port 80. But
most companies may change this port to something else such as 1253 to
make the server secure. This change would be easily discovered by Amap.
CaseFile
We discussed about Maltego in the previous chapters. CaseFile is known as
the younger sibling of Maltego. Casefile has the same ability as Maltego to
create graphs but it cannot run transforms on it. Although, you can quickly
add data and then link and analyze it using CaseFile. The CaseFile tool is
for investigators who work on data that is fetched from offline sources since
the data they require can be queried by automation or programming. These
are investigators who are getting their data from other team members and
are using that data to build an information map based on their investigation.
braa
Braa is a tool that is used for scanning mass Simple Network Management
Protocol (SNMP). The tool lets you make SNMP queries, but unlike other
tools which make single queries at a time to the SNMP service, braa has the
capability to make queries to multiple hosts simultaneously, using one
single process. The advantage of braa is that it scans multiple hosts very
fast and that too by using very limited system resources.
Unlike other SNMP tools, which require libraries from SNMP to function,
braa implements and maintains its own stack of SNMP. The implementation
is very complex and dirty. Supports limited data types, and cannot be called
up to standard in any case. However braa was developed to be a fast tool
and it is fast indeed.
dnsmap
dnsmap is a tool that came into existence originally in 2006 after being
inspired from the fictional story “The Thief No One Saw” by Paul Craig.
Dnsmap also helps on subdomain brute forcing which helps in cases where
zone transfers of DNS do not work. Zone transfers are not allowed publicly
anymore nowadays which makes dnsmap the need of the hour.
DotDotPwn
The dotdotpwn tool can be defined simply to call it a fuzzer. What is a
fuzzer? A fuzzer is a testing tool that targets software for vulnerabilities by
debugging and penetrating through it. It scans the code and looks for flaws
and loopholes, bad data, validation errors, parameters that may be incorrect
and other anomalies of programming.
Whenever an anomaly is encountered by the software, the software may
become unresponsive, making way for the flaws to give an open door to an
attack. For example, if you are an attacker whose target is a company’s web
server, with the help of dotdotpwn, you will be able to find a loophole in the
code of the web server. Perhaps there has been a latest HTTP update on the
server overnight. Using a fuzzer on the web server shows you there is an
exploit with respect to data validation which leaves an open door for a DoS
attack. You can now exploit this vulnerability, which will make the server
crash and server access will be denied to genuine employees of the
company. There are many such errors that can be discovered using a fuzzer
and it is very common for technology to have error when it releases
something new in the market and it takes time to identify the error and fix
it.
Fierce
Fierce is a Kali tool which is used to scan ports and map networks.
Discovery of hostnames across multiple networks and scanning of IP spaces
that are non-contiguous can be achieved by using Fierce. It is a tool much
like Nmap but in case of Fierce, it is used specifically for networks within a
corporate.
Once the target network has been defined by a penetration tester, Fierce
runs a whole lot of tests on the domains in the target network and retrieves
information that is valuable and which can be analyzed and exploited by the
attacker.
Wireshark
Wireshark is a kali too that is an open source analyzer for network and
works on multiple platforms such as Linux, BSD, OS X and Windows.
URLCrazy
URLCrazy is a Kali tool that can that tests and generates typos and
variations in domains to target and perform URL hijacking, typo squatting
and corporate espionage. It has a database that can generate variants of up
to 15 types for domains, and misspellings of up to 8000 common spellings.
URLCrazy supports a variety of keyboard layouts, checks if a particular
domain is in use and figures how popular a typo is.
The Harvester
The Harvester is a Kali tool that is not your regular hacking tool. Whenever
there is a mention of hacking tools that are implemented using the
command line, one usually thinks of tools like Nmap, Reaver, Metasploit
and other utilities for wireless password cracking. However, the harvester
refrains from using algorithms that are advanced to break into firewalls, or
crack passwords, or capture the data of the local network.
The Harvester crawls through the Internet as your surrogate, looking for
information on your behalf as long as the criteria provided by you matches
the information on the Internet. Given that you can also gather email
addresses using the Harvester, this tool can be very useful to a hacker who
is trying to penetrate an online login by gaining access to the email account
of an individual.
Metagoofil
Metagoofil is a kali tool that is aimed at fetching publicly available such as
pdf, xls, doc, ppt, etc. documents of a company on the Internet.
The tool makes a Google search to scan through documents and download
them to the local machine. It then extracts the metadata of the documents
using libraries such as pdfminer, hachoir, etc. It then feeds the information
gathering process with the results of its report which contains usernames,
server or machine names and software version which helps penetration
testers with their investigation.
Miranda
Miranda is a Kali tool that is actively or passively used to detect UPnP
hosts, its services, its devices and actions, all through on single command.
The Service state parameters and their associated actions are correlated
automatically and are then processed as input/output variables for every
action. Miranda uses a single data structure to store information of all the
hosts and allows you access to that data structure and all its contents.
Let's discuss what exactly ÚPnP is. Universal Plug and Play or UPnP is a
protocol for networking that allows devices on the network such as
computers, printers, routers mobile devices, etc. to discover each other
seamlessly over a network and established services between them for
sharing of data, entertainment and other communication. It is ideally for
networks inside a private residence as opposed to corporate infrastructure.
Ghost Phisher
Ghost Phisher is a Kali tool, which is used as an attack software program
and also for security auditing of wired and wireless networks. It is
developed using the Python programming language and the Python GUI
library. The program basically emulates access points of a network
therefore, deploying its own internal server into a network.
Fragroute
Fragroute is a Kali tool that is used for intercepting, modifying and
rewriting traffic that is moving toward a specific host. Simply put, the
packets from attacking system known as frag route packets are routed to the
destination system. It is used for bypassing firewalls mostly by attackers
and security personnel. Information gathering is a well-known use case for
fragroute as well which used by penetration testers who use a remote host,
which is highly secured.
Masscan
Masscan is a Kali tool, which is used by penetration testers all around the
world and has been in the industry for a long time. It is a tool of
reconnaissance which has the capability to transmit up to 10 million packets
every second. The transmission used by masscan is asynchronous and it has
custom stack of TCP/IP. Therefore, the threads used for sending and
receiving packets are unique.
However, to achieve those high transmission rates, special drives and NICs
are required. The communication of the tool with the users is very similar to
that between the user and the Nmap tool.
The technique of Reverse Engineering in its initial days would only be used
with hardware. As the process evolved over the years, engineers started
applying it to software, and now to human DNA as well. Reverse
engineering, in the domain of cyber security helps understand that if a
system was breached, how the attacker entered the system and the steps that
he took to break and enter into the system.
Apktool
Apktool is a Kali Linux tool that is used in the process of reverse
engineering. This tool has the ability to break down resources to a form that
is almost the original form and then recreate the resource by making
adjustments. It can also debug code that is small in size,step by step. It has a
file structure, which is project-like, thus making it easy to work with an
app. Using apktool you can also automate tasks that are repetitive in nature
like the building of an apk.
Dex2jar
Dex2jar is a Kali tool which is a lightweight API and was developed to
work with the Dalvik Executable that is the .dex/.odex file formats. The tool
basically helps to work with the .class files of Java and Android.
- dex-tools component works with the .class files. It is used for tasks
such as modifying an apk, etc.
diStorm3
diStorm is a Kali tool which is an easy to use decomposer library and is
lightweight at the same time. Instructions can be disassembled in 16 bit, 32
bit and 64 bit modes using diStorm. It is also popular amongst penetration
testers as it is the fast disassembler library. The source code, which depends
on the C library is very clean, portable, readable and independent of a
particular platform which allows it to be used in embedded modules and
kernel modules.
edb-debugger
edb debugger is a Kali tool which is the Linux equivalent for the popular
Windows tool called “Olly debugger.” It is a debugging tool with
modularity as one of its main goals. Some of its features are as follows.
- An intuitive Graphical User InterfaceI
- The view of the data dump is in tabbed format. This feature allows
the user to open several views of the memory at a given time while
allowing you to switch between them
Jad Debugger
Jad is a Kali Linux tool that is a Java decompiler and the most popular one
in the world. It is a tool, which runs on the command line and is written in
the C++ language. Over the years, there have been many graphical
interfaces which have been developed which run Jad in the background and
provide a comfortable front end to the users to perform tasks such as project
management, source browsing, etc. Kali Linux powers Jad in its releases to
be used for Java application debugging and other processes of reverse
engineering.
Javasnoop
JavaSnoop is a tool developed by Aspect Security tool for Kali Linux that
allows testing of Java application security. By developing JavaSnoop,
Aspect has proved how it is a leader in the security industry in providing
verification services for all applications and not just web based applications.
OllyDbg
OllyDbg is a Kali Linux tool, which is a debugger at a level of a 32 bit
Assembler developed for Microsoft Windows. What makes it particularly
useful is its emphasis on code that is in binary in times when the source is
not available.
Valgrind
Valgrind is a tool in Kali Linux tool, which is used for profiling and
debugging Linux based systems. The tool allows you to manage threading
bugs and memory management bugs automatically. It helps eliminate hours
that one would waste on hunting down bugs and therefore, stabilizes the
program to a very great extent. A program’s processing speed can be
increased by doing a detailed profiling on the program by using Valgrind
too.suite for debugging and profiling Linux programs. The Valgrind
distribution has the following production quality tools currently.
- Memcheck which detects errors in memory
- DRD and Helgrind which are two other thread error detectors
- Cachegrind which is a branch prediction and cache profiling tool
- Callgrind which branch detection profile and a call graph
generating cache profiler
- Massif which profiles heaps
Three experimental tools are also included in the Valgrind distribution
- SGCheck which detector for stack or global array overrun
- DHAT which is a second profiler for heap and helps understand
how heap blocks are being used
- BBV which basic block vector generator
Reverse Engineering plays an important role where manufacturers are using
it to sustain competition from rivals. Other times reverse engineering is
used to basically figure out flaws in software and re-build a better version
of the software. Kali Linux provides tools, which are known in the reverse
engineering domain. In addition tools that we have discussed, there are
many 3rd party reverse engineering tools as well but the ones we have
discussed come installed in the Kali Linux image.
AirSnort
AirSnort is another Kali Linux tool which is used for cracking passwords of
wireless LANS and is very popular. Wi-Fi802.11b network’s WEP keys can
be cracked by using AirSnort. This tool basically monitors the packets that
are being transmitted on the network passively. When it has sufficient
packets, it computes the encryption key from the packets it has gathered.
AirSnort is available for free on both Linux and Windows platforms and is
fairly simple to use as well. The tool has not seen any development or
updates in 3 years but the company, which created the tool is now looking
to develop and maintain it further. The tool due to its direct involvement in
cracking WEP is popular around the globe.
Kismet
Kismet is another Kali Linux tool, which is basically used in
troubleshooting issues on wireless networks. It can be used with any wi-fi
device, which supports rfmon, which is a monitoring mode. It is available
on most of the platforms, which include Linux, Windows, OS X and other
BSD platforms. Kismet again collects packets passively to understand the
network standard and can also detect networks that are hidden in nature. It
is built on the client-server architecture and it can sniff traffic from802.11b,
802.11a, 802.11g, and 802.11n. It supports the recent wireless standards,
which are faster as well.
CoWPAtty
CoWPAtty is another Kali Linux too that is used for cracking passwords of
wireless networks. It cracks passwords of the WPA-PSK networks using an
automated dictionary attack. It maintains a database, which contains
thousands of passwords which it uses during the attack. The chances of the
tool cracking the password are very high if the password is there in its
database. The drawback is that the speed of the tool can be slow and it
depends on the password strength and the number of words in its database.
The fact that the tool uses SHA1 algorithm with a seed of SSID is another
reason for its slow speed. What this means is that thee SSIM of the
password will be different. Thus the rainbow table of the tool may be
ineffective while being used for the access points. Therefore, for each word
that is being used for the SSID, the password dictionary of the tool
generates a hash for each word. The tool is fairly simple to use with a list of
commands that are to be used.
The newer versions of CoWPAtty use hash files which are pre computed
and therefore the time used for computation during the process of cracking
is brought down significantly, resulting in increasing the speed of the
process. The hash file which is pre computed already contains 172000
dictionary files which contain at least 1000 of the most popular SSIDs. It is
important for your SSID to be in that list for the attack to be successful. If
the SSID is not in that list, you are just plain unlucky.
Airjack
Airjack is a Kali Linux too which is used for packet injection in Wi-Fi
802.11. DOS and MIM attacks are a specialty of this tool. This tool forces
the network to give a denial of service by injecting bogus packets into the
network. The tool can also help create a man in the middle attack in a given
network. The tool is both powerful and popular among users.
WepAttack
WepAttack is another Kali Linux tool built on open source platform for
breaking keys of 802.11 WEP. It maintains a dictionary of millions of
words, which it uses to crack the password of a network. The only
requirement to perform an attack using WepAttack is a WLAN card that is
in a working condition. The usability of WepAttack is very limited but it
works amazingly well on WLAN cards that are supported.
Wifiphisher
Wifiphisher is a Kali Linux tool, which is again used to crack the password
of a wireless network. The tool steals passwords of a wireless network by
executing fast paced phishing attacks. Kali Linux has Wifiphisher pre-
installed on it. It is a tool that is available on Linux, Windows and MAC
and completely free to use.
Reaver
Reaver is an open-source Kali Linux tool, which is used for creating attacks
which are brute force in nature against WPS. The tool is used to crack the
passwords WPA/WPA2 encryptions. The tool is hosted on code developed
by Google and there are high chances that the tool will be taken down if
there is no local backup made for it. The last time Reaver was updated was
about 4 years ago. It is a good to have tool, in addition to all the other
password cracking tools that a penetration tester may want to have as it uses
the same attack method.
Wifite
Wifite is also a Kali Linux tool which helps crack networks that are
encrypted with WPS via reaver. It works on all Linux based operating
systems. Many features related to cracking passwords are offered by Wifite.
WepDecrypt
WepDecrypt is Kali Linux tool written in C language to target wireless
networks. It performs a dictionary attack and tries to guess WEP keys.
Additionally it also uses key generators and performs distributed network
attacks and other methods to figure out the key of a wireless network. It
depends on a few libraries to function. It i snot a very popular tool among
users but advisable for beginners to understand the functions of dictionary
attacks.
Pyrit
Pyrit is also a very good Kali Linux tool which allows you to attack lets you
perform attack IEEE 802.11 WPA/WPA2-PSK encrypted wireless
networks. This is a freely available tool, which is hosted on Google Code.
Again since it is hosted by Google, it may be taken off in the coming
months and therefore, it is good to have a local copy of it. It supports a wide
range of operating systems such as Linux, OS X, FreeBSD, etc.
Reporting Tools
The report you get as a result of the penetration test that you have
conducted is a key deliverable in an activity carried out for security
assessment. The final deliverable of penetration testing is the report, which
gives a record of the service that was provided, the methods that were used,
the findings or results of the tests and the recommendations that come as an
output to better the security. Report making is most of the times ignored as
it is found to be boring by many penetration testers. In this part, we will talk
about the Kali Linux tools that are available to make the process of making
reports simple. The tools help you store your penetration test results, which
can be referred to when you are working on making the report. The tools
will also help you communicate and share data with your team.
We are covering the 2 main tools, which are Dradis and Magic Tree.
Dradis
The Dradis framework is an open source Kali tool which functions as a
platform to collaborate and report for security exports in the network
security domain. The tool is developed in Ruby language and is
independent of platform. Dradis provides the option to export reports and
all the activities can be recorded in one single report. Exporting the report
in file formats that are PDF or DOC is currently only supported in the pro
version and is missing from the community version.
Magic Tree
Magic Tree is a Kali Linux tool, which is used for reporting and data
management and it is much like Dradis. It is designed in a way such that
data consolidation, execution of external commands, querying and
generation of reports becomes an easy and straightforward process. Kali
Linux has this tool pre-installed and it is located at “Reporting Tools”
category. It manages the host and its associated data using the tree node
structure.
Stress tests are designed to test systems even beyond the regular points of
operation to understand how well it can handle pressure. Stress testing was
introduced to ensure that a system, which is in production would not crash
under extreme situations.
Let us see the various stress testing tools that are available in Kali Linux.
DHCPig
DHCPig is a Kali Linux tool that exhausts the DHCP server system by
initiating an exhaustion attack on it. This tool will use up all the IPs
available on the network and stop new users from being assigned any IPs,
release IPs that have been already assigned to genuine devices, and then for
a good amount of time, it will send out gratuitous ARP and kick all the
Windows hosts from the network. The tool requires admin privileges and
scapy >=2.1 library to execute. The tool does not need any configuration as
such and you just have to pass the environment as a parameter on which
you plan to release the test. It has been successfully tested on multiple
DHCP server in Windows and on several Linux distributions.
inviteflood
Inviteflood is a Kali Linux tool, which is used to send SIP/SDP INVITE
message to cause a flooding over UDP/IP.
It has been tested over several Linux platforms and it performs well on all
distributions.
mdk3
MSK is a Kali Linux too which is proof-of-concept tool used to exploit the
protocol weaknesses of IEEE 802.11
Note: Ensure that the network owner has permitted you to run MDK on it
before you run it on the network.
FunkLoad
FunkLoad is a Kali Linux too that web tester for functions and load on a
system. It is developed in Python and has the following use cases.
Testing web projects for their functionality and regression testing as well.
Test the performance of the web application by applying load on it. This
helps to understand bottlenecks, and helps you to get a detailed report of the
test.
Primary testing like volume testing or longevity testing would not result in
showing bugs that would show up on load testing. This is achieved through
FunkLoad.
It is a stress testing tool which will end up overwhelming a web application
and its resources. This also helps in understanding the recoverability of the
application.
ipv6-toolkit
The IPV6 toolkit by SI6 Network is a set of tools to test the security of IPv6
networks and troubleshoot any problems that arise on it. You can perform
real-time attacks on an IPv6 network which will help you assess the
security, resiliency, and will help you troubleshoot the networking problem
on IPv6 networks. The tools in this suite include tools from packet crafting
tools to the most elaborate IPv6 tool out there for network scanning which
is scan6 tool.
The following list will give you an idea of all the tools in the suite.
- addr6: A tool which analyzes an manipulates the IPv6 network
- flow6: And IPv6 security assessment tool
- frag6:A tool that performs fragmentation based attacks on an IPv6
network to perform a number of fragmentation related aspects and
security assessment
- icmp6: A tool that performs attacks on the basis of errors thrown by
ICMPv6 network protocol.
- jumbo6: A tool that looks at the handling of IPv6 jumbograms
andassesses potential flaws in it.
- na6:A tool that sends arbitrary messages of neighbor
advertisements.
- ni6: A tool that checks the potential flaws in processing ICMPv6
packages by sending information messages of the ICMPv6 node.
- s6: A tool that sends messages of arbitrary neighbor solicitation.
- ra6: A tool that sends messages of arbitrary router advertisements.
- rd6: A tool that sends messages of arbitrary ICMPv6 redirects.
- rs6: A tool that sends messages of arbitrary router solicitation
- scan6: A tool that scans IPv6 networks
- tcp6: A tool to send arbitrary TCP segments and perform a variety
of TCP- based attacks.
SlowHTTPTest
The SlowHTTPTest is a Kali Linux tool that can simulate the Denial of
Service attacks in the application layer. It is supported on most platforms
such as Linx, OS X and the command line interface on Windows systems.
The tool basically implements Dos attacks of application layer which are
low bandwidth in nature such as Slow HTTP POST, slowloris, Slow Read
attack by leeching the concurrent pools of connection, and also the Apache
Range Header attack which causes high load on the CPU and memory of a
server.
We will look at the various tools available in Kali Linux, which will help us
to maintain access to a system.
The client side which exists behind a firewall and will accept connections
on ports that are connected to a remote server or will play the role of
SOCKS proxy. The authentication source for SOCKS source can be a list of
fixed users which is fetched from a MySQL or LDAP directory. The client
component is aPerl script that is independent of platform or is also available
as a Win32 binary.
The server side component exists on the Internet to which the client makes
HTTP requests. The server side then translates and forwards these requests
to network connections on upstream servers, which are remote.
There are two available servers. A web server, which basically hosts a PHP
script. The PHP script that you host on the web server will allow your web
server to act as the server to run HTTP tunnel.
Let’s go through a few tools, which are used for packet sniffing and
spoofing.
Burp Suite
Burp Suite is a Kali Linux tool, which serves as a platform to run security
tests on web applications. It has a number of tools that work together and
make the whole testing process work seamlessly right from the initial
mapping of the test and analyzing the attack surface of the application, to
finding the vulnerabilities in the security and exploiting them.
DNSChef
DNSChef is a highly configurable Kali Linux tool for configuring DNS
proxy for Malware analysts and Penetration Testers. A DNS proxy is a fake
DNS is a tool that is used for analyzing network traffic.
There are a lot of tools for DNS proxy available on the Internet. Most will
allow you to point the incoming DNS queries to one single IP. DNSChef
was developed a complete solution for a DNS proxy tool, which would
provide a user with every kind of configuration that is needed. As a result of
this vision, DNSChef is a tool that works across all platforms and is capable
to create fake responses while supporting multiple types of DNS records
The use of a DNS proxy is advisable in times when you cannot force a web
application to use a specific proxy server. For example, there are some
mobile applications, which discard proxy settings in the OS HTTP settings.
In cases like these, use of a tool like DNSChecf as a DNS proxy server will
come handy. It will allow you to redirect the incoming HTTP request to a
desired destination by tricking the application.
Wifi Honey
Wifi Honey is a Kali Linux tool, which is essentially a script that creates
five monitor interfaces. One window is used for the tool airodump-ng and
the remaining four are used for APs. The tool runs the five windows in a
screen session making it simple to switch between the five screens and
ultimately makes this process even more comfortable. All the sessions are
labelled and therefore you will not end up getting confused with the
screens.
Let us go through a few of the password cracking devices that are available
in Kali Linux.
crowbar
Crowbar, which was previously known as Levye is a Kali Linux tool which
is used for penetration testing. According to authors of regular brute forcing
tools, crowbar was developed to brute force protocols in a manner, which
was different than the regular tools. For example, during an SSH brute force
attack, most tools use the username and the password to carry the attack but
crowbar unlike the majority of the tools, uses SSH keys. This means that is
there was any kind of a private key that was retrieved during any of the
penetration tests, it could then be used to attack servers which have SSH
access.
john
John the Ripper is Kali Linux tool, which is both fast and feature-rich in its
design. You can customize it to your specific needs and it also combines
many other cracking methods in one simple program. There is a built-in
compiler, which is a part of the C compiler, which will even allow you to
define a cracking mode which is completely custom. John is available on all
platforms, which means you can use the same tool everywhere you go.
Additionally if you started cracking a session on one platform, you could
very well continue it on another platform. Such is the portability of John.
John, out of the box, auto detects and supports the following crypt types in
Unix by default.
DES based tripcodes, Windows and Kerberos/AFS hashes, OpenBSD
Blowfish, FreeBSD MD5, BSDI extended DES, bigcrypt and traditional
DES.
Ncrack
Ncrack is a Kali Linus tool, which is high speed and used to crack network
authentication. The motive for building this tool was that corporates could
check their network infrastructure and devices proactively for any flaws and
loopholes such as poor passwords. Ncrack is also used by security
professionals while conducting audits for their clients. A command line
syntax similar to Nmap, a modular approach, and a dynamic engine that
would take feedback from network and adapt its behavior, were the
foundations that Ncrack was built up on. Nmap allows auditing of hosts on
a large scale and that too in a reliable way.
Ncrack’s list of features provide an interface that is very flexible and gives
the user full control of the network operations, making it possible to
perform brute force attacks that are very sophisticated in nature, providing
time templates for easy usage, a runtime interaction that is much like
Nmap’s and many other things. Ncrack supports the protocols such as
OWA, WinRM, MongoDB, Cassandra, MySQL, MSSQL, PostgreSQL,
Redis, SIP, SMB, VNC, POP, IMAP, HTTP and HTTPS, Telnet, FTP, RDP
and SSH
RainbowCrack
RainbowCrack is a general propose Kali Linux tool, which was an
implementation of Philippe Oechslin. It is used to crack hashes, which have
rainbow tables. Rainbow Crack cracks hashes of rainbow tables by making
use of the time-memory tradeoff algorithm. This makes it different from
hash crackers that are brute force.
A brute force hash cracker will generate all the plaintexts that are possible
and then compute the hashes that correspond to the plaintext, all during
runtime. It will then compare the hashes that need to be cracked with the
hashes in hand. If no match is found even after comparing all available
plaintexts, all results of the intermediate computation are discarded.
A time-memory tradeoff hash cracker sets up a stage for pre-computation,
and all results of all hashes are stored in rainbow table. This is a time
consuming computation. But on the first stage of pre-computing is over,
hashes that were stored in the rainbow table can be cracked with a
performance that is much better and efficient as compared to a brute force
cracker.
Conclusion
I want to thank you once again for choosing this book. Kali Linux is a very
advanced flavor of Linux, which is used for Security Auditing and
Penetration Testing. After all the tools that we have looked at, it is pretty
clear that if you want to succeed in the domain of Security Research, Kali
Linux will provide with unlimited power to achieve the same. It is also
clear that if you are just beginning with Linux, Kali Linux is not the place
that you would want to start with as it is a highly complex operating system
created and aimed at achieving one goal and that is security.
References
http://tutorialspoint.com/kali_linux/
https://docs.kali.org/
https://tools.kali.org/
KALI
LINUX
Ethan Thorpe
Introduction
In this book, we will learn about Kali Linux, its purpose, its effect on the
hacking scene, the installation process, and other important concepts
surrounding it.
All the topics covered in the book are covered from the perspective of
beginners. We start by looking at how to install Kali Linux properly. Our
methods will include creating a dual boot or creating a virtual machine in
Windows 10. Both methods are covered to ensure a proper learning
experience. In the later part of the book, our focus will shift to cyber
security, hacking, or the tools that Kali Linux has to offer.
Also, our focus will be mainly on ethical hacking. But that doesn’t mean
that we will not cover some of the black hat techniques.
At the end of the book, you will be equipped with the skills to make the
most out of the Kali Linux, understand hacking, vulnerability, and be ready
to protect your own installation.
Chapter 1
Getting Started With Kali Linux
Kali Linux is one of the leading Linux distros out there. It is mainly used
for hacking purposes. The hacking part can be both black hat and white
hat(we will cover the different types of hackers in detail later on). As a
learner myself, I have always wondered what makes Kali Linux so
interesting. That encouraged me to write the book, and here we are!
If you are using Windows 10, the latest iteration of Windows, then you can
use virtualization to install Kali Linux. Windows 10 has been slowly
accepting Linux, and that’s why in 2016, they introduced their own Hyper-
V solution for virtualization. If you are using the latest Windows 10 version
or 1803 version or above, your Windows should come pre-equipped with
Hyper-V software.
Let’s first learn how to install Kali Linux using the USB-drive method. But,
before we do, check out the minimum requirements to install Kali Linux.
You can download the Kali Linux ISO from the official Kali Linux website,
www.kali.org. There you can find all the download options under the Kali
Linux Downloads: https://www.kali.org/downloads/. I also recommend you
to use torrents to download it as you will get better speeds doing so.
From there, you should choose the Kali Linux 64-bit. For this book, we are
going to use the 2019.3 version. I recommend you to download the same
version as I did. This way, you can easily follow the tutorials and methods
shared in the book. However, if you opt to download a slightly different
version(especially the latest version), you will do just fine.
You first need to boot from your USB drive or the choice of your
medium installation. Once you are in the Kali Linux boot screen,
you now need to select “Live.” This will book the Kali Linux
default desktop.
Once GParted starts, you need to select the Windows partition and
then right-click on it. Then click on “Resize/Move.” Make sure that
you have 20 GB of installation size for Kali Linux.
After you select the changes, now click on “Apply All Operations.”
Once it is completed, now you need to boot the Kali Linux again
and select the Guided -- use the largest continuous free space as the
partition disk.
After the installation is done, the system will reboot, and you can
finally boot into Kali Linux using a GRUB boot menu.
4 GB minimum RAM.
Press Enter
Once done, you need to reboot and then move on to the actual installation
process.
You will then be greeted with the Create Virtual Machine window.
There you will find few options, including Ubuntu 18.04.3 LTS and
Ubuntu 19.04.
Here you need to click on the “Local installation source” first and
then move to “Change installation source.”
From there, select the Kali Linux ISO. Also, untick the “This virtual
machine will run windows option.”
Now, from there, go to the SCSI connector and then choose a hard
drive.
From here, you need to click on “New” if you want to change the
location of your virtual disk. This is important as, by default, the
vhdx file is stored within the C: drive.
Click on “Connect.” Once done, you will now see the Kali Linux
Live Boot Menu, as shown below.
Here you can see the Live system option. The live system option is useful
for using the Kali Linux without the need for installation. This is okay for
testing out a feature, but it is not user-friendly as it doesn’t save the work
environment settings or the work you have actually done. This makes
working with installed Kali Linux a good idea.
To start the installation, you need to press Enter on start installer option.
Once done, it will start the installation using the installation wizard.
Select the language of your choice for the installation process. It will
also ask you the language choice for the installed system. We are
going to choose English for both options.
It will then ask you to configure the keyword. Choose the keyboard
layout that you like.
After that, it will load installer components from the source. In our
case, it is an ISO. The wizard will also configure the network.
Once you select the guided partition, it will ask you to choose the
partition scheme. It includes the following:
As you are new to Kali Linux, we recommend using the first option.
Lastly, it will give you an overview of the partitions that are created. If
everything looks fine to you, it is now time to click on choose “Finish
partitioning and write changes to disk.”
ARM Installations
In this section, we will discuss how to do ARM installations. ARM stands
for Advanced RISC Machine. Some of the examples of the ARM-based
devices include embedded computers, developer boards, laptops, and so on.
If you wish to install Kali Linux on ARM devices, then you cannot use the
normal Kali Linux installation that we discussed just above. For the
devices, you need to configure the kernel to make the boot loader work.
To get started, you need to use the Offensive Security scripts aimed at ARM
devices. Check the link to download script:
https://gitlab.com/kalilinux/build-scripts/kali-arm
Once you have downloaded the image and the script, follow the steps to
complete the Kali Linux installation on ARM-based devices.
Once you are sure you have downloaded the right image, then you
need to acquire a storage device depending on what your ARM has
to offer. You also need to make sure that the storage device has at
least 8 GB of storage capacity.
Now copy the image to the storage device of your choice using the
dd. You can also use Rufus to copy the image.
If you are using dd, you need to use the following command.
Once done, log in using the credentials, user → root, and password
→ toor. Once connected, generate new SSH keys and root password.
Open source
Kali Linux is licensed under the Open Source model. It brings multiple
benefits, including the ability to use it for free. The open-source community
around Kali Linux is also strong, and we also see many developers
contributing to it.
Free to use
Kali Linux is free to use. This makes Kali Linux the number one choice for
pen-testers. It comes with all the necessary things that you will need to
work optimally. All of these without paying a single penny.
FHS compliance
It follows the Filesystem Hierarchy Standard, which is also used by other
Linux distros, including Ubuntu distro. As a user, you benefit from it as it
allows you to carry your FHS knowledge from one distro to another. You do
not have to re-think where you can find the libraries, binaries or other files.
Custom kernel
Kali Linux kernel is custom made and includes the latest injection patches.
It is frequency patched and also developed securely.
Language support
It supports many languages out of the box.
GPG signed
All the packages used in Kali Linux are GPG signed, which means that the
packages are secure and are made based on the standard protocols.
Customizable
Kali Linux is highly customizable from the core. It is developed in such a
way that it can meet every user requirement. The customization needs to be
done on top of the kernel.
All these features make Kali Linux different from other Linux distros. First
of all, it is a single user, i.e., root. This means that all the critical changes
can only be made through root user. It also means that it is a single-user
operating system. This is a good approach considering that most of the tools
require high-level access. Apart from that, network services come disabled
so that you can install applications without much difficulty. Lastly, it comes
with minimal repositories which ensure better system integrity.
First of all, Kali Linux is not for normal users. It is an operating system that
especially for penetration testing. This means if you want to become a
security specialist or are already a one, you have made the right choice in
learning or using Kali Linux. However, it is not a good choice for doing
other development things or using it as a normal day-to-day activity.
Another thing that makes Kali Linux so amazing is its production value.
Only a few veteran people are in a position to update the project. You can
suggest new changes, but these veteran people decide if changes are made
to it or not. Initially, the developer signs the repositories, which is followed
by the entire team signature. As a user, this means you have restrictions
when it comes to adding or customizing packages. So, if you wish to add a
package, you need to do a lot of research and patience to accomplish it.
So, does it mean it is for you? To ensure that you are going the wrong path,
ensure that you do not choose Kali Linux in the following case:
If you think you are going to use Kali Linux as your daily driver
when it comes to doing daily activities such as browsing the web,
watching videos, or gaming.
Also, you should learn about the legal terms that come when it comes to
doing unauthorized penetration testing on networks. If you make changes
that damage a computer or network, you might get in trouble. Law
enforcement against these kinds of activities is pretty strong, and you
should know it beforehand then repent later.
However, if you are someone who wants to make computing safe for
everyone, then Kali Linux is for you. You know your way when it comes to
use penetration testing tools and have proper authorizing while doing your
activities.
Things We Learned in This Chapter
Kali Linux is used for penetration testing purposes.
Installing Kali Linux is easy. You can choose between the USB
method(with or without dual boot) and the virtualization method.
Hyper-V lets you install Kali Linux directly into the Windows 10.
You need to have the Windows 10 1903 version or above to use it.
Kali Linux key features include custom kernel, FHS compliance, language
support, free to use, open-source, customizable, GPG signed, and so on!
Chapter 2
Getting Started With Hacking
As we already learned, Kali Linux is mainly used for hacking. And, that’s
why we need to cover the topic in detail. We need to learn what is hacking,
types of hackers, and the path you should take. We will also learn the role
of Kali Linux in making you a security expert.
What is Hacking?
Hacking is an activity that is done by hackers, which involves modification
of a system, service, or solution. It can be done in a subversive manner,
where the hacker can have authorized or unauthorized access.
However, in general space, hacking is always seen as a bad thing. It is all
about doing criminal activity, including gathering information or data
unauthorized, hacking security systems, or transferring a huge amount of
money from a bank account. Even though they are an example of hacking,
they do not confine what actually hacking is.
Currently, hacking can be related to multiple definitions. The best way we
can define is hacking as “being creative.” Hacking is not only a computer-
related activity. It is an activity that is carried out in our daily lives. If you
modify or transform an object or process to the way you want -- that can be
termed as hacking.
Hacking in computer terminology is exploring for vulnerability -- using it
or fixing it. The world of cybersecurity runs on finding vulnerabilities and
solving them so that anyone using that service or solution are safe.
Computer hacking has now become one of the biggest skills to have. It is
now performed by certified professionals who know what they are doing.
This also gives rise to different types of hackers, including white hat, black
hat, and gray hat hackers. The approach, motivation, and method of
penetration determine their type.
You may find hackers and crackers confusing. Crackers are hackers but
only do specific types of activity, including breaking passwords, bypassing
software access, or going around computer security.
Hacking Consequences
Hacking can be a fascinating thing to do, especially for new learners, but it
comes with its consequences. The consequence of unauthorized access can
vary depending on the situation. In many cases, hackers, once caught, are
prosecuted according to law. The laws are also not light when it comes to
hacking. The criminal charges can be big, depending on the hacking done.
For example, if you hacked a financial institute, you are bound to get a
severe penalty, including serving in jail and paying a hefty amount. This is
done to ensure to discourage hackers from doing unethical hacking.
But not all hacking is bad. White hat hackers or ethical hackers are at the
core of good hackers. There are also cases where white hat hackers are
caught doing unethical hacking. In those cases, their punishment depends
on their actions and contributions they have made to the community.
Victims
If you are going to do penetration testing with Kali Linux, you should also
learn about the victims of your actions. If you are on the right path, then
there is no need to worry, but what happens if you try to be unethical? Who
will be your victims?
The victims can be anyone who is on the internet. There are hundreds of
instances where hackers hack personal photos and post them on social
media, embarrassing the said person. The hacker can also blackmail the
person. In fact, the number one activity that hackers do is identity theft.
They hack a person's account and copy all their photos and information.
Once they are done, they create a similar profile and try to act as that said
person. Another common activity is to do credit card theft and unauthorized
payments.
Kali Linux is a hacker tool. If you choose Kali Linux, I hope you know by
now that you are going to use it for hacking or penetration testing. That’s
why you need to learn about the hacking process. The hacking process can
be applied to most of the hacking attempts and can be used as a framework.
These steps will guide you to become better at hacking(both ethical and
unethical).
The key five steps that are present within a hacking process include the
following:
Scanning
Gaining Access
Maintaining Access
Covering Tracks
Information Gathering(Reconnaissance)
The very first step that you are going to do is information gathering. It is the
most important part of the hacking process. And, most of the time, it gets
ignored. The information-gathering process is known as reconnaissance. In
this step, your job is to gather as much information as you can — the more
useful information you have, the better the chance of success of the hacking
process. The information you gathered in your very first step will help you
in all the next four steps, including scanning, gaining access, maintaining
access, and covering tracks.
As a hacker or a learner, you may find the information gathering step a little
boring -- as it has basically no need for the technical tools. Most of the time,
you have to keep staring at the system and try to find information. You need
to decide which information is useful to you. In terms of tools, you might
need to use one. And, when it comes to techniques, there are quite a few of
them out there that you need to learn.
Types of Reconnaissance
Reconnaissance can be done in two types. To help you understand the
concept, we will go through each of them one by one.
Passive Reconnaissance
In passive reconnaissance, your work is to not interact with the system
directly, but passively try to gather information. So, if you want to find
loopholes in a system, you may want to go to the company’s website, learn
about who they are hiring, understanding what technologies they are using,
and so on. By doing so, you can learn about the company without trying to
interact with the system you want to hack.
To get started, you can use Google to your advantage. There, you can find
public records. To learn more about the company, you may want to do a
WHOIS search. It will help you know about more data, the hosting they are
using, and other important details.
Next, you can also try to research about the client to which the company
works with. Also, try to find which employees are working on which
project or at least try to find their most valuable employee. This information
might seem insignificant but can be game-changing in the later phase of
your hacking process.
Social Engineering is also a great technique that you can use. In social
engineering, you simply stole the identity of a person and then used the
identity to gain information from other people. This way, you might get
access to a company’s account that the employee uses. Social engineering is
a very powerful tool, but you should be very cautious before you start doing
it. If you make a single mistake, your cover will be blown, and it will
become harder for you to get into the system or gather more critical
information.
The best way to approach social engineering is to make fake social media
profiles and connect with people you think that you can get more
information. Social engineering can also be done through calls. It might
look a little intimidating initially, but with practice, you will become more
successful in doing so.
Dumpster Diving is a technique where you look for information from the
discarded place. You can gain information from the documentation that is
dropped in the trash can. For example, you can gain access to an ATM slip,
and from there, you can learn about the person’s transaction information.
You can also gain access to phone numbers or even bank statements.
Active Reconnaissance
Active reconnaissance is the complete opposite of passive reconnaissance.
It requires active engagement with the system. The target needs to be
clearly defined, and you should actively search for the system. But, active
information gathering is more challenging than passive ones. One of the
ways is to take help from an employee of the company. May be asking them
to let you go through the normal process of using the solution/software. You
may also want to go through their documentation(if they have any) and try
to learn about their system as much as you can.
Try all the different ways to connect with the server. However, be
very wary of how you do your interaction as it can activate the
safety mechanisms of the system and flag your identity.
Scanning
The next step in the hacking process is scanning. The scanning phase
includes heavy use of tools. The scanning tools will help you further refine
the information you gather from the reconnaissance phase. As a hacker, you
need to use a variety of tools, including port scanners, ping tools, sweepers,
vulnerability scanners, and network mappers. The network scanning is
important as it will help you gain access to the system(the next step).
Learning about the list of open ports is also vital, as well. It will also inform
you about more information, including the operating system being used.
Also, the response type will be different depending on the operating system
or the response ports that are open on the platform. So, if you are trying to
access a Linux based operating system, you will get a different response.
Another technique you need to follow is "sniff" network packets. There are
many tools out there that will let you do it. However, I recommend you use
Wireshark, the number one tool used to analyze traffic. Once the phase is
completed, you should be able to understand the whole network structure.
Open ports
Also, you need to make sure that you have all the information in one single
place. By doing all of this, you will be able to make sense of the data, and
also remove or separate data that you think is less important.
Gaining Access
With all our information gathering done, we are now ready to gain access to
the target system. Until now, we have a good amount of information in our
hands. This information will help us to gain access. Our information
contains network mapping, logging information, and other vital
information.
So, what methods you can use to gain access? Actually, there are many
ways you can do so. If you were successful in your social engineering
technique, you might get a direct username and password to enter the
system. That would be awesome! However, that’s extremely rare. In most
cases, you need to find the vulnerability on the application hosted on the
system. Otherwise, you need to find the vulnerabilities with the system
version.
Denial of Service attack will not enable you to get access to the system but
will allow you to expose the vulnerability of the system.
Once you find at least one vulnerability, you should be able to get into the
system. However, the time to break in depends on how robust their security
system in. Most companies invest heavily in their security aspects. They do
have white hat hackers, and their job is to protect the system at any cost. If
they find someone accessing the system unauthorized, then they will try to
prevent it. It is better to be pre-equipped with this type of threat. As a
hacker, it goes a long way to learn the working time for the white hat
hackers and only try to get access to the system when you think that there
are very minimal chances of you getting caught or defined the entry to the
system.
If you are a grey hat hacker yourself, then you might want to report the
vulnerability to the company. You can also continue with the process and
may be reported later with more details about the vulnerability. The choice
is yours.
Gaining access can also take some time to accomplish. Most of the hackers
give up at this point. But, if you are determined, then you will eventually
get into the system.
Another thing that you need to keep track of is human errors. They are
pretty common, and you can find your way by capitalizing on the errors.
Humans are prone to make mistakes. They lack 100% attention when doing
tasks, which results in loopholes. These loopholes can be both technical and
non-technical in nature.
Maintaining Access
Once you get access to the system or the network, you now need to
maintain access to it. This part is as challenging as getting access to the
network. The networks/system have their own custom-made firewalls
which continuously monitor the network for any anomalies. Some firewalls
come equipped with advanced systems powered by the latest technologies.
This makes maintaining access to one of the hardest steps in the hacking
process.
The best approach is to ensure that you do not get identified as a rogue in
the system. Also, to maintain access to the system, you need to include a
backdoor or trojan into the system. A rootkit can also help you keep access
to the system in the future.
Once you establish access, now you need to monitor emails, system login
information, and other important things. You can also monitor the network
traffic and modify them according to your requirements. The best approach
to gather information from a particular terminal or machine is to equip it
with a keylogger. This way, you can get further access to specific accounts,
giving you more control over the network.
The goal is to keep yourself hidden within the system for as long as you
can. You need to be slow and steady in your approach. Initially, you can
simply observe the different workings of the system. Once you are
confident about how the system/network work, then you can go and infect
the environment.
The main goal is to hide from the IT professionals that maintain the system.
You should also think like a white-hat hacker and protect yourself against
his techniques of finding you.
The best approach is to override the log mechanisms of the system. Logs
offer different information about how the system works. This means you
can remove your entries from the log. You can automate the system to do
so. The logs are commonplace for white hat hackers who are looking for
anomalies within the system.
Once you gain access, you need to maintain Access to it. You can do
it by staying low, deleting entries in the log files, or installing
malware.
Lastly, you need to clear tracks so that you can have access to the system in
the long run.
Chapter 4
Learning About Cyber Security
Not everyone is on the dark side. Many people want to make the world a
safer place. As a learner who is interested in Kali Linux, you also need to
get yourself equipped with the cybersecurity terminology and knowledge.
We will keep this chapter short, and soon after this, we will move into the
realms of Kali Linux. The fact that learning Kali Linux is not all about
tools; you need to have the proper background knowledge to use them
properly.
Confidentiality
The first element of the CIA triad is confidentiality. In other words, it is
related to privacy. By maintaining confidentiality, a system ensures that the
user’s privacy is maintained at any cost. It also ensures that the owner only
accesses sensitive information, and malicious actors cannot access it.
Confidentiality rules can differ based on the data type and owner status. The
categorization is done based on how intense the damage can be if the data
falls in the wrong hands.
Integrity
The second element in the CIA triad is integrity. It is all about the data
trustworthiness, accuracy, and consistency through the data life cycle. This
means that the data should not be modified or changed by unauthorized
access or malicious actors. Most of the time, if the confidentiality breaks,
the integrity of the data breaks too.
Some of the algorithms used for checking data integrity include SHA1,
SHA2, SHA3, SHA5, and MD5.
Availability
The last trait is the availability trait. The data stored should be available at
all times. The data that is not available is useless. To achieve 100%
availability, the hardware manufacturers need to maintain their hardware
and immediately repair them if any issues occur. They also need to focus on
the software, or the operating system used so that the requested data can be
served to the user in the best possible way.
The two best ways to provide data availability is redundancy and backup.
Other technologies also pose their own issues. For example, IoT brings a
new whole level of challenge. Connecting different devices together
through a different medium, interface, and networks is in itself a challenge.
Now, protecting data confidentiality, integrity, and availability is much
bigger a challenge. IoT is not as secure as other technologies.
Malware
One of the most common cyber attacks is the use of malware. It is a
software that is used to gain system access. It can also be used to cause
harm to the system without the owner’s prior knowledge.
Social Engineering
Social engineering is a non-technical threat where a person tries to
impersonate and gather information through social skills. It is all about
psychologically manipulate people.
Ransomware
Ransomware is a new type of malware. It is used mainly to ask for ransom
from an affected computer. The extortion starts after the target machine is
infected with malicious software. The software can lock important files in
the system and then ask for money in exchange for unlocking them. Many
ransomware would lock users completely out of their system. Even after the
user agrees to pay the amount, the hacker might keep a backdoor to the
system so that he can infect other computers in the network. He can also try
to infect the system again after some time.
Phishing
The last type of cyber attack that we want to discuss is phishing. It is a
common attack that begins with fake emails. The emails are then used to
gather key information, including credit card numbers or login information.
The best way to protect against is to have proper filter mechanisms in the
email service.
Other types of cyberattacks include the following:
Man-in-the-middle(MITM) attack
SQLi attack
Denial-of-service(DoS) attack
There are other cyber attacks other than the above attacks. The type of
attack depends on the devices and the network that the hacker is trying to
hack.
Let’s try to explain these types of attack in simple terms below.
SQLi Attack
In the SQLi attack, the hacker tries to execute malicious SQL statements on
the database. If the hacker can execute them successfully, then he gains
access to the database or the system. There are plenty of ways to protect the
database against his common cyber-attack.
Denial-of-Service(DoS) Attack
This is also one of the most common cyber-attacks out there. It takes place
by jamming a network or service to provide the service. A large number of
machines are used to carry out DoS attacks. DoS attack's main aim is to
disrupt service and also reveal a weakness in the system. If multiple
machines make the attack, then it is known as a distributed denial-of-
service(DDoS) attack.
Another thing is that anything can never be 100% secure. This means that
the cybersecurity field is always a growing field. New technologies and
evolutions take place almost every year, which makes it even harder for
cybersecurity specialists to make the work safer.
Integrity, the 2nd CIA triad, deals with data accuracy, consistency,
and trustworthiness during the data life cycle.
Availability, the third CIA triad, is all about 100% system or data
availability at any condition or scenario.
There are many challenges the CIA triad brings to the table.
Kali Linux is a genuine Debian derivative. The work on Kali Linux started
in 2012. Its connection to Debian is important to learn as it will make you
understand its importance and also understand how it works.
More specifically, it is based on top of Debian Testing. This means that the
packages that you see in Kali Linux are from Debian repository -- not all,
but most. However, do not make the confusion that Kali Linux is dependent
on Debian. Kali Linux has its own infrastructure when it comes to
packaging selection and distribution. The user can choose whatever he
wants and has the complete freedom to do so.
The Debian gets updated by contributors daily. They update packages and
also ensure that the packages get updated to the unstable Debian
distribution. Once the packages are uploaded, it is then moved to the
Debian Testing distribution. This is where all the bugs are removed, and the
packages are then made available for release.
Debian testing is the best playground for Kali Linux as their goals are
aligned.
The contributors of Kali Linux then take a two-step process to include the
packages.
The first step is to force-inject the Kali packages to the Kali-dev repository.
This can break the repository, but that’s the expected outcome. To make it
work, the next step is to make sure that the new packages are recompiled
along with the old ones to make it work.
Kali Linux also has a distribution named “Kali-rolling,” which can be used
by the users to track all the changes that are made to the Kali-dev
distribution. The end goal is to ensure that all dependencies are met before
packages are migrated.
If the packages are good, they are then moved to the main Kali distribution.
Chapter 6
Linux Fundamentals Refresh
Understanding Linux
We can define Linux as an operating system, but in reality, it is simply an
operating system kernel. A kernel is a collection of files, libraries, and
features that makes an OS work. It acts as a mediator between the software
and the hardware and provides you the means of exploring your computer.
A kernel is responsible for managing users, file system processes, hardware,
and permission system. All the system related activities run in ring zero,
which is also known as kernel space. On the contrary, Linux also has user
space, which is defined as the space where everything other than kernel
activities takes place.
The new hardware is detected with the help of /sys/ and /proc/ virtual file
systems. The applications, on the other hand, need to access /dev/ as files
are created there.
Everything in Linux is a file. This means that hardware is also represented
as a file. For example, the disk drives are represented as /dev/sda. The
partitions, on the other hand, are represented as /dev/sda1.
The device files, however, can be of two types, character and block. They
are defined based on the method of how the information is stored or
retrieved. A block is fixed in nature, and bytes can be accessed from any
given block position. The character file, on the other hand, acts as a flow of
characters.
If you are using multiple disks, then one disk is assigned as /root, whereas
the other disks are named as ext2, ext3, and so on.
Process Management
The kernel is also well-equipped with process management features. Any
program in its running state is known as a process. The process makes sure
that the program instance runs as intended. To do so, it uses memory. The
kernel, in this case, makes sure that it creates and tracks the process. The
memory management is also done by the kernel while ensuring that there is
enough memory for the optimal work of the system. Once it allocates the
memory, it then loads the executable file into the memory and starts running
it. To make sure that it can track and manage the process, a process
identifier(PID) is also allocated to the process.
Once you start your terminal, you can now use commands on it. Let’s start
with the ls command.
ls command lists all the files and directory at the location it is run.
As you can see, you need to provide input to the command line prompt.
Once done, shell -- a command-line interpreter will then execute the input.
In the case of Kali Linux, the default shell is Bash shell. Bash stands for
Bourne Again Shell. If you see either $ or # at the beginning, it means the
shell is waiting for your input.
I would also suggest you to read free online tutorials on the Linux
command line. There are plenty of good tutorials out there that are worth
your time. Always remember, that without proper working knowledge of
Linux, it is next to impossible to learn Kali Linux, forget mastering it.
/sys/ and /proc/ used by Linux Kernel and is not part of FHS
Home Directory
The home directory is also an important part of any Linux OS. However, it
doesn’t contain any standardized elements, but it does contain some of the
interesting stuff that you should know.
The home directory is mostly referred to as “~” tilde sign. This makes it
easy for the user and as well as the command interpreters as they can
change the tilde sign to the home directory.
To know the value of the home directory, you need to check the
environmental HOME variable. In most cases, it is set to “/home/user.”
In the home directory, you can find the application configuration files. Also,
the files contained within the home directory can be hidden by default. The
files that are hidden start with . (dot), signifying that it is hidden. If you
want to see all files including hidden files, then you need to use the ls
command with the -a option as below.
ls -a
The configuration files used by programs and services can be multiple files.
This can lead to issues as to where the configuration files are stored. To
ensure that this doesn’t happen, XDG Base Directory Specification is
followed. This ensures that the files have a clean structure attached to it --
the place they are stored. For instance, the cache files always need to be
stored within ~/. cache, the configuration files in ~/. config, and so on.
If you want to limit the content shown on the screen, then you need to use
either less or more command with it. To run two commands together, you
need to use pipe (|). It takes one command’s output and makes it an input to
the other.
cat file1 | more
This will show the contents of file1, making sure you can view one page at
a time. If you want to view more, you can use the enter key. To close the
operation, you can press CTRL + Z and terminate it.
You can also use greater than (>) to store commands or string text to a file.
Most of the time, a text editor is used when you want to modify a file. It can
be either vi or nano. You can use the vi or nano command followed by the
file name to open up the file in the respective text editor.
But, the simplest way to add content to a file is to use the > or >>
command. The > replaces the content of the file, whereas the >> appends it
to the file’s content.
Finding Files
You can search for files with the help of the find command. It takes the
directory in which you are searching as input, followed by the text string.
Process Management
Another important part of the Linux operating system is process
management. You can do process management through the command line.
Each process has its own PID. This means that it is easy to manage them.
kill [pid]
This will send a signal and stop or terminate the process. You can also make
a command run in the background. To do so, you need to use the & after the
command. This will make the command run in the background, and you
will also instantly gain access to the shell itself. You can also use the jobs
command to see the processes that are running on the system, and then do
things accordingly.
If you want to move a process in the foreground, you need to use the fg
command, which will bring the background process to the foreground.
Also, once a process is moved to the background, it cannot be terminated.
So, you need to bring it to the foreground to terminate it.
It also utilizes a proper file system for easy access to files and
directories.
You have reached a point where you are now ready to go into the Kali
Linux operating system. In this chapter, we will learn how to configure Kali
Linux. Configuring Kali Linux is important as it will make you use it to its
full potential. This includes configuring the network, services, and Unix &
user groups.
Network Configuration
Before you start to use your Kali Linux, you need to configure the network.
Network configuration will help you connect with the internet. Let’s see
how you can configure the network.
NetworkManager
Gnome provides an interactive way to access different Kali Linux. It offers
NetworkManager, an interactive way to configure your network. To get
started, go to the top-right menu of your desktop view, and there you can
see the drop-down arrow. Click on it, and then choose wired connection.
From there, you need to choose “wired settings.”
Once you click on wired settings, you will see the following window open
up.
Here you can see that the connection is already setup. DHCP is used to
configure the network, including IP address, gateway, and DNS server. If
you want advanced settings, you need to click on the gear icon on the wired
connection. From there, you can change settings, including IPv4, IPv6,
security, and identity.
In fact, you can create multiple profiles by clicking on the plus symbol.
This way, you can change between different settings. For a wired
connection, you can change easily. If you are on the wireless network, then
the SSID setting is used to connect to those networks. SSID stands for the
public identifier.
You can also see that there is an option to set up a VPN. VPN works with
the protocols used by the NetworkManager. You can connect with different
VPN types through plugins, including OpenVPN, SSH, and so on.
Lastly, you can set the network proxy. By default, it is set as off. You can
change it to manual or automatic.
Configuring Network Using Command Line
You can also configure the network using the command line. There are
instances where you might not have access to the graphical desktop.
Configuring the network through the command line includes the use of the
ifupdown package. The package includes two tools, ifup, and ifdown tool.
The tools are at the core of init script stored in the /etc/init.d/networking
directory. The file is used to network configuration during system boot. The
devices that are managed by ifupdown can be registered and deregistered
using the ifdown tool.
So, how do you do it? Let’s take a look at the ifupdown configuration file.
Inside the file, there are two main derivatives that you should know about:
The ifup is used to activate a network interface, whereas the ifdown is used
to disable network interface. When you enable a network, it is now ready to
receive and transmit data. On the other hand, disabling a network means
that it can no further receive or transmit data.
Using systemd-networkd
There can be instances where ifupdown tool might not work. This can be a
reason behind it being too old. After all, it is a historical tool that is being
used in Debian. You can use the new tool known as systemd-networkd. It
comes integrated with the init systemd. This is a new tool and is not Debian
based. It is also lightweight and is easy to integrate with multiple distros.
Sometimes, the networkd might be disabled. That’s why you need to enable
it to use it. Also, before you use it, you need to ensure that you have done
the DNS resolution integration. It can be done by creating a symlink to the
/run/systemd/resolve/resolv.conf replacing the /etc/resolv.conf file.
However, as you can see from the above screenshot, it asks for a variety of
information before finishing the process of creating a new user. It starts by
creating the user, adding a new group, and adding a new user (1000) with a
group. The group is created similar to that of the username. You can also
mention the group name by adding it after the username. adduser command
takes two inputs. The first input is the username, whereas the second input
is groupname.
You can also gather more information on how the adduser function by
typing the help command as below.
adduser --help
First, it asks for the password. You can set a password for the new user. The
user can then change this password once he logs into his/her session.
Next, it will ask you to enter values asking for more information about the
user. You can opt to skip it by simply pressing enter. The user itself can
enter this information once he uses his user account.
The information asked by the adduser command includes the following.
Full Name
Room Number
Work Phone
Home Phone
Other
If you still want to know more, then you can check out the configuration
file used by the adduser command. It is stored in /etc/adduser.conf. The
configuration files include some nice stuff that you can learn about. For
example, you will find that a user identity(UID) range is defined to ensure
if something is shared with the group or not.
Also, you noticed how it created directories in the user home directory. The
structure of the directories utilizes the /etc/skel/template. The adduser
command uses the template and configuration files to ensure that a user is
added by following set standards.
Getent Command
There is one more useful command that you should know about. It is the
getent command. It stands for get entries as it can query the system
database. To do so, it first calls the needed library function, then followed
by the calling the NSS(name service switch) module. This module is
configured in the /etc/nsswitch.conf.
So, if you want to search for a password for a particular user, you can run
the following query.
passwd
The first command that we are going to discuss is passwd command. It is a
straightforward command that lets you change password. Any root or
normal user can use the command. No root privilege is required to run
passwd.
It will ask you to type the password once you enter the command. It will
once again ask to re-type it before changing the password.
chfn
chfn lets you change the full name of the user. It is only reserved for the
superuser, i.e., root user.
chage
chage command is used to change the password expiration settings for a
user. It can only be used by an administrator and is used to enforce good
password habits. Passwords are sensitive in nature and hence needs to be
modified from time to time. If you want a user to change the password
immediately, then you need to use the -e argument. It will force the user to
change the password the next time he logs in.
Account Disabling
Some accounts need to be disabled due to many reasons, including not
following rules or if an account gets hacked by someone else. To ensure that
this does not hamper your Kali Linux installation, then you need to delete
the account or at least lock the user out for an indefinite time while you run
an investigation.
passwd - l [username]
This will lock the account. This also means that the account files are not
deleted and are only locked. They can be referenced later on once it is
unlocked. As a Kali Linux administrator, you should only use account
disabling to ensure that you can revert the account if needed. Also, some
users may be sensitive information in their home directory. Data once
deleted cannot be reverted, so be wary of the consequences before you
delete a user account.
If you want to modify a group command, then you need to use the
groupmod command. It lets you modify the group using the GID or the
identifier.
You can also set a group password using the gpasswdgroup. For removing
the password, you need to use the following command.
gpasswd - r group
This leads us to the end of our Unix groups and user management. Now,
let’s move to configure the services.
Configuring Services
Service configuration is also an important part of Kali Linux. When we say
services, we generally mean daemons. They are the programs that keep
running in the background. The services are also responsible for making
sure that the systems function as intended.
As there are tons of services running in the background, it is not possible to
discuss each one of them. That’s why we are going to discuss a few of the
important ones only. Let’s get started and see how important services can be
configured.
By going through the documentation, you will only save time. Generally,
package configuration can be very specific, and the documentation does
have the required information to do so. The documentation might also
contain a link to other resources that you can find useful.
If you feel lost, then you should check out the dpkg -L package command.
This command will return a list of files. From there, you can easily find the
documentation.
Another useful command is the dpkg -s package, which shows you the
meta-data about the package. The meta-data can contain important
information or simply can suggest other packages that can contain the
required information.
Also, you can always try to run the configuration beforehand. By going
through the configuration, you will know what to expect, and then find
those things in the documentation.
To use SSH, you first need to make sure that your machine comes pre-
installed with the openssh-server. By default, it comes pre-installed. If it
doesn’t, then you need to install it using sudo apt-get install command.
Sometimes, SSH services can also be disabled. To make it work, you need
to use the following command.
You can also configure it to start it with the boot. To do so, you need to run
the following command.
Configuring SSH
By default, the SSH comes with good enough configuration. However, if
you can configure it to make it more functional. To know what it has to
offer, you can check its configuration file at /etc/ssh/sshd_config file. The
documentation can be found in the sshd_config(5) file.
If you are using SSH for the first time, then you will notice that it doesn’t
allow password-based logins. To connect, you need to use the SSH keys.
The SSH keys is generated using the ssh-keygen.
If you want every user to use the SSH key-based login, then you need to set
the PassswordAuthentication to “no” in the configuration file. This is
always a better option compared to other password-based logins.
To ensure that the changes are applied, you need to use the following
command.
One more thing that you need to make sure is to create new SSH keys. If
you installed your OS using the debian-installer or simply copied the full
disk image, then there can be some pre-installed SSH host keys. As a user,
you do not want to use those keys. Moreover, you also need to reset the root
password that comes along with them. This way, you will make sure that
the keys are not being misused by someone else.
# passwd
The above command will change the password.
Next, you need to generate new keys using the following set of commands.
# rm /etc/ssh/ssh_host_*
# dkpg-reconfigure openssh-server
To start the service, all you need to do is run the following command.
In the postgresql.conf file, you can change the port by editing the port
directives. Other key directives include listen_address to change the address
to which PostgreSQL will listen and the unix_socket_directories which
deals with the file-based sockets that are created during the operation.
Whenever someone connects from the network, they can connect in two
different ways. The two different ways are as below.
The first way is using a file-based socket. It is a popular way as it utilizes
the Unix user account to log in as a PostgreSQL user. This means that once
it connects, it requires no further authentication, making it the most obvious
way of connecting.
To change the behavior and configure how logins are done, you can check
out the pg_hba.conf file, where you can define the socket for connection,
and the method that needs to be used for authentication.
If you want full control over the database, then it is a good idea to use the
2nd method as the Postgres user has special privileges.
Getting Started With User And Database Creation
Our next step is to create a new database and users now. To create a user,
you need to use the createuser command. Removing a user is also easy. All
you need to use is dropuser command. If you are confused about how these
commands work or need more help, then you can always use the man
command to read their manuals.
Apache Configuration
Another important service that we need to configure is the Apache
webserver. Kali Linux comes pre-installed with Apache. If it doesn’t, then
you need to install the apache2 package.
To start the apache service, you need to use the following command.
We need to learn a little bit of Apache as most of the applications are now
distributed as web applications. By learning how to use Apache, you can
teach yourself how to host your own applications on the network or use the
other hosted network applications.
Apache has a modular design. This means that you can add features to
Apache by adding new modules. Also, not all modules come pre-installed,
and you need to install it to use it. Also, most of the libraries are external in
nature.
As an Apache user, you will be able to find common modules that come
installed. The default configuration makes sure of that.
To enable new modules, you need to run the a2enmod module to enable
the module. You can also disable a module by using the a2dismod module.
The two of the above programs simply removes the symbolic links to
disable and enable modules. The symbolic links are stored in
/etc/apache2/mods-enabled. The actual files, on the other hand, is stored in
the /etc/apache2/mods-available/.
Web applications that utilize PHP use Apache webserver for execution. It
utilizes the libapache-mod-php package. So, if you install Apache, it will
automatically get enabled. The other package SSL, on the other hand, is
required to make a proper HTTPS connection. It is included in Apache 2.4
and beyond.
To enable SSL, you need to use the a2enmod SSL. Once done, now, you
need to add the directives, you also need to edit the configuration file.
Managing Services
Until now, we have learned how to manage some particular services on Kali
Linux. Now, it is time to learn how to manage services. At the boot
sequence, Kali Linux utilizes systemd for initializing the system.
The systemd init system is also a fully-featured service manager. It lets you
manage services, including starting and monitoring them.
To learn about the active services on the system, you need to use the
following command.
systemctl list-units
You can also list the services in a hierarchical overview by running
systemctl status command.
The status command, as you can see, gives a hierarchy output. You can also
see that there are different kinds of units. The services, on the other hand, is
part of those units.
A service unit represents each service. The service units are service file
which is stored in /lib/systemd/system/. There are two other directories in
which these service units are stored. These include the /etc/systemd/system/
and /run/systemd/system/.
Kali Linux is a complex operating system. Even though you read the book
completely, there would be something that will be left behind. Also, it
doesn’t matter if you are working on it for years; there will be moments
where you feel stuck. That’s where the Kali Linux community and
documentation comes in. In short, you need to be as resourceful as possible.
You need to be able to find solutions to your problems yourself. This will
make you competent and a great problem solver.
We will also cover strategies on the best way to use the information
available. Let’s get started.
Documentation Sources
Kali Linux is well documented. That makes it easy for you to work with
Kali Linux. Also, if you want to make sure what is going on, it is better to
read documentation. A program can be a complex thing, and to be sure,
read the documentation. This way, you can be sure of what is going around
the program.
There is one more thing that you need to be wary about when going through
forums or communities asking questions. If you are new to this, you may
find others reply with the keyword, RTFM. This is a popular way of
responding to queries that are covered in the manual. Its full form is “Read
The Fine Manual.” It can also mean “Read The F**king Manual” as well
on the internet. If you get these kinds of replies, that means that your
answer is in the documentation itself. Also, do not get offended by the term.
It simply means that you need to read the manual.
Manual Pages
Your first place of hunting for information is manual pages. Manual pages
take a different approach for organizing the information. The command to
find the manual for a program or a command is ‘man.’
man [command]
For instance, if you want to learn what ls command does and all its possible
outcomes, then you need to use the following command.
man cp
The manual pages are also used to document other important aspects of the
Kali Linux. For example, it also documents things like system calls, C
library functions, configuration, and so on. This, however, can cause issues
as the names can collide with each other. One classic example is the read
command and the read system call. To ensure that the issue doesn’t interfere
with your work, the manual pages are organized in a numbered way. Let’s
take a look at the sections below.
Commands
System calls
Library functions
Devices
Configuration files
Games
Kernal routines
The above section number can help you to read the right manual for the
command you are looking for. So, if you want to read the manual for a read
system call, then you need to use the following command.
man 2 read
This will show you the manual page for the read system call. If you want to
learn about the read command, then you need to use the following
command.
man 1 read
You can also not include the number if you want to read the manual page of
command as they are at the top of the section number. It takes the 1 by
default or the number the command or program relates to. If you want to
read the manual for the shadow and do not put any number, it will simply
return the shadow(5), considering that the 1-4 sections do not have anything
to return for the manual page.
However, there can be cases where you do not know what the name of the
command is. This can lead to issues. But, you can still search for manual
pages using a command.
You can use the apropos command with any keyword you think that can
relate to the command or program you are searching for. The keyword
choice is important here as it will enable you to find the right command or
program. The command will return you a list of choices. You can then
select the one that you are looking for. It will also return a single sentence
about the command so that you get a better idea.
If you are looking for more information about the command, then you can
also lookout for a “See Also” section. If the documentation has the section,
it will include links and more information about some external
documentation.
There are other ways to find documentation. You can use yelp in Gnome
and Konqueror in KDE.
You may also want to run the following command so that all the
dependencies are pre-installed without any issue.
So, how does the info document looks like? It is in a hierarchical structure.
If you open the documentation, you will be able to find that there are a lot
of things that are covered in the documentation including introduction, USB
installation, Kali On ARM, Virtualization, Base Images, Containers, Cloud,
Windows Subsystem for Linux, Tools, General Use, Kali NetHunter
Documentation, Troubleshooting, Community, Kali Development and
Policy.
We recommend using irssi if you are fond of console mode. Hexchat is also
a good option as it offers a graphical interface. If you are not interested in
downloading any client, then you can check out their web client at
webchat.freenode.net.
Understanding Rules
IRC channels are very strict when it comes to rules and regulations. Before
you join or interact with other members, make sure that you read the rules.
If you make mistakes, you can get silenced or removed from the server.
By sharing the bug report, you are going to share valuable information with
the developers, which can then be used by the developers to fix the issue.
The more information you can provide, the better bug reports become. If it
is well-thorough and explains the conditions at which you are able to
generate it, the chances are that your bug report will be read and resolved in
a few days.
You can read the manual pages with the man command
You can also join the Kali Linux community by doing bug reports.
Chapter 9
Kali Linux Monitoring and Security
To ensure that you do not make hasty decisions, you need to find the goal.
To do so, you need to ask questions and then find answers to them. Let’s go
through the questions below together.
Answering these three questions will give you critical information on how
to define the security policy. Let’s try to understand each question below.
What aspects of your system need to be protected? In this question,
you need to find out the type of system or data you want to protect.
If you identify the system or the data, then you need to answer the
question of what type of data or system you want to protect.
When it comes to 2nd question, you need to figure out the threats.
The threats can be a malicious entity or simply the way the data or
system is compromised. For example, you may want to protect
against malicious actors that try to gain entry to the system. When it
comes to method, you may want to protect confidential data leak,
service disruption due to DDoS, and so on.
Lastly, you need to find figure out the threat types. For example, the
threat can easily be the user or a third-party malicious entity. In both
cases, you have to make sure that your system is protected at any
cost.
As a Kali Linux user, you also need to understand that security is not just
one-time. It can be equated to an ongoing process where you need to work
hard towards protecting the system constantly. With the system’s evolving
every second day, it is common for bugs or exploits to go through. This is
where hackers get a chance to do harm. This makes security one of the
hardest things to do.
In reality, you need to make sure that you minimize the risk factor. There
will always be a slight risk, but it should not be more than acceptable.
Depending on the system evolution, risks change with time. By ensuring
that you cover the constraints correctly, you can minimize the risk in a great
way.
That’s why creating a risk model that evaluates all parameters can be of
great help. Modeling around the risk model is what you need to do. Initially,
you need to cover the basic minimal parameters. Once they are covered,
then you need to find the extreme conditions at which the system can be
compromised.
Another important factor is the cost of implementing the security and the
risk associated with it. There can be instances where protecting risk is not
worth the cost associated with it. You also need to evaluate the loss if the
risk is exploited by someone else. If the loss is less than the cost of
implementation, it is better to leave it as is.
Data Confidentiality
Data confidentiality is very important. It is the number one priority for
anyone who wants to protect their system. As a Kali Linux user or any
system’s user, you need to make sure that your or system’s critical data.
This should be your top priority, and you should consider this more
important than any other security concerns. If you do not protect the data, it
can land into a malicious entity that can harm you in one way or another.
The hackers can also erase your data or destroy your hard disk or simply
can use the information to gain an advantage over other computers. This
makes data confidentiality a big topic in the security world.
Extreme Cases
Any security policy should consider extreme cases while securing a system
or data. Extreme cases are those that have low chances of happening and
rely on hard exploits in any system. Zero-day vulnerability exploits can also
be considered within the extreme cases as they are fresh and new in their
own way. Almost every system out there suffers from zero-day
vulnerability exploits. Also, not all extreme cases can be considered due to
the hardness they carry to solve them or simply the cost associated with
them to solve them. However, few extreme cases should be solved
depending on the severity it carries.
Approach
Systems can be complex in nature. That makes creating system policy a
tricky thing. However, there is an approach that can simplify the process.
As a user, you can create security policies for subsystems. This
segmentation needs to be used to ensure that you can do slowly and
steadily. It will also help you understand the constraints and requirements of
each subsystem and then do a proper risk assessment depending on the
broad security policy and needs.
Also, it is always easy to defend your system against small types of attacks.
There are already established means of protecting your system against
those. However, large attacks are where you should spend most of the time.
In the end, you need to make sure that the data is protected at any cost.
One last thing that you also need to make sure is to define your firewall
rules depending on the traffic you receive.
Security Measures
So, what are the security measures you can do to secure Kali Linux? Let’s
go through the options below.
Laptop Security
If you are using a laptop as a penetration tester, then you have to protect
yourself from risks associated with personal computers. As you are not on
the public server, you at least do not have to worry about people who use
scripts to hack into the system. As you are not connected to the network,
you are almost safe from network-based attacks.
The real challenge is to protect your laptop from others who are around
you. There can be a chance that authorities can seize your laptop, and you
might not want them to read through the contents of your laptop. To make
sure that they do not do it, you need to use full-disk encryption. If you are
serious about data or other information within your laptop, then you can
also go with the nuke option. If you have a nuke option, then it simply
removes all the data from the laptop with a combination.
Apart from the data safety, you also need to make sure that you have proper
firewall protection if you connect to the internet. This will provide you
unwanted access by others. Configuring the firewall rules is important here.
Just make sure that you only filter the traffic that you need.
Apart from it, you need to make sure that no firewall is running by default.
If a firewall is running by default, then it means that it is listening to
network interfaces that you do not want.
Also, some of the services running on the public server might not require
any authentication to connect or discover. As a Kali Linux user, you need to
make sure that the authentications are enabled and set a good password for
them to discover you. The key here is to implement privacy in the best
possible way. You may also want to disable services that require root access
to run. If someone gets access to those services, they can simply gain access
to your Kali Linux installation.
However, as a Kali Linux user, your main job is to protect your local
installation than that of a network. The good news is that Linux comes with
its own firewall solution. It is the Netfilter firewall. But, there is one caveat
that you need to take care of. You simply cannot just turn it on and leave it.
You need to configure Netfilter according to your network requirement.
You can also use the GUI-based fwbuilder tool that lets you graphically
select the firewall rules. We will not go in-depth into these tools as you can
easily find information on how to set up the firewall by yourself. If you are
still confused, then you can check the documentation for each tool. They
are simple and straightforward.
So, which files are monitored by logcheck? They include the directory
/etc/logcheck/logcheck.logfiles.
Paranoid is the most verbose type of report generation. This means that it is
not the best option out there. It is only useful for machines that host
firewalls for the network. The default mode that logcheck uses is server
mode. It is used for most users. The last mode is the workstation mode,
which is meant for the workstation. The workstation mode is also very terse
and is the only ideal for few scenarios where it is needed.
logcheck also offers different parameters which can then be used for
customizing it. Some of these rules can help you detect cracking attempts
and other security issues.
Real-Time Monitoring
Real-time monitoring can also be done if you feel the need for it. The tool
that you need to use for real-time monitoring includes the top interactive
tool. It offers a currently running processes list.
The top tool offers a good amount of information, including the processor
time, occupied memory, process identifier. It also lets you kill a process
using the k key.
The top tool is excellent for monitoring the system. It also helps you to find
out which process is slowing down your system by eating memory or
processor.
You can use dpkg --verify tool to verify if there is a change in the system
files integrity. The command is as below
dkpg -- verify
dkpg -V
However, this is not always a sure shot answer to know if the system in
question is really compromised or not. That’s why you might need to use
more advanced tools. We are not going to discuss the tools as they are
beyond the scope of the book.
The package management system also ensures that you do not have to work
hard to make things work as the management system takes care of most of
the things by itself. Let’s get started below.
APT Introduction
APT stands for Advanced Package Tool(APT). It is more advanced than
dpkg. But, what does dpkg do in the first place and how both of them
compare? Let’s find out below.
In short, a Debian package comes well equipped with all the information
that is required to install the package. The metadata also includes the
dependencies and have the proper information to know how to manage the
package’s installation, upgrades, and removal.
To install the Debian package, you need to use the dpkg tool. The tool is
very hand and is used most of the time to install the package. However, if
there is a missing dependency, then it will not be able to install the package.
An error will be thrown, telling you that the packages are missing.
By using the command, you will be able to analyze the .deb packages and
install them. However, dpkg is limited in nature. They simply do not know
about any other packages. APT, on the other hand, has a better feature set
compared to dpkg.
APT is a complete solution that enables you not only install and manage
Debian applications or packages but also upgrade the system when needed.
If you have used Linux before, you should know about the apt-get and apt-
upgrade options. These options let you upgrade and update all the available
packages(including their dependencies) correctly. We can consider APT as
an umbrella tool. Also, you should not forget that the APT tool is useless
without dpkg as dkpg handles all the core package management tasks,
including installation, removal, and upgrade. APT’s advantage is the fact
that it can connect online and then learn about the dependencies of a
package during the installation process. This solves the dependency process
and improves user experience.
APT and dkpg are a boon for the current Linux users. Earlier, a user need to
compile programs by themselves by using the programs such as GCC, make
and configure. They are compiling programs and can easily make the
installation process complex. You might have to go through the different
errors and mistakes before you can finally install the process. This required
reading documentation and researching online -- which in turn takes a lot of
time and effort.
With the advancement in user experience, we can say that Kali Linux(or
Linux in general) has come a long way. APT and dkpg have solved the
problems in a unique way, which makes Linux-based operating systems
more user-friendly.
The source in the APT source.list file consists of three parts. Spaces
separate these three parts. Let’s take a look at the example below.
deb http://http.kali.org/kali kali-rolling main non-free contrib
The first part of the command is the deb. In this case, it stands for binary
packages. It is the source type. It can also be deb-src, which stands for the
source packages.
The 2nd part is kind of clear by how it looks. It is the source URL. In this
case, it can be the Debian mirror or other third-party URL. Yes, third-party
can also maintain the sources to provide better services depending on the
place you share. The source here is an HTTP:// which means that it is a web
server where the source is stored. If you see FTP:// instead of HTTP://, this
means that the sources are stored on an FTP server. Lastly, if the user is
installing packages from a CD/DVD ROM, then they will see the cdrom:
syntax used. However, that rarely helps as most of the work is now done
online. Also, packages are frequently updated and it is not possible to
update the device. This also means that CD/DVD ROM source can go
outdated easily.
The third part is where things get interesting. Its structure depends on the
repository that is being used.
The packages that are contained in the MAIN are compliant with the
Debian Free Software Guidelines.
Kali Repositories
Kali repositories are repositories where the packages are stored. The main
Kali repository is as below.
To get a better idea of the repositories, let’s take a look at the different types
of repositories below.
Kali-Rolling Repository
The Kali-Rolling repository is aimed at the end-user. This is where you can
find recent packages that you can use in your Kali Linux operating system.
A tool that merges the Kali-specific packages and Debian Testing is used so
that the dependencies are maintained. This makes it ideal for end-users as
all packages can be installed without much issue. The Kali-Rolling
Repository is updated almost every day. This also means that the Debian
Testing is also evolved.
Kali-Dev Repository
The Kali-Dev Repository is maintained for developer’s use. It is not
available to the public. The developers ensure that the dependency
problems are solved here before the packages are moved to the main Kali-
Rolling repository. The packages from the Debian Testing first land here,
and then go through a proper testing method. If you are an advanced user,
you can choose to work with the repository but beware you try it as it can
lead to many hours of troubleshooting
Kali-Bleeding-Edge Repository
The repository holds all the new packages that are built from the upstream
Git. It is automatically built. This means that you can access to the bug
fixes and latest features. These changes are so fresh that you can get it as
soon as the changes are made available to it. If you think that your bug
report is resolved, you can verify it by trying out the repository. Of Course,
there is a downside to it as well. For instance, the changes are not
thoroughly checked and hence can have issues in it. There can also be a
dependency issue.
Before you start your journey with APT, make sure to run the apt update
command. It will update the available package list and the sources from
which the packages can be downloaded.
Installing Packages
Let’s take a look at how packages can be installed using the tools. First, we
will go through the dkpg and APT.
Here you first need to unpack the package using the --unpack option for
dkpg. It will unpack the package and process triggers, as well. Now, you
need to configure the database for the package. To do so, you need to run
the following command.
Here you change the packagename to the name of the package that you are
going to use.
Some of the steps are automatically executed once you run the dkpg
command with the --unpack or --configure command. Also, if there is a
dependency, then the command will throw an error showing that
dependency packages are not present.
You can also forcefully install a package by simply enabling forcing the
dpkg command to ignore the error. One such common error is the file
collision error. To forcefully install a package, you need to run the
following command.
Once run, it will first read the package list and then create a dependency
tree. Once the tree is complete and it doesn’t find any missing dependency,
it will move forward to install the package itself. But, if any dependency is
missing, then it will update them and then install the package. Before it
does that, it will ask you for confirmation. It will also show a message on
how many packages need to be updated or installed before the operation
can be done. If you press Y on your keyboard, it will automatically handle
everything from there and complete the installation process.
Kali Linux Upgrade
Kali Linux is an active operating system. It continually gets updated with
new features, packages, and programs. In this section, we will learn how to
keep your Kali Linux upgraded most of the time.
To do regular upgrades, you need to use the three basic upgrade commands.
apt upgrade
apt-get upgrade
aptitude safe-upgrade
All of the three commands lookout for the packages that can be upgraded. It
also makes sure that the packages that need upgrades will not be removed.
By running the command, you get access to the best possible Kali Linux
experience.
The package selection is made by the apt tool. It chooses the recent stable
version.
If you do not mind removing old packages that are obsolete, then you can
choose to use the following command.
apt full-upgrade
The command will not hesitate to remove old packages if it requires new
packages to be installed. We recommend using the command if you want to
stick close to the Kali Rolling system.
As a Kali Linux user, you can also learn about the potential issues with the
help of the apt-listchanges package. You simply need to install it and run it.
Once done, it will showcase the problems before you run the upgrade. The
information is stored in the /usr/share/doc/packages/NEWS.Debian file.
Also, one thing that you need to take care of is the frequency of updating
your Kali Linux. The Kali Linux Rolling gets new updates every single day.
As a user, you do not want to upgrade daily as it can mess up with your
setup.
Only update if you know that a security update is out or there is a bug fix in
the release. You should also make sure that you check the release notes
before reporting a new bug. It might get fixed already.
So, which instances you need to avoid when it comes to not upgrading?
Let’s list them below.
If you think that the new upgrade will cause more problems, then do
not upgrade
And, finally, do not upgrade if you think that it removes some of the
packages that you need. Simply review it using apt-listchanges
packages before making the decision.
You can remove a package using the dpkg command along with the --
remove or -r option. The syntax of the command is as below.
Once you use the command, it will remove the package from your system.
However, it is a soft removal, which means that associated files, including
maintainer script, log files, configuration files, and associated files. This
means that you should use the option only when you want to re-install the
program later on. The leftover residue files can then be used once the
package is installed back.
However, if you want to remove the packages, including the dependent
packages completely, then you need to use the APT command. The
command to completely purge the package from your system is as below.
The APT command also ensures that the user data and configuration files
are not removed.
If you want to remove the user data, but no configuration file, then you
need to use dpkg with the -p option. For apt, you need to use the apt purge
command.
The purge command should be used cautiously as it can remove the user
data, which cannot be retrieved in any condition.
To read the package files, you need to use the --listfiles or -L option with
dpkg. The syntax of the command is as below.
dkpg -L [package-name]
dkpg -s [package-name]
dkpg -s [package-name]
dpkg --list
dpkg -l
Both the commands work the same. You can also provide a wildcard as the
third parameter to search for a particular package if you want. This will
execute the search based on the wildcard or the string that you used for
searching. The command for it is as below.
dpkg -l ‘file*.’
Troubleshooting Packages
Running into problems is a part of working with Kali Linux. That’s why, in
this section, we will go through troubleshooting.
Bug Reports
As a user, you may want to report the bug. You can also follow the Kali bug
tracker to know if the bug is already reported or not. If it is not, then you
should go forward and report it. You should also read the section where we
discussed on bug reporting. Also, make sure that you do a proper bug report
with as much information as possible.
Downgrading
You can also downgrade if needed. Sometimes, it is required to downgrade
your Kali Linux or the package that you upgraded. You can downgrade if
you know the old package version. This way, you can use the APT
command to install that version. If you have the old .deb file, then also you
can downgrade the package. Kali Linux or Debian, in general, have the .deb
file stored in few places.
var/cache/apt/archives/
You can upgrade your packages using the apt upgrade command
In this chapter, we will explore how Kali Linux can help us with the
Security Assessment. First, let's familiarize ourselves with what security
means in terms of an information system. We covered the CIA triad in
earlier as well. For a refresh, let’s go through them again.
These three factors form the triad of cybersecurity, also known as the CIA.
These are the areas where you will focus your security concerns as a part of
the deployment, maintenance, and assessment. With this in mind, let’s move
on to discussing how to use Kali Linux in a Security Assessment.
For starters, during the security assessments, you will need to reinstall,
tweak, and change the system. All these changes will build on one another,
increasing the overall complexity of future configurations. Furthermore,
each assessment is unique in its own way, and using the same installation
can cause cross-contamination of client data.
However, you can use a pre-customized version of Kali Linux primed for
the network/system it is assessing. This can, in fact, help automate parts of
the process, which will lead to more convenient and less time consumption.
Here are some points to keep in mind while creating your custom
installation of Kali Linux:
Preplan all the tools and packages you will need during the
assessment beforehand. During the assessment, it is highly likely
that you won't have ready access to the internet. Therefore keep all
these packages with you from the get-go.
Keeping these few things in mind will help you during and after the security
assessment to ensure everything is handled smoothly.
What Is A Vulnerability?
It is basically a flaw in the network that a bad actor can use to compromise
the confidentiality, integrity, and availability of your system information.
What Is An Exploit?
It is a software, which if and when used, can take advantage of a specific
vulnerability in the system. In practice, an exploit requires changing a
running process and forcing it to make unintended actions.
Now, with the definitions out of the way, here is a look at the different types
of security assessments:
Vulnerability Assessment
In a vulnerability assessment, you are required to create a simple inventory
highlighting all the discovered vulnerabilities inside a target environment.
You will most likely use an automated tool to identify listening services,
server software, versioning, platform, and so on.
Once done, you will have to check each of them for any known signature of
the potential threat of vulnerabilities. These signatures include a wide range
of data point combinations which include but are not limited to:
Patch Level
Many times, even though a security patch is released, the admin hasn’t
installed on their system, making it more vulnerable.
Processor Architecture
Depending on what architecture the system is based on - Intel x86, Intel
x64, ARM, UltraSPARC, the network might be prone to different
vulnerabilities.
Software Version
Certain software versions have security vulnerabilities that can be used by
hackers to break into an otherwise secure system.
Your job will be to use these data points to create a signature as a part of
your vulnerability assessment. Now, as you can imagine, the more data
points you have, the more accurate the signature you will be able to create.
While conducting a compliance test, you might first have to start with a
vulnerability assessment as it will satisfy many of base the requirements of
most compliance frameworks.
Technically, it can get a bit more complicated. Not only will you have to
find the vulnerabilities, you must follow up its impact by using an exploit,
and then exploring the level of access the exploit provides to ultimately
understanding if it can lead to further attacks against the target environment.
You will have to critically review your target environment and have to
resort to manual searching, out of the box thinking, apart from using tools
and vulnerability scanners. This generally needs to be done a couple of
times to make sure that no stone is left unturned.
Application Assessment
While the previous assessments involved testing the entire targeted
environment, an application assessment requires you to focus all your
resources on a single application. With more organizations putting extra
focus on their mission-critical apps, this is slowly becoming an extremely
popular and important security assessment.
There is also room for a hybrid assessment between white box and black
box assessment, but as we said, it all depends on what goal you want to
achieve.
Scanning your network and server is very important. You might think that
everyone, especially the professionals working on the network, has an idea
about all the devices and ports connected to the system, but that isn’t always
the case. Furthermore, routine scanning helps identify unauthorized users
on the system, which helps in strengthening security.
So with that being said, let’s discuss on how you can scan your server and
network on Kali Linux to make sure everything is working as it should be.
Here we have put together a set of questions that you can use to give you a
direction in terms of where to look for vulnerability and potential breaches.
Are there certain areas in the network you are not properly familiar
with or rarely checked?
By focusing on these points, you will have a good sense of which areas to
prioritize and how to organize your system scans. The next bit would be to
follow a checklist to make sure you cover every point of entry the
hackers/bad-actors can use to infiltrate your system. This will include:
Routers
Switches
Firewalls
And so on.
These are the most common point of entry for hackers, and therefore you
should multiple tests to make sure they are secure and fortified. However,
with that being said, with more devices connected to your system, you have
more vulnerabilities, which means you will need to spend more time and
resources to check/scan them.
Here are somethings that you can search online to see what information is
publically available:
Press Releases that make public any major changes occurring within
your company, including news of Technology adoption, Company
Merger, and so on.
To begin the process, you will want to head on over to the Whois website
from where you can figure out the domain registrar of the website as well as
personal information about the website owner, including their names, email
addresses, and the likes.
Whois can also provide information about the DNS server related to a
particular domain along with information relating to their tech support. You
might want to take a look at the DNSstuf where you should find a lot of
information about your domain name including:
Information regarding how the host handles emails for the domain
name.
And so on.
Now, Whois is just one of the site which offers public access to all this
information. Therefore, it is a good idea to go ahead and check information
about yourself to understand what hackers are using to break into your
system.
Apart from Whois, you can also snoop around Google Forums and Groups,
where you are likely to find similarly useful information about your system
and network. In fact, you might be amazed at the extensive collection of
information on these pages, even though you haven’t submitted them
yourself.
Step 1:
First, as mentioned earlier, you need to browse around the internet to find
publicly available sensitive information about your hosting provider, IP
addresses, and so on. However, there is no reason to think all this
information is correct. You can do a scan yourself to verify the legitimacy
of this information.
If they are wrong, then there is nothing to worry as the hackers will be led
down a wild goose chase. But if they are correct, you can request the
website to remove it. But do note that removing Whois information about
your site can affect your business in terms of trustability and some SEO
metrics.
Step 2:
Now, it's time to scan your internal hosts and see what parts of your
network is visible to your users. There is a high likelihood that the hacker
might just come from within the network, either as a user of your services
or via a compromised employee account.
Once you know all the network areas which are exposed to your users, you
can exercise extra caution to make sure they are well protected. Also, make
sure that your employees adhere to strict protocol and don’t lose their
security credentials. Just as an extra measure of security, you can make it
compulsory to change their passwords every two months or so.
Step 3:
Next, you will want to check out the ping utility of the system. This can be
easily handled by using a third-party tool like SuperScan, which can even
help you get more than one address to ping at a time.
Step 4:
Finally, we would recommend doing an outside scan of your system, going
over all the ports that are open and vulnerable to cyber threats. SuperScan
can help you here, as well. Alternatively, you can also use a tool like
Wireshark. It goes without saying that once you detect a vulnerable port, it's
time to secure it to prevent any malicious attacks.
Now, following all these scans and basic precautionary steps, you will have
the upper hand over the hackers trying to break into your network. You will
know what information our IP address is sending out and therefore have an
idea regarding what information hackers might seem if they try to intercept
the signals.
As discussed earlier, the basic point of all these scans is to cultivate an
understanding of what information the hackers are going to use to base their
attacks. So the key takeaway of all these scans is to reinforce all these
vulnerabilities or ready a plan of action which you will initiate as soon as
there is a breach in your network using the weak links you discovered.
With time, your network and system will change, and the security concerns
will shift from one area to the other. Hackers are going to be always on the
lookout for these vulnerabilities, so you need to be on your toes to make
sure all angles are well protected and secured from malicious attacks.
Getting into the hacker mindset and understanding how they are
going to attack your network.
In our previous chapter, we talked about the specific approach and mindset
required to reinforce our network security. Now, here we are going to focus
on a more practical topic - the different tools that can help us improve our
network security.
We will cover a whole range of tools that can help us perform various
security tests and scans on our system to detect vulnerabilities and fix them
before they are exploited by hackers.
Now the best thing about Kali Linux that it includes tons of powerful
security-hacking tools which can help you with information gathering,
password cracking, hardware hacking, reverse engineering, wireless attacks,
vulnerability analysis, exploitation testing, stress testing, sniffing &
spoofing, and so on.
In fact, if you do a little searching online, you will find there are literally
hundreds of Kali Linux tools advertised to help you with your network
security. It can get really confusing when choosing which tools to use on
your system to detect vulnerabilities and weak points.
This is why we have put together a list going over some of the best Kali
Linux Tools in different categories to help you out. We have also made sure
to include alternatives to a particular category of tools, so you are not
completely stripped out of options.
However, it can help you locate likely targets both inside and outside a
specific network, which is one of the reasons why it is mostly used in
corporate environments. At its core, it is essentially a PERL script that can
quickly scan domains in a couple of minutes, using sophisticated algorithms
and clever tactics.
The tool can also collect and showcase information about the software and
applications running on each of these remote hosts. Other notable features
include the option to use custom data sets along with support for SQL
relational output.
Now coming to the feature side of things, the tool offers useful features like
Packet Live Capture, Offline Analysis, Full Protocol Inspection, Gzip
Compression and Decompression, VoIP analysis, and much more. You can
also use the tool to help you decrypt WPA/WPA2, SSL/TLS, IPsec, and the
likes.
Some of the notable tools available with Aircrack-ng can help you capture
packets of data and export them to text files to get processed by third-party
tools. Besides this, you also get access to attacking tools that can help you
replay attacks, create fake access points, perform packet injects, and help
with deauthentication.
Some of the main noteworthy features of the tool include a dedicated Web
User Interface, a modular structure in terms of functionality, Metasploit
Integration, powerful history and gathering intelligence, interprocess
communication and exploitation, and much more. Also, being a browser
exploitation framework, the tool can also help you detect any installed
plugins on the browser.
Yersinia - L2 Attacks
Yersinia is a security framework dedicated for layer 2 Attacks on different
networks. It can scan out flaws and vulnerabilities in the security protocols
used by the networks to find points of attack. The tool works with a wide
range of network protocols, including CDP, DHCP, DTP, ISL, HSRP, STP,
and VTP.
You will get access to a sleek GTK Graphical User Interface from where
you get to control all the features. Some of its notable functionalities
include a dedicated ncurses mode, option to read custom configuration files,
a debugging mode, support for log files to save all results & data, and much
more.
Once you execute the script, it will first grab your Neighbours’ IPs and
listen for DHCP requests from any connected clients. If it detects an offer,
the tool will respond with a request for that offer. It can also loop and send
DHCP requests from all different hosts and MAC addresses, detect
neighbor MAC & IP address and release them from the DHCP server, and
much more.
The tool is known for its super-fast password cracking speeds, the
capability to run on multiple operating systems, option to launch multiple
brute force attacks parallelly, and much more. Also, being a module-based
application, it comes with the option to add custom modules to extend its
functionality.
Metasploit Framework - Penetration Testing Suite
The Metasploit Framework can help you create, test, and execute exploits
against remote hosts. It gives you access to a whole suite of penetration
testing tools paired with a powerful terminal-based console – msfconsole -
to help you locate targets, start scans, exploit any vulnerabilities, and collect
any and all available data.
It is, in fact, one of the most powerful security auditing tools in the market,
and being available for free, it is something you should have up your belt.
Notable features of the tool include support for network enumeration and
discovery, ability to evade detection on remote hosts, development and
execution of exploits, and much more.
In terms of functionality, the tool can help you will functional testing and
regression testing of your web projects. It can also monitor your server
performance after loading the application to help find any bottlenecks.
Other notable features include load testing to help find bugs, stress testing
to gauge application recoverability, and so on.
All the false positives generated using the tools used very poor pattern
matching rules. As such, if the system detects little to no false positives,
then it means it is based on a well-written set of rules. Whereas, if it
becomes victim to the hundreds of false positives, then you should consider
adopting heuristic-based detection or anomaly-based detection mechanisms
on your networks.
You will get access to tools that can help you with WiFi-based attacks that
can redirect or intercept packets from users on the same WiFi network as
yours. On top of that, you will get to create SMS, Email, and web-based
spoofing and phishing attacks. The tool can even let you create malicious
.exe files that will compromise users’ systems after they run it.
OpenVAS - Vulnerability Scanning Tool
OpenVAS is free software that can help you detect vulnerabilities in any
local or remote networks. It can also help you write, create, and integrate
your custom security plugin straight on the OpenVAS platform. On top of
that, the platform will give you access to over fifty-thousand NVTs
(Network Vulnerability Tests), which can scan almost any security
vulnerability in your system.
Now, taking a look at some of the notable features of the software, you get
the option to perform simultaneous host discovery, network mapping and
port scanning, access to OpenVAS transfer protocol, full integration with
SQL databases and SQLite, automatic scheduled scans, and much more.
You can use it to scan several ports on the server at the same time. On top
of that, it comes with IDS evasion techniques, the option to output results in
various formats, username enumeration for both Apache and cgiwrap, and
much more. The tool can even help you scan CGI directories, use
configuration files customized to your requirements, debug output, and help
identify software through headers, favicons, and files.
The tool can also help you scan weak passwords used by all registered
users, and stimulate brute force attacks to see if the passwords can be easily
cracked or not. Other notable features include the option to perform non-
intrusive security scans, WP username enumerations, and Scheduled
WordPress Security Scans.
The tool can help you find security flaws on all the CMSs mentioned above
by running brute force attacks, scanning for vulnerabilities, and launching
exploits to break into any found vulnerabilities. The tool can also help you
set custom user-agent and header, comes with support for SSL, a dedicated
verbose mode for debugging purpose, and so on.
Kali Linux is the number one penetration testing tool. If you have an
interest in security or hacking in general, then Kali Linux is something you
should learn. I hope that you found the book useful. The book is also
suitable for those who are into the Linux ecosystem and wants to learn
about different distribution.
The book tried to teach you how to use Kali Linux to your advantage. We
also covered other important topics such as cybersecurity, hacking process,
and Debian package management. Our focus soon shifted more towards the
intricacies of Kali Linux, where we learned about how to configure Kali
Linux. We also learned Debian Package Management.
You can also think of Kali Linux as a tool. Without the necessary problem-
solving skills and aptitude, you will not be able to prosper the use of it. So,
why I am stressing it? It is because, after you read the book, I want you to
experiment with Kali Linux as much as possible. This will open up new
possibilities and improve your understanding of a whole new level.
If you are interested more on Kali Linux, then I recommend reading more
about the tools that we discussed on the Kali Linux Tools chapter. I also
recommend contributing to the community to make the Kali Linux
community more awesome! Kali Linux is mostly community-driven, and
any contributions can make it more secure and useful.
I congratulate you on completing the book and wish you the best of luck in
your future endeavors.
KALI
LINUX
Ethan Thorpe
Introduction
When we talk about Kali Linux, we quickly think of the phrase “security
auditing and penetration testing.” But to use Kali Linux for this purpose, we
need to understand that multiple tasks are carried out to reach the goal of
these two activities. Kali Linux is considered to be a complete framework
as it a complete set of tools that cover multiple use cases. This being said,
you can always use a combination of these tools while you are working on
penetration testing as well.
For example, you can install and use Kali Linux on multiple systems such
as a personal laptop of a penetration tester, as well as public servers where
server admins want to monitor a network, and even on workstations used by
forensic analysts of a company. You will be surprised that in addition to
this, Kali Linux can also be installed on small embedded devices that have
ARM architecture CPUs. An example of this would be a raspberry pi device
that can be used as a powerful tool combining it with Kali Linux and
dropping it in a wireless network or simply plugin into a target computer.
ARM devices like the raspberry pi can access servers as time bombs, given
their small size and low consumption of power. Moreover, you can also
deploy Kali Linux on cloud architecture, ultimately creating a farm of
machines that can be used to crack passwords rigorously.
But that is not the end of it. Penetration testers need Kali to be installed on a
server so that they can work based on collaboration by setting up a web
server for the set of tools to scan vulnerabilities, phishing campaigns, and
other such activities. Most hackers have Kali Linux installed on their
systems since this operating system will suit their hacking needs.
When you boot up Kali Linux for the first time, you will instantly realize
that the Kali Linux desktop theme is designed in a way to serve the needs of
penetration testers and other information security professionals. You will
have gathered information about this operating system in the first book.
This book will shed some light on what penetration is, and the different
features in this operating system that will make it easier for you to hack into
a system.
The following tasks and activities of Kali Linux are included under this.
Web Application Analysis: In this task, you will identify the flaws
and loopholes present in web applications. This information helps
you fix the flaws beforehand as web applications are publicly
available over the internet and can be exploited to breach into the
main system. This is the purpose of any hacking. A malicious
hacker or cracker will use this method to hack into the system to
extract sensitive information or data.
System Services: This suite of Kali Linux has tools that can help you alter
the status of all system services that run in the background.
Chapter 1
Firewalls in Kali Linux
In book one of this series, we read about the Kali Linux firewall in brief.
Given that we will be deep diving into making your Kali Linux system a
tool for penetration testing, we will cover the basic information and
commands that will make the Kali Linux system secure. This will ensure
that it is not open to attacks from the outside. This will be achieved using
the firewall in Kali Linux.
You can choose whichever method you are comfortable with to configure
The Kali Linux firewall. Let us take a closer look at how this firewall
works.
Behavior of Netfilter
There are four types of tables in Netfilter. These tables store three types of
operations on network packets.
Filter: This table contains rules for filtering packets. The rules
define whether a packet will be accepted, refused, or simply
ignored.
NAT: NAT stands for Network Address Translation. This table is
responsible for translating the address of the source and destination
and packet ports.
Mangle: All other changes to IP packets are stored in this table.
This includes fields like the TOS - Type of Service and other fields.
Raw: This table allows you to make any manual modification to
network packets before they hit the system.
There is a list of rules inside each of the above tables called chains. The
firewall will make use of these chains to manage packets. A Linux
administrator can create new custom chains other than the standard chains,
but these will still only be used when a standard chain redirects a packet to
the custom chain.
OUTPUT: This chain modifies the packets that the firewall itself
generates.
The figure below illustrates how Netfilter chains are employed.
Each chain defines a list of rules. These rules consist of a set of conditions
and actions that the system should perform when all conditions are
satisfied. When a packet is coming into the system or leaving the system,
the firewall puts it through every chain, rule by rule. When the packet meets
the condition defined by any rule, it will then act as defined by that rule and
process the packet. The chaining process will be interrupted now since the
firewall has already decided what needs to be done with the packet.
REJECT: This action will reject the packet and throw an error
known as the Internet Control Message Protocol (ICMP) packet
error.
--log-prefix: Using this parameter, a specific text prefix can be added to the
logs messages, which will help you differentiate it from other system logs.
chain_name: This action will jump the packet to the defined chain
and evaluate it through its rules.
SNAT: This action is available only in the nat table. This action
applies Source Network Address Translation(SNAT) to the packet.
There are options in place to define the exact actions that are to be
applied to the packet. Some of these options are --to-source
address: port, which will define the new source IP address and port
for the packet.
DNAT: This action is also available only in the nat table. This action
applies Destination Network Address Translation(SNAT) to the
packet. There are options in place to define the exact set that are to
be applied to the packet. Some of these options are --to-destination
address: port, which will define the new destination IP address and
port for the packet.
Understanding ICMP
Internet Control Message Protocol, known as ICMP, in short, is a network
protocol used to send ancillary information in communications.
The ping command under ICMP is used to test network connectivity. The
ping command sends an echo request message using ICMP, in which the
recipient is supposed to reply with the echo reply message. ICMP lets us
know if a firewall rejects a packet or if there is an overflow in a receive
buffer. It also proposes better routing for the subsequent packets in the
traffic. The RFC documents like RFC777 and RFC792 first defined the
ICMP protocol but have been revised over the years. You can find them in
Sources section of this book.
A receive buffer is a small part of memory that stores a packet for a brief
time when the packet arrives into the system till the time it is handled by the
kernel. There are times when this buffer will be full, and there is no space
for new packets to arrive. In such an event, the ICMP flags the issue and
tells the emitter to slow down the transfer rate. It can instruct the system to
stabilize the transfer rate in some time.
Another point worth noting is that ICMP is not mandatory for an IPv4
network to function but is necessary for an IPv6 network. IPv6 is defined in
the RFC4443 documentation and can be found in the resource section of
this book..
iptables and ip6tables syntax
We learned about tables, chains, and rules of the Netfilter firewall in Kali
Linux. The commands used to manipulate these entities in Kali Linux
are iptables and ip6tables. The commands are passed with the option -t to
indicate which table the commands should execute on. If no option is
specified, the commands operate on the filter table by default.
Commands
Let us go through the major options which are used with iptables
and ip6tables commands to interact with the various chains.
-L chain: This option is used to list all the rules that are part of a
particular chain. This is additionally used with the -n option to
enable listing rules concerning a particular chain.
For example, the command iptables -n -L INPUT will list down all the
rules concerning incoming packets.
-A chain rule: This option is used to add a rule at the end of the
chain that is passed. It is important to take care while adding new
rules as rules are always processed from top to bottom.
-I chain rule_num rule: This option adds a new rule before the rule
number mentioned. Just like with option -A, it is important to take
care while adding new rules with this option.
-F chain: This option is used for flushing a chain and deleting all its
rules. For example, if you want to delete all the rules for incoming
packets, you can use the command iptables -F INPUT. If you do
not specify any particular chain, all the rules in the entire table will
be flushed and deleted.
-P chain action: This option defines the default policy for the chain.
This default policy can be applied only to standard chains. If you
want to drop all incoming packets by default for a chain, you can
define the standard policy using the command iptables -P INPUT
DROP.
Rules
The syntax for rules is represented as conditions -j action
action_options. If there is more than one condition in the rule, they can be
added using the logical AND operator.
Note: You can prefix a condition with the exclamation mark, and it will
negate the condition. For example, if you use an exclamation mark with the
-P option, it will indicate that the rule should execute on all the other
protocols except for the one specified in the rule. You can use negation with
all other conditions as well.
You can use the condition -s address or -s network/mask to match a packet
with its source address. Similarly, you can use the condition -d address or -
d network/mask to match a packet with its destination address.
The --state condition is used to match the state of a packet. This will work
provided the ipt_conntrack kernel module is installed.
For example, if there is malicious traffic coming from the IP 11.2.1.6 and
the 30.12.75.0/24 class C subnet, you can use the following commands.
# iptables -n -L INPUT
Chain INPUT (policy ACCEPT)
Chain INPUT
(policy ACCEPT)
# iptables -D INPUT 2
# iptables -D INPUT 1
There are more specific conditions that you can define as per your
requirement in addition to the general conditions that we have discussed
above.
Creating Rules
To create a new rule, you will need to invoke either iptables or ip6tables. It
can be very frustrating to keep manually typing these commands.
Therefore, it is better to store the calls you need in a script and ensuring that
the Script is called every time the system is rebooted. You can write the
entire Script manually, but you could also use a high-level tool
like fwbuilder to create a script as per your needs.
It is very easy to create a script using the fwbuilder tool. It follows a simple
principle. Firstly, you need to lay down all the elements that you want to
make a part of the actual rules. The elements will be as follows.
The servers.
The next step is to create the rules using the drag and drop feature available
in fwbuilder’s main window, as shown in the image below. You can use
negation in the conditions as well. You then need to choose the required
option and configure it.
With respect to IPv6, you have the option to create a separate set for IPv6
and IPv4, or you can just create one set of rules and let fwbuilder translate it
based on the IP stack that connects.
Once you have selected the rule you required, fwbuilder will automatically
create a Kali Linux shell script for it. The architecture for fwbuilder is very
modular and flexible, making it a good graphical interface to generate
scripts for iptables in Linux, pf in OpenBSD, and ipf in FreeBSD.
auto eth0
address 192.168.0.1
network 192.168.0.0
netmask 255.255.255.0
broadcast 192.168.0.255
up /usr/local/etc/newscript.fw
In the above example, we assume that we are configuring the network using
the ifupdown utility. You can also use alternative tools
like NetworkManager or systemd-networkd. You can refer to their man
pages to see how you can define a script through them to run at system
boot-up.
Chapter 2
The Lifecycle of a Penetration Test
Introduction
It is a common misconception amongst people who are not technologically
savvy that a hacker or an attacker can just sit with his laptop, write a few
lines of code on his laptop, and gain access to any computer or internet-
powered device in the world. People have started believing this because that
is how it is conveyed to them through movies, but it is very far from what
happens. Attackers and Information Security professionals need to be very
careful and precise while trying to exploit or uncover the vulnerabilities
present in different systems. The framework for penetration testing has
evolved, and there is a solid framework present today that are adopted by
attackers and information security professionals. The first four stages of this
framework guide an attacker to exploit computer systems in a manner that
results in reports that can be used later again when they need to exploit
another system. There is a proper structure defined by this framework,
which helps information security professionals develop a well-defined plan
to execute penetration testing activities. Each stage is built from the
previous stage of the framework providing inputs to the next stage. This is a
process that is run in a defined sequence, but it is natural for testers to refer
to the previous stages to gain more information or clarity about their
findings.
Patrick Engebretson defines the first four stages of penetration testing in his
book “The Basics of Hacking and Penetration Testing.” These steps are as
follows.
1. Reconnaissance
2. Scanning
3. Exploitation
4. Maintaining Access
In this book, we will go through these four stages, and an additional stage
called Reporting.
Also, if you have gone through the five stages defined in the Certified
Ethical Hacking Course by EX Council, you will notice that the last stage
known as “Covering Tracks” is missing from this book. This has been done
intentionally to put more focus on the first four stages and to include the
Reporting stage in this book. If you read other books on Penetration
Testing, you will realize that they do not include the Reporting stage, which
we believe to be important. You will also find this book to be different from
other books. We have removed the cyclic version of the penetration testing
life cycle and made it a linear process. This is what an ethical hacker would
encounter in the process of penetration testing. This would begin with an
ethical hacker beginning with the reconnaissance stage where they would
begin by observing the target system, and the process would conclude with
a presentation of the findings to the management team in the form of reports
that were generated. The linear process has been shown in the image above.
We will briefly go through each stage in this chapter and then deep dive into
each stage through dedicated chapters. We will also discuss the common
tools that are used for each stage when we go through the dedicated
chapters. This will help you to have an understanding of each stage of
penetration testing, along with getting hands-on knowledge of the common
tools that are used.
Reconnaissance
Let us try to understand this stage of penetration testing with the help of an
analogy. Consider a military operation with a room occupied by military
professionals. In a dimly lit room, officers and analysts are looking at the
maps of the target region. A few other people in the room are constantly
looking at activity happening in the target region with the help of television
and monitors, and are making their notes. There is one final group in this
room that consolidates the data and writes a report on that data. This is
exactly what penetration testers do during the reconnaissance stage of the
penetration testing life cycle.
The activities mentioned above are synonymous with what ethical hackers
do during the first stage of the penetration testing life cycle. During this
stage, penetration testers focus on anything and everything that would
provide insights into the organization and network that is the target of the
attack. Ethical hackers usually launch passive scans on the target network
and crawl through the information available on the internet about the target.
During this stage, a penetration tester would not launch an attack on the
target network but will assess the target network to find out as much
information as possible and document it all.
Scanning
We will continue with the military analogy to understand the scanning
stage. Imagine a hilltop, where one of your soldiers is camouflaged and
hitting among the trees and bushes. The responsibility of this soldier is to
send back a report which will give details about the camps he can see, what
he believes is the objective of that camp, and what activity is happening in
each building present in that camp. The report will also include information
about the roads that go in and out of the camp. It will also talk about the
security measures in place for the camp.
The soldier in the above analogy was given reports that were generated
from the first stage of penetration testing to go closer to the target system
without getting detected and scan it for more information. The penetration
tester will further make use of scanning tools to actually get confirmed
information about the network infrastructure of the target system. The
information collected in this stage will then be used in the exploitation stage
of the penetration testing life cycle.
Exploitation
There are three soldiers deployed onto the field with all the information
collected in the previous two stages. The moon is covered with clouds, but
the soldiers can still see everything. They enter the target camp by using a
gap in its fence and then entering through an unsupervised open door. They
spend only a few minutes inside the camp and gather information which
tells them about the plans of the camp in the months to come.
This is what penetration testers do during the exploitation stage. The task at
this stage is to enter the system, gain the required information, and leave the
system without being noticed. This is achieved by exploiting vulnerabilities
in the system.
Maintaining Access
The team of soldiers that raided the camp has now retrieved drawings that
details about the camp with respect to the demographics, the checkpoints,
unsupervised open doors, manned sections, etc. Using this information, a
set of skilled engineers chart out a plan to dig the earth and reach the
required room in the camp from below. The purpose of this tunnel is to
reach the required room easily and continue maintaining access to it.
This is similar to what a penetration tester does in maintaining the access
stage. Once the target system has been exploited, and access has been
gained, and there are rootkits left on the target system so that it can be
accessed without issues in the future as well.
Reporting
The commander of the raid team will present the report to generals and
admirals explaining what happened through every stage of the raid. The
report contains detailed information explaining what helped with the
exploitation.
In this stage, the penetration tester also creates reports that will explain the
process, vulnerabilities, and systems that were attacked. In some
organizations, one or more members of the penetration testing team will
have to present the report to the senior management.
Chapter 3
Reconnaissance
In this chapter, we will dive deep into the reconnaissance stage of the
penetration testing life cycle. This process will guide a penetration tester to
discover information about the target system or organization. The
information gathered will be used in the later stages of the penetration
testing life cycle.
Introduction
A military unit will try to analyze a target camp by using readily available
information before actual plans to attack are developed. Similarly, a
penetration tester needs to analyze the target system buy reading through
readily available information, which can be used later to perform
penetration. Most of the time, information about a target can be found by
doing a google search and checking if the target system has any information
about it on social media. Some more information could be found about the
nameservers of a target system on the internet, which would lead you to the
browser of the user as well. There are Email messages which can be
tracked, and you may also reply to an address available on the genuine
Email to gain more information. Once you know how the website of a target
system looks like, you may download its code to develop an offline copy of
it which will help understand the target system more. It may also serve as a
tool for social engineering tasks later.
The reconnaissance stage is the first stage, and the penetration testing team
has negligible knowledge about the target system. The range of information
provided to the team during this stage can vary from minimal information
such as the name and the website URL of the target organization to specific
information of the system with its IP address and the technologies used by
the target system. The management team may have certain restrictions on
the types of tests being done, such as social engineering and attacks, which
may cause a Denial of Service DoS or Distributed Denial of Service DDoS.
The main goal of this stage is to find out as much information about the
target organization as possible.
Trusted Agents
A trusted agent is the representative in the organization that employed the
penetration testing team or any other individual who is in charge of the
penetration testing operation and can answer questions daily of what is
happening. He or she is expected not to divulge the information about the
penetration testing activity to the whole organization.
Almost all organizations maintain a page for career and job opportunities.
This page can give you an insight into what technology is being used by the
organization. For example, if there is a job opening for a system
administrator with knowledge of Windows Server 2012 and Active
Directory, it is evidence enough that the organization uses Windows Server
2012. If the job opening is saying that there is knowledge of Windows
Server 2000 or 2003 required, it should alert the penetration tester that the
organization is still using older technologies that are easier to break into.
You should check if every website has a link to access the webmail of the
organization as the default URL is always webmail.organizationname.com
or mail.organizationname.com. If resolving this link takes you to the Gmail
access page, you will know that the organization uses Gmail as its backend
for mails. If you see an Office365 page, you will know that the backend
being used is through Office365. This also means that mail servers will be
out of bounds for penetration testing as they belong to the technology
giants, and you can get in trouble if you try playing with them. Therefore,
certain boundaries need to be defined with respect to penetration tests as
well. If there are chances of a boundary is crossed, it should always be
consulted with the trusted agent.
Mirroring Websites
There are times when it will be just more helpful to download as much of
the target’s website and regenerate missing parts of it for offline evaluation.
This will help for automated tools to scan through the website code for
keywords, or even if you want to make changes to the website code to test a
few things. Also, it is always good to have one copy of the website offline
while you are working in the reconnaissance stage. You can use tools like
wget on the Kali Linux command line, which can copy all the static HTML
files from a website and store it locally. The wget tool is available by
default in Kali Linux and is easy to use. You can use the command shown
below to copy all the HTML files from a website and store it on your local
machine. However, do note that the wget command only gets static HTML
files, and pages created using PHP code for server-side scripting will not be
downloaded.
In this example, many options are used by the wget command. You can use
the man pages for wget in Kali Linux to understand the use of each of the
options passed with the wget command. You can use the man wget
command to get the man pages for wget.
You can go through the content available in the man pages using the up and
down arrow keys or the page up and page down keys. You can get help by
using the h key, and you can quit the man pages using the q key. If you go
through the man pages for wget, you will see something like below.
-m: stands for the mirror, and is used for turning on the
requirements for mirroring a website.
-E: This option adjusts the extension and will ensure that the
downloaded files are stored locally in the HTML format.
-k: this option is used for link conversion and ensures that all
downloaded files get converted such that they can be viewed
locally.
-K: this option is used to convert the backup, and it backs up the
original files with the .orig suffix.
Once the wget tool is downloaded, and all the files are on the system, it
stores them in a folder with the name of the website. While the tool is
working on the download, you may see errors on the output if the tool
comes across pages coded with PHP. This is because the code used to create
the website is running on the backend. This means that it is not easily
accessible to any cloning too.
After you have downloaded the file, you need to ensure that other people
cannot view it, or the code is not deployed online again as it would end up
violating copyright laws.
Google Search
There are advanced search options available in Google that can be used
during the reconnaissance stage. If you have never used the advanced
search, you can locate it on the following URL.
http://www.google.com/advanced_search
Language
You can specify a language in this field to ensure that the result of the
Google search contains pages that match the language.
Region
You can specify a region from the dropdown, and the search results will
contain web pages that were published in that particular region. If you have
not combined this with the language selection dropdown, the search results
will show all pages from that region irrespective of the language used in the
region. You can conduct a more focused search by specifying the language
and the region together.
Last Updated
You can specify a time limit in the dropdown of this search parameter to
display search results of web pages, which were last modified within the
specified time frame. For example, if an organization merged with another
organization recently or added a new technology stack recently, you can
specify the time frame of that event to get the required results.
Site or Domain
This can be one of the most helpful search parameters to narrow down a
search. For example, if you want to restrict your search to only government
organizations, you can specify the domain to be a.GOV domain. Or, if you
want to search for a particular company, you could specify the company’s
website to restrict your search to only that company.
Terms Appearing
You can use this field to target your search to a particular part of the web
page. If you select “anywhere on the page,” the search will go through the
complete page of a website on the internet.
If you use the option as “in the title of the page,” the search will be targeted
only to the title section of all the web pages. The title of a web page is what
appears in the tab of your browser when you open a website. If you use the
parameter as “in the text of the page,” the search will only query all the text
content of a website and will leave out elements such as the title,
documents, images, etc. However, if these elements are written as text on
the page, they will still be returned in the search results. For example, if
there is an image that is referenced in the text of the web page, it will be
returned in the results. This condition holds for links and image markups
within the text as well.
If you use the parameter “in URL of the page,” the search results will be
restricted to the uniform resource locator of the website. The URL is the
website’s address, which shows in the address bar of the browser.
Using the parameter “in links to the page” will show web pages that have
links that have a reference to the website you have mentioned.
Safe Search
There are two parameters available in the Safe Search option. “Filter
explicit” and “show most relevant results.” If you use the explicit filter
option, the search result will leave out pages that contain sexually explicit
content such as images and videos. If you use the show most relevant
results option, the search will not filter out any sexually explicit content.
Reading Level
This option filters out the search results based on how complex the text in
the web pages is. If you use the “no reading level” option, the search will be
executed with no reading level filter. If you use the option “annotate results
with reading level,” the results will include all results along with the
indications of the reading level of each page.
File Type
This parameter again is one of the most important and useful tools that can
be used by a penetration tester. You can specify and narrow down the search
results to a website that contains the file types specified by you. For
example, you can specify file types such as Adobe PDF or Microsoft
DOCX and XLS, etc. You can use various file types to search for various
web pages. For example, usernames and passwords are usually stored in a
database, and the file type could be SQL. The drop-down for this parameter
offers a list of the most commonly used file extensions used today.
Usage Rights
This parameter narrows down the search results based on the publisher’s
declaration of whether the content can be reused or if it has any copyright
issues. If you select the option as “free to use, share, or modify,” the search
results will return pages that are allowed to be reused with a few restrictions
that define how the content can be reused. The common restrictions include
declarations such as the content modification will have a nominal fee. If
you select the option as “commercial,” the results will return websites that
have a license for you to reuse their content.
Region: Japan
Language: Japanese
Google Hacking
A computer security expert named Johnny Long pioneered a technique
known as Google Hacking. It is a technique that makes use of specific
Google operators and can be employed to tweak the search results to get
relevant results. This technique makes use of particular expressions to fetch
results about people and organizations from the Google database. The
technique makes use of the operators we discussed earlier in advanced
Google search and further amplifies the results. It makes use of linked
options and advances operators to create complex Google search queries to
be fired at the Google search engine.
Passing this in the google search returned results of more than a million
websites containing Cisco passwords. While there were files that did not
contain any passwords, there were a lot of them which did contain the Cisco
passwords as well. A penetration tester can further refine this search string
to include the website or a domain operator as follows.
Social Media
Social media is a daily routine and a part of everyone’s life these days.
Given this, it can be considered a box full of treasures for someone who is
working on penetration testing. People may try to protect information about
themselves in person but will neglect it and post it on social media such as
Instagram, Twitter, Facebook, LinkedIn, etc. This information is very useful
for social engineering. One can get a structure of an organization’s
hierarchy by taking advantage of LinkedIn. LinkedIn will help you connect
the dots on the profile of a target, and help gather organizational charts and
even email addresses. However, there might be an additional level of social
engineering required to get the email addresses, as they are not displayed
publicly on LinkedIn. Finally, organizations tend to post job opportunities
on LinkedIn as well. These listings contain the requirements for a job
profile, which can let you know the technologies used by the organization.
A Doppelganger Creation
A doppelganger is defined as an individual who looks like another
individual. It is a common practice to create a personality or profile before
starting reconnaissance in the world of social media. You do not want to
start with research on a target using the profile of a penetration tester or a
security expert. A penetration tester can create a personality or profile on
social media, which could have been an ex-colleague or a college friend of
the target at some point in time. However, this may not be allowed to be
executed by your company as it can be claimed to be theft of identity as
well. It could get you into trouble if you go deep into creating the
personality, but again two people can have the same name as well. For
example, you can create a fictitious personality names John Doe who went
to Brown University, and it would not mean that you stole the identity of an
actual Jon Doe who went to Brown University. In any case, you need to
ensure that the personality does not run too deep into the personality of
someone real, as it could then be treated as identity theft or fraud. This
usually means that you are not supposed to fill in any legal forms using the
name of the personality that you have created.
Job Sites
As a penetration tester, you can also resort to research on job portals such as
Dice, Career Builder, Monster, etc. as that can lead to useful findings too.
These websites can also help you understand the technologies used at the
target organization. If you search these pages for the target organization, it
can reveal the current openings at that organization, which can help a
penetration tester to understand the target better. Many companies have
started figuring out this flaw and, therefore, list openings as confidential so
that third parties cannot easily get access to these listings.
DNS Attacks
The Domain Name System, known as DNS, in short, is the telephone
directory of the internet. It is easier for humans to remember names as
compared to IP addresses. For example, you would remember the URL
google.com over an IP like 165.1.13.56, which could be the IP address for
google.com. On the other hand, computers can remember numbers better,
and therefore DNS helps convert these names to IP addresses while looking
for a resource over the internet. The internet uses a hierarchical structure
that makes use of numbered octets for efficiency for the internet. This
creates an inconsistency between what humans can remember and what
computers can remember. This problem is solved by name servers, which
act as translators between computers and humans. The topmost hierarchy of
a nameserver has a top-level domain such as .com, .net, and other top-level
domains. On the other end of this hierarchy, there are servers with IP
addresses, which, thanks to the nameservers, can be accessed using domain
names. You can understand how nameservers work if you understand how a
computer interacts with a web browser. The querying begins from the local
nameserver and goes all the way up to the root name servers. Every name
server has information about the nameserver below it or above it.
#nslookup
Server: 172.27.152.39
Address: 172.27.152.39#53
Non-authoritative answer:
Name: google.com
Address: 172.217.166.174
In the above example, the first part gives a result of the authoritative name
servers, and the second part gives a result of the non-authoritative name
servers. You can get information from the non-authoritative zone easily
since it is served directly from the server’s cache.
You can exit from nslookup using the exit command.
The nslookup command can also make use of the name servers set up for
the local system. You can use the following commands to see the name
server being used for a given nslookup.
#nslookup
>server
You can make the nslookup command give other results as well. For
example, you can use the following commands to find all the mail servers
used by a domain.
#nslookup
Server: 172.27.152.39
Address: 172.27.152.39#53
Non-authoritative answer:
As you can see from the above example, the result returns a list of mail
servers used by google.com.
#cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 172.27.152.39
nameserver 172.27.1.21
You can change the default name servers to use the name servers of the
target system. You can use the following command to find out the target
system’s nameserver.
# nslookup
> google.com
Server: 172.27.152.39
Address: 172.27.152.39#53
Non-authoritative answer:
The above output gives a result of the default name servers used by
google.com. Once you have found out the name servers of a target system,
you can change the name servers used by the nslookup command to those
of the target system. You can use the following command. We will be using
one of google.com’s name servers.
#nslookup
Address: 216.239.34.10#53
Various types of records can be discovered using the nslookup tool in Kali
Linux. The following table will give you an idea of all the DNS records
used on the internet.
The Domain Internet Gopher tool known as dig, in short, can help to
process zone transfers. You can use the following command to perform a
zone transfer.
#dig @[name server] [domain] axfr
Let us look at an example.
#dig @ns2.google.com google.com
; <<>> DiG 9.9.4-RedHat-9.9.4-73.el7_6 <<>> @ns2.google.com
google.com
; (2 servers found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 26226
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0,
ADDITIONAL: 1
;; WARNING: recursion requested but not available
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;google.com. IN A
; ANSWER SECTION:
google.com. 300 IN A 172.217.166.110
;; Query time: 41 msec
;; SERVER: 216.239.34.10#53(216.239.34.10)
;; WHEN: Tue Jan 21 21:52:36 IST 2020
;; MSG SIZE rcvd: 55
As you can see, this command has zone a zone transfer, and now the A
record of google.com is set to the IP 172.217.166.110.
There is a chance for most of the zone transfers failing. However, if the
target system’s name servers are misconfigured or are open to public access,
the zone will be transferred to your local Kali Linux system. You have to
ensure that you do not use www with the domain name while specifying the
domain in this command — the axfr option requests for a zone transfer to
happen. If the zone transfer goes through successfully, you will find
information on the target system. This information can help a lot in the
future states of penetration testing.
Chapter 4
Scanning
In this chapter, we will learn about the scanning stage of the penetration
testing life cycle. We will learn about certain networking protocols such as
TCP, UDP, and ICMP. We will also learn about Kali Linux network tools
such as Nmap, Hping3 and Nessus.
Introduction
After completing the reconnaissance stage of the penetration testing life
cycle, a tester will proceed to the scanning stage. All the information
collected on the employees, organizations, information systems, etc. during
the reconnaissance stage can now be used to understand the physical and
logical structures of a target organization. Although the penetration tester
has begun with the scanning stage, they are still free to go back to the
reconnaissance stage if they feel they need some more information.
Network Traffic
Some people find network traffic to be complicated, but we will explain it
in this section as it is a prerequisite for the scanning stage. The
communication that happens between various computers through a network
is known as network traffic. Two types of networking exist today - wired
networks and wireless networks. It is very important to understand the
fundamentals of Ethernet with respect to networking. In this chapter, we
will go through
IP Protocols
Protocols are a set of rules defined for both the real world and for computer
networks. There are staff members that are assigned to politicians,
diplomats, and bureaucrats who manage issues related to the protocol for
them. These members ensure that visitors or messages that need to reach
politicians, diplomats, and bureaucrats always reach by following protocol,
that is by following the correct manner. Protocols in the computer world
help communication to happen between network devices by following a set
of rules. There are multiple protocols available for computer networks
today, but we will go through the most important and common networking
protocols in this chapter. This will help us leverage Kali Linux tools which
are used in scanning and discovering vulnerabilities during the penetration
testing life cycle. These three protocols are TCP, UDP and ICMP.
TCP
TCP is one of the most common and important protocols used in network
communication. The TCP protocol is connection-based. This means that
whenever there is a connection between two devices using TCP, the devices
on both sides of the network will acknowledge the opening of a session
followed by messages being sent and received on both the devices. This can
be explained using a phone call.
Alice: “Hello”
This is an analogy from way back in the past but it explains a three-way
handshake that occurs when a connection takes place via TCP. In
communication via TCP, there is a three-packet exchange initiated when
communication is being established between two network devices. The first
packet that is sent is called the synchronization packed commonly known as
SYN. When the device at the receiving end receives this SYN packet, it will
acknowledge and send another synchronization packet referred to as
SYN/ACK, if it is available. Once the initiating device receives the
SYN/ACK packet, it will also send an acknowledgment ACK packet and
establish the connection. The following figure will illustrate the three-way
handshake.
All the TCP connections that are established successfully over the internet
will use the three-way handshake to ensure that there is a synchronized
connection taking place on devices on both ends of the network. We will
learn to use this three-way handshake in a way that avoids being detected
later in this chapter. After the connection has been established between two
devices using TCP, there is a continuous process of acknowledgment
between the two devices. This ensures that all the packets sent by the first
device are successfully reaching the second device, and the packets not
received are resent by the first device. An analogy to this would feedback
that is provided in the process of verbal communication. Let us look at an
example.
Bob: “Can you confirm the time you want to meet me at the
restaurant?”.
This process will cause some load on the server and will consume more
bandwidth than regular. Sometimes, it will take more time than usual for
communication to process as well. Because of this, the three-way
handshake is often used for establishing sessions for communication that
are not highly impacted by the latency in receiving the packets. There are a
set of applications that make use of TCP, such as File Transfer
Protocol(FTP), Hypertext Transmission Protocol(HTTP) and email
protocols such as Simple Mail Transfer Protocol(SMTP), Post Office
Protocol(POP), and Internet Message Access Protocol(IMAP).
UDP
The load on a connection using the UDP protocol is less compared to the
TCP protocol. As we have learned, a TCP connection is like a phone call
that is happening between two parties, where both parties are continuously
sending and receiving messages from each other and are acknowledging it
as well. A UDP connection would be more like a radio broadcast between
two parties where neither of the parties is acknowledging that the messages
have been received. It is understood by default that the packet that was
broadcasted was received.
Radio Station: “This is ABC radio; kindly join us at the restaurant today at
3 PM”.
ICMP
ICMP was designed to be a network protocol for the health and
maintenance of the network. The protocol helps in finding out if a device on
the network is functioning as intended and if it can communicate properly.
ICMP applications are not directly exposed to end users but there are
various exceptions to this rule as well. A common exception to this rule
would be the PING and TraceRoute utilities. Another difference is that
ICMP does not carry user data like TCP and UDP protocols.
On the contrary, ICMP will carry messages related to the system, to and
from computers, network devices and other application services. The header
of an ICMP packet contains a specific code or a number set. The sets help
in asking questions or providing information about network nodes.
Penetration testers can make use of these codes and sets to get information
about the target system. Let us go through the codes available in the ICMP
header.
PING
PING is an ICMP based command which is very commonly used by both
end-users and administrators. When you PING a device, an ICMP packet of
type 8 and code 0 is sent to the device indicating that it is an echo request.
The end device which is usually configured to reply to such an echo request
will ideally reply with another ICMP packet of type 0 and code 0 indicating
that it is an echo reply. A ping is considered to be successful when there is a
response from the end device which is verified to be a live host. When you
send a ping request using the command line on a Windows system, sends
the ping request four times by default. As opposed to this, ping requests
from the Linux terminal do not have any such limit and will continue the
request until the user cancels it. You can cancel the ping command on the
Linux terminal by pressing hr Control+C keys on the keyboard together. Let
us go through the examples of a successful ping and an unsuccessful ping.
Live Host
Ping 192.168.1.1
Pinging 192.168.1.1 with 32 bytes of data:
Reply from 192.168.1.1: bytes532 time52ms TTL564
Reply from 192.168.1.1: bytes532 time51ms TTL564
Reply from 192.168.1.1: bytes532 time51ms TTL564
Reply from 192.168.1.1: bytes532 time,1ms TTL564
Host Unreachable
Ping 192.168.1.200
Pinging 192.168.1.200 with 32 bytes of data:
Reply from 192.168.1.129: Destination host unreachable.
Reply from 192.168.1.129: Destination host unreachable.
Reply from 192.168.1.129: Destination host unreachable.
Reply from 192.168.1.129: Destination host unreachable.
Ping statistics for 192.168.1.200:
Packets: Sent 5 4, Received 5 4, Lost 5 0 (0% loss)
Traceroute
Traceroute is another ICMP based utility that helps you find out the number
of network devices that need to be hopped before the source device can
reach the target device. This command functions by manipulating the Time
to Live or the TTL of a packet. Time to Live or TTL indicates the number
of times a packet can be broadcasted by the host that encounters the packet
on the next hop. The initial value of TTL for a packet is 1 which means that
the packet can only hop one device. The device that receives this packet
will reply with an ICMP type 11 and code 0 packet which means that the
packet is logged. The sender then increases the TTL and sends the next set
of packets in the series. The packets will reach the next hop in the network
and reach their time to live. As a result of this, the router that receives the
packet will send another time exceeded reply. This process will continue
until the packet reaches the target and all the hops in the patch have been
recorded creating a complete list of devices that lie between the source
device and the target device. This information can be used by a penetration
tester to find out all the device that is between them and the target on the
network. There is a default TTL of 128 on Windows device, Linux devices
have a default TTL of 64 and networking devices by Cisco have a ping of
255. The command used for traceroute on the Windows command line is
tracert. On a Kali Linux system, the command to use is traceroute. The
traceroute result would give the following output.
traceroute www.google.com
1 1 ms,1 ms 1 ms 192.168.1.1
2 7 ms 6 ms 6 ms 10.10.1.
2 3 7 ms 8 ms 7 ms 10.10.1.45
4 9 ms 8 ms 8 ms 10.10.25.45
5 9 ms 10 ms 9 ms 10.10.85.99
6 11 ms 51 ms 10 ms 10.10.64.2
7 11 ms 10 ms 10 ms 10.10.5.88
8 11 ms 10 ms 11 ms 216.239.46.248
9 12 ms 12 ms 12 ms 72.14.236.98
10 18 ms 18 ms 18 ms 66.249.95.231
11 25 ms 24 ms 24 ms 216.239.48.4
12 48 ms 46 ms 46 ms 72.14.237.213
13 50 ms 50 ms 50 ms 72.14.237.214
14 48 ms 48 ms 48 ms 64.233.174.137
15 47 ms 47 ms 46 ms dfw06s32-in-f19.1e100.net [74.125.227.179]
Trace complete.
Most of the scanning tools available in Kali Linux employ the TCP, UDP,
and ICMP protocols to map the targets. When a scanning stage is
successful, the output will provide
IP addresses.
Operating Systems.
Some of the Kali Linux scanning tools can also be used for finding
vulnerabilities and user account details. These details will help amplify the
exploitation stage as the attacks can be more specific with respect to hosts,
vulnerabilities and technologies.
nmap 10.0.2.100
If you do not specify any options with the Nmap command, it runs a stealth
scan by default and uses the speed as T3. Also, since you have not specified
where the output is to be directed, they will be printed on the monitor
screen in the terminal by default. This is a basic scan which stands at the
lowest end of the Nmap spectrum. The other end of the spectrum consists of
detailed and lengthy scans that tell the Nmap command to perform many
more tasks. You can use Nmap at an advanced level too by using hr Nmap
Scripting Engine(NSE) which helps you create scripts for Nmap scanning.
To understand Nmap scans better, we will learn about options that can be
used in the Nmap command which help enhance the power of Nmap as a
scanning too in the penetration testing life cycle.
Even when no scan type is defined in the Nmap command, the Nmap
command by default runs in the stealth scan mode. You can also
intentionally specify a stealth scan to the Nmap command by passing -sS as
the options. A stealth scan will initiate a TCP connection with the target
system but will fall shy of completing the three-way handshake. The Nessus
engine sends a SYN packet to the target and when the target system returns
a SYN/ACK packet back, the Nessus engine simply does not acknowledge
it. Given this, there is no channel built for communication and the
connection is left open. In such a scenario, most devices on the internet will
automatically close this open connection after a set time interval. Therefore,
this scan can run without getting detected on legacy systems that are
configured poorly. However, a stealth scan can be detected by almost all
network devices and hosts. But this should not demotivate a penetration
tester from using a stealth scan as it is still far more difficult for a system to
detect a stealth scan. Also, there is a high chance of it still being successful
if the target system is configured poorly. The following figure illustrates the
stealth scan technique.
Timing Templates
As we have already discussed above, Nmap uses the T3 or normal timing
option by default of no timing option is exclusively specified. There is in-
build functionality in Nmap wherein this default timing can be changed by
using the timing options available for Nmap. This lets the user specify the
speed of the scans. There are various timing templates available for Nmap
that decide the speed of the Nmap scan. The most important timing
templates are the ones used for delaying scanning probes and the status of
parallel processing. We will be going through the templates scan_delay,
max_scan_delay, and max_parallelism to explain how timings for a scan
can be manipulated. These templates contain a predefined time set for
Nmap scanning to be used on a target network or system. You can use the
scan_delay template ensures that probes are sent to the target system with a
minimum number of pauses, while the max_scan_delay will specify the
maximum time that the Nmap scan will allow delay in scanning based on
the target system settings. This is an important tool because some systems
on the internet only reply if the probes are coming at a specific rate. You
can use these tools which help Nmap to adjust the probe time as per the
target system or network requirements up to the max_scan_delay setting.
The max_parallelism template instructs the Nmap command for the probes
to be sent serially or in parallel. Let us go through an example that will run
a UDP scan on a target. Although we have not talked about the -p option,
we will use it with a switch combination of p1500 to scan the first 500
ports. The command will look like the example shown below but the # will
be substituted by the number of the required template that you want to use.
This will help you compare the scan timings. We are using the T# switch in
the example below, but you can use the complete English text to get the
same results.
OR
-T0 Paranoid
You can use the T0 paranoid scan as an option to Nmap where network
links are slow or if you want to minimize the risk of detection. The nature
of this scan is serial and it can be paused for a minimum of 5 minutes. The
base can_leay value is set above the default value and therefore, the
max_delay option value is ignored. You can easily check the amount of
time a paranoid scan took to complete on UDP ports in the 500 range on a
single target in our example. The system time is 10.29 AM and the scan
started at 8.23 AM. This means that it has been over 2 hours since the scan
was initiated. The last line shows that it will take another 45 hours and 37
minutes for the scan to conclude. This is an effective timing parameter but
should be used when you have a lot of time and when using stealth mode is
possible.
-T1 Sneaky
The T1 or the --timing sneaky scan is relatively faster than the paranoid
scan, while still maintaining stealth and reducing the time needed to
complete the scan. The process used by this scan to scan a target system is
also serial. It also brings down the scan_delay to as low as 15 seconds.
Although the scan_delay is low value, it is still a lot compared to
max_scan_delay, and therefore, the second value is ignored. In our
example, the difference between the T1 sneaky scan and the T0 paranoid
scan. The total scan time is reduced by 138 minutes or 8331 seconds.
-T2 Polite
The T2 or --timing polite scan is faster than the T0 or T1 scan and is the last
timing template that uses the technique of serial scanning. The scan_delay
parameter for this template is 400 milliseconds and therefore, there is a use
case for the max_scan_delay option in this scan which has a default value
of one second. The Nmap command, in combination with this template, will
use a scan_delay of 400 milliseconds while scanning targets but can adjust
the delay to as low as one second dynamically. In our example, we are
using the polite scan to scan the same UDP port 500, and you will notice
that the total time required for the scan to complete has been drastically
reduced down to just 9 minutes or 544 seconds.
-T3 Normal
The T3 or --timing normal scan is the default scan used by the Nmap
command. This means that if you do no exclusively specify a timing
template for the Nmap command, it will use the T3 normal template. The
T3 normal template makes use of parallel processing, and multiple probes
are sent in parallel which increases the speed of the scan. The default
scan_delay for this scan is 0 seconds and it can make use of the
max_scan_delay option to increase the delay to 1 second. This implies that
this scan will be very fast but after a port is scanned, it abandons that port to
hop to the next port. If we scan the same target on the UDP port 500 using
T3 normal, the scan will take 547 seconds to complete, which is slower in
comparison to the polite scan. This is an exceptional case. Many factors
affect scan time and there will be times when a slower scan will not actually
be slow. Therefore, a penetration tester needs to have all the tools handy
and have knowledge about as many tools as possible.
-T4 Aggressive
The T4 or --timing aggressive scan also uses the parallel scanning technique
and increases the scan speed. The can_delay option for this scan is set to 0
seconds and can make use of a max_scan_delay of 10 milliseconds. There
are high chances of scans that use a max_scan delay of less than one second
to encounter errors as many target systems have a requirement of at least
one second between the probes. If you look at the scan time taken by this
scan to complete scanning the 500 UDP port is well under 8 minutes or 477
seconds.
-T5 Insane
The T5 or the --timing insane scan is the fastest built-in timing template for
Nmap. The scan_delay on this template is 0 seconds and it has a
max_scan_delay of 5 milliseconds. Just like in an aggressive scan, there can
be scan errors with the insane template as well if the target system needs a
delay of at least 1 second between the probes. This scan will just take 22
seconds if we use it on the UDP 500 port but the results will be a little
different compared to other scans.
Targeting
One of the important parts of running a Nmap scan on a target system is
identifying the target. If you pass an incorrect IP space, you may end up
scanning an incorrect network which is not defined under the rules of
engagement, or even an empty set. There are various ways to pass the target
in the Nmap command string. The two methods that we have been using in
this book are the IP method and a scan list.
IP Address Range
The method of using an IP address to define a target for the Nmap
command is very straightforward. In our example, we will use a class C
address which has the range 10.0.2.x. This means that we can include a
maximum of 254 hosts for this particular scan. You can use the following
command to scan all the hosts.
Nmap 10.0.2.1-255
You can use the CIDR method to run this same scan as well. The CIDR
method uses the postfix of /24 as shown in the command below.
Nmap 10.0.2.1/24
You can use CIDR to define a complete range of IP addresses, but it is
beyond the scope of this course. You can learn more about it in a book on
networking. You can use an online calculator such as the one on
http://www.mikero.com/ misc/ipcalc/ to calculate CIDR ranges for an IP
address. You can enter the starting IP address of the range and the ending IP
address of the range and click on the convert button to get the CIDR
conversion.
Scan Lists
Nmap has a feature wherein it can get a list of targets from a text file. Let us
look at an example where the following IP addresses are stored in test.txt.
10.0.2.1
10.0.2.15
10.0.2.55
10.0.2.100
You can use the following command to run tests on all these targets.
Port Selection
You can use the -p switch to specify ports that you wish to use the Nmap
scan command on. You can specify a range of ports using a hyphen in the
command. You can also specify multiple ranges by using comma-separated
values in the command. You can look at the commands given below.
Output Options
There are many times when the result of your penetration test would be too
long to read it all on the monitor, or you may just want to log it to a file to
analyze later. You can use the pipe | operator available in Kali Linux to
redirect the output of the Nmap command to a required file. We will discuss
the options used for the output of Nmap scans in this section. We will
include normal, GREPable and XML outputs. Let us look at all the options
one by one. The filename we will use in our example is logthis.
-oN Normal Output
Using the -on Normal Output option creates a text file that can be used for
analysis later or can be used as an input to another program.
http:// nmap.org/nsedoc/
In the following example, we will use a pre-configured script to fetch
information about the target system’s MAC address and NetBIOS. We will
use the --script flag which will tell the Nmap command that a script will be
used in the command.
There are new scripts to being developed every day to be used by Nmap by
the community. Therefore, a penetration tester needs to ensure that the
script database to be used with Nmap is up-to-date. It is a good practice to
update the database of a particular script every time before you run it. You
can use the following command to achieve the same.
nmap --script-updatedb
HPing3
You can use the Hping application if you want to place customized packets
inside a network. The process is manual but it similar to how the Nmap
command creates packets automatically. The Hping command can use the -
S flag to create a continuous set of synchronization packets. Let us go
through an example command.
hping3 -S 10.0.2.100
You can get a detailed list of options and flags that can be used with the
Hping3 command by using the -h switch.
Hping3 -h
Nessus
Tenable, which is a very well known and popular name in the security
domain, has developed a beautiful application for vulnerability scanning
called Nessus. The application is available in the Home and Professional
versions and offers different levels of functionality. There are many plugins
available in the professional version that can be used for compliance and
configuration checks and is one of the best tools for a penetration testing
team. In this book, we will learn how to configure the home version of the
Nessus vulnerability scanner.
Installation
The first important step is to clean the current state of your system and
update it before installing Nessus. You can use the following commands in
your Kali Linux terminal to do this.
The next step is to download and install Nessus. You can download the
latest version of Nessus from the following URL.
http://www.nessus.org/download
To download it for your Kali Linux, ensure that you select a 32-bit or a 64-
bit operating system as per your system. Read through the agreements and
click on the Agree button. If you do not accept the agreement, you will not
be able to install Nessus. The file download will start, and you need to note
down the location to complete the installation.
After the download is complete, run the following command on the Kali
Linux terminal.
dpkg -i B/{Download_Location}/Nessus-{version}.deb
You can start the Nessus scanner using the following command.
/etc/init.d/nessusd start
Once the Nessus scanning service has been started, you need to launch the
IceWeasel web browser available in Kali Linux and go to the following
URL.
https://localhost:8834/
The localhost section of the URL connects to the local server on the Kali
Linux system and the section after the colon specifies that it should connect
to port 8834 instead of any default ports. It is always a good idea to go
through the Nessus documentation to see which port to use as different
versions of Nessus may use different port numbers. The default port number
for any web browser looking up a URL is 80 and in Kali Linux, port 809
may mostly be unavailable or incompatible with the IceWeasel browser.
When you connect on port 8834, you will be directed to the Nessus
Console, which is a graphical user interface used to set up, configure and
scan by using the Nessus engine. You will first be presented with the
registration screen. Registration will help you with getting files and updates
for the Nessus tool in the future.
You will be able to set up an administrator account on the next screen. You
can fill up the username, password, and other fields in the form available on
this screen. We will be using the username and password as Nessus in this
example. Please ensure that you these credentials only for a test
environment. Click on the Next button.
On the next screen, you will be able to activate the Nessus Feed plugin. You
can use the “I already have an activation code” button as you are a
registered user. You need to enter the activation code you received on
registration. On the next prompt, select, “I will use Nessus to scan my
Home Network.” Enter your first name, last name and email address. If you
have a network proxy present, hit the button for Proxy Settings and fill in
the respective information. In this example, we are not using proxy and
therefore, will click on the Next button.
If the registration were successful, you would see a screen that says that the
registration was successful. You will also see a button on this screen that
allows you to download the latest plugins. Click this button.
After the plugins have been downloaded, you will see a login prompt. Enter
the username and password for the administrator account that you created
earlier. You can click on the “Sign In to Continue” button next. You have
now completed the initial installation and setup of the Nessus tool.
SMTP settings
Proxy ports
Mobile settings
Results settings
More advanced settings
Nessus Feed
Activation code
All the tabs that you see in this dialog box are useful, and you are
encouraged to go through all of them in a testing environment before using
them in production. For example, you will know the username and
password of the target machine in a test environment; so you can enter
those details so that the Nessus scanning engine has more access. In a real
scenario, you may have uncovered the credentials in the Reconnaissance
stage.
If you want to scan a target machine for specific services, settings, and
options, you can use the plugins tab. One of the default options groups is
DoS, which stands for Denial of Service. You can disable this default option
if the current rules of engagement do not allow it. You can click on the
green enabled button to disable this option. On doing this, you should see a
grey colored button that reads “disabled.” You can click on the text next to
the various buttons in this group which will let you know what the option
exactly does. The number next to the text, 103 in this case, tells you how
many checks are available in the given group.
You can return to the tab for “General Settings” after you are done making
changes. In this tab, enter a new name in the field specified for name and
enter anything of your choice. We will use “No DoS” in our example and
click on Update. Once you have clicked on Update, this will be shown as a
new policy with the title “No DoS.”
The final step in configuring a scan is a scan template. Click on the “+ New
Scan” button to create a new template. Provide a name to the new template
in “General Scan Settings,” we will be using the “No DoS Test Scan” in our
example. We did not change the type from the default “Run Now,” used the
policy as “No DoS,” and entered the IP of the target system. You could also
upload a text file containing a list of targets using the “Upload Targets”
button.
There is an Email tab where you can enter the email addresses of users who
need to be notified about the status of the scan and get other information
that is directed from the scan. However, you need to ensure that you have
configured the Simple Mail Transfer Protocol (SMTP) for this feature to
work. We are excluding this from our example.
After you have checked that all your configurations are in place, you can
run the scan. You can do this by clicking on the blue “Run Scan” button.
The scan will begin using the selected scan profile. You will see the status
of the ongoing scans in the scan view, as shown in the figure.
After the scan has concluded, you can export the data in the Results tab in
multiple file formats such as Comma Separated Values(CSV), HTM, and
PDF. We have exported it in the PDF format for our example. We have
included all the chapters in our example as we have selected
“Vulnerabilities by Host,” “Host Summary,” “Vulnerabilities by Plugin,”
etc. Once data is available for export, the buttons turn blue and you can
click on the “Export” button to export the data.
Exploitation is the third stage of the penetration testing life cycle. In this
chapter, we will learn about the differences between attack types and attack
vectors. We will go through the tools available in Kali Linux that can be
used for exploitation. We will learn specifically about the Metasploit
framework and how it can be used to attack a target system. We will also
learn about hacking web services in brief.
Introduction
The National Institute of Science and Technology defines a vulnerability as
a “weakness in an information system, system security procedures, internal
controls, or implementation that could be exploited by a threat source.”
However, this definition is very broad with respect to exploitation and
needs further discussion. An “error” leads to a vulnerability. The error can
be placed in multiple points such as somewhere within the information
system itself, or even within the humans that manage these information
systems. Vulnerabilities for an information system can be present both
inside and outside the system’s network. They can be a result of poor
coding, incorrect security policies, etc. They can be present outside the
technical network as well, through the humans that manage these
information systems.
Web-Based Defacement
Cross-Site Request
Forgery (CSRF)
Cross-Site Scripting
(XSS)
SQL Injection
Code Buffer Overflow
Injection Buffer Underrun
Viruses
Malware
Social Impersonation
Engineering Spear Phishing
Phishing
Intelligence Gathering
Social Impersonation
Engineering Spear Phishing
Network- Phishing
Based Intelligence Gathering
Denial of Service (DoS)
Password and Sensitive
Data Interception
Distributed Denial of
Service (DoS)
Stealing or Counterfeiting
Credentials
The foundation is of exploitation is not only know what type of attack is
taking place but understand by what means the attack is taking place. We
will go through the different types of attacks in the sections that follow and
will learn about the tools that come into the picture in brief. We will learn
about the Metasploit framework in detail. It is important to where you need
to put effort, how you need to put efforts, and when to apply the tools.
Without this knowledge, you will put in significant effort which will return
negligible results during penetration testing.
Local Exploits
As suggested by the title, local exploits are exploits that are executed
locally using devices such as your computer, laptop, a network device such
as a mobile phone, using an established session. You can classify an exploit
to be local if a penetration tester has physical access to the target system
such a terminal to a system, or SSH access to a system, a Virtual Private
Network(VPN) connection, or a Remote Desktop Connection(RDP). You
can modify privileges of accounts, create a Denial of Service attack, upload
malicious content, or steal data, using local exploits. A penetration tester
needs to keep in mind that local exploits cannot be executed over a public
network, but only networks that are locally defined. If you are trying to
locally exploit a system without using the specific code for it, alarms will
be triggered and your time will be wasted.
People often misunderstand how local exploits can be taken advantage of. It
is not necessary to execute local exploits via an attacker. With the use of
social engineering, an attacker can simply trick a legist user of the system
into executing a code leading to a local exploit. An example of this would
be a trojan code that can be embedded in a PDF file or a Microsoft Excel
sheet that appears to be completely legit. Another example would be a USB
drive that is left as a courier at an organization and is waiting to be plugged
into any device, after which it will auto-launch an exploit code. The
possibilities for exploitation are countless and are only limited by the
thinking ability of the penetration tester. There are various scenarios where
it becomes difficult to execute remote exploits and the options for local
exploits that need to be considered.
Using the three keywords, the search returned a single result. This is how
simple it is to use Searchsploit. The search linked the three keywords local,
windows and IIS, to return a vulnerability present in the Windows
dynamically linked library, running IIS and using the PHP version 5.2.0.
You can execute a local exploit here resulting in a buffer overflow
vulnerability, causing a denial of service on the host. We have shown the
output of the locate command in the figure below which gives us more
information about the exploit pipe.
Remote Exploits
You can classify an exploit as a remote exploit when you do not have
physical access to a computer, network or a mobile device but have gained
access to it remotely through the network. This is why remote exploits are
also known as network exploits. Irrespective of what the exploit is called,
the thumb rule to remember is that if the exploit is not local, it is remote.
The target of a remote exploit is not just a computer, or server, or network-
related devices. The target range of remote exploits extends to web
applications, web services, databases, mobile phones, printers, and anything
else that can connect to a network. As technology is progressing, there are
more and more smart devices being developed every day that can connect
to the network. For example, you can look at gaming consoles such as the
Xbox by Microsoft, Playstation by Sony, smart televisions, smart
refrigerators, and the list goes on. You need to accept that if the device is an
electronic device which can connect to a network, someone in the world is
already trying to hack it, for fun, or for profit. We will go through remote
exploits in detail later when we learn about the Metasploit Framework.
Metasploit Framework
Metasploit is arguably one of the most powerful tools available inside the
toolkits of a penetration tester. Metasploit is what it is because of years of
knowledge, multiple tests and trials, by penetration testers, attackers,
researchers and even governments from all around the world which
represent different parts of a community that works in the security domain.
From mischievous black hats to the best white hats, and everyone between
them, everyone has used Metasploit at some point in their lives. The
Metasploit tools were developed by Rapid7 which is headquartered in
Boston, MA, and they have not spared a single cent or CPU cycle to
develop the solid framework that is known as Metasploit which can be used
in the penetration testing life cycle from start to finish. There is also support
for reporting and government compliance in Metasploit for professionals
working in the security domain. You will be amazed if this is the first time
you will be getting your hands on Metasploit.
Code and messages were all scattered in the corners of hidden notice
boards. In late 2003, the creator of Metasploit framework, HD Moore,
released the very first version of Metasploit developed using Perl, with only
11 exploits. The motive was to have a single tool that can parse through
multiple lines of buggy code, exploit poorly written code, and publicly
accessible vulnerabilities. The second version was released in 2004 and had
a total of 19 exploits but has around 30 payloads. The third version was
released in 2007 and this is when the tools gained recognition and became a
critical tool in the domain of penetration testing. The latest version of
Metasploit today is above 4 and is an integrated program that is bundled
with Kali Linux. Metasploit today has over 1080 exploits, 275 payloads,
675 modules, 29 types of encoding and is aimed at all platforms like
Microsoft, Mac and Linux. The Rapid7 team does not have a particular bias
toward any one platform and all platforms are supported equally.
Metasploit Versions
There are two versions of Metasploit available today. The default version
that comes with Kali Linux is the express version. It is available free of cost
and was developed for private use through researchers and students. The
professional version was developed for commercial and government use
and offered additional features such as reporting, collaboration with groups,
compliance, and additional plugins for control with precision. There is a
cost on the professional version and therefore, if you need it only for testing
and personal use, we’d suggest that you stick to the free version. The
express version and the professional version both have the same exploit
modules.
On the other hand, Cover testing is when you are secretly conducting a
penetration test on the information systems of an organization wherein you
have limited knowledge about the target systems. In covert testing, only a
few members of the organization are aware of the fact that there is a test
being conducted on their infrastructure. A penetration tester is not given all
access to the information system and therefore needs to have a complete
toolkit to conduct the tests without creating any noise on the network. The
motive of a covert test is not only to find vulnerabilities of the system but
also to test the Computer Emergency Response Teams(CERT) and Intrusion
Detection Systems(IDS) of an organization. A covert test may start as a
covert mission but can escalate into an over mission if there are multiple
vulnerabilities in the system or if the covert nature of the mission has been
compromised.
Metasploit: Basic Framework
The Metasploit system is modular. We can understand the Metasploit
framework better if we view it to be a vehicle. Consider an Aston martin
which belongs to James Bond which has multiple modules as per his
requirements housed in an actual car. Comparing to the Aston Martin, HD
Moore has provided a lot of goodies around an engine in Metasploit. If a
module was to be removed or if it were to stop working, the framework
would still be capable of using all the other modules to unleash a series of
attacks.
Exploit Modules
Auxiliary Modules
Payloads
Listeners
Shellcode
There is a sixth category of modules as well. These are modules that would
interfere with the Metasploit framework and are known as “Armitage,” but
they are not a part of the actual framework. Analogically speaking, James
bond has a wristwatch that he can use to control his Aston Martin, but that
does not mean that he needs to wear a wristwatch while operating the car.
Exploit Modules
Metasploit has a package with predefined codes in its database which can
be executed on a target system to take advantage of the vulnerability on the
local or remote system by creating a Denial of Service(DoS) or fetch
sensitive information, upload a malicious payload module like Meterpreter
shell, and other things.
Auxiliary Modules
Auxiliary modules differ from exploit modules in the sense that there is no
requirement for a payload. There are useful programs available in auxiliary
modules such as fuzzers, scanners, and tools for SQL injection. There are a
few tools in the auxiliary module that are extremely powerful and should be
used with care. Penetration testers basically use all the tools available in
auxiliary modules to gather information about the target systems and then
transition to exploit modules to attack the system.
Payloads
Again using the analogy of James Bond’s Aston Martin, if the car is the
Metasploit framework, then the exploit modules and auxiliary modules can
be termed as its flame throwers and rocket launchers under the car’s hood.
In this analogy, payloads can be thought of communication devices that are
dropped on the target to maintain tracking and covert communications.
When you are launching an exploit on a vulnerable system, a payload is
attached to the exploit before executing it. The payload will have
instructions for the target system that need to be processed by the target
system after it has been compromised. There are various types of payloads
available today right from ones that contain a few lines of code to payloads
that contain applications like the Meterpreter Shell. It is not advisable to use
the Meterpreter shell payload directly. There are over 200 types of payloads
available in the Metasploit framework which include payloads for Dynamic
Link Library Injection, NetCat, shells, user management, and more. You
can decide which payload to deploy if you actually start thinking like a spy.
As a penetration tester, you need to ask yourself the goal of the entire
activity after you have exploited the target system. Do you want to deploy a
dormant code on the target system? Does the code deployed need to
communicate with the attacker at definite intervals? Does the code need to
run a series of commands? Payloads are commonly classified into bind
shells and reverse shells.
Bind Shells: These are usually shells that will remain dormant on a
target system. They will lie there until they have received further
instructions from an attacker. If the motive of the penetration tester
is just to deploy code in the target system that will allow access to
the target system in the future, bind shells would be an excellent
choice. If a target system is protected by a firewall and does not
have direct access to the network, bind shells would not be a great
choice.
Reverse Shells: A shell which is deployed on a target system and
immediately requests further instructions from the attacker is known
as a reverse shell. If an exploit containing a reverse shell is executed
on a target machine, the attacker will get a level of access to the
machine as if they had the keyboard of that machine in their own
hands.
Meterpreter Shell: The meterpreter shell is a special type of shell. It
is popularly known as the bread and butter of the Metasploit
framework. Rapid7 has been developing a meterpreter shell in a way
that it contains its own small set of tools. The meterpreter shell can
be deployed with an exploit, wither in the form of a blind shell or
reverse shell. We will discuss the use of a meterpreter shell in detail
later in this chapter.
The young blood of penetration testers often ignore the activity of payload
selection because they want to rush directly into getting root access to a
system using the meterpreter shell. This is not the ideal way to go about
getting access to a system, and a deep thought process is recommended for
exploiting a vulnerability. If you are trying to conduct a covert penetration
test, if you penetrate with all loud guns, you may just blow your cover by
triggering all the alarms in the system. If James Bond were not covert in his
operations, his career would have ended within a couple of projects.
linux/x64/shell/bind_tcp (Staged)
linux/x64/shell_bind_tcp (Inline)
Listeners
Even James Bond has sometimes taken orders from above. The Metasploit
framework contains specific handlers known as listeners that communicate
with the session that a payload established with the target system. Again a
listener can be embedded in a bind shell where it will lay dormant and wait
for a connection or it can also be active and keep prompting for a
connection from the attacker. A listener is needed to maintain back and
forth communication between the attacker and the target system. Listeners
are automatically taken care of by the Metasploit framework and therefore,
require very little manual intervention.
Shellcode
Shellcode is not an independent module but is again part of payloads
available in the Metasploit framework. James Bond’s car has missiles but
the explosives inside the missile cause the actual explosion. This is what
shellcode is like. The shellcode resides inside the complete framework and
is responsible for creating a hole in the target system, upload malware, and
execute payloads commands to create a shell in the target system, which
gives it the name shellcode. Shellcode doesn't need to be present in every
payload. For example, the Metasploit payload called “windows/adduser”
contains just a few commands to create an admin account on the target
windows platform.
Accessing Metasploit
There are various ways to access Metasploit. We recommend using its
graphical interface in Kali Linux until you have understood the tool
thoroughly. You can launch the graphical tool for Metasploit in Kali Linux
by following the steps below.
You can also access Metasploit on port 3790 using the web browser. The
following URL needs to be used.
https://localhost:3790/
There is no valid certificate present for Metasploit. So when you access the
URL mentioned above via IceWeasel, you will receive the prompt
“Connection is Untrusted.” You can ignore this and click on the “Confirm
Security Exception” button and continue.
You will need to create a user and specify a username and password for the
first run on Metasploit. There are a few other options available as well. The
other options include reporting features in Metasploit. After you are done
filling in the form, click on the “Create Account” button.
Startup/Shutdown Service
There will be times when you need to restart the Metasploit service. The
Metasploit service consumes a lot of resources as many of its services need
the network to function. So there are chances that you may face network
errors at times if the consumption is very high. In this case, it is best to
restart the Metasploit service. You first need to check the current status of
the service. You can run the start, restart, stop commands for Metasploit
using the Kali Linux terminal. The commands are as shown below.
Database Update
Although Rapid7 developed Metasploit, there are constant contributions to
its codebase from the community. Therefore, we recommend you to update
its database before every run. Even James bond would check his
ammunition before going on a new mission.
You can run the msfupdate command to update the Metasploit database.
After typing and executing it, just sit back and relax. The update will
complete on its own. Now we can proceed further.
You can also update the Metasploit database from the graphical interface. If
you are already logged into the Metasploit web interface, select “Software
Updates” located on the upper right-hand corner of the page. On the next
screen, click on “Check for Updates.”
Metasploit downloads and installs the updates instantly if they are available.
It is recommended to restart the Metasploit service after it is updated. You
can close the web user interface and reopen it again after the update is
complete.
Metasploit Scanning
Now that James Bond is locked and loaded with ammo, it is time to set
forth on the mission. You will see a landing page that says “mission” when
you log in to the Metasploit web interface. You will see a list of ongoing
projects, mission folders, current targets, and newly discovered
vulnerabilities on this page. If you are logging in for the first time, you only
see one project named “default.” As and when you start working on
multiple projects, you can use the “New Project” button to add more
projects. Beginners should stick to the default project. This will make it a
comfortable experience and you will be able to import results from Nmap
or Nessus conveniently.
When you open the default project, you will see options such as discovery,
mission dossier, penetration, cleanup, evidence collection, and recent
events.
Using Metasploit
In the sections that follow, we will go through a hands-on experience of
using the Metasploit framework. We assume that the IP address from where
we are running Metasploit is 192.168.56.101 and is accessible through the
network.
You can click on the “Scan” button in the discovery section to start
scanning a host. In “Target Settings,” you can specify the targets by
entering a single host like 192.168.1.100, a group of hosts like
192.168.1.100, 192.168.1.101, 192.168.1.110 or a range of host like
192.168.1.100-200, just like you did for NMAP and Nessus. You can
choose to use or not choose CIDR notation.
There are a few fields in the “Advanced Target Settings” that are important,
and you should know. Let us go through these fields one by one.
Perform Initial Portscan: If you are scanning a host for the first time,
kindly check this box so the port can be scanned. If you are coming
back to this host, you can uncheck this box to save time.
Additional TCP Ports: The default Metasploit scan will scan the
commonly known ports. If a penetration tester has found out that the
target system has applications running on an obscure port during the
reconnaissance stage, the specific port can be entered here.
Exclude TCP Ports: Again, you may need to exclude certain ports
from scan for various reasons or if the rules of engagement demand
it. You can list the ports you wish to exclude using this option.
Custom TCP Source Port: There are times when even James bond
wears a disguise. This option can be useful to specify a different
source port which will help in bypassing certain access control lists
and security controls set up on the target system’s firewalls.
Now to scan the target machine. Enter the Ip of the target machine using the
“Target Addresses” field. Continue with the “Launch Scan” button. The
time taken to complete the scan will depend on the speed of your own
computer and the state of the network at your end, as well as at the target
system’s end. Metasploit is an efficient tool but it has a huge number of
processes running in the background.
You can click on the “Overview” tab from the maintenance section after the
scan has concluded. You will see that the Discovery section will give a
detailed report of the scan. In our case, it showed that one host was scanned,
which had 30 or more service, and one vulnerability was found. It is a very
good result as it came from a single scan using Metasploit. If you conduct
custom scans on the target system, you may end up finding more
vulnerabilities. We didn't even use Nexpose to check compliance.
Metasploit is a fun tool and you should continue to experiment, enjoy, and
exploit.
On the “Analysis” tab in the maintenance section, you will see a list of all
scanned hosts with a small summary of the scan results. You can get more
information about a particular host by clicking on the host IP.
File Shares: If there are file shares available, they are shown in this
list. Linux does not have shared files in the same structure as that on
Microsoft Windows.
Credentials: This section will show any user login credentials that
were found during the scan.
Launching an exploit by clicking on its hyperlink will give you page with
details of the vulnerability, which is very useful to create reports. It will
then fill in the required details to continue the vulnerability execution.
Metasploit will launch a generic payload accompanied by the meterpreter
shellcode by default. You can review the settings and then click on the “Run
Module” button.
If the session is successful, you will see the message “Success! 1 session
has been created on the host”. This implies that the target system has been
compromised successfully, and the scan exploited the vulnerability. You can
click on the “Sessions” tab to get complete details of the session that was
established. You can also see the type of shell that is available for
interaction with the target system. You will also be able to see the level of
access you have which is indicated by the type of account that has been
made available to you. You can click on the hyperlink for any session to
start Meterpreter Shell on the target system.
You need to maintain a balance between time and execution of your plans.
Since our example is showing only one vulnerability on our target system,
there is no time constraint in our example, but you need to remember that
time can be an important aspect to consider in a real environment. Alarms
can be triggered with wrong actions, and no action will lead to a loss of
effort and the session.
If you look at the figure below, you will see that along with actionable
buttons, a penetration tester will also get session history and a post-
exploitation modules tab. This information can be exported to create reports
later.
Actions Inside a Meterpreter Session
Access File System: You will be able to access the file system on
the target system. This access will let to upload, download, modify,
and even delete files on the target system.
Command Shell: This will let you use the command shell on the
target to further interact with other connected systems.
Create Proxy Pivot: Using this option, you can use the remote
target system as a gateway. This means that the target system, if
connected to other systems on the network, will serve as a gateway
to start a scan on those systems too.
Create VPN Pivot: This option will help you use the remote target
system to pivot traffic. This is not very different from the “Create
Proxy Pivot” button. The only difference is traffic through this will
be in an encrypted format over VPN.
Command Shell
Next, we will see what happens when you select the “Command Shell”
button from the “Available Actions” menu. You will be welcomed with the
meterpreter shell at first, and not a command-line tool related to Linux or
Windows. It is advisable to use the help command first in the meterpreter
shell so that you can get comfortable with it before firing actual commands
in production. You can get a command-line tool associated with the
operating system of the system that was hacked by typing “shell” on the
command line of the meterpreter shell.
1. Injection
2. Broken Authentication
3. Sensitive data exposure
4. XML External Entities (XXE)
5. Broken Access control
6. Security misconfigurations
7. Cross-Site Scripting (XSS)
8. Insecure Deserialization
9. Using Components with known vulnerabilities
10. Insufficient logging and monitoring
Step 2: Fingerprinting
A manual review may not be enough to know the operating system, server,
and web applications are running on the target system. Kali Linux makes
use of fingerprinting to find information about these three parameters.
Kali Linux has a tool called NetCat, which serves the purpose of fingerprint
and works as a listener for incoming connections as well.
You can use the following command on the Kali Linux terminal to use
NetCat
nc {host} {port}
:example: nc 192.168.56.102 80
nc 192.168.56.102 80
Press Enter
HEAD / HTTP/1.0
Press the Enter key twice.
Just like NetCat, there is another tool called Telnet that can also be used to
find out system information. The command for telnet is as follows.
telnet {ipaddress} {port}
:example: telnet 192.168.56.102:80
There is another tool that can be used for fingerprinting known as SSLScan.
Most of the websites in the world today have an SSL certificate installed a
use encryption. It will always be good information for a penetration tester to
know what kind of encryption is being used on a website. The SSLScan
tools queries a host for the SSL version being used and also returns the
active certificate being used by the website. The command for this tool in
Kali Linux is as follows.
sslscan {ipaddress}:{port}
Step 3: Scanning
Setting up automation for the scanning process can help you search for
vulnerabilities and save a lot of time. There are many tools available for
webserver scanning and it is a good practice to have more than one
application in your toolkit. There is no one single application that is capable
of scanning hundreds of vulnerabilities that are present in systems today. It
is always good to use at least two or three applications to scan a web server
so that you can establish the number of vulnerabilities the web server may
have.
We will discuss in brief about a few tools available for scanning web
servers and web applications in this chapter.
Arachni
The Arachni tool available for scanning web applications runs through a
web interface much like the Nessus tool we discussed earlier. However, as
compared to Nessus, Arachni can perform a single scan on single host on a
single port at a given time. If the host has multiple web service running on
different ports, you will need to run a scan individually on every port. For
example, if the URL thiscomany.com has a web hosting service on port 80
and SSH on port 22, you will need to run two scans to assess both the ports.
You can access the Arachni web application scanner in Kali Linux using the
following path.
Applications > Kali Linux > Web Applications > Web Vulnerability
Scanners > arachnid_web
You can enter the target system host or URL in the URL field to start a scan
on the target system.
While the scan is in progress, you will see the following screen.
After the scan is complete, Arachni will provide a scan report, as shown in
the figure below.
When the w3af application is launched, a graphical interface for the tools is
presented with an empty profile and no plugins selected by default. You can
create a new profile with the plugins of your choice and click on “Save As”
from the menu bar. There are some predefined profiles to be used as well.
You can select the OWASP_TOP10 profile to begin with. You have control
over which plugin you wish to use for your scans. Even if you select a
predefined profile, you can uncheck the plugins that you do not want to use
for your scan.
Websploit
Websploit is another tool developed using ruby and looks similar to
Metasploit, but was developed specifically to scan web applications and
web servers, and social engineering. Websploit supports integration with
Metasploit by using exploits, payloads and even meterpreter. The tool is
capable of crawling through web servers and then attacking them resulting
in a Denial of Service.
Chapter 6
Maintaining Access
In the previous stages of the penetration testing life cycle, we have learned
how to explore a system and then scan and attack it. In this chapter, we will
deal with how we can maintain access to a particular system after we have
managed to gain access to it. We will learn about Malware, Trojans,
Backdoors, Viruses, Worms, Botnets, Keyloggers, etc. in this chapter.
Introduction
It feels great when you have gained access to a system that does not belong
to you. But the main motive of penetration testing is to maintain access to
the compromised system to conduct activities if required in the future.
There are multiple methods to maintain access to a system, but the main
goal of it is not to steal information but to reduce the time and effort taken
to gain access to the same system again and again, especially when you
have been able to gain access to it in the past. Maintaining access to a
system comes into the picture when a penetration tester is working with a
team and needs to provide access to their team members. A team member
should be easily able to gain access for their tests and need not repeat the
whole process again to gain access to the system in concern.
Terminology
It is expected of a penetration tester or a security professional to know the
basic terminologies used in the activity of maintaining access. The terms
below will help you understand the relation between them and the activity
of maintaining access.
Malware
Malware is short for malicious software and is a generic term used for
worms, viruses, trojans, bots, and keyloggers. With respect to penetration
testing, you can use the broad term malware when you need to report
something to the upper management. However, while working with the
penetration testing team, it is always good to be more specific about the
type of malware you are dealing with.
Backdoors
Many people confuse backdoors with trojan horses. However, a backdoor is
just a program that is planted on a compromised system for future entry,
such that you do not need to go through the process of exploitation again. A
backdoor may be a subset of a trojan horse but the converse is not true.
Backdoors are programs that have an embedded script to work like a trojan
horse but the program does not have any function to be used by the system
owner.
Trojan horse
A Trojan Horse, known commonly as a trojan, is a software that is planted
on the owner’s system overtly for their use but has a hidden functionality to
run scripts, create backdoors, steal information, etc. In certain scenarios, it
can also trick a user into entering sensitive information such as details of
their credit card.
Virus
A virus can be defined as a malicious code that can infect an existing
process on the system. A virus is capable of infecting files, system memory,
hard disk sectors, and other hardware. Viruses are further classified as a
resident or nonresident.
Resident
A virus that gets into the RAM space during system runtime and gets out of
the RAM space during the shutdown is known as a resident virus. These
viruses attach themselves like leeches to other programs that make function
calls from the RAM space to the kernel.
Nonresident
Nonresident viruses look for hosts on the system’s hard disk, infect the
files, and then leave from memory.
Worms
Worms imitate the same destruction as a virus. The difference between a
worm and a virus is that a work can multiply on its own and does not
require any input from human interaction. Worms will keep hopping from
one host to another continuously. Worms are not used in the process of
penetration testing as they are very powerful and may get out of control. It
is advisable to experiment with worms only in a lab environment with zero
access to any network, especially the internet.
Keyloggers
As suggested by the name, keyloggers capture everything that is typed by a
user and log it. This information is then relayed back to a penetration tester
or an attacker. Keylogger is an essential tool and is used routinely by a
penetration tester. However, certain Rules of Engagement may prevent the
use of keyloggers by penetration testers, since keyloggers can end up
logging personal information of an employee such as login credentials or
credit card details. Information that is logged by keyloggers should be
protected during the penetration testing phase and should be immediately
destroyed afterward.
Botnets
Bots is short for robots which are popularly known as zombies. They can be
planned on a network of computers and are usually controlled by a single
person known as the botmaster.
A bot network can include a network of computers that are already infected
by worms, viruses, and trojans. The botmaster has a master computer from
where commands are trickled down to the bots that are planted on various
computers. Bots are commonly used by attackers to cause a Denial of
Service, Distributed Denial of Service, brute force attacks, and other
malicious activities. A bit network can range from being very tiny
consisting of two systems, or very huge consisting of multiple servers.
Colocation
Colocation simply means having your services at an off-site location. A
penetration tester or an attacker may not always want to use their personal
computer or laptop as their source system. There are various companies
today that allow you to host your service on their server ranging from a few
dollars a month to thousands of dollars a month. However, colocation does
not necessarily mean you pay and host your services on a remote server.
You could also host them simply on a user’s computer that you have
managed to gain access to and run your activities from there without the
user’s knowledge. For example, a spamming botnet can be hosted on any
system that you have access to, and you will not necessarily need to pay for
a remotely located server.
Remote Communications
Communication that makes use of tunneling or VPN servers, remote
desktops, or any communication between a host and server that are not a
part of the same network is termed as remote communication. Remote
communication is important for penetration testers from the point of view
that it is needed to maintain access to a target system that they have
exploited and compromised.
Backdoors
In this section, we will discuss a few Kali Linux tools that can be used for
backdoors.
msfpayload windows/meterpreter/reverse_https S
The output of the command will provide fields to the penetration tester that
need to be set to convert the payload into an executable binary.
The following formats are available in the msfpayload tool to pipe the
output to a file.
[C] C
[H] C-sharp
[P] Perl
[Y] Ruby
[R] Raw
[J] Javascript
[X] Executable
[D] Dynamic Link Library (DLL)
[V] VBA
[W] War
[N] Python
We will be using X in our example to convert the payload into an
executable binary. This is a single command which you need to enter on a
single line.
Note: The binaries for the calc.exe program in versions Windows 7 and
later are not going to be impacted by the trojan that we are using in this
example.
We will use the following command to create the trojan horse on a calc.exe
binary. The command is to be written on a single line on the command line
prompt of Kali Linux.
msfconsole
use exploit/multi/handler
run
Persistent Backdoors
A college student keeps calling his home to keep a check on his parents or
siblings. Much like this, a trojan or a backdoor also follow the same routine.
There is a task known as scheduleme in meterpreter which can be used to
achieve this. The scheduleme tool allows you to launch commands as per
your time requirements(every day, every week, every 30 minutes), or
commands can be triggered using a user action such as when the user logs
in to their system.
scheduleme -c {“file/command”} -i -l
Detectability
Many antivirus systems already have a database of known trojans and
backdoors. If you want to test the strength of your trojan or backdoor, you
can upload it to http://www.virustotal.com/ wherein you can know which
antivirus is capable of detecting your trojan or backdoor. For example, the
trojan-calc.exe that we created earlier is detectable by AVG and
BitDefender antivirus.
Keyloggers
In this section, we will discuss a few Kali Linux tools that can be used for
backdoors. As we have already discussed the process of capturing
everything that a user types on their keyboard using a software is known as
keylogging. There are many third-party keylogger applications available
today which can be installed and used on a target system without being
detected. While this is true, using keyloggers requires physical access to the
target system most of the time, or you may need to attach a listening device
to the target system physically. The third-party applications also do not
consider the presence of an intrusion detection system or an antivirus that
could block the keylogger. Metasploit has a keylogger tool called keyscan
available via the meterpreter shell. If a penetration tester has cracked access
to a target system, they can use the following keyscan command to set up a
keylogger.
keyscan_start
keyscan_dump
keyscan_stop
The output of this command will show you all the keystrokes that were
captured by the keylogger. You can also pass the PID of an application to
the keyscan command if you want to see keystrokes only from a particular
application. You can use the ps command to know the PID of all running
applications.
Chapter 7
Reporting
Findings
The weaknesses, flaws, loopholes, and vulnerabilities discovered during the
penetration test are listed in this section. It is necessary to list down the
vulnerabilities for each system individually so that the management can
work on rectifying the flaws. The vulnerabilities could also be linked to the
compliance requirements with respect to government requirements or
regulatory requirements so that the owners of those systems can track the
costs back to the source of the funds. This will help system owners to
arrange the funds that are required to fix the system as soon as possible. For
example, some of the compliance requirement sources are Payment Card
Industry (PCI), Federal Information Security Management Act (FISMA),
and standards or Sarbanes Oxley (SOX).
Recommended Actions
The actions to be taken for all the vulnerabilities and weaknesses
discovered during the penetration tests are listed in this section. This can be
a general section, or there can be a dedicated part given in the section to
every vulnerability that was listed in the Findings section. It should be
followed by recommendations on how to fix the vulnerability. It is not
necessary to describe the exact technical fix required to correct the
vulnerability. You need to describe it in general so that the system owner
and their technical staff understand it enough to make corrections to the
system. For example, if the finding is that the password of the system was
too simple, the corrective recommendation for it would be to set up a strong
password policy on that system.
Conclusion
The conclusion section should have a summary of all the findings and the
recommended actions described using very brief statements. If there were
critical findings that need extra attention, they could be reiterated and
reemphasized in this section, indicating that the system owner needs to
correct those issues first.
Appendices
This section will cover information that supports the complete report, but
the appendices section should not be a part of the main report body. The
section will include information about the penetration testing company, raw
test data, glossary, definitions, and biographies of individual testers who
worked on the penetration testing activity.
Presentation
The management of an organization who requested for the penetration
testing activity and funded it will want a formal or semiformal presentation
on the entire activity to explain the outcome in brief. This could include a
slideshow along with a briefing by the presenter. In any case, if a
presentation has been requested, it should be presented professionally. You
need to avoid any attacks on the owners, developers, system admins,
engineers, etc. of the system on which the vulnerability was discovered as
they will play an important role in deciding which teams will be called for
future penetration testing on their systems. As an alternative, you need to
present facts that will not hurt anyone’s sentiments and do not blame any
group. In short, you just need to keep it short and talk about the flaws of the
system and how they can be fixed.
Then there are organizations which would request you to delete the
penetration test report. It would be best to do this in the presence of legal
counsel as an organization may hold you responsible in the future if some
findings were missed on the original test report. If there is a go-ahead from
the legal team, you can wipe it off the hard disk and ensure that no backup
copies are remaining and that the file cannot be retrieved again after
deletion. It is also a good practice to have two people verify deletion of
digital documents, which is also known as two-person integrity.
Reporting Tools
There are various reporting tools available in Kali Linux. We will go
through 2 widely used tools of Kali Linux, Dradis, and Magic Tree.
Dradis
The Dradis Framework is an open-source Kali tool which functions as a
platform to collaborate and report for security exports in the network
security domain. The tool is developed in Ruby language and is
independent of the platform. Dradis provides the option to export reports
and all the activities can be recorded in one single report. Exporting the
report in file formats that are PDF or DOC is currently only supported in
the pro version and is missing from the community version.
Magic Tree
Magic Tree is a Kali Linux tool that is used for reporting and data
management, and it is much like Dradis. It is designed in a way such that
data consolidation, execution of external commands, querying, and
generation of reports becomes an easy and straightforward process. Kali
Linux has this tool pre-installed and it is located at “Reporting Tools”
category. It manages the host and its associated data using the tree node
structure.
Kali Linux is the best tool available today for a penetration tester. As we
have seen in this course, Kali Linux has inbuilt tools that will help a
penetration tester throughout the penetration testing life cycle. Penetration
testing is an activity that should be adopted by every organization that
values its customers and their data, as it helps them to develop a more
secure and reliable system.
At the end of it all, it is also very important that the penetration test results
fall into the right hands, that too in a manner that was requested by the
client. The end result of a penetration test has to be a report that points out
all the vulnerabilities in the system and contains appropriate measures to fix
those vulnerabilities. Using Kali Linux for penetration testing will help you
rise the ladder in a career of penetration testing wherein you will end up
helping organizations throughout the world to make their systems and the
organization as a whole more secure. This is the best operating system for
any hacker to use.
Sources
The RFC documents, like RFC777 and RFC792, first defined the ICMP
protocol but have been revised over the years. You can find them here:
http://www.faqs.org/rfcs/rfc777.html
http://www.faqs.org/rfcs/rfc792.html
http://www.faqs.org/rfcs/rfc4443.html
https://kali.training/downloads/Kali-Linux-Revealed-1st-edition.pdf