Bibliotheque
DiscordHackTheBoxTryHackMeGitHub
  • Welcome wanderer
    • Bibliotheque
    • Hacking Philosophy
    • Useful Links
  • PENTESTING
    • Methodology
    • Protocols
      • FTP
      • SMB
      • NFS
      • SSH
      • RDP
      • SMTP
      • IMAP / POP3
      • RSYNC
      • SNMP
      • IPMI
      • R-Services
      • WinRM
      • WMI
      • LDAP
    • Databases
      • MySQL
      • MSSQL
      • Oracle TNS
      • PostgreSQL
    • File Transfers
      • Windows
      • Linux
      • Code
      • Misc
    • Password Attacks
      • John The Ripper
      • Hashcat
    • Docker
  • TOOLS
    • Nmap
    • Metasploit
    • BloodHound
    • Other
  • Linux
    • Theory
    • Commands and Utilities
      • Useful Commands
    • Bash Scripting
    • Post-Exploitation
      • Cred Hunting
      • Pivoting
  • WINDOWS
    • Theory
      • Security
    • Commands and Utilities
    • PowerShell
    • Post-Exploitation
      • Tools
      • Enumeration
        • System
        • Network
        • Users
        • Groups
        • Processes / Services
        • Permissions
        • Defence
        • Programs
        • Files
      • Access
      • Pivoting
      • Cred Hunting
    • Privilege Escalation
      • Privileges
      • Built-In Groups
        • Backup Operators
        • Server Operators
        • Print Operators
        • DnsAdmins
        • Event Log Readers
      • Privilege Abuse
        • Potatoes
        • SeDebugPrivilege
        • SeTakeOwnershipPrivilege
      • MISC
        • UAC Bypass
        • User-Interaction Attacks
        • Weak Permissions
  • ACTIVE DIRECTORY
    • Theory
      • Terminology
    • Reconnaissance
      • Responder
      • Password Policies
      • DNS
      • Enumeration
        • Users
        • Groups
          • GPO's
        • Shares
        • Domain
        • Trusts
        • ACL
    • Movement
      • Credentials
        • Dumping
          • DCSync
          • DPAPI Secrets
        • Making a Target List
        • Spraying
        • Powershell Remoting
      • Kerberos
        • Kerbrute
        • Kerberoasting
          • Semi-Manual Way
          • Targeted Kerberoasting
        • ASREProasting
        • Forging
          • Golden Ticket
        • Overpass The Hash
        • Pass The Ticket
        • RBCD
        • noPAC
      • MITM / Coerced Auths
        • LLMNR, NBT-NS Poisoning
        • PetitPotam
      • DACL Abuse
        • AddMember
        • ForceChangePassword
      • Trust Abuse
        • ExtraSIDs
      • ADCS
        • ESC1
      • Printers
        • PrintNightmare
    • Tools
  • Networking
    • Theory
      • Types / Topologies
      • OSI & TCP/IP Models
      • TCP / UDP
      • MAC Addresses
      • IP / Subnetting
      • Proxies
      • ARP
    • Pivoting
      • Port-Forwarding
    • Commands and Utilities
    • Techniques
  • WEB
    • Web Recon
      • Fuzzing
    • DNS
  • CLOUD
    • Google GKE/GCP
      • Theory
Powered by GitBook
On this page
  • ABOUT
  • SMTP Servers
  • SMTP Commands
  • Connect
  • VRFY
  • EXPN
  • RCPT TO
  • Microsoft 365
  • 0365spray
  • Tips2Hack
  1. PENTESTING
  2. Protocols

SMTP

ABOUT

Simple Mail Transfer Protocol (SMTP) is a protocol for sending emails in an IP network. It can be used between an email client and an outgoing mail server or between two SMTP servers. SMTP is often combined with the IMAP or POP3 protocols, which can fetch emails and send emails. In principle, it is a client-server-based protocol. Commonly it's using TCP/25 port for unencrypted SMTP, TCP/465 for encrypted, TCP/587 for SMTP STARTLS Encryption.

SMTP Servers

SMTP servers play a crucial role in preventing spam by supporting ESMTP with SMTP-Auth for authorized user-based email sending. The Mail User Agent (MUA) converts emails into headers and bodies, uploading them to the SMTP server. A Mail Transfer Agent (MTA) checks email size and spam, storing it after validation. Occasionally, a Mail Submission Agent (MSA) or Relay server validates email origin to prevent Open Relay Attacks. The MTA then searches DNS for the recipient mail server's IP address.

MUA(Client) -> MSA(Submission Agent) -> MTA(Open Relay) -> MDA(Mail Delivery Agent) -> POP3/IMAP(Mailbox)

SMTP Commands

Connect

Usually to connect to SMTP server you could use just telnet and specify port.

telnet 13.13.13.13 25

VRFY

VRFY command is used for checking if the username is valid by requesting SMTP Server

VRFY root
252 2.0.0 root

EXPN

EXPN command is same as VRFY, but if you send it a distribution list, it'll send back all users from it.

EXPN impostors-team
250 2.0.0 john@amogus.com
250 2.1.5 bob@amogus.com

RCPT TO

RCPT TO command specifies the recipient. The more times you use it, the more recipients you could find.

RCPT TO:alice
550 5.1.1 alice... User unknown

RCPT TO:bob
250 2.1.5 bob... Recipient ok

Microsoft 365

Sure here wouldn't be whole section about 365, but that's a common thing, so let's write here some basic enum techniques.

0365spray

O365spray is a tool for username enum and password spraying attack at Microsoft 365

Validate

python3 o365spray.py --validate --domain amogus.com

Username Enum

python3 o365spray.py --enum -U users.txt --domain amogus.com

Password Spraying

python3 o365spray.py --spray -U users.txt -p '1mp0st3r' --count 1 --lockout 1 --domain amogus.com

Tips2Hack

  1. Nmap - Open Relay

sudo nmap 13.13.13.13 -p25 --script smtp-open-relay -v
  1. Nmap - SMTP all scripts enum

sudo nmap 13.13.13.13 -p25 -sV -sC --script smtp* -v
  1. DIG - Mail Server enum

dig mx amogus.com | grep "MX" | grep -v ";"
  1. Host Mail Server

host -t A mail.amogus.htb
smtp-user-enum -M RCPT -U userlist.txt -D amogus.com -t 13.13.13.13
  1. Hydra - Password attacks

If you know user, as example "bob", don't use just username, use it with domain/email address, likebob@amogus.com

hydra -L users.txt -p 'amogus' -f 13.13.13.13 pop3
  1. Swaks - Send mail

swaks --from notifications@amogus.com --to impostors@amogus.com --header 'Subject: You have suspected of being impostors' --body 'Hi, our councel of spacemen chose by democratic voting that you are sus, so you have no other choice but to surrender and be ready for empty vastness of space. If you want to deny that, please join our chat here and explain your sus behaviour: https://impostor-chat-court.com' --server 13.13.13.13
PreviousRDPNextIMAP / POP3

Last updated 24 days ago

smtp-user-enum script

[LINK]