Day 1 OSCP | Starting with Kali Linux

Reading Time: ( Word Count: )

December 6, 2020

Intro

Let’s get started

What is an ethical hacker or penetration tester?

  • An ethical hacker looks for weaknesses in a system and tries to manipulate them to gain access legally. Reporting the vulnerabilities afterwards to the customer for patching to prevent others from using them illegally against them.

So what is Kali Linux, and why should we use it rather than other operating systems out there?

Kali Linux is the operating system most hackers use or used before others came out, like Parrot, BackBox, DEFT Linux, BlackArch Linux, etc. Kali Linux is a free OS with all the tools for beginners and advanced users to do penetration tests and security analytics. When we advance, we can also start exploring the other systems’ workings.

I will be using Kali Linux in a virtualized environment with VMware Workstation Pro, but you can also use the free version for personal use or VirtualBox.

Go to https://www.kali.org/downloads/ to download the latest version for your hypervisor.

 

Commands

After configuring the system, let us get to the basics.

Simply press Alt + Ctrl + T to open the terminal.

 

Changing the default password

First, we want to change the default password (kali) that’s been previously configured by typing “passwd“.

Type the current password, followed twice by the new password.

  ┌──(kali㉿kali)-[~]      └─$ passwd Changing password for kali. Current password: New password: Retype new password: passwd: password updated successfully

 

Printing (showing) the current working directory

pwd stands for “print working directory.” It writes the full pathname of the current working directory.

  ┌──(kali㉿kali)-[~]      └─$ pwd /home/kali

 

Changing the current working directory

cd stands for “change directory” & when you hit TAB twice, you can see where you can go. You can use your arrows on the keyboard to navigate and “Enter” to select. To go back, “cd ..

  ┌──(kali㉿kali)-[~]      └─$ cd Desktop/ Desktop/ Documents/ Downloads/ Music/ Pictures/ Public/ Templates/ Videos/
  ┌──(kali㉿kali)-[~/Desktop]      └─$ pwd /home/kali/Desktop
  ┌──(kali㉿kali)-[~/Desktop]      └─$ cd ..
  ┌──(kali㉿kali)-[~]      └─$ pwd /home/kali

 

Creating a new directory

mkdir stands for “make directory”. We can also create multiple directories at once with “mkdir -p“, which will also create any required parent directories.

Let’s create a directory called “notes” and within that directory, two sub-directories called “basics” and “scripting” (avoid spaces within your filenames or use “-” or “_” to save yourself some headache later).

ls” is for showing the files in the current working directory, when we include “notes/”, we see the files in that directory.

  ┌──(kali㉿kali)-[~]      └─$ mkdir new
  ┌──(kali㉿kali)-[~]      └─$ ls new
  ┌──(kali㉿kali)-[~]      └─$ mkdir -p notes/{basics,scripting}
  ┌──(kali㉿kali)-[~]      └─$ ls notes/ basics scripting

 

Removing an empty directory

rmdir stands for “remove (empty) directory“, it will only work if the directory is empty. Typing “ls” afterwards doesn’t show anything, because we deleted the empty directory. We can also force delete with the “-rf” option added.

  ┌──(kali㉿kali)-[~]      └─$ rmdir new
  ┌──(kali㉿kali)-[~]      └─$ ls

 

Creating and running a new file

echo is usually used to display a line of text, but can also be used to create a file. I’ll show you both.

Suppose you want to add a second line of text, to the existing file & not overwrite it. Then you add a second “>“.

cat (short for “concatenate “) command is one of the most frequently used commands in Linux/Unix like operating systems. The “cat” command allows us to create single or multiple files, view the contents of a file, concatenate files and redirect output in terminal or files.

Other ways to create files:

touch comes by default.

nano comes by default (we create & enter the file to edit it, just like a text editor in the terminal).

gedit is my favourite, but not included in the default kali image. (text editor not on the terminal, more comfortable to navigate & possible to use the mouse).

  ┌──(kali㉿kali)-[~]      └─$ echo "hello" hello
  ┌──(kali㉿kali)-[~]      └─$ echo "hello" > new.txt
  ┌──(kali㉿kali)-[~]      └─$ cat new.txt hello
  ┌──(kali㉿kali)-[~]      └─$ echo "hellow there" > new.txt (now we overwrote the file)
  ┌──(kali㉿kali)-[~]      └─$ cat new.txt hellow there
  ┌──(kali㉿kali)-[~]      └─$ echo "how are you doing?" >> new.txt hellow there how are you doing?
  ┌──(kali㉿kali)-[~]      └─$ touch new2.txt (creates a new2.txt file)
  ┌──(kali㉿kali)-[~]      └─$ cat > new3.txt Hello there! How are you? ^C (Ctrl+C) → to save and exit
  ┌──(kali㉿kali)-[~]      └─$ ls new.txt new2.txt new3.txt
  ┌──(kali㉿kali)-[~]      └─$ cat new3.txt Hello there! How are you?

 

Copying and moving a file

cp is for copying and “mv is for moving a file to a different directory. Let’s first copy the “new.txt” to the “Desktop/” and afterwards see if it’s been copied successfully with the “ls command (more on it later).

We don’t need to be in the directory of the copied or moved file to check if it’s there. The “mv” command can also be used to rename a file while moving. If we move the “new.txt” file again from “Downloads/” to “Desktop/” but use a different name for the destination, it’ll change. 

  ┌──(kali㉿kali)-[~]      └─$ cp new.txt Desktop/new.txt
  ┌──(kali㉿kali)-[~]      └─$ ls Desktop/ new.txt
  ┌──(kali㉿kali)-[~]      └─$ mv new.txt Downloads/new.txt
  ┌──(kali㉿kali)-[~]      └─$ ls Downloads/ new.txt
  ┌──(kali㉿kali)-[~]      └─$ mv Downloads/new.txt Desktop/renamed.txt
  ┌──(kali㉿kali)-[~]      └─$ ls Desktop/ renamed.txt

 

Removing a file

rm stands for remove. Let’s remove the “renamed.txt” file that we’ve recently moved and renamed to the “Desktop/”. We don’t need to be in the directory of the file to delete it. In case you get an error message, try using the “-rf” option to forcefully remove it.

  ┌──(kali㉿kali)-[~]      └─$ rm Desktop/renamed.txt
  ┌──(kali㉿kali)-[~]      └─$ ls Desktop/

 

Listing the files

ls stands for “list“, to see what we have in the current or specified folder.

ls -la” stands for “list all“, includes the hidden files too.

-l” option is for long listing format (includes permissions)

 “-a” or “–all” means do not ignore entries starting with “.“, which are hidden.

Below we see the files and directories that are assigned permissions and colour coded on the terminal for their type:

d” in the beginning (highlighted) of the permissions, stands for “directory”, it’s also colour coded as blue.

If it were a “” instead of “d“, like the third file (.bash_history) on the terminal below, then that would mean it’s a “file rather than a “directory and would be colour coded as white. See below for all colour codings.

l” below for the “.face.icon stands for Symbolic link file, which is a shortcut to the real path.

Color Coded

Blue: Directory Green: Executable or recognized data file Sky Blue: Symbolic link file Yellow with black background: Device Pink: Graphic image file Red: Archive file Red with black background: Broken link

 

Permissions/Access:

rwx” stands for read-write-execute

 “rw” → read-write

 “r” → read

 If switched on, it’ll be either rw or x, otherwise a ““.

The permissions are separated into three groups:

The first grouprwx” is for the file/folder owner.

The second grouprwx is for the group ownership permissions.

The third grouprwx are all other permissions, let’s say we create an account for Bob, he’ll only have the “read” access/permission by default.

Later I’ll cover how to add/change file or directory permissions with the “chmod” command.

  ┌──(kali㉿kali)-[~]      └─$ ls Desktop Documents Downloads Music Pictures Public Templates Videos
  ┌──(kali㉿kali)-[~]      └─$ ls -la total 136 drwxr-xr-x 15 kali kali 4096 Dec 3 05:41 . drwxr-xr-x 3 root root 4096 Nov 17 07:31 .. -rw-r--r-- 1 kali kali 1 Nov 17 09:49 .bash_history -rw-r--r-- 1 kali kali 220 Nov 17 07:31 .bash_logout -rw-r--r-- 1 kali kali 4503 Nov 17 07:31 .bashrc -rw-r--r-- 1 kali kali 3526 Nov 17 07:31 .bashrc.original drwxr-xr-x 9 kali kali 4096 Dec 2 03:31 .cache drwx------ 11 kali kali 4096 Nov 21 06:19 .config drwxr-xr-x 2 kali kali 4096 Dec 3 05:32 Desktop -rw-r--r-- 1 kali kali 55 Nov 17 09:06 .dmrc drwxr-xr-x 2 kali kali 4096 Nov 17 07:33 Documents drwxr-xr-x 2 kali kali 4096 Nov 29 07:19 Downloads -rw-r--r-- 1 kali kali 11759 Nov 17 07:31 .face lrwxrwxrwx 1 kali kali 5 Nov 17 07:31 .face.icon -> .face drwx------ 3 kali kali 4096 Dec 2 03:31 .gnupg -rw------- 1 kali kali 0 Nov 17 07:33 .ICEauthority drwxr-xr-x 3 kali kali 4096 Nov 17 07:33 .local drwx------ 5 kali kali 4096 Nov 21 04:21 .mozilla drwxr-xr-x 2 kali kali 4096 Nov 17 07:33 Music drwxr-xr-x 2 kali kali 4096 Nov 17 07:33 Pictures -rw-r--r-- 1 kali kali 807 Nov 17 07:31 .profile drwxr-xr-x 2 kali kali 4096 Nov 17 07:33 Public drwxr-xr-x 2 kali kali 4096 Nov 17 07:33 Templates drwxr-xr-x 2 kali kali 4096 Nov 17 07:33 Videos -rw------- 1 kali kali 49 Dec 2 03:31 .Xauthority -rw------- 1 kali kali 7104 Dec 3 04:10 .xsession-errors -rw------- 1 kali kali 10132 Nov 29 07:44 .xsession-errors.old -rw-r--r-- 1 kali kali 2686 Dec 2 03:31 .zsh_history -rw-r--r-- 1 kali kali 8063 Nov 17 07:31 .zshrc

 

Bonus command: whoami

whoami prints the username associated with the current effective user id. Same as “id -un“.

  ┌──(kali㉿kali)-[~]      └─$ whoami kali

Other interesting articles

How Many Types of Penetration Testing are There?

How Many Types of Penetration Testing are There?

A penetration test is a deliberate attack on a software or hardware system with the goal of exposing security ...
5 Types of Social Engineering Attacks and How to Prevent Them

5 Types of Social Engineering Attacks and How to Prevent Them

The term "social engineering" refers to a wide range of malevolent behaviours carried out through human ...
What are Some Risks and Benefits of Performing Penetration Testing?

What are Some Risks and Benefits of Performing Penetration Testing?

In the world of cyber security, various methods and tests are conducted to ensure the security barrier of a ...
How to Hire the Best IT Security Consultant: 4 Simple Tips

How to Hire the Best IT Security Consultant: 4 Simple Tips

Whether you run an online business or an offline store, your business needs to be secure. You might be surprised, ...
0 Comments

Submit a Comment

Your email address will not be published.

error: Alert: Content is protected !!