~/hunting-traffic

Hunting (Traffic)

CPTS Notes3 min read

TL;DR

Protocols without TLS send logins in cleartext. A capture file left on a box, or traffic you record on a host you control, can hold usernames, passwords, community strings, and NTLM hashes. Search it with Wireshark filters, or let Pcredz pull every credential at once.

Cleartext protocols

Each of these has an encrypted counterpart. Legacy systems and test services still run the cleartext one.

Cleartext Encrypted Leaks
HTTP HTTPS Form logins, Basic auth headers
FTP FTPS, SFTP USER and PASS
SNMP v1, v2c SNMPv3 Community strings
POP3, IMAP POP3S, IMAPS Mail logins
SMTP SMTPS, STARTTLS AUTH logins
LDAP LDAPS Simple bind passwords
SMB, HTTP NTLM SMB 3 encryption NTLMv1 and NTLMv2 hashes
Telnet SSH Logins typed in the session

Capture traffic

With root on a host that sees other traffic, record to a file and search it later:

sudo tcpdump -i eth0 -w capture.pcap # -w write raw packets to a file
sudo tcpdump -i eth0 -w capture.pcap port 21 # capture only FTP

Look for capture files already on the box, too: *.pcap, *.pcapng, *.cap.

Wireshark filters

Display filters that find credentials:

http.request.method == "POST" # form submissions
http contains "passw" # HTTP packets with the string
frame contains "passw" # any packet with the string, any protocol
http.authorization # HTTP Basic or NTLM headers
ftp.request.command == "PASS" # FTP passwords
snmp # SNMP, community string in each packet
ntlmssp # NTLM authentication in any protocol

Filters that narrow a capture:

ip.addr == 10.10.10.5 # traffic to or from one host
ip.src == 10.10.10.5 && ip.dst == 10.10.10.9 # one direction between two hosts
tcp.port == 80 # one port
tcp.stream eq 53 # one TCP conversation

Right-click a packet and pick Follow > TCP Stream to read the whole conversation as text. Edit > Find Packet searches for a string without a filter.

Pull everything with Pcredz

Pcredz parses a capture and prints every credential it recognizes: HTTP Basic and form fields, FTP, POP3, IMAP, SMTP, LDAP simple bind, SNMP community strings, MSSQL, NTLMv1 and NTLMv2 hashes, Kerberos AS-REQ hashes, and credit card numbers.

./Pcredz -f capture.pcapng -t -v # -f parse a file, -t print timestamps, -v show duplicates too
./Pcredz -d ./pcaps/ # -d parse every capture in a directory
sudo ./Pcredz -i eth0 # -i capture live from an interface
./Pcredz -f capture.pcapng -c # -c skip credit card scanning

Pcredz writes each credential type to its own file under logs/. Crack the NTLMv2 hashes with hashcat mode 5600 in Cracking, or test the cleartext logins with Spraying and Defaults.