Hacking With Kali Linux-Part 1 PDF
Hacking With Kali Linux-Part 1 PDF
Introduction
Welcome to hacking with Kali Linux!
This Kali Linux course covers the basics and does not require any prior knowledge
of Linux or ethical hacking.
3. Allocate memory and virtual CPUs to the VM, with a minimum of 2 GB of RAM
and 1 CPU recommended for Kali Linux. Click Next when done.
5. Review the new VM setup on the Summary page. Select Finish to create the
virtual machine.
3. Ensure the network your Kali machine is running on is set to NAT network , and
the previously created network is selected.
3. Find and select your country from the list, or choose other.
2. Type a domain name that the OS will use to identify the VM within a network.
Specifying a domain name is not necessary if the VM is not part of an extensive
3. Create a user account by providing the user's full name and username.
4. Create a strong password for the user account.
1. Select how to partition the hard disk. The default option is Guided - use entire
disk.
4. The wizard provides an overview of the configured partitions. Ensure that the
Finish partitioning and write changes to disk option is selected.
5. Confirm the choice by selecting Yes on the next screen.
1. Select the desktop environment and the tools you want, or click Continue to
proceed with the default options.
3. If you use an HTTP proxy, enter the necessary information. Otherwise, leave
the field blank.
4. Install the GRUB bootloader on the hard disk. Select Yes and Continue.
5. Select a bootloader device to ensure the newly installed system is bootable.
2. Select the desired architecture and click the download button in the bottom left
corner of the VirtualBox card.
5. Locate the virtual machine file you downloaded and unpacked. Double-click the
file to open it.
A Kali Linux VM instance appears in the menu on the left side of the screen.
6. Select the instance and click the Start button in the top menu.
System Requirements
The requirements for VMware Player and VMware Workstation Pro are very
similar, as detailed below.
CPU: You'll need a 64-bit processor with a core speed of at least 1.3 GHz.
Disk Space: Workstation Player only requires 150 MB of free disk space for
installing the software. If you install Workstation Pro, you'll require
approximately 1.2 GB of free disk space for the application installation.
Here are the minimum system requirements for installing Kali Linux on VMware:
You will be taken to the Broadcom website where you must create an account and
sign in.
Accept the license agreement and click Next. Click Next three more times, and
finally, click Install. Once VMware is installed, click Finish, and you can proceed to
install Kali on VMware.
Alternatively, if you want to download the .iso file, head over to the Kali website
and download the
Kali installer image.
We will show you how to Install the image on both the Pro version.
Locate the extracted Kali VMware virtual configuration file and click Open.
Username kali
Password kali
Cloning a VM
Another great feature in VMware Pro is the ability to clone a VM, allowing you to
create multiple base systems for testing different configurations. Unlike
snapshots, which can't run simultaneously with the original, VM clones can
operate at the same time. Keep in mind that cloning requires additional disk space
since it creates another VM. To create a clone in VMware Pro, open the VM menu,
click on Manage, and then select "Clone.”
pack ,
Go to the downloads page, scroll down and click all supported platforms to download.
Click the plus sign, find your download, and install it, making sure to accept the
terms.
Lastly, go to the network tab and click create while inside the NAT Networks window.
1. Click on the machine you want to set the NAT Network connection for, and
click settings
Sudo Usage
The sudo command, short for superuser do , allows us to run commands with
elevated privileges. For instance, to view the sensitive /etc/shadow file, we use sudo
cat /etc/shadow . This command runs as root , granting access to the file.
Best practices
While most commands in this course may require sudo , it’s best to run commands
as a regular user and use sudo only when necessary. This is possible because
‘Kali’ is part of the ‘sudoers’ file, granting it permission. Not all users have this
privilege; a new user ‘john’ would need permission to run commands as ‘root’.
Thus, ‘Kali’ acts as an administrator only when needed.
sudo su
pwd
You can run sudo su to switch to root and su kali to switch back to kali.
sudo su
su kali
clear
We’ll now explore file system navigation with the ls and cd (list and change
directory) commands.
To list the contents of the directory you’re currently in, type ls :
ls
cd Downloads
cd ..
To clear the screen, use Ctrl + L. To list files and folders in the current directory,
use ls . Folders appear in dark blue, and files in various colors.
To return to the ‘home’ folder, type cd h and hit Tab for auto-completion. If there
are multiple options, type enough to differentiate and press Tab.
cd home
cd kali
because it’s not directly accessible. You need to use the full path, like cd /etc , to
navigate to it from anywhere. Use Tab to see available folders and ls to list
contents.
cd /etc
ls
cd ~
If you want to list files in 'etc' without changing directories, just use ls /etc .
ls /etc
mkdir test
ls
cd test
cd ..
rmdir test
ls -la
man ls
ls -la
cd ~
Let's cd back to our home folder. Now, I'll introduce the echo command. For
example, echo 'hi' simply prints "hi" to the screen. We'll cover echo in more detail
later.
cp test.txt Downloads
ls Downloads
rm Downloads/test.txt
and to move the file entirely, we use mv , which relocates it without leaving a copy
behind. The key difference is that cp copies while mv moves the file.
mv test.txt Documents/
test.txt . Initially, it may not return the file if the database isn't updated.
locate test.txt
sudo updatedb
Enter your password to update the database. Then, rerun locate test.txt , and
you'll see the correct file path, like /home/kali/downloads/test.txt . Hitting the right
arrow can also auto-complete your previous command.
Autocompleting commands
To navigate previous commands, use the up and down arrows. For example, to
quickly re-run locate test.txt , hit the up arrow on your keyboard and press Enter.
Also, remember that file and folder names are case-sensitive. For instance, cd
downloads won't work if the directory is named Downloads . To navigate correctly, use
the right case. Auto-complete can help—type cd d and press Tab to auto-
complete to Downloads if it exists.
passwd
Enter your current password (e.g., kali ), then type your new password (e.g.,
'password'). Your password will be updated successfully. That covers all the
commands for this section. See you in the next section.
ls -la
means the owner has read, write, and execute permissions, while others have
read and execute permissions only.
Permissions are grouped into three sets: for the owner, the group, and others. For
instance, if the owner is kali , the first set of permissions ( rwx ) applies to k ali . In
our home folder, files are typically owned by the user kali .
Understanding groups
Let's discuss group and other user permissions. Group members can read and
execute, but not write to files or directories. All other users can also read and
execute, but cannot write.
For example, in the tmp folder, which has read, write, and execute permissions,
it's a useful location for pen testing. You can drop and execute files here without
worrying about permissions. This folder is often used to upload malware or write
malicious files during attacks.
In pen testing and scripting, having execute permissions is crucial. If you can't
execute a script, you'll need to change its permissions first, especially when
working with downloaded files or scripts in our bash scripting section.
has read and write permissions but no execute permissions. This means it can't
be run as a script.
cd tmp
echo "hello" > test.txt
ls -la | grep hello.txt
After running this command and checking with ls -la , you'll see the permissions
have changed.
Alternatively, you can use chmod 777 hello.txt , which sets full read, write, and
execute permissions for everyone.
sets read (4), write (2), and execute (1) permissions for all users, totaling 7. Here's
a quick breakdown:
0 = no permissions
400 = owner has read only (common for SSH PEM files)
You can refer to a chart or search online for more details on chmod numbers. For
full permissions, use 777 , but for specific files like PEM files, you might use 644 or
400 .
After setting up the user, switch to John using su john and enter John's password.
su john
For passwords, check cat /etc/shadow (requires sudo access). If John lacks sudo
privileges, switch back to Kali using su kali and run sudo cat /etc/shadow .
Next, review the sudoers file with sudo cat /etc/sudoers . This file defines who can
execute commands with sudo.
This will list users with sudo privileges, such as Kali in this case. To grant sudo
access to John, add him to the sudo group in /etc/group or configure specific
permissions in the sudoers file using the following:
sudo -l
ip a
ip addr
Ifconfig
You can also use the ifconfig command to view network information, which
provides similar details as ip a . ifconfig is the older method and might require
sudo or be absent on some systems, while ip is newer and more colorful.
ifconfig
ip n
This is similar to the arp -a command. ARP (Address Resolution Protocol) maps IP
addresses to MAC addresses. When querying ARP, a broadcast message asks,
arp -a
You can use either the ip command or the older arp command, with ip being
more modern and user-friendly.
Another useful command is ip r (for route), similar to route . This displays the
routing table, showing how traffic is directed. For example, it shows the gateway
and network mask. Understanding routing is crucial, as you might find routes to
networks outside your current subnet.
ip r
This knowledge is vital during pen tests, where routes might be adjusted to
access otherwise isolated networks. Knowing how to add and remove routes is
essential for effective network navigation and penetration testing.
ping google.com
The ping command verifies if a machine is online and responds to ICMP requests.
However, a lack of response might mean ICMP is disabled or the host is
unreachable. For instance, pinging an unused IP address might show "host
unreachable," indicating either the host is not present or ICMP is disabled.
Ping sweeping is useful for network host discovery, which will be covered in more
detail later. Although we didn't cover netstat in this section—used for identifying
open ports and services—it will be discussed later in the course.
cd /tmp
echo hello
To append to a file, use >> instead of > . For example, echo hello again >> hey.txt
adds to the file without overwriting. This is useful for scripting where you might
gather data (like IP addresses) and need to append multiple entries.
touch newfile.txt
To edit files, you can use terminal editors like nano (my preferred choice for
simplicity) or vi / vim . For instance, nano newfile.txt allows you to edit and save the
file.
For graphical text editing, mousepad is an option similar to Notepad. You can open
and modify files with mousepad newfile.txt , and save changes with Ctrl+S.
cat newfile.txt
With editors like nano or mousepad , you can create new files. For example, use nano
brandnewfile.txt , type your content, then save with Ctrl+X, Y, and Enter. You can
verify the file with cat brandnewfile.txt .
http://127.0.0.1:80
The files served by Apache are located in the /var/www/html directory. You can host
any file there, including malicious ones if needed.
While Apache is useful, I now prefer Python for quick and easy file hosting. To do
this, create a file with echo hello > hello.txt , then start a web server with python3 -m
http.server 80. This will serve all files in the current directory on port 80. It’s a fast
and efficient way to host a web server without managing services.
cd tmp
echo hello > hello.txt
do python3 -m http.server 80
disable ssh . These commands are crucial for managing services and ensuring they
run when needed.
sudo su
Then, run the update and upgrade commands again. You'll see a list of packages
that need upgrading, and you'll be asked if you want to proceed. Be cautious, as
updating Kali can sometimes break tools. Always back up your system before
making significant changes.
If you need to install specific tools, you can do so with the apt install command.
For instance, to install gobuster and seclists , you would run:
sudo apt install gobuster seclists
Gobuster is a tool used for brute-forcing URIs (directories and files) in web
servers, as well as DNS subdomains, making it valuable in penetration testing.
Installing Aquatone
Before diving into Pimpmykali, let's install Aquatone, a tool used for visual
reconnaissance of websites across a large number of hosts. Here's how to get it
up and running:
unzip <aquatone_filename>
move <aquatone_filename>
3. Set Permissions:
Aquatone is now installed and ready to use for scanning and visualizing websites.
Installing Pimpmykali
su kali
cd /opt/pimp-my-kali
ls
sudo ./pimpmykali.sh
Then follow the prompts of the script. I recommend the N option since this is a
new VM setup.
After a few minutes, you'll be asked if you want to enable root login. In Kali 2019.x,
the default user was root, but now it's kali . If you feel comfortable running as
root, select "yes" and set a new root password. If not, sticking with the kali user
is perfectly fine.
If you choose to copy everything from the kali folder to the root folder, that's up
to you. I chose "no," but this step is optional.
Once everything is done, you'll see an "All done, happy hacking" message. If you
chose the root option, you can log out and back in as root; otherwise, continue
using the kali user.