Hacking is the most important skill set ofthe 21st century! I don’t make that state-ment lightly. Events in recent years seem toreaffirm this statement with every morning’s Headlines.
You are now ready to begin your journey into the exciting field of hacking! Welcome!
Introductory Terms and Concepts:-
Binaries This term refers to files that can be executed, similar to
executables in Windows. Binaries generally reside in the /usr/bin or
usr/sbin directory and include utilities such as ps, cat, ls, and ifconfig
(we’ll touch on all of four of these in this chapter) as well as applica-
tions such as the wireless hacking tool aircrack-ng and the intrusion
detection system (IDS) Snort.
Case sensitivity Unlike Windows, the Linux filesystem is case sensi-
tive. This means that Desktop is different from desktop, which is different
from DeskTop. Each of these would represent a different file or directory
name. Many people coming from a Windows environment can find this
frustrating. If you get the error message “file or directory not found”
and you are sure the file or directory exists, you probably need to check
your case.
Directory This is the same as a folder in Windows. A directory pro-
vides a way of organizing files, usually in a hierarchical manner.
Home Each user has their own /home directory, and this is generally
where files you create will be saved by default.
Kali Kali Linux is a distribution of Linux specifically designed for
penetration testing. It has hundreds of tools preinstalled, saving you
the hours it would take to download and install them yourself. I will be
using the latest version of Kali at the time of this writing: Kali 2018.2,
first released in April 2018.
root Like nearly every operating system, Linux has an administrator
or superuser account, designed for use by a trusted person who can do
nearly anything on the system. This would include such things as recon-
figuring the system, adding users, and changing passwords. In Linux,
that account is called root. As a hacker or pentester, you will often use
the root account to give yourself control over the system. In fact, many
hacker tools require that you use the root account.
Script This is a series of commands run in an interpretive environ-
ment that converts each line to source code. Many hacking tools are
simply scripts. Scripts can be run with the bash interpreter or any of
the other scripting language interpreters, such as Python, Perl, or Ruby.
Python is currently the most popular interpreter among hackers.
Shell This is an environment and interpreter for running commands
in Linux. The most widely used shell is bash, which stands for Bourne-
again shell, but other popular shells include the C shell and Z shell. I
will be using the bash shell exclusively in this book.
Terminal This is a command line interface (CLI).
With those basics behind us, we will attempt to methodically develop
the essential Linux skills you’ll need to become a hacker or penetration tes-
ter. In this first chapter, I’ll walk you through getting started with Kali Linux.
You should now have access to your Kali desktop (see Figure 1-2). We’ll
quickly look at two of the most basic aspects of the desktop: the terminal
interface and file structure.
The Terminal
The first step in using Kali is to open the terminal, which is the command
line interface we’ll use in this book. In Kali Linux, you’ll find the icon
for the terminal along the left of the desktop. Click this icon to open the
terminal. Your new terminal should look like the one shown in Figure
This terminal opens the command line environment, known as the shell,
which enables you to run commands on the underlying operating systems
and write scripts. Although Linux has many different shell environments,
the most popular is the bash shell, which is also the default shell in Kali and many other Linux distributions. To change your password, you can use the command passwd.
The Linux Filesystem:-
The Linux filesystem structure is somewhat different from that of Windows.Linux doesn’t have a physical drive (such as the C: drive) at the base of the filesystem but uses a logical filesystem instead. At the very top of the file- system structure is /, which is often referred to as the root of the filesystem, as if it were an upside-down tree (see Figure 1-4). Keep in mind that this is different from the root user. These terms may seem confusing at first, but they will become easier to differentiate once you get used to Linux.
The root (/) of the filesystem is at the top of the tree, and the following
are the most important subdirectories to know:
/root The home directory of the all-powerful root user
/etc Generally contains the Linux configuration files—files that control when and how programs start up
/home The user’s home directory
/mnt Where other filesystems are attached or mounted to the filesystem
/media Where CDs and USB devices are usually attached or mounted to the filesystem
/bin Where application binaries (the equivalent of executables in Microsoft Windows or applications in macOS) reside.
/lib Where you’ll find libraries (shared programs that are similar to
Windows DLLs)
We’ll spend more time with these key directories throughout this book.
Understanding these first-level directories is important to navigating through
the filesystem from the command line.
It’s also important to know before you start that you should not log in
as root when performing routine tasks, because anyone who hacks your
system (yes, hackers sometimes get hacked) when you’re logged in as root
would immediately gain root privileges and thus “own” your system. Log in
as a regular user when starting regular applications, browsing the web, run-
ning tools like Wireshark, and so on. For the practice you’ll do in this book,
staying logged in as root should be fine.
Finding Yourself with pwd:-
Unlike when you’re working in a graphical user interface (GUI) environ-
ment like Windows or macOS, the command line in Linux does not always
make it apparent which directory you’re presently in. To navigate to a new
directory, you usually need to know where you are currently. The present
working directory (or print working directory) command, pwd, returns your
location within the directory structure.
Enter pwd in your terminal to see where you are:
kali >pwd
/root
In this case, Linux returned /root, telling me I’m in the root user’s
directory. And because you logged in as root when you started Linux, you
should be in the root user’s directory, too, which is one level below the top
of the filesystem structure (/).
If you’re in another directory, pwd will return that directory name
instead.(/)
Checking Your Login with whoami:-
In Linux, the one “all-powerful” superuser or system administrator is named
root, and it has all the system privileges needed to add users, change pass-
words, change privileges, and so on. Obviously, you don’t want just anyone
to have the ability to make such changes; you want someone who can be
trusted and has proper knowledge of the operating system. As a hacker,
you usually need to have all those privileges to run the programs and com-
mands you need (many hacker tools won’t work unless you have root privi-
leges), so you’ll want to log in as root.
If you’ve forgotten whether you’re logged in as root or another user, you
can use the whoami command to see which user you’re logged in as:
Navigating the Linux Filesystem
Navigating the filesystem from the terminal is an essential Linux skill. To
get anything done, you need to be able to move around to find applications,
files, and directories located in other directories. In a GUI-based system,
you can visually see the directories, but when you’re using the command
line interface, the structure is entirely text based, and navigating the file-
system means using some commands.
Changing Directories with cd
To change directories from the terminal, use the change directory command,
cd. For example, here’s how to change to the /etc directory used to store con-
figuration files:
kali >cd /etc
kali:/etc >
The prompt changes to root@kali:/etc, indicating that we’re in the /etc
directory. We can confirm this by entering pwd:
kali:/etc >pwd
/etc
To move up one level in the file structure (toward the root of the file
structure, or /), we use cd followed by double dots (..), as shown here:
kali:/etc >cd ..
kali >pwd
/
kali >
This moves us up one level from /etc to the / root directory, but you can
move up as many levels as you need. Just use the same number of double-
dot pairs as the number of levels you want to move:
• You would use .. to move up one level.
• You would use ../.. to move up two levels.
• You would use ../../.. to move up three levels, and so on.
So, for example, to move up two levels, enter cd followed by two sets of
double dots with a forward slash in between:
kali >cd ../..
You can also move up to the root level in the file structure from any-
where by entering cd /, where / represents the root of the filesystem.
Listing the Contents of a Directory with ls
To see the contents of a directory (the files and subdirectories), we can use
the ls (list) command. This is very similar to the dir command in Windows.
kali >ls
bin initrd.img media run var
boot initrd.img.old mnt sbin vmlinuz
dev lib opt srv vmlinuz.old
etc lib64 proc tmp
home lost+found root usr
This command lists both the files and directories contained in the
directory. You can also use this command on any particular directory, not
just the one you are currently in, by listing the directory name after the
command; for example, ls /etc shows what’s in the /etc directory.
To get more information about the files and directories, such as their
permissions, owner, size, and when they were last modified, you can add
the -l switch after ls (the l stands for long). This is often referred to as
long listing. Let’s try it here
Getting Help
Nearly every command, application, or utility has a dedicated help file in
Linux that provides guidance for its use. For instance, if I needed help
using the best wireless cracking tool, aircrack-ng, I could simply type the
aircrack-ng command followed by the --help command
kali >aircrack-ng --help
Note the double dash here. The convention in Linux is to use a double
dash (--) before word options, such as help, and a single dash (-) before
single-letter options, such as –h.
When you enter this command, you should see a short description of
the tool and guidance on how to use it. In some cases, you can use either -h
or -? to get to the help file. For instance, if I needed help using the hacker’s
best port-scanning tool, nmap, I would enter the following:
kali >nmap -h
Unfortunately, although many applications support all three options
(--help, -h, and -?), there’s no guarantee the application you’re using will.
So if one option doesn’t work, try another.
Referencing Manual Pages with man
In addition to the help switch, most commands and applications have a
manual (man) page with more information, such as a description and syn-
opsis of the command or application. You can view a man page by simply
typing man before the command, utility, or application. To see the man page
for aircrack-ng, for example, you would enter the following:
kali >man aircrack-ng
NAME
aircrack-ng - a 802.11 WEP / WPA-PSK key cracker
SYNOPSIS
aircrack-ng [options] <.cap / .ivs file(s)>
DESCRIPTION
aircrack-ng is an 802.11 WEP and WPA/WPA2-PSK key cracking program.
It can recover the WEP key once enough encrypted packets have been
captured with airodump-ng. This part of the aircrack-ng suite deter-
mines the WEP key using two fundamental methods. The first method is
via the PTW approach (Pyshkin, Tews, Weinmann). The main advantage
of the PTW approach is that very few data packets are required to
crack the WEP key. The second method is the FMS/KoreK method. The
FMS/KoreK method incorporates various statistical attacks to dis-
cover the WEP key and uses these in combination with brute forcing.
Additionally, the program offers a dictionary method for determining
the WEP key. For cracking WPA/WPA2 pre-shared keys, a wordlist (file
or stdin) or an airolib-ng has to be used.
This opens the manual for aircrack-ng, providing you with more
detailed information than the help screen. You can scroll through this
manual file using the enter key, or you can page up and down using the
pg dn and pg up keys, respectively; you can also use the arrow keys. To exit,
simply enter q (for quit), and you’ll return to the command prompt.
" Thank You "
Also Join Our Telegram Channel:-