Pentest_Notes

Recon

# Enumerate subnet
nmap -sn 10.11.1.1/24

# Fast simple scan
nmap -sS 10.11.1.111

# Full complete slow scan with output
nmap -v -sT -A -T4 -p- -Pn --script vuln -oA full 10.11.1.111


#Scan All the ports:
masscan -p1-65535,U:1-65535 --rate=1000 192.168.232.43 -e tun0 > ports
ports=$(cat ports | awk -F " " '{print $4}' | awk -F "/" '{print $1}' | sort -n | tr '\n' ',' | sed 's/,$//')
sudo nmap -Pn -sV -sC -p$ports 192.168.232.43

# OneTwoPunch
https://raw.githubusercontent.com/superkojiman/onetwopunch/master/onetwopunch.sh
onetwopunch.sh ip.txt tcp

# Scan for UDP
nmap 10.11.1.111 -sU
unicornscan -mU -v -I 10.11.1.111

# Connect to udp if one is open
nc -u 10.11.1.111 48772

# Responder
responder -I eth0 -A

# Amass
amass enum -ip 10.11.1.1/24
  • Sparta

  • python /root/Reconnoitre/Reconnoitre/reconnoitre.py -t 10.11.1.111 -o test --services

Enumeration AIO

File enumeration

Common

Disk files

Images

Audio

Port 21 - FTP

(https://book.hacktricks.xyz/pentesting/pentesting-ftp)

Port 22 - SSH

  • If you have usernames test login with username:username

  • Vulnerable Versions: 7.2p1

Port 25 - SMTP

https://book.hacktricks.xyz/pentesting/pentesting-smtp#basic-information

REF:Postfish

Port 69 - UDP - TFTP

This is used for tftp-server.

  • Vulns tftp in server 1.3, 1.4, 1.9, 2.1, and a few more.

  • Checks of FTP Port 21.

Port 79 - Finger

Ref:HtB Sunday

Kerberos - 88

Port 110 - Pop3

Port 111 - Rpcbind

Port 135 - MSRPC

Some versions are vulnerable.

Port 139/445 - SMB

Port 143/993 IMAP

REF: Postfish

Banner Grab

Port 161/162 UDP - SNMP

LDAP - 389,636,3268, 3269

The use of LDAP (Lightweight Directory Access Protocol) is mainly for locating various entities such as organizations, individuals, and resources like files and devices within networks, both public and private. It offers a streamlined approach compared to its predecessor, DAP, by having a smaller code footprint.

LDAP Data Interchange Format

LDIF (LDAP Data Interchange Format) defines the directory content as a set of records. It can also represent update requests (Add, Modify, Delete, Rename).

  • Lines 1-3 define the top level domain local

  • Lines 5-8 define the first level domain moneycorp (moneycorp.local)

  • Lines 10-16 define 2 organizational units: dev and sales

  • Lines 18-26 create an object of the domain and assign attributes with values

HTTPS - 443

Read the actual SSL CERT to:

  • find out potential correct vhost to GET

  • is the clock skewed

  • any names that could be usernames for bruteforce/guessing.

500 - ISAKMP IKE

513 - Rlogin

541 - FortiNet SSLVPN

Fortinet Ports Guide

SSL VPN Leak

Port 554 - RTSP

  • Web interface, transfer images, streaming

Port 873 - Rsync

https://book.hacktricks.xyz/pentesting/873-pentesting-rsync

Port 1030/1032/1033/1038

Used by RPC to connect in domain network.

MSSQL - 1433

Port 1521 - Oracle

Port 2049 - NFS

Port 2100 - Oracle XML DB

Default passwords https://docs.oracle.com/cd/B10501_01/win.920/a95490/username.htm

2375, 2376 Docker

Step 1: External Reconnaissance

  • Identify Docker Versions: Use tools like docker or curl to enumerate the Docker API. For example:

Step 2: Vulnerability Exploitation

  • Shellshock Vulnerability: Use a Docker image with a vulnerable Bash package (e.g., CVE-2014-6271) to exploit the Shellshock vulnerability. For example:

Step 3: Privilege Escalation

  • FakePip Exploit: After gaining access to the container shell, use the FakePip exploit to escalate privileges. For example:

Step 4: Docker Escape

  • Create a New Ubuntu Container: Use the docker.sock to create a new Ubuntu container with high privileges.

Tools and Resources

  • CDK (Container Docker Kit): A penetration testing toolkit for containers that can be downloaded from here.

  • Trivy: A tool for detecting known vulnerabilities in Docker images.

  • Falco: A tool for detecting Docker escapes.

Security Best Practices

  • Use Non-Root Access: By default, use non-root access to manage containers, as it is more secure than many other alternatives.

  • Regularly Update Images: Regularly update Docker images to ensure you have the latest security patches.

  • Use Secure Networking: Ensure that your Docker network settings are secure to prevent unauthorized access.

3306 - MySQL

https://book.hacktricks.xyz/pentesting/pentesting-mysql#basic-information

Port 3339 - Oracle web interface

  • Basic info about web service (apache, nginx, IIS)

RDP - 3389

PostgreSQL - 5432/5433

REF: Nibbles, Splodge

https://book.hacktricks.xyz/pentesting/pentesting-postgresql

https://book.hacktricks.xyz/pentesting-web/sql-injection/postgresql-injection#rce-from-version-9.3

Erland Port Mapper - 4369

https://book.hacktricks.xyz/pentesting/4369-pentesting-erlang-port-mapper-daemon-epmd

VNC - 5900

WinRM - 5985

Redis - 6379

Ref: Sybaris, Wombo

MsDeploy - 8172

Port 27017 - MongoDB

https://book.hacktricks.xyz/pentesting/27017-27018-mongodb

Webdav

Unknown ports

  • nmap -d 10.11.1.111 8000

  • netcat: makes connections to ports. Can echo strings or give shells: nc -nv 10.11.1.111 110

  • sfuzz: can connect to ports, udp or tcp, refrain from closing a connection, using basic HTTP configurations

  • Try zone transfer for subdomains: dig axfr @10.11.1.111 hostname.box, dnsenum 10.11.1.111, dnsrecon -d domain.com -t axfr

Try admin:admin, user:user

Port 80 - Web server

  • Basics:

    • Navigate && robots.txt

    • Headers

    • Source Code (Read for comments)

    • Pay attention to errors (Is there a protocol relationship)

Url brute force

Default/Weak login

Search documentation for default passwords and test them

LFI/RFI

SQL-Injection

XSS

SQL-login-bypass

  • Open Burp-suite

  • Make and intercept a request

  • Send to intruder

  • Cluster attack.

  • Paste in sqlibypass-list (https://bobloblaw.gitbooks.io/security/content/sql-injections.html)

  • Attack

  • Check for response length variation

Bypass image upload restrictions

Password brute force - last resort

Offline local resources

Hashcat

Online crackers

Vulnerability analysis

BOF

Find exploits - Searchsploit and Google

Where there are many exploits for software, use Google. It will automatically sort it by popularity.

Reverse Shells

https://www.revshells.com/

escape quotes if running from command line (ex., (("192.168.49.232",80)))

Privilege escalation

Common

Set up Webserver

Set up FTP Server

Set up TFTP

Linux

Now we start the whole enumeration-process over gain.

  • Kernel exploits

  • Programs running as root

  • Installed software

  • Weak/reused/plaintext passwords

  • Inside service

  • Suid misconfiguration

  • World writable scripts invoked by root

  • Unmounted filesystems

  • Look in /var/backups

  • Look in /etc/fstab y en mount

Less likely

  • Private ssh keys

  • Bad path configuration

  • Cronjobs

Useful commands

Basic info

Kernel exploits

Programs running as root

Look for webserver, mysql or anything else like that.

Installed software

Weak/reused/plaintext passwords

  • Check database config-file

  • Check databases

  • Check weak passwords

  • Check plaintext

Inside service

Suid misconfiguration

Binary with suid permission can be run by anyone, but when they are run they are run as root!

Example programs:

Unmounted filesystems

Here we are looking for any unmounted filesystems. If we find one we mount it and start the priv-esc process over again.

Cronjob

Look for anything that is owned by a privileged user but writable for you

SSH Keys

Check all home directories

Privilege Escalation with SSH keys

Bad path configuration

Require user interaction

Find plain passwords

Scripts

BASH

SUID

MSFVENOM LIBRARY Priv Esc

PS Monitor for cron

Linux Privesc Tools

Linux Precompiled Exploits

Windows

Now we start the whole enumeration-process over gain. This is a checklist. You need to check of every single one, in this order.

  • Kernel exploits

  • Cleartext password

  • Reconfigure service parameters

  • Inside service

  • Program running as Admin/System

  • Installed software

  • Scheduled tasks

  • Weak passwords -Check installed apps and versions for priv esc when all else fails

Basic info

Kernel exploits

Cleartext passwords

Reconfigure service parameters

  • Unquoted service paths

  • Weak service permissions

https://pentest.blog/windows-privilege-escalation-methods-for-pentesters/

Dump process for passwords

Inside service

Check netstat to see what ports are open from outside and from inside. Look for ports only available on the inside.

Programs running as Admin/system

Installed software

Scheduled tasks

Weak passwords

Remote desktop

Add user and enable RDP

Powershell sudo for Windows

Windows download with bitsadmin

Windows download with certutil.exe

Windows download with powershell

PowerShell Priv Esc

Windows Download from FTP

Windows NC File Transfer

Windows create SMB Server transfer files

Windows download with VBS

Windowss XP SP1 PrivEsc

Pass The Hash

Scripts

Useradd

Powershell Run As

Powershell Reverse Shell

Windows privesc/enum tools

Windows precompiled exploits

Port Forwarding

Windows

Linux

Active Directory

LLMNR/NBT-NS

SMB Relay Attack

IPv6 Attack

AD Recon

#asPeas for enumeration scripting

PowerView

Bloodhound

Mimikatz Commands

#Kerberoasting Cheatsheet

Loot

Linux

Checklist

  • Proof:

  • Network secret:

  • Passwords and hashes:

  • Dualhomed:

  • Tcpdump:

  • Interesting files:

  • Databases:

  • SSH-keys:

  • Browser:

  • Mail:

Proof

Local

Network secret

Passwords and hashes

Dualhomed

Tcpdump

Interesting files

Databases

SSH-Keys

Browser

Mail

GUI

If there is a gui we want to check out the browser.

Windows

Proof

Passwords and hashes

Dualhomed

Tcpdump

Interesting files

Last updated