smtp-penetration-testing
Conduct comprehensive security assessments of SMTP (Simple Mail Transfer Protocol) servers to identify vulnerabilities including open relays, user enumeration, weak authentication, and misconfiguration.
What this skill does
> AUTHORIZED USE ONLY: Use this skill only for authorized security assessments, defensive validation, or controlled educational environments. # SMTP Penetration Testing ## Purpose Conduct comprehensive security assessments of SMTP (Simple Mail Transfer Protocol) servers to identify vulnerabilities including open relays, user enumeration, weak authentication, and misconfiguration. This skill covers banner grabbing, user enumeration techniques, relay testing, brute force attacks, and security hardening recommendations. ## Prerequisites ### Required Tools ```bash # Nmap with SMTP scripts sudo apt-get install nmap # Netcat sudo apt-get install netcat # Hydra for brute force sudo apt-get install hydra # SMTP user enumeration tool sudo apt-get install smtp-user-enum # Metasploit Framework msfconsole ``` ### Required Knowledge - SMTP protocol fundamentals - Email architecture (MTA, MDA, MUA) - DNS and MX records - Network protocols ### Required Access - Target SMTP server IP/hostname - Written authorization for testing - Wordlists for enumeration and brute force ## Outputs and Deliverables 1. **SMTP Security Assessment Report** - Comprehensive vulnerability findings 2. **User Enumeration Results** - Valid email addresses discovered 3. **Relay Test Results** - Open relay status and exploitation potential 4. **Remediation Recommendations** - Security hardening guidance ## Core Workflow ### Phase 1: SMTP Architecture Understanding ``` Components: MTA (transfer) → MDA (delivery) → MUA (client) Ports: 25 (SMTP), 465 (SMTPS), 587 (submission), 2525 (alternative) Workflow: Sender MUA → Sender MTA → DNS/MX → Recipient MTA → MDA → Recipient MUA ``` ### Phase 2: SMTP Service Discovery Identify SMTP servers and versions: ```bash # Discover SMTP ports nmap -p 25,465,587,2525 -sV TARGET_IP # Aggressive service detection nmap -sV -sC -p 25 TARGET_IP # SMTP-specific scripts nmap --script=smtp-* -p 25 TARGET_IP # Discover MX records for domain dig MX target.com nslookup -type=mx target.com host -t mx target.com ``` ### Phase 3: Banner Grabbing Retrieve SMTP server information: ```bash # Using Telnet telnet TARGET_IP 25 # Response: 220 mail.target.com ESMTP Postfix # Using Netcat nc TARGET_IP 25 # Response: 220 mail.target.com ESMTP # Using Nmap nmap -sV -p 25 TARGET_IP # Version detection extracts banner info # Manual SMTP commands EHLO test # Response reveals supported extensions ``` Parse banner information: ``` Banner reveals: - Server software (Postfix, Sendmail, Exchange) - Version information - Hostname - Supported SMTP extensions (STARTTLS, AUTH, etc.) ``` ### Phase 4: SMTP Command Enumeration Test available SMTP commands: ```bash # Connect and test commands nc TARGET_IP 25 # Initial greeting EHLO attacker.com # Response shows capabilities: 250-mail.target.com 250-PIPELINING 250-SIZE 10240000 250-VRFY 250-ETRN 250-STARTTLS 250-AUTH PLAIN LOGIN 250-8BITMIME 250 DSN ``` Key commands to test: ```bash # VRFY - Verify user exists VRFY admin 250 2.1.5 [email protected] # EXPN - Expand mailing list EXPN staff 250 2.1.5 [email protected] 250 2.1.5 [email protected] # RCPT TO - Recipient verification MAIL FROM:<[email protected]> RCPT TO:<[email protected]> # 250 OK = user exists # 550 = user doesn't exist ``` ### Phase 5: User Enumeration Enumerate valid email addresses: ```bash # Using smtp-user-enum with VRFY smtp-user-enum -M VRFY -U /usr/share/wordlists/users.txt -t TARGET_IP # Using EXPN method smtp-user-enum -M EXPN -U /usr/share/wordlists/users.txt -t TARGET_IP # Using RCPT method smtp-user-enum -M RCPT -U /usr/share/wordlists/users.txt -t TARGET_IP # Specify port and domain smtp-user-enum -M VRFY -U users.txt -t TARGET_IP -p 25 -d target.com ``` Using Metasploit: ```bash use auxiliary/scanner/smtp/smtp_enum set RHOSTS TARGET_IP set USER_FILE /usr/share/wordlists/metasploit/unix_users.txt set UNIXONLY true run ``` Using Nmap: ```bash # SMTP user enumeration script nmap --script smtp-enum-users -p 25 TARGET_IP # With custom user list nmap --script smtp-enum-users --script-args smtp-enum-users.methods={VRFY,EXPN,RCPT} -p 25 TARGET_IP ``` ### Phase 6: Open Relay Testing Test for unauthorized email relay: ```bash # Using Nmap nmap -p 25 --script smtp-open-relay TARGET_IP # Manual testing via Telnet telnet TARGET_IP 25 HELO attacker.com MAIL FROM:<[email protected]> RCPT TO:<[email protected]> DATA Subject: Relay Test This is a test. . QUIT # If accepted (250 OK), server is open relay ``` Using Metasploit: ```bash use auxiliary/scanner/smtp/smtp_relay set RHOSTS TARGET_IP run ``` Test variations: ```bash # Test different sender/recipient combinations MAIL FROM:<> MAIL FROM:<test@[attacker_IP]> MAIL FROM:<[email protected]> RCPT TO:<[email protected]> RCPT TO:<"[email protected]"> RCPT TO:<test%[email protected]> ``` ### Phase 7: Brute Force Authentication Test for weak SMTP credentials: ```bash # Using Hydra hydra -l admin -P /usr/share/wordlists/rockyou.txt smtp://TARGET_IP # With specific port and SSL hydra -l admin -P passwords.txt -s 465 -S TARGET_IP smtp # Multiple users hydra -L users.txt -P passwords.txt TARGET_IP smtp # Verbose output hydra -l admin -P passwords.txt smtp://TARGET_IP -V ``` Using Medusa: ```bash medusa -h TARGET_IP -u admin -P /path/to/passwords.txt -M smtp ``` Using Metasploit: ```bash use auxiliary/scanner/smtp/smtp_login set RHOSTS TARGET_IP set USER_FILE /path/to/users.txt set PASS_FILE /path/to/passwords.txt set VERBOSE true run ``` ### Phase 8: SMTP Command Injection Test for command injection vulnerabilities: ```bash # Header injection test MAIL FROM:<[email protected]> RCPT TO:<[email protected]> DATA Subject: Test Bcc: [email protected] X-Injected: malicious-header Injected content . ``` Email spoofing test: ```bash # Spoofed sender (tests SPF/DKIM protection) MAIL FROM:<[email protected]> RCPT TO:<[email protected]> DATA From: CEO <[email protected]> Subject: Urgent Request Please process this request immediately. . ``` ### Phase 9: TLS/SSL Security Testing Test encryption configuration: ```bash # STARTTLS support check openssl s_client -connect TARGET_IP:25 -starttls smtp # Direct SSL (port 465) openssl s_client -connect TARGET_IP:465 # Cipher enumeration nmap --script ssl-enum-ciphers -p 25 TARGET_IP ``` ### Phase 10: SPF, DKIM, DMARC Analysis Check email authentication records: ```bash # SPF/DKIM/DMARC record lookups dig TXT target.com | grep spf # SPF dig TXT selector._domainkey.target.com # DKIM dig TXT _dmarc.target.com # DMARC # SPF policy: -all = strict fail, ~all = soft fail, ?all = neutral ``` ## Quick Reference ### Essential SMTP Commands | Command | Purpose | Example | |---------|---------|---------| | HELO | Identify client | `HELO client.com` | | EHLO | Extended HELO | `EHLO client.com` | | MAIL FROM | Set sender | `MAIL FROM:<[email protected]>` | | RCPT TO | Set recipient | `RCPT TO:<[email protected]>` | | DATA | Start message body | `DATA` | | VRFY | Verify user | `VRFY admin` | | EXPN | Expand alias | `EXPN staff` | | QUIT | End session | `QUIT` | ### SMTP Response Codes | Code | Meaning | |------|---------| | 220 | Service ready | | 221 | Closing connection | | 250 | OK / Requested action completed | | 354 | Start mail input | | 421 | Service not available | | 450 | Mailbox unavailable | | 550 | User unknown / Mailbox not found | | 553 | Mailbox name not allowed | ### Enumeration Tool Commands | Tool | Command | |------|---------| | smtp-user-enum | `smtp-user-enum -M VRFY -U users.txt -t IP` | | Nmap | `nmap --script smtp-enum-users -p 25 IP` | | Metasploit | `use auxiliary/scanner/smtp/smtp_enum` | | Netcat | `nc IP 25` then manual commands | ### Common Vulnerabilities | Vulnerability | Risk | Test Method | |--------------|------|-------------| | Open Relay | High | Relay test with external recipient | | User Enumeration | Medium | VRFY/EXPN/RCPT commands | | Banner Disclosure | Low | Ba
Related in Security
mac-ops
IncludedComprehensive macOS workstation operations — diagnose kernel panics, identify failing drives, audit launchd startup items, decode wake reasons, triage TCC permission denials, manage APFS snapshots, recover from no-boot. Use for: Mac is slow, slow bootup, won't boot, kernel panic, kernel_task hot, mds_stores CPU, photoanalysisd, cloudd, login loop, gray screen, sleep wake failure, drive failing, IO errors, APFS snapshots eating space, Time Machine local snapshots, Spotlight indexing, launchd, LaunchAgent, LaunchDaemon, login items, TCC permissions, Full Disk Access, Screen Recording denied, Gatekeeper, quarantine, com.apple.quarantine, app is damaged, helper tool, /Library/PrivilegedHelperTools, pmset, wake reasons, dark wake, sysdiagnose, panic.ips, DiagnosticReports, configuration profile, MDM profile, remote diagnostics over SSH.
a11y-audit
IncludedRun accessibility audits on web projects combining automated scanning (axe-core, Lighthouse) with WCAG 2.1 AA compliance mapping, manual check guidance, and structured reporting. Output is configurable: markdown report only, markdown plus machine-readable JSON, or markdown plus issue tracker integration. Use this skill whenever the user mentions "accessibility audit", "a11y audit", "WCAG audit", "accessibility check", "compliance scan", or asks to check a web project for accessibility issues. Also trigger when the user wants to verify WCAG conformance or map findings to a specific standard (CAN-ASC-6.2, EN 301 549, ADA/AODA).
erpclaw
IncludedAI-native ERP system with self-extending OS. Full accounting, invoicing, inventory, purchasing, tax, billing, HR, payroll, advanced accounting (ASC 606/842, intercompany, consolidation), and financial reporting. 413 actions across 14 domains, 43 expansion modules. Constitutional guardrails, adversarial audit, schema migration. Double-entry GL, immutable audit trail, US GAAP.
assess
IncludedAssesses and rates quality 0-10 across multiple dimensions (correctness, maintainability, security, performance, testability, simplicity) with pros/cons analysis. Compares against project conventions and prior decisions from memory. Produces structured evaluation reports with actionable improvement suggestions. Use when evaluating code, designs, architectures, or comparing alternative approaches.
spring-boot-security-jwt
IncludedProvides JWT authentication and authorization patterns for Spring Boot 3.5.x covering token generation with JJWT, Bearer/cookie authentication, database/OAuth2 integration, and RBAC/permission-based access control using Spring Security 6.x. Use when implementing authentication or authorization in Spring Boot applications.
code-hardcode-audit
IncludedDetect hardcoded values, magic numbers, and leaked secrets. TRIGGERS - hardcode audit, magic numbers, PLR2004, secret scanning.