Kali Linux

❗ This page is under construction…

Basic Installation

See Create Bootable USB drive with Kali Linux Installer.

💡 Kali changed to a non-root user policy by default since the release of 2020.1. Follow these steps to reset root password.

Software selection

Select “Xfce” and “large”, unselect the rest.

When things go wrong…

If installation fails at “Software install” but Kali is installed without a desktop interface

apt-get update && apt-cache search kali-linux
apt install kali-linux-everything

Install the desktop graphical user interface

sudo apt install task-xfce-desktop
sudo systemctl set-default graphical.target
sudo reboot

Installation on VMware

💡 Exclude path of your virtual machine from the AV and add exception for http://kali.download/*

Using Offensive Security’s VMware image

  • Download VirtualBox Kali image from Offensive Security
  • Double-click on the downloaded file
  • Set the RAM to 1024MB and create a shared folder.
  • Reset the root password if needed. Default user/password is kali/kali.
  • Configure the proxy if needed.
  • Fix copy/paste between host and VM
  • Follow Setup steps below.

Add a shared folder

https://www.kali.org/docs/virtualization/install-vmware-guest-tools/

  • Player -> Manage -> Vitual Machine Settings.
  • Select the Options tab -> Shared Folders.
  • Add the folder that should be shared.
sudo su -
cat <<EOF | sudo tee /usr/local/sbin/mount-shared-folders
#!/bin/sh
vmware-hgfsclient | while read folder; do
  vmwpath="/mnt/hgfs/\${folder}"
  echo "[i] Mounting \${folder}   (\${vmwpath})"
  sudo mkdir -p "\${vmwpath}"
  sudo umount -f "\${vmwpath}" 2>/dev/null
  sudo vmhgfs-fuse -o allow_other -o auto_unmount ".host:/\${folder}" "\${vmwpath}"
done
sleep 2s
EOF
chmod +x /usr/local/sbin/mount-shared-folders

Mount

sudo mount-shared-folders
cd /mnt/hgfs
ls -la

Troubleshooting

VM disappears from VMware

  • Go to the virtual machine folder
  • Create a backup folder.
  • Move all .lck folders to the backup folder.
  • Double-click on the .vmx file.

Installation on VirtualBox

💡 Exclude path of your virtual machine from the AV and add exception for http://kali.download/*

Set VirtualBox Preferences

  • Click File -> Preferences -> General, set Default Machine Folder to “C:\VM” or any other path you choose
  • Click File -> Preferences -> Network, add NAT Networks

Using Offensive Security’s VirtualBox image

  • Download VirtualBox Kali image from Offensive Security
  • Double-click on the downloaded file (.vbox)
  • Right-click on the machine name, click on Settings
    • Click on System, set the RAM to 1024MB
    • Click on Shared Folders, create a shared folder
  • Reset the root password if needed. Default user/password is kali/kali.
  • Configure the proxy if needed.
  • Follow Setup steps below.

Installation in a new virtual machine

Download Kali Linux

Determine which Kali Linux installer to use

# On Mac OS X
uname -m
  • x86_64: use the 64-bit ISO image (the one containing “amd64” in the file name), like kali-linux-2020.3-amd64.iso
  • i386: use 32-bit image (the one containing “i386” in the file name)

Download Kali Linux image from Kali.org

# Check that the checksum matches the one on the website
shasum -a 256 kali-linux-2020.3-amd64.iso

Create a virtual machine

❗ If the wrong OS version is selected, it will give SEGFAULT in the syslog.

Click Machine -> New
Name: Kali 64
Type: Linux
Version: Debian (64-bit)
Memory size: 1024MB (or 2G if you have enough RAM)
Select "Create a virtual hard disk now"
Click Create
File location: C:\VM\<Virtual Machines folder>\Kali 64.vdi
File size: 30GB (or more if possible)
Hard disk file type: VDI (VirtualBox Disk Image)
Storage on physical hard disk: Dynamically allocated
Finish

Click on Settings
General -> Avanced
Shared Clipboard: Bidirectional
Drag'n'Drop: Bidirectional
System -> Processor: 2
Click OK
Click Start
Select the .iso file
Choose Graphical Install
Choose English for install
Select Canada as location
Keyboard Canadian French
Hostname: kali64
domain name: leave empty
Enter user name (Full name)
Enter user name (for login)
Enter password for user

Enter root password and keep note of it in password manager
Timezone: Eastern

Partition: Guide - use entire disk and set up LVM
Partition: Guided using entire disk

All files in one partition
Write changes to disk: yes
network mirror: yes

proxy: leave empty
# Or find proxy information from http://wpad/wpad.dat

install GRUB boot loader: yes
Select /dev/sda

Fix: Screen upside down problem

xrandr --listmonitors
xrandr -o normal
xrandr --output VGA-1 --rotate inverted

Install VirtualBox Guest Additions

vi /etc/fstab
# Change /dev/s0 to user,noauto,exec   (add exec)
# The user option automatically implies noexec which strips executable bits off all binary files on the mounted file system

# Install Linux headers
apt-get install linux-headers-$(uname -r)

# If it gives an error
# apt-cache search linux-headers
# apt install linux-headers-amd64

####### IMPORTANT ####
Menu Devices -> Insert Guest Additions CD Image
If not prompted by auto-run, run "VBoxLinuxAdditions.run" from the CD.

# Need to run this after or it won't work
apt-get install -y virtualbox-guest-x11

Add a shared folder

Click on Settings -> Shared Folders
Select Machine Folders
Click on + to add a shared folder, name it "shared"
Auto-mount: Yes
Access: Full

Reboot the vm

Should appear in /media/sf_Shared

Installing VirtualBox on Kali Linux

# Install virtualbox package. virtualbox-ext-pack needs license agreement. 
apt install -y linux-headers-amd64
apt install -y virtualbox virtualbox-guest-additions-iso virtualbox-ext-pack

Do you accept the terms of the VirtualBox PUEL license? [yes/no] yes

# Run virtualbox command
virtualbox

Setup

Set default shell

Change kali and root default shell to /bin/bash.

sudo nano /etc/passwd

Change the time zone

  • On the upper right corner, right-click on the time.
  • Click Properties.
  • Set the timezone.

Change the keyboard settings

  • Click on Kali menu -> Settings -> Settings manager -> Keyboard.
  • Under the Layout tab:
    • Disable Use system defaults
    • Add the appropriate language (French – Canada) and remove other layouts

Change privacy and power settings

❗ These settings example are for a virtual machine, review as needed.

  • Click on Kali menu -> Settings -> Settings manager -> Power Manager.
  • Under Display: (do for both On battery and Plugged in)
    • Blank after: Never
    • Put to sleep after: Never
    • Switch off after: Never
  • Under the Security tab:
    • Automatically lock the session: Never
    • Unselect Lock screen when system is going to sleep

Change default passwords

  • OS (OffSec VM): kali/kali
  • BeEF-XSS: beef/beef, config: /etc/beef-xss/config.yaml
  • MySQL: root/<blank>, setup: mysql_secure_installation
  • OpenVAS: admin/<generated at setup>, setup: openvas-setup
  • Metasploit: postgres/postgres, config: /usr/share/metasploit-framework/config/database.yml

Kali Linux

Default password for kali is kali.

passwd
sudo passwd root

Beef-xss (not installed by default anymore)

Username: beef
Password: beef
nano /etc/beef-xss/config.yaml

MySQL

User root has default password set to blank (no password).

sudo systemctl start mysql
sudo mysql_secure_installation
[Switch to unix_socket authentication [Y/n] n]
[Change the root password? [Y/n] y]
[Remove anonymous users? [Y/n] Y]
[Disallow root login remotely? [Y/n] Y]
[Remove test database and access to it? [Y/n] Y]
[Reload privilege tables now? [Y/n] Y]
quit
sudo systemctl stop mysql

PostgreSQL

User postgres has password postgres.

sudo systemctl start postgresql.service
sudo -u postgres psql postgres
\password postgres
\q
sudo systemctl stop postgresql.service

Download SecLists

cd /usr/share
git clone https://github.com/danielmiessler/SecLists.git
mv /usr/share/SecLists /usr/share/seclists

Set repository for installs & updates

sudo nano /etc/apt/sources.list

Should contain (uncomment) & set HTTPS:

# See https://www.kali.org/docs/general-use/kali-linux-sources-list-repositories/
deb https://http.kali.org/kali kali-rolling main contrib non-free non-free-firmware

# Additional line for source packages
deb-src http://http.kali.org/kali kali-rolling main contrib non-free non-free-firmware
# Refresh
sudo apt-get clean

Apply updates

❗ Be careful during a penetration test not to brake anything…

If behind a proxy, configure proxy settings.

apt-get update
apt-get -y full-upgrade
apt autoremove

Import SSL certificates for the whole system

See SSL Certificates.

Create Bootable USB drive with Kali Linux Installer

Download Kali Linux (Installer)

# Determine which Kali Linux installer to use
# On Mac OS X
uname -m
  • x86_64: use the 64-bit ISO image (the one containing “amd64” in the file name), like kali-linux-2020.3-amd64.iso
  • i386: use 32-bit image (the one containing “i386” in the file name)

Download Kali Linux image – Bare Metal 64-bit Installer – from Kali.org

# Check that the checksum matches the one on the website
shasum -a 256 kali-linux-2020.3-installer-amd64.iso

Identify the device path to write the image to the USB drive

Without the USB drive plugged into the system, open a Terminal

Mac OS X

diskutil list

Linux

df

Plug in the USB key and check which path is new

Mac OS X

diskutil list

Linux

df

Mac OS X

#Result: /dev/disk4

Linux

#Result: /dev/sdb1

Unmount the drive (DO NOT UNPLUG)

IMPORTANT: Do NOT unplug the USB key

Mac OS X

DO NOT SIMPLY COPY THIS – VERIFY THE CORRECT PATH (CHANGE /dev/disk4)

diskutil unmount /dev/disk4

or

diskutil unmountDisk /dev/disk4

Linux

sudo umount /dev/sdb1

Format the USB key if needed

DO NOT SIMPLY COPY THIS – VERIFY THE CORRECT PATH

Mac OS X

diskutil eraseDisk free EMPTY /dev/disk3
diskutil list
diskutil eraseDisk MS-DOS USBKALI /dev/disk3

Linux

sudo mkfs.vfat /dev/sdb1

Image the Kali Linux ISO file on the USB drive

Note: Increasing the blocksize (bs) will speed up the write progress, but will also increase the chances of creating a bad USB stick. Using the given value on OS X has produced reliable images consistently.Imaging the USB drive can take a good amount of time, 40 minutes is not unusual. Check that the bytes transferred correspond to the .iso size.

To boot from an alternate drive on an OS X system, bring up the boot menu by pressing the Alt Key (or Option key) immediately after powering on the device and select the drive you want to use.

DO NOT SIMPLY COPY THIS – VERIFY THE CORRECT PATH

Mac OS X

sudo dd if="/Users/someuser/kali-linux-2020.3-installer-amd64.iso" of=/dev/disk4 bs=1m

Linux

sudo dd if=/root/Downloads/kali-linux-2020.3-installer-amd64.iso of=/dev/sdb1 bs=4M

Windows

Making a Kali Bootable USB Drive (Windows)

  • Download the portable version of Etcher for Windows (recommended from Kali documentation).
  • Insert USB drive into the Windows computer
  1. Click Flash from file
  2. Select the Kali ISO file and click Open
  3. Click Select target
  4. Select the USB drive and click Select
  5. Click the Flash! button.