Introduction to Linux Basics
Introduction to Linux Basics
Linux word derived and evolved from UNIX.
Unix was the first operating system came to existence with CLI environment and mainly used for server side working as per today's requirements. It is the most flexible and customizable OS used by skilled individuals.It is an open source
Like INDIA has its own linux based operating system i.e. BOSS.
Its a myth that linux based system are purely Command based like now we can see that like ubuntu or any other version have its GUI
Advantages of using Linux OS
It is very secure compared to windows as to even implement a malware most of the time it need to be run seperately not like a windows just al click and a program executed.
Unix : Server Side OS
File Extension : .tar.gz and other compressed packages
Popular OS : Red Hat, Fedora, CENT OS, MAC OS etc.
Linux : Is derived from Unix and to engage more users (simple users) Linux was developed under a open source community began in 1991 and hence is the most popular non commercial os on the planet.
File Extension : .tar.gz , .deb etc.
Popular OS : Ubuntu Flavours, Linux Mint, Kali OS etc.
INTRODUCTION TO PENTESTING OS - KALI
- Virtual Box (Vmware)
- Kali Linux (Image download : kali.org)
- Run it LIVE
- Shutdown
= Installation of Kali Linux. During the installation one will encounter several issues : Unable to boot from CD-DVD rom setting a SWAP memory -> needs to be approx twice of ram installed Grub installation. etc.. etc.. Then after installation we will first update the repositories by going to the directory #cd /etc/apt Now go to kali official documentation pag and copy the repository copy the content to soureces.list
nano sources.list
apt-get update
apt-get upgrade
DIRECTORIES ARCHITECTURE IN LINUX
/root : This is known as the home directory for the root user. Every single file path in Linux begins from root in one way or another.
/bin : Binary folder, this is where most of your binary files are stored, typically for the Linux terminal commands and core utilities,
/boot : This is where all the needed files for Linux to boot are kept which helps in loading the operating system.
/dev : This is where your physical devices are mounted, devices are those whenever we insert a USB, or any other device via peripheral ports they always go in dev folder.
/etc : Configuration files specific to the machine are stored in the "/etc" folder. Configuration files of each and every thing present in the linux is stated as “.conf” extensions.
/home : It is like the "Users" folder in Windows os. The Desktop, Documents, Downloads, Photos, and Videos folders are all stored under the /home/username directory of every particular user.
/lib : This is where libraries are kept which are having basic utility files of the operations performed in the OS.
/proc : This includes a directory for each running process, including kernel processes, in directories named /proc/PID, where PID is the process number for every processes.
/media : Removable Media Devices Folder. It is a place where external devices such as USB drives can be mounted. it holds and mounts the external devices attached to the devices
/mnt : This is basically a placeholder folder used for mounting other folders or drives. When we want to mount or place any internal drive or folder in the operating system we will use "/mnt" folder.
/usr : Contains files and utilities that are shared between users. This folder is use for sharing data and other stuffs between two different users on the same OS.
Basic Commands of Linux
cd: Changes directories.
ls : List directory
man : To get the manual page of any command or tool.
mkdir : To make a directory in linux
cp : Copy a file to another folder
mv : Move a file to another location
rm : To remove a file only.
rmdir : Remove Directory.
grep : To check whether a particular word is in a perticular file or not
cat : To read the contents of the file.
locate : To locate the specific file.
echo : For printing something on the terminal.
date : For viewing the current date and time
cal : For finding the Calendar.
uname : Finding out your OS Version.
uname -a : Finding out all the information of the OS. Like User Information, OS Information etc.
init 0 : Shutting down the OS.
reboot : Restarting the OS.
Starting a Python Server : python -m SimpleHTTPServer 4444(Port Number) Any machine who is connected to a particular router of that network can share any content of that machine in which a server is starting on. To stop the Server, Ctrl+C .
sudo : Sudo allows a system admin to give certain users the ability to run some (or all) commands at the root level and logs all commands and arguments.
ifconfig : Interface configuration and details
iwconfig : Wireless Configuration and details
route -n : Gateway IP Details
apt-get install applicationname : Installation of Application through terminal.
gunzip filename.tar.gz | .zip : For unzipping the file.
gedit filename.txt : Text Editor
leafpad filename.txt : Text Editor
vi fulename.txt
there are multiple editors present in a Linux based system which gives you several interface to edit a file.
Understanding Privileges and Permissions
- Read - a readable permission allows the contents of the file to be viewed. A read permission on a directory allows you to list the contents of a directory.
- Write - a write permission on a file allows you to modify the contents of that file. For a directory, the write permission allows you to edit the contents of a directory.
- Execute - for a file, the executable permission allows you to run the file and execute a program or script. For a directory, the execute permission allows you to change to a different directory and make it your current working directory.
= Command : "ls -al" - Show Privileges
drwxr-xr-x 7 prabhankartripathi staff 224 Jun 13 17:29 .xdman
d -> directory if its a file then it will be like -
In this example, the file owner has read and write permissions only.
- The first three characters (rwx) define the owner’s permission to the file.
- The next three characters (r-x) are the permissions for the members of the same group as The file owner (which in this example is read only).
- The last three characters (r-x) show the permissions for all other users and in this example it is read only.
Command "chmod" : chmod changes the permissions of each given file according to mode, where mode describes the permissions to modify.
Syntax : "chmod 754 filename"
4 stands for "read",
2 stands for "write",
1 stands for "execute",
and 0 stands for "no permission."
Here, 7 is the combination of permissions 4+2+1 (read, write, and execute) 5 is 4+0+1 (read, no write, and execute) and 4 is 4+0+0 (read, no write, and no execute)
WORDLISTS GENERATOR
Tool = Crunch
Usage Syntax -
Crunch Min.Value Max.Value Characters
Example - crunch 4 4 0123456789
For saving it to a file : crunch 4 4 0123456789 > filename.txt
now if I want to generate a file with some specific characters in a word we can go like crunch 9 9 -t ^%hello%%
OWASP ZAP - LINUX TOOL
The OWASP ZAP (ZAP) tool is one of the most popular free penetration testing tool. It can help you automatically find security vulnerabilities in your web applications while for experienced pentesters to use for manual security testing. The main goal is to allow easy penetration testing to find vulnerabilities in web applications.
ZAP tool in Kali Linux.
Steps
- Adding the Target site to the testing scope.
- Setting up Proxy for ZAP. - ZAP tool > Tools Menu > Options > Local Proxy > Change Address = 127.0.0.1 Port = 8080. Setting up the Proxy in the Browser : Mozilla browser > Tools Menu > Options > Advanced tab > Network > Settings > Select Manual Proxy configuration:- HTTP Proxy = 127.0.0.1 Port = 8080.
- Attacking on the Websites through ZAP.
- Saving the ZAP Session.
- Generating Report = ZAP tool > Report > Generate HTML report > Save and share the report.
- rwx r-x r-x