🧿Enumeration

Initial external enumeration steps.

Initial Scan

Start with an nmap script across all ports. This helps identify what would be useful to tackle next.

sudo nmap -Pn -sV -sC -p- TARGET -oN nmap_TARGET_sC_sV_allports.nmap

For any service, try searching the relevant services in the script database for nmap using the aliased command (see Resources page).

nmapsearch SEARCHTERM

If a hostname is available, add that to the /etc/hosts file. In the event that the target is also a domain controller, add the domain in the hosts entry.

Ping

Assuming ICMP traffic isn't blocked, pinging the host can be used to infer OS.

If the TTL is... in the 60s -> Linux, in the 120s -> Windows, in the 200s -> possibly networking equipment.

FTP/21

Anonymous FTP Access

  • Try the following combinations: anonymous/anonymous, anonymous/BLANK, ftp/ftp

SSH/22

SSH is a protocol offering encrypted remote terminal access to a host.

If an authorized_keys file is obtained and it has a dss key at the top, look at this techniquearrow-up-right.

SMTP/25/POP3/110

Look around at what you can find

  • Telnet in, poke around to see if you can see a list of users and change their passwords

  • Try to login to their email via POP3

  • Example: look at SolidState walkthrough/notes

Use swaks to interact and script SMTP

  • Usage:

  • Example: Look at SneakyMailer write-up

DNS/53

Start with an nmap scan:

Nslooklup:

  • Changes default server to IPADDR: server IPADDR

    • Only necessary when using a specific server (i.e. target host is running DNS)

  • IP address to lookup: IPADDR

DNSRecon:

  • Reverse DNS Lookup

  • Example: dnsrecon -r 10.10.10.10/24 -n 10.129.104.91

Zone Transfer:

  • Try to see if there is a TLS certificate domain name to try

  • This can be useful for finding A records

  • Add these to hosts file!

  • Quickly pull the domains:

  • Visit all of these sites!

TFTP/69

TFTP, of the Trivial File Transfer Protocol, runs on UDP. It basically can only upload/download files.

Using a Python terminal, a client can be created to pull down files. This seems to only accept 8.3 directory notation, which can be found using dir /x.

Reference: https://book.hacktricks.xyz/network-services-pentesting/69-udp-tftparrow-up-right

Finger/79

Interact with finger service: finger @IPADDR

If you have a user: finger USER@IPADDR

Enumerate with finger-user-enum: ./finger-user-enum.pl -U /usr/share/seclists/Usernames/Names/names.txt -t IPADD

HTTP/80/HTTPS/443

Start with nmap scan:

If site is HTTPs, check the certificate and make sure the domains are added to hosts file.

Directory Bruteforcing

Gobuster everything:

  • Additionally run Gobuster for all subdirectories identified that aren't visitable.

  • If needed, use a stronger wordlist: /usr/share/wordlists/dirbuster/directory-list-lowercase-2.3-medium.txt

  • Also consider some SecList wordlists

    • /usr/share/seclists/Discovery/Web-Content/raft-small-words.txt

  • If using a specific application, search for relevant wordlists: find /usr/share/SecLists/ | grep APPLICATION

If stuck with Gobuster, consider switching to Dirb as there is not 100% overlap.

Watch out for configuration/test files, such as phpinfo()

  • ALWAYS search 'password' on any configs or test files

Subdomain Fuzzing

Wfuzz for subdomain bruteforcing:

Additional Attacks

Web exploitation is a vast area, so more techniques can be found in the Web Exploitation page: https://notes.notmalicio.us/web-exploitationarrow-up-right

Kerberos/88

Check that localhost time is within one minute of listed scan time

SMB/139/445

SMB Enumeration

Identify dialect and modify /etc/samba.conf min client protocol accordingly:

Follow up with another nmap scan:

Start with enum4linux:

Find null sessions:

Enumerate with smbmap:

Brute force logins with a userlist and a password list:

Interact with SMB

Interact with SMBClient:

Using smbmap to recurse through a share:

Note: Check for Groups.XML on older Windows (i.e. pre-2012) hosts --> Attacking Groups.XMLarrow-up-right

Using smbmap to download a file:

  • -q is for quiet to make it clog the terminal less

  • To find the file: locate FILENAME

Using smbmap with credentials:

  • Add a domain with -d DOMAIN

  • If you have admin, you can also use -x COMMAND to execute commands

Use crackmapexec to further enumerate and interact with SMB:

  • -u can take in a list or a single username

  • Add --share to enumerate shares

  • Add --continue-on-success to enumerate all accounts that may be valid

  • May be worth trying -u whatever and -p ""

The file explorer can be used to browse shares easily by typing smb://IPADDR/SHARENAME in the address bar

rpcclient can be used with credentials to extract additional information from SMB

  • Below is a table with useful commands for rpcclient

Command
Goal

querydispinfo

Queries display info, can return users and accounts

enumprinters

Enumerates printers

Mount a Share

Mount a share:

  • Create directory: mkdir smb

  • Mount the share on the directory: sudo mount -t cifs //TARGET/SHARE ./smb/

Change Password with SMB

Change the password of an SMB account:

Alternative for changing password with Impacket:

SNMP/161

Use snmpwalk to pull information about host

  • Where -c public is the default community

  • A script to parse the very dense output of snmpwalk:

Another tool snmp-check can be used to enumerate SNMP

LDAP/389

LDAP is a service that offers a way to search for information that is in AD.

Use ldapsearch to search for LDAP information

Basic usage:

  • Where -x means simple authentication

Finding naming conventions:

Using the naming conventions to search base:

Generic querying of LDAP:

  • Use the following for the QUERYHERE argument

    • Find people: '(objectClass=Person)'

    • Find usernames: '(objectClass=Person)' sAMAccountName

      • Convert this list into a user list: cat ldap_TARGET_users.ldapsearch | grep sAMAccountName | awk '{print $2}' > users_list.users

IPSEC/500/4500

Enumerate with ike-scan

Usage:

Aggressive mode (for pulling hashes):

Connect to the VPN

Using strongswan

IPMI/623

IPMI allows for management and monitoring of computer performance.

Using nmap for version enumeration:

MS-SQL/1433

Use nmap to do some initial enum on MS-SQL:

Master.mdf

The master.mdf file offers an opportunity to extract hashes.

Credentialed Access

Once credentials are obtained for MS-SQL, a few tools can be used to obtain shell access:

  • Crackmapexec: crackmapexec mssql IPADDR -d "DOMAIN" -u sa -p "PASSWORD" -x "COMMAND"

    • sa is the username in this case

  • Impacket: impacket-mssqlclient sa@IPADDR

    • You may need to enable_xp_cmdshell

Oracle Database/1521

Use Nmap to brute force the SIDs and then use the output to brute force

  • Brute force SIDS:

  • SID will be used in the rest of the commands to denote the identified SID from this scan

  • Brute force users:

  • Brute force:

  • To change the password list, add the argument brute.credfile

    • Possibly this one from SecLists: /usr/share/seclists/Passwords/Default-Credentials/oracle-betterdefaultpasslist.txt

      • Use Sed to conform it into a brute file: sed -i 's/:///g' oracle-betterdefaultpasslist.txt

Connect to Oracle DB

  • Once valid credentials are obtained, use sqlplus64 to interact with the service

    • Usage: sqlplus64 USERNAME/PASS@TARGET/SID

    • Higher privs (like sudo for Oracle DB): sqlplus64 USERNAME/PASS@TARGET/SID as sysdba

Extracting information from the DB as a given user

  • User privileges: select * from user_role_privs;

  • Session privileges: select * from session_privs;

  • Reading a file:

  • If no output, turn on server output: set serveroutput ON

NFS/2049

Nmap enumeration of NFS:

Show NFS mount:

To mount the NFS:

MySQL/3306

Attempt to connect: mysql -h TARGET -u root

For additional nmap enumeration:

RDP/3389

RDP is the remote desktop protocol, so the best way into this service is with creds.

For additional enumeration:

SVN/3690

Subversion is a software versioning system.

To checkout a repository with subversion:

To see the log after checkout:

To go to a previous revision, where the desired "step back" is a number X):

VNC/5800/5801/5900/5901

Refer to https://book.hacktricks.xyz/network-services-pentesting/pentesting-vncarrow-up-right

WinRM/5985/5986

If these ports are open, then Windows Remoting may be enabled. This can offer a foothold if credentials are found. If the `Remote Management Users` group is identified to exist, this protocol may also be enabled.

Use crackmapexec to further enumerate and interact with SMB:

  • -u can take in a list or a single username

  • Add --continue-on-success to enumerate all accounts that may be valid

Login with evil-winRM:

Redis/6379

Redis acts as a key-value store.

Nmap enumeration:

Directly connect via nc: nc -nvv TARGET 6379

  • Try INFO command first

  • If you have creds, try AUTH USERNAME PASSWORD

Interact with Redis:

  • Select database: SELECT 0, SELECT 1

  • Return keys: KEYS *

  • Get key ABC: GET ABC

Arbitrary file write:

  • Identify current directory: CONFIG GET DIR

  • Set to desired directory: CONFIG SET DIR /desired/path

  • Set contents (CONTENT) of key (KEYFILE): SET KEYFILE CONTENT

    • Switch to redis-cli for this portion

  • Name file NAME: CONFIG SET DBFILENAME NAME

  • Save file: SAVE

Refer to https://book.hacktricks.xyz/network-services-pentesting/6379-pentesting-redisarrow-up-right

Splunkd/8089

Last updated