Introduction to Linux – Practical Ethical Hacking by TCM

by Kal Bartal

Exploring Kali Linux

Kali Linux is essentially an ethical hacking distribution of Linux and it’s built on Debian.

Sudo Overview

The default user is ‘kali’ with no root privileges in Kali Linux. This is an improved security feature as certain commands can only be run as root users.

These commands can be run with elevated user privileges using ‘sudo’.

‘Sudo’ allows the command to rung as a one-off scenario. As a best practice, all commands should be run as a regular user and use ‘sudo’ as necessary.

Only users that are part of the sudoers file can use ‘sudo’.

Switching over to ‘root’.

sudo su -

This instance of root is only good for the current tab.

Navigating The File System

‘~’ means the user’s home folder

Print working directory

pwd

Change directory

cd

(control + L to clear the screen)

List what’s in the current directory

ls

Making a directory

mkdir kal

Removing a directory

rmdir kal

List all (long all) (use to list hidden files)

ls -la

Man pages (manuals)

man ls

Help (less detailed)

ls --help

‘Echo’ out to the screen or file

echo 'Hi!'
echo 'Hi!' > test.txt

Copying files

cp test.txt Downloads

Moving files

mv test.txt Downloads

Locating files

locate test.txt

Autocompleting

‘tab’, ‘up arrow’ and ‘right arrow’ can be used for autocompleting a command

Changing password

passwd

Users and Privileges

‘d’ = directory (marked blue)
‘-‘ = file (marked white)
‘l’ = link (marked lighter blue)

rwx = read, write, execute

In the first item:
1st group – rwx – the owner of the file/directory
2nd group – r-x – group ownership
3rd group – -x – all other users

The temp folder typically has ‘rwx’ privileges, ideal for pen-testing and dropping a file in there.

Changing privileges

chmod +777 hello.txt
chmod +rwx hello.txt

Adding a user

sudo adduser sam

switch user

su sam

Users may or may not be part of the sudoers file.

To see the sudoers file

sudo cat /etc/sudoers

‘grep’ pulls out a string or a specific element from a file.

grep 'sudo' /etc/group
sudo -l

Displays what commands the current user can run.

Common Network Commands

ip 

Show/manipulate routing, network devices, interfaces and tunnels

ip a for Kali

ifconfig

Configure/show a network interface

iwconfig

Configure/show a wireless network interface

ip n 

Show/manipulate routing, devices, policy routing and tunnels

‘ARP’ Address Resolution Protocol. It tells us what IP address is associated with what MAC address.

arp -a 

Show/manipulate routing, devices, policy routing and tunnels

ip r 
route 

Show/manipulate the IP routing table

ping 

Send ICMP ECHO_REQUEST packets to network hosts

Not all machines allow ICMP traffic.

netstat 

Print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships

Viewing, Creating and Editing Files

echo 

Display a line of text

cat 

Concatenate files and print on the standard output

‘>>’ append string/text to file

touch newfile.txt creates a new file

Installing and Updating Tools

sudo apt update && apt upgrade 

Updates and upgrades our machine

Updating can break Linux. It’s ideal to have a backup copy of Linux.

Pimpmykali

sudo git clone https://github.com/Dewalt-arch/pimpmykali.git

Scripting with Bash

#!/bin/bash

if [ "$1" == "" ]
then 
echo "You Forgot an IP address!"
echo "Syntax: ./ipsweep.sh 192.168.80"

else
for ip in `seq 1 254`; do
ping -c 1 $1.$ip | grep "64 bytes" | cut -d " " -f 4 | tr -d ":" &
done
fi

Related Posts

Leave a Comment