Resources
- Anonymous Domain & Vps Registeration :
- 1984 : https://1984.hosting/
- oragneWebsite : https://orangewebsite.com/
- Njalla : https://njalla.com/
- GoodBadISPs : https://gitlab.torproject.org/legacy/trac/-/wikis/doc/GoodBadISPs
- CheckLists :
- DNSbl : https://www.dnsbl.info/dnsbl-database-check.php
- ExpiredDomains : https://www.expireddomains.net/
- Semrush : https://www.semrush.com/
- Ahrefs : https://ahrefs.com/
- Mxtoolbox : https://mxtoolbox.com/
- Spamhus : https://check.spamhaus.org/
- Multribl : https://multirbl.valli.org/
- Urlfiltering : https://urlfiltering.paloaltonetworks.com/
- Talosintelligence : https://www.talosintelligence.com/
- Dkimvalidator : https://dkimvalidator.com/
- mail-tester : https://mail-tester.com/
- Email Auth :
- By xakep : https://xakep.ru/2019/06/18/mail-server-security/ || https://xakep.ru/2017/01/09/howto-configure-mail-server-spam-filters/ || https://xakep.ru/2017/02/13/gmail-spoofed/
- By cloudfare : https://www.cloudflare.com/learning/dns/dns-records/dns-mx-record/ || https://www.cloudflare.com/learning/email-security/dmarc-dkim-spf/ || https://www.cloudflare.com/learning/dns/dns-records/dns-a-record/ || https://www.cloudflare.com/learning/dns/dns-records/dns-cname-record/
- By it-security-in-plain-english : https://medium.com/it-security-in-plain-english/fortifying-digital-communications-a-comprehensive-guide-to-spf-dkim-dmarc-and-dnssec-136d8d1a2390
- By whoisfreaks : https://whoisfreaks.com/resources/blog/spf-dkim-dmarc-explained-the-dns-trio-that-secures-your-emails
- By praetorian : https://www.praetorian.com/blog/email-security/
- By snov : https://snov.io/blog/how-to-set-up-spf-dkim-dmarc/
- By easydmarc : https://easydmarc.com/blog/dmarc-dkim-spf-best-practices/
- By woodpecker : http://woodpecker.co/blog/spf-dkim/
- By uriports : https://www.uriports.com/blog/introduction-to-spf-dkim-and-dmarc/ || https://www.uriports.com/blog/spf-dkim-dmarc-best-practices/
- By bitsight : https://www.bitsight.com/blog/domain-insecurity-state-dmarc
- Mailgun Namecheap setup : https://help.gohighlevel.com/support/solutions/articles/48000981680-mailgun-setup-namecheap-domain-setup
- Evasion :
Commands
- Local SMTP [Evasive]
- Postfix
# Configuer PTR record [VPS] # Configure TXT SPF Record [Domain] # A @ record with VPS IP # A mail. record with VPS IP apt-get update # regular update export DEBIAN_FRONTEND=noninteractive # don't shows questions echo "postfix postfix/main_mailer_type select No configuration" | debconf-set-selections # Don't creat auto configs apt-get install -y postfix mailutils swaks opendkim opendkim-tools # install my tools cp /usr/share/postfix/main.cf.dist /etc/postfix/main.cf # just ensure it copies postconf -e 'myhostname = mail.fadymoheb.com' # Sets the server's FQDN (Fully Qualified Domain Name) postconf -e 'mydomain = fadymoheb.com' # Used as a variable for other settings. postconf -e 'myorigin = $mydomain' # Sets the domain appended to local sender addresses insted of [email protected] to [email protected] postconf -e 'mydestination =' # do not accept mail for any local domain. postconf -e 'mynetworks = 127.0.0.0/8' # Only trusts the loopback interface , Only programs running on this same machine can send mail through me without a password. postconf -e 'inet_interfaces = 127.0.0.1' # Postfix listens ONLY on localhost postconf -e 'inet_protocols = ipv4' # Disable IPv6 postconf -e 'relayhost =' # will look up the recipient's MX record via DNS and connect directly to their mail server. postconf -e 'smtp_tls_security_level = may' # try to use TLS if the remote server supports it. it has none never use TLS , may use TLS if available , encrypt require TOLS postconf -e 'smtpd_relay_restrictions = permit_mynetworks, reject_unauth_destination' # open-relay prevention rule one only 127.0.0.1 postconf -e 'disable_vrfy_command = yes' # Disables the VRFY SMTP command. postconf -e 'message_size_limit = 15360000' # Max email size 15 Mib postconf -e 'default_transport_rate_delay = 15s' # Wait 15s between every email and other postconf -e 'initial_destination_concurrency = 1' # One email per thread postconf -e 'default_destination_concurrency_limit = 1' # only one destenation thread per connection postconf -e 'minimal_backoff_time = 60s' # if failed retry after 1 min postconf -e 'maximal_backoff_time = 5m' # max time retring 5 min postconf -e "setgid_group = postdrop" postconf -e "mail_owner = postfix" postconf -e "mailq_path = /usr/bin/mailq" postconf -e "newaliases_path = /usr/bin/newaliases" postconf -e "sendmail_path = /usr/sbin/sendmail" postconf -e "manpage_directory = /usr/share/man" postconf -e "readme_directory = /usr/share/doc/postfix" postconf -e "html_directory = /usr/share/doc/postfix/html" postconf -e "alias_maps = hash:/etc/aliases" postconf -e "alias_database = hash:/etc/aliases" postfix check systemctl restart postfix@- systemctl is-active postfix@- ss -tlnp | grep ':25 '- Slef Fix Script [Postfix on Debian]
for p in debugger_command sendmail_path newaliases_path mailq_path setgid_group \ html_directory manpage_directory sample_directory readme_directory; do
- Slef Fix Script [Postfix on Debian]
- DKIM
mkdir -p /etc/dkimkeys/fadymoheb.com # Creat a dir for the keys opendkim-genkey -b 2048 -d fadymoheb.com -s mailvps -D /etc/dkimkeys/fadymoheb.com # Creat the private & Public Keys chown -R opendkim:opendkim /etc/dkimkeys/fadymoheb.com # OpenDKIM daemon runs as the opendkim user. It must be able to read the private key nano /etc/dkimkeys/key.table # <key-name> <domain>:<selector>:<private-key-path> mailvps._domainkey.fadymoheb.com fadymoheb.com:mailvps:/etc/dkimkeys/fadymoheb.com/mailvps.private nano /etc/dkimkeys/signing.table # Which mail gets signed <sender-pattern> <key-name> *@fadymoheb.com mailvps._domainkey.fadymoheb.com [email protected] mailvps._domainkey.fadymoheb.com # just to be sure chown root:opendkim /etc/dkimkeys/key.table /etc/dkimkeys/signing.table chmod 640 /etc/dkimkeys/key.table /etc/dkimkeys/signing.table nano /etc/opendkim.conf KeyTable /etc/dkimkeys/key.table SigningTable refile:/etc/dkimkeys/signing.table systemctl restart opendkim # restart ss -tlnp | grep ':12301 ' # work ? postconf -e 'milter_default_action = accept' # if opendikm unreachaple accept postconf -e 'milter_protocol = 6' # milter protocol version 6 postconf -e 'smtpd_milters = inet:127.0.0.1:12301' # sign via this port [dkim port ] postconf -e 'non_smtpd_milters = inet:127.0.0.1:12301' # for locally injected not smtpd [sendmail eg.] # grep -o '"[^"]*"' mailvps.txt | tr -d '"' | tr -d '\n'; echo # Add them as TXT mailvps._domainkey - Sending
swaks --server 127.0.0.1:25 --from [email protected] --to [email protected] --header "Subject: order summary " --body "order accepted" # Test and Pingo grep -E "status=" /var/log/mail.log | tail -60 | awk "{print substr(\$1,1,16)}" | uniq -c # See the logs
- Postfix
Tools
- fail2ban : https://github.com/fail2ban/fail2ban
- gophish : https://github.com/gophish/gophish
- swaks : https://github.com/jetmore/swaks
Notes
The Full Email Delivery Chain: MUA, MSA, MTA, MDA
In modern email architecture, submitting an email (requiring user authentication on Port
587or465) is strictly separated from transferring an email between servers (unauthenticated server-to-server relay on Port25).
1. The Four Agents Mapped to Applications and Daemons
Agent Functional Role Core Responsibility Standard Applications / Daemons Offensive / Security Testing Tools 1. MUA Mail User Agent Composes and reads messages; submits outgoing mail to the MSA. Thunderbird, Outlook, Apple Mail, Roundcube, muttGophish, Swaks, Python smtplib2. MSA Mail Submission Agent Listens on Ports 587/465; enforcesAUTH LOGIN, applies rate limits, and signs headers via OpenDKIM.Postfix ( submissioninmaster.cf), Exim, SendGrid, AWS SESAuthenticated SMTP relay configured in a Gophish Sending Profile 3. MTA Mail Transfer Agent Queries target DNS MX records; relays messages server-to-server over Port 25 without password authentication. Postfix ( smtpd/qmgr), Sendmail, Exchange Transport, ProofpointOutbound Postfix daemon relaying to gmail-smtp-in.l.google.com:254. MDA Mail Delivery Agent Receives messages from the Inbound MTA via LMTP, evaluates spam/filtering rules (Sieve), and writes to disk ( /Maildir).Dovecot ( dovecot-lda), Procmail, Maildrop, CyrusTarget mailbox store accessed by the recipient client over IMAPS ( 993)
2. Port Assignments and Security Models
Port 25 (MTA-to-MTA Relay)
- Authentication: None by default. Receiving MTAs cannot hold passwords for every external mail server; instead, trust is established via SPF, DKIM, DMARC, PTR (Reverse DNS), and IP reputation.
- Open Relay Risk: An MTA listening on Port 25 must only accept unauthenticated mail destined for local domains it manages. Permitting unauthenticated third-party relay creates an Open Relay.
- Network Restrictions: Outbound Port 25 is restricted by default across most residential ISPs and cloud providers (AWS, DigitalOcean, Hetzner) to prevent compromised hosts from operating as unauthorized MTAs.
Ports 587, 465, and 2525 (Authenticated Client Submission)
- Port 587 (Explicit TLS / STARTTLS): The standard client submission port. Connections initialize in plaintext and upgrade to an encrypted channel via the
STARTTLSverb prior to authentication.- Port 465 (Implicit TLS / SMTPS): Establishes a TLS handshake immediately upon TCP connection before any SMTP traffic is exchanged. Requires user authentication.
- Port 2525 (Alternative Submission): A non-standard port commonly supported by commercial ESPs (SendGrid, Mailgun, SMTP2GO) utilizing
STARTTLSwhen outbound Ports 25, 465, and 587 are filtered by firewalls.
3. Architecture Flowchart
flowchart LR subgraph Sender_Side ["Sender Environment"] MUA1["<b>1. MUA (Client)</b><br/>Thunderbird / Gophish / Swaks"] end subgraph Sender_Server ["Sender Mail Server (Postfix VPS)"] MSA["<b>2. MSA (Submission)</b><br/>Postfix (submission)<br/>Auth + OpenDKIM Sign"] MTA1["<b>3. Outbound MTA</b><br/>Postfix (qmgr/smtp)<br/>DNS MX Lookup"] end subgraph Target_Server ["Target Infrastructure (Google / Proofpoint)"] MTA2["<b>3. Inbound MTA</b><br/>gmail-smtp-in.l.google.com<br/>Checks SPF, DKIM, DMARC, IP Rep"] MDA["<b>4. MDA (Delivery)</b><br/>Dovecot / Procmail<br/>Sieve Rules -> /Maildir"] end subgraph Recipient_Side ["Recipient Environment"] MUA2["<b>Recipient MUA</b><br/>Outlook / Gmail Client"] end MUA1 -->|"Port 587 (STARTTLS)<br/>Port 465 (Implicit TLS)<br/>AUTH LOGIN"| MSA MSA -->|"Internal Queue"| MTA1 MTA1 ==>|"Port 25 (SMTP Relay)<br/>No Password (DNS Auth)"| MTA2 MTA2 -->|"Port 24 (LMTP)<br/>or Local Socket"| MDA MDA -.->|"Port 993 (IMAPS)<br/>Port 995 (POP3S)"| MUA2 style MUA1 fill:#1e293b,stroke:#38bdf8,stroke-width:2px,color:#fff style MSA fill:#064e3b,stroke:#10b981,stroke-width:2px,color:#fff style MTA1 fill:#312e81,stroke:#818cf8,stroke-width:2px,color:#fff style MTA2 fill:#312e81,stroke:#818cf8,stroke-width:2px,color:#fff style MDA fill:#4c1d95,stroke:#c084fc,stroke-width:2px,color:#fff style MUA2 fill:#1e293b,stroke:#38bdf8,stroke-width:2px,color:#fff
4. End-to-End Protocol Sequence
sequenceDiagram autonumber actor User as MUA (Client) participant MSA as MSA (Postfix :587) participant DNS as DNS Server participant MTA as Target MTA (Inbound :25) participant MDA as MDA (Dovecot / Mailstore) Note over User,MSA: Stage 1: Authenticated Submission User->>MSA: TCP Connect Port 587 -> EHLO -> STARTTLS User->>MSA: AUTH LOGIN (Credentials) User->>MSA: MAIL FROM:<[email protected]> MSA->>MSA: Sanitize headers and apply OpenDKIM signature Note over MSA,MTA: Stage 2: MTA-to-MTA Relay MSA->>DNS: Query MX record for recipient domain DNS-->>MSA: Return inbound MX host MSA->>MTA: TCP Connect Port 25 -> STARTTLS MSA->>MTA: Transmit signed message (Unauthenticated) MTA->>DNS: Validate SPF, DKIM Public Key, DMARC, and PTR Note over MTA,MDA: Stage 3: Local Mailbox Delivery MTA->>MDA: Transfer via LMTP (Port 24 or Unix Socket) MDA->>MDA: Execute SpamAssassin/Rspamd and Sieve rules -> Write to /Maildir
