{"id":13845549,"url":"https://github.com/cytopia/smtp-user-enum","last_synced_at":"2025-04-06T12:08:12.385Z","repository":{"id":44411858,"uuid":"235630645","full_name":"cytopia/smtp-user-enum","owner":"cytopia","description":"SMTP user enumeration via VRFY, EXPN and RCPT with clever timeout, retry and reconnect functionality.","archived":false,"fork":false,"pushed_at":"2024-05-14T13:18:58.000Z","size":54,"stargazers_count":136,"open_issues_count":3,"forks_count":29,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-30T11:07:01.267Z","etag":null,"topics":["cytopia-sec","enumeration","penetration-testing","pentest","pentest-tool","pentesting","pentesting-python","pentesting-tools","smtp","smtp-server","smtp-user-enumeration","user-enumeration"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cytopia.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-01-22T17:49:02.000Z","updated_at":"2025-03-29T11:50:31.000Z","dependencies_parsed_at":"2024-10-22T18:34:47.073Z","dependency_job_id":null,"html_url":"https://github.com/cytopia/smtp-user-enum","commit_stats":{"total_commits":21,"total_committers":2,"mean_commits":10.5,"dds":0.1428571428571429,"last_synced_commit":"758d60268733b00d9b18d510ede3dabd1fab3294"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cytopia%2Fsmtp-user-enum","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cytopia%2Fsmtp-user-enum/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cytopia%2Fsmtp-user-enum/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cytopia%2Fsmtp-user-enum/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cytopia","download_url":"https://codeload.github.com/cytopia/smtp-user-enum/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247478321,"owners_count":20945266,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cytopia-sec","enumeration","penetration-testing","pentest","pentest-tool","pentesting","pentesting-python","pentesting-tools","smtp","smtp-server","smtp-user-enumeration","user-enumeration"],"created_at":"2024-08-04T17:03:28.107Z","updated_at":"2025-04-06T12:08:12.359Z","avatar_url":"https://github.com/cytopia.png","language":"Python","readme":"# smtp-user-enum\n\n[![](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![PyPI](https://img.shields.io/pypi/v/smtp-user-enum)](https://pypi.org/project/smtp-user-enum/)\n[![PyPI - Status](https://img.shields.io/pypi/status/smtp-user-enum)](https://pypi.org/project/smtp-user-enum/)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/smtp-user-enum)](https://pypi.org/project/smtp-user-enum/)\n[![PyPI - Format](https://img.shields.io/pypi/format/smtp-user-enum)](https://pypi.org/project/smtp-user-enum/)\n[![PyPI - Implementation](https://img.shields.io/pypi/implementation/smtp-user-enum)](https://pypi.org/project/smtp-user-enum/)\n[![PyPI - License](https://img.shields.io/pypi/l/smtp-user-enum)](https://pypi.org/project/smtp-user-enum/)\n\n[![Build Status](https://github.com/cytopia/smtp-user-enum/workflows/linting/badge.svg)](https://github.com/cytopia/smtp-user-enum/actions?workflow=linting)\n\nSMTP user enumeration via `VRFY`, `EXPN` and `RCPT` with clever timeout, retry and reconnect functionality.\n\nSome SMTP server take a long time for initial communication (banner and greeting) and then\nhandle subsequent commands quite fast. Then again they randomly start to get slow again.\n\nThis implementation of SMTP user enumeration counteracts with granular timeout, retry and\nreconnect options for initial communication and enumeration separately.\nThe defaults should work fine, however if you encounter slow enumeration, adjust the settings\naccording to your needs.\n\nAdditionally if it encounters anything like `421 Too many errors on this connection` it will\nautomatically and transparently reconnect and continue from where it left off.\n\n\n\u003e Inspired by [smtp-user-enum](http://pentestmonkey.net/tools/user-enumeration/smtp-user-enum) Perl script and rewritten in Python with full Python2 and Python3 support.\n\n**Table of contents**\n\n1. [Installation](#tada-installation)\n2. [Features](#star-features)\n3. [Usage](#computer-usage)\n4. [VRFY mode (default)](#smiling_imp-vrfy-mode-default)\n    1. [How does VRFY work](#how-does-vrfy-work)\n    2. [Successful VRFY enumeration](#successful-vrfy-enumeration)\n    3. [Failed VRFY enumeration](#failed-vrfy-enumeration)\n5. [EXPN mode](#smiling_imp-expn-mode)\n    1. [How does EXPN work](#how-does-expn-work)\n    2. [Successful EXPN enumeration](#successful-expn-enumeration)\n    3. [Failed EXPN enumeration](#failed-expn-enumeration)\n6. [RCPT mode](#smiling_imp-rcpt-mode)\n    1. [How does RCPT work](#how-does-rcpt-work)\n    2. [Successful RCPT enumeration](#successful-rcpt-enumeration)\n    3. [Troubleshooting EXPN enumeration](#troubleshooting-expn-enumeration)\n        1. [550 A valid address is required](#550-a-valid-address-is-required)\n        2. [450 Relaying temporarily denied](#450-relaying-temporarily-denied)\n        3. [False positives](#false-positives)\n        4. [Investigating timeouts](#investigating-timeouts)\n7. [Mitigation](#cop-mitigation)\n    1. [VRFY and EXPN](#vrfy-and-expn)\n        1. [Postfix](#postfix)\n        2. [Sendmail](#sendmail)\n        3. [Exim](#exim)\n    2. [RCPT TO](#rcpt-to)\n8. [cytopia sec tools](#lock-cytopia-sec-tools)\n9. [Contributing](#octocat-contributing)\n10. [Disclaimer](#exclamation-disclaimer)\n11. [License](#page_facing_up-license)\n\n\n## :tada: Installation\n```bash\npip install smtp-user-enum\n```\n\n\n## :star: Features\n\n* Enumerate users via `VRFY`, `EXPN` or `RCPT`\n* Find out which users are aliases via `RCPT`\n* Fully customize from email for `RCPT` mode\n* Append domains to usernames\n* Wrap usernames or emails in `\u003c` and `\u003e`\n* Very verbose mode\n* Very granular timing, retry and reconnect options for all phases\n* Works with Python2 and Python3\n\nSee troubleshooting section for examples on how to use different options\n\n\n## :computer: Usage\n\n```bash\n$ smtp-user-enum --help\n\nusage: smtp-user-enum [options] -u/-U host port\n       smtp-user-enum --help\n       smtp-user-enum --version\n\nSMTP user enumeration tool with clever timeout, retry and reconnect functionality.\n\nSome SMTP server take a long time for initial communication (banner and greeting) and then\nhandle subsequent commands quite fast. Then again they randomly start to get slow again.\n\nThis implementation of SMTP user enumeration counteracts with granular timeout, retry and\nreconnect options for initial communication and enumeration separately.\nThe defaults should work fine, however if you encounter slow enumeration, adjust the settings\naccording to your needs.\n\nAdditionally if it encounters anything like '421 Too many errors on this connection' it will\nautomatically and transparently reconnect and continue from where it left off.\n\npositional arguments:\n  host                  IP or hostname to connect to.\n  port                  Port to connect to.\n\noptional arguments:\n  -h, --help            show this help message and exit\n  -v, --version         Show version information,\n  -m mode, --mode mode  Mode to enumerate SMTP users.\n                        Supported modes: VRFY, EXPN, RCPT\n                        Default: VRFY\n  -d addr, --domain addr\n                        Domain to append to users to convert into email addresses.\n                        Useful if you see this response: '550 A valid address is required'\n                        Default: Nothing appended\n  -w, --wrap            Wrap the username or email address in '\u003c' and '\u003e' characters.\n                        Usefule if you see this response: '501 5.5.2 Syntax error in parameters or arguments'.\n                        Makes sense to combine with -d/--domain option.\n                        Default: Nothing wrapped\n  -f addr, --from-mail addr\n                        MAIL FROM email address. Only used in RCPT mode\n                        Default: user@example.com\n  -l addr, --helo addr  Domain name of sending host used in HELO command.\n  -u user, --user user  Username to test.\n  -U file, --file file  Newline separated wordlist of users to test.\n  -V, --verbose         Show verbose output. Useful to adjust your timing and retry settings.\n  --timeout-init sec    Timeout for initial communication (connect, banner and greeting).\n                        Default: 25\n  --timeout-enum sec    Timeout for user enumeration.\n                        Default: 10\n  --retry-init int      Number of retries for initial communication (connect, banner and greeting).\n                        Default: 4\n  --retry-enum int      Number of retries for user enumeration.\n                        Default: 5\n  --reconnect int       Number of reconnects during user enumeration after retries have exceeded.\n                        Default: 3\n```\n\n\n## :smiling_imp: VRFY mode (default)\n\n\u003e The SMTP \"VRFY\" command allows you to verify whether a the system can deliver mail to a particular user.\n\u003e\n\u003e Source: https://www.rapid7.com/db/vulnerabilities/smtp-general-vrfy\n\n### How does VRFY work\n\nThe `VRFY` mode can easily be tested with `nc` or `telnet` as shown below:\n```bash\n$ nc mail.example.tld 25\n```\n```\n220 mail.example.tld ESMTP Sendmail 8.12.8/8.12.8; Thu, 23 Jan 2020 16:03:22 +0200\nHELO changeme\n250 mail.example.tld Hello [10.0.0.1], pleased to meet you\nVRFY someuser\n550 5.1.1 someuser... User unknown\nVRFY bob\n250 2.1.5 \u003cbob@mail.example.tld\u003e\n```\n\nAs can be seen `VRFY someuser` tells us it does not exist whereas `VRFY bob` yields a positive result.\n\n### Successful VRFY enumeration\n\n```bash\n$ smtp-user-enum -U /usr/share/wordlists/metasploit/unix_users.txt mail.example.tld 25\n\nConnecting to mail.example.tld 25 ...\n220 mail.example.tld ESMTP Sendmail 8.12.8/8.12.8; Wed, 22 Jan 2020 19:33:07 +0200\n250 mail.example.tld Hello [10.0.0.1], pleased to meet you\nStart enumerating users with VRFY mode ...\n[----] admin             550 5.1.1 admin... User unknown\n[----] OutOfBox          550 5.1.1 OutOfBox... User unknown\n[SUCC] root              250 2.1.5 root \u003croot@mail.example.tld\u003e\n[SUCC] adm               250 2.1.5 \u003cadm@mail.example.tld\u003e\n[----] avahi-autoipd     550 5.1.1 avahi-autoipd... User unknown\n[----] backup            550 5.1.1 backup... User unknown\n[TEST] bin ...\n```\n\n### Failed VRFY enumeration\n\nIn case the VRFY mode is not successful as shown below, you will need to try out a different mode.\n\n```bash\n$ smtp-user-enum -U /usr/share/wordlists/metasploit/unix_users.txt mail.example.tld 25\n\nConnecting to mail.example.tld 25 ...\n220 mail.example.tld ESMTP Sendmail 8.12.8/8.12.8; Wed, 22 Jan 2020 19:33:07 +0200\n250 mail.example.tld Hello [10.0.0.1], pleased to meet you\nStart enumerating users with VRFY mode ...\n[----] 4Dgifts           502 VRFY disallowed.\n[----] EZsetup           502 VRFY disallowed.\n[----] OutOfBox          502 VRFY disallowed.\n[----] root              502 VRFY disallowed.\n[----] adm               502 VRFY disallowed.\n[----] admin             502 VRFY disallowed.\n[----] administrator     502 VRFY disallowed.\n[----] anon              502 VRFY disallowed.\n```\n\n\n## :smiling_imp: EXPN mode\n\n\u003e The SMTP \"EXPN\" command allows you to expand a mailing list or alias, to see where mail addressed to the alias actually goes. For example, many organizations alias postmaster to root, so that mail addressed to postmaster will get delivered to the system administrator. Issuing \"EXPN postmaster\" via SMTP would reveal that postmaster is aliased to root.\n\u003e\n\u003e The \"EXPN\" command can be used by attackers to learn about valid usernames on the target system. On some SMTP servers, EXPN can be used to show the subscribers of a mailing list -- subscription lists are generally considered to be sensitive information.\n\u003e\n\u003e Source: https://www.rapid7.com/db/vulnerabilities/smtp-general-expn\n\n### How does EXPN work\n\nThe `EXPN` mode can easily be tested with `nc` or `telnet` as shown below:\n```bash\n$ nc mail.example.tld 25\n```\n```\n220 mail.example.tld ESMTP Sendmail 8.12.8/8.12.8; Thu, 23 Jan 2020 16:03:22 +0200\nHELO changeme\n250 mail.example.tld [10.0.0.1], pleased to meet you\nEXPN someuser\n550 5.1.1 someuser... User unknown\nEXPN bob\n250 2.1.5 \u003cbob@mail.example.tld\u003e\nEXPN bin\n250 2.1.5 root \u003croot@mail.example.tld\u003e\n```\n\nAs can be seen `EXPN someuser` tells us it does not exist whereas `EXPN bob` and `EXPN bin` yield positive results. You can also see from the output that `bob` is a real user on the system, whereas\n`bin` is just an alias pointing to `root`.\n\n### Successful EXPN enumeration\n\n```bash\n$ smtp-user-enum -m EXPN -U /usr/share/wordlists/metasploit/unix_users.txt mail.example.tld 25\n\nConnecting to mail.example.tld 25 ...\n220 mail.example.tld ESMTP Sendmail 8.12.8/8.12.8; Wed, 22 Jan 2020 19:33:07 +0200\n250 mail.example.tld Hello [10.0.0.1], pleased to meet you\nStart enumerating users with EXPN mode ...\n[----] 4Dgifts           550 5.1.1 4Dgifts... User unknown\n[----] EZsetup           550 5.1.1 EZsetup... User unknown\n[----] OutOfBox          550 5.1.1 OutOfBox... User unknown\n[SUCC] root              250 2.1.5 root \u003croot@barry\u003e\n[SUCC] adm               250 2.1.5 root \u003croot@barry\u003e\n[----] admin             550 5.1.1 admin... User unknown\n[----] administrator     550 5.1.1 administrator... User unknown\n[----] anon              550 5.1.1 anon... User unknown\n[----] auditor           550 5.1.1 auditor... User unknown\n```\n\n**Note:** the right side shows to what mailbox the email will be forwarded for the alias.\n\n### Failed EXPN enumeration\n\nIn case the EXPN mode is not successful as shown below, you will need to try out a different mode.\n\n```bash\n$ smtp-user-enum -m EXPN -U /usr/share/wordlists/metasploit/unix_users.txt mail.example.tld 25\n\nConnecting to mail.example.tld 25 ...\n220 mail.example.tld ESMTP Sendmail 8.12.8/8.12.8; Wed, 22 Jan 2020 19:33:07 +0200\n250 mail.example.tld Hello [10.0.0.1], pleased to meet you\nStart enumerating users with EXPN mode ...\n[----] adm               502 Unimplemented command.\n[----] admin             502 Unimplemented command.\n[----] administrator     502 Unimplemented command.\n[----] anon              502 Unimplemented command.\n[----] auditor           502 Unimplemented command.\n[----] avahi             502 Unimplemented command.\n[----] avahi-autoipd     502 Unimplemented command.\n[----] bbs               502 Unimplemented command.\n[----] bin               502 Unimplemented command.\n```\n\n## :smiling_imp: RCPT mode\n\nThis is usually the most useful command to fish for usernames as `VRFY` and `EXPN` are often disabled.\n\n### How does RCPT work\n\nThe `RCPT` mode can easily be tested with `nc` or `telnet` as shown below:\n```bash\n$ nc mail.example.tld 25\n```\n```\n220 mail.example.tld ESMTP Sendmail 8.12.8/8.12.8; Thu, 23 Jan 2020 16:03:22 +0200\nHELO changeme\n250 mail.example.tld [10.0.0.1], pleased to meet you\nMAIL FROM:user@example.com\n250 2.1.0 user@example.com... Sender ok\nRCPT TO:someuser\n550 5.1.1 someuser... User unknown\nRCPT TO:bob\n250 2.1.5 bob... Recipient ok\n```\n\nAs can be seen `RCPT TO: someuser` tells us it does not exist whereas `RCPT TO: bob` yields a positive result.\n\n\n### Successful RCPT enumeration\n\n```bash\n$ smtp-user-enum -m RCPT -U /usr/share/wordlists/metasploit/unix_users.txt mail.example.tld 25\n\nConnecting to mail.example.tld 25 ...\n220 mail.example.tld ESMTP Sendmail 8.12.8/8.12.8; Wed, 22 Jan 2020 19:33:07 +0200\n250 mail.example.tld Hello [10.0.0.1], pleased to meet you\n250 2.1.0 user@example.com... Sender ok\nStart enumerating users with RCPT mode ...\n[----] OutOfBox          550 5.1.1 OutOfBox... User unknown\n[SUCC] root              250 2.1.5 root... Recipient ok\n[SUCC] adm               250 2.1.5 adm... Recipient ok\n[----] admin             550 5.1.1 admin... User unknown\n[----] administrator     550 5.1.1 administrator... User unknown\n[----] backup            550 5.1.1 backup... User unknown\n[----] bbs               550 5.1.1 bbs... User unknown\n[SUCC] bin               250 2.1.5 bin... Recipient ok\n[----] checkfs           550 5.1.1 checkfs... User unknown\n[----] checksys          550 5.1.1 checksys... User unknown\n```\n\n### Troubleshooting EXPN enumeration\n\n#### 550 A valid address is required\n```bash\n$ smtp-user-enum -m RCPT -U /usr/share/wordlists/metasploit/unix_users.txt mail.example.tld 25\n\nConnecting to mail.example.tld 25 ...\n220 mail.example.tld ESMTP Sendmail 8.12.8/8.12.8; Wed, 22 Jan 2020 19:33:07 +0200\n250 mail.example.tld Hello [10.0.0.1], pleased to meet you\n250 2.1.0 user@example.com... Sender ok\nStart enumerating users with RCPT mode ...\n[----] 4Dgifts           550 A valid address is required.\n[----] EZsetup           550 A valid address is required.\n[----] OutOfBox          550 A valid address is required.\n[----] root              550 A valid address is required.\n[----] adm               550 A valid address is required.\n```\n\nBy the above output you can see that pure usernames are not allowed to be specified,\nthis can be counteracted with the `-d` command, to append a domain to each username during enumeration:\n\n#### 450 Relaying temporarily denied\n```bash\n$ smtp-user-enum -m RCPT -d 'example.com' -U /usr/share/wordlists/metasploit/unix_users.txt mail.example.tld 25\n\nConnecting to mail.example.tld 25 ...\n220 mail.example.tld ESMTP Sendmail 8.12.8/8.12.8; Wed, 22 Jan 2020 19:33:07 +0200\n250 mail.example.tld Hello [10.0.0.1], pleased to meet you\n250 2.1.0 user@example.com... Sender ok\nStart enumerating users with RCPT mode ...\n[----] 4Dgifts           450 4.7.1 4Dgifts@example.com... Relaying temporarily denied. Cannot resolve PTR record for 10.0.0.1\n[----] EZsetup           450 4.7.1 EZsetup@example.com... Relaying temporarily denied. Cannot resolve PTR record for 10.0.0.1\n[----] OutOfBox          450 4.7.1 OutOfBox@example.com... Relaying temporarily denied. Cannot resolve PTR record for 10.0.0.1\n[----] root              450 4.7.1 root@example.com... Relaying temporarily denied. Cannot resolve PTR record for 10.0.0.1\n[----] adm               450 4.7.1 adm@example.com... Relaying temporarily denied. Cannot resolve PTR record for 10.0.0.1\n```\n\nLooks like the server is also hardened against relaying. To circumvent this, you could try to specify the server's hostname (cann be seen in the banner or greeting) or use `127.0.0.1` as the domain for users:\n\n#### False positives\n```bash\n$ smtp-user-enum -m RCPT -d '127.0.0.1' -U /usr/share/wordlists/metasploit/unix_users.txt mail.example.tld 25\n\nConnecting to mail.example.tld 25 ...\n220 mail.example.tld ESMTP Sendmail 8.12.8/8.12.8; Wed, 22 Jan 2020 19:33:07 +0200\n250 mail.example.tld Hello [10.0.0.1], pleased to meet you\n250 2.1.0 user@example.com... Sender ok\nStart enumerating users with RCPT mode ...\n[SUCC] 4Dgifts           250 2.1.5 4Dgifts@127.0.0.1... Recipient ok (will queue)\n[SUCC] EZsetup           250 2.1.5 EZsetup@127.0.0.1... Recipient ok (will queue)\n[SUCC] OutOfBox          250 2.1.5 OutOfBox@127.0.0.1... Recipient ok (will queue)\n[SUCC] root              250 2.1.5 root@127.0.0.1... Recipient ok (will queue)\n[SUCC] adm               250 2.1.5 adm@127.0.0.1... Recipient ok (will queue)\n[SUCC] admin             250 2.1.5 admin@127.0.0.1... Recipient ok (will queue)\n[SUCC] administrator     250 2.1.5 administrator@127.0.0.1... Recipient ok (will queue)\n[SUCC] anon              250 2.1.5 anon@127.0.0.1... Recipient ok (will queue)\n[SUCC] auditor           250 2.1.5 auditor@127.0.0.1... Recipient ok (will queue)\n[SUCC] backup            250 2.1.5 backup@127.0.0.1... Recipient ok (will queue)\n```\n\nLooks like `127.0.0.1` as the user's domain leads to false positives, let's try the exact domain speified in the banner `mail.example.tld`:\n\n```bash\n$ smtp-user-enum -m RCPT -d '127.0.0.1' -U /usr/share/wordlists/metasploit/unix_users.txt mail.example.tld 25\n\nConnecting to mail.example.tld 25 ...\n220 mail.example.tld ESMTP Sendmail 8.12.8/8.12.8; Wed, 22 Jan 2020 19:33:07 +0200\n250 mail.example.tld Hello [10.0.0.1], pleased to meet you\n250 2.1.0 user@example.com... Sender ok\nStart enumerating users with RCPT mode ...\n[----] 4Dgifts           550 5.1.1 4Dgifts@mail.example.tld... User unknown\n[----] EZsetup           550 5.1.1 EZsetup@mail.example.tld... User unknown\n[----] OutOfBox          550 5.1.1 OutOfBox@mail.example.tld... User unknown\n[SUCC] ROOT              250 2.1.5 ROOT@mail.example.tld... Recipient ok\n[SUCC] adm               250 2.1.5 adm@mail.example.tld... Recipient ok\n[----] admin             550 5.1.1 admin@mail.example.tld... User unknown\n[----] administrator     550 5.1.1 administrator@mail.example.tld... User unknown\n[----] anon              550 5.1.1 anon@mail.example.tld... User unknown\n[----] auditor           550 5.1.1 auditor@mail.example.tld... User unknown\n[----] avahi             550 5.1.1 avahi@mail.example.tld... User unknown\n[----] avahi-autoipd     550 5.1.1 avahi-autoipd@mail.example.tld... User unknown\n[----] backup            550 5.1.1 backup@mail.example.tld... User unknown\n[----] bbs               550 5.1.1 bbs@mail.example.tld... User unknown\n[SUCC] bin               250 2.1.5 bin@mail.example.tld... Recipient ok\n[----] checkfs           550 5.1.1 checkfs@mail.example.tld... User unknown\n```\n\n#### Investigating timeouts\n```bash\n$ smtp-user-enum -m RCPT -U /usr/share/wordlists/metasploit/unix_users.txt mail.example.tld 25\n\nConnecting to mail.example.tld 25 ...\n220 mail.example.tld ESMTP Sendmail 8.12.8/8.12.8; Wed, 22 Jan 2020 19:33:07 +0200\n250 mail.example.tld Hello [10.0.0.1], pleased to meet you\ntimed out\n```\n\nLet's add the `-V` to get some verbosity:\n\n```bash\n$ smtp-user-enum -V -m RCPT -U /usr/share/wordlists/metasploit/unix_users.txt -l mydomain.com mail.example.tld 25\nConnecting to mail.example.tld 25 ...\n[1/4] Connecting to mail.example.tld:25 ...\n[1/4] Waiting for banner ...\n220 beta SMTP Server (JAMES SMTP Server 2.3.2) ready Wed, 22 Jan 2020 16:10:10 -0500 (EST)\n[1/4] Sending greeting: HELO mydomain.com\n[1/4] Waiting for greeting reply ...\n250 beta Hello test (10.0.0.1 [10.0.0.1])\n[1/4] Sending: MAIL FROM: user@example.com\n[1/4] Waiting for MAIL FROM reply ...\n501 5.1.7 Syntax error in MAIL command\n[2/4] Waiting for MAIL FROM reply ...\n[3/4] Waiting for MAIL FROM reply ...\n[4/4] Waiting for MAIL FROM reply ...\ntimed out\n```\n\nSo apparently the mailserver does not like our command: `MAIL FROM: user@example.com`.\nTo circumvent this, let's put the from email in brackets like so: `MAIL FROM: \u003cuser@example.com\u003e` via the `-f` argument:\n\n\n```bash\n$ smtp-user-enum -f '\u003cuser@example.com\u003e' -m RCPT -U /usr/share/wordlists/metasploit/unix_users.txt mail.example.tld 25\n\nConnecting to mail.example.tld 25 ...\n220 mail.example.tld ESMTP Sendmail 8.12.8/8.12.8; Wed, 22 Jan 2020 19:33:07 +0200\n250 mail.example.tld Hello [10.0.0.1], pleased to meet you\n250 2.1.0 Sender \u003cuser@example.com\u003e OK\nStart enumerating users with RCPT mode ...\n[----] 4Dgifts           501 5.5.2 Syntax error in parameters or arguments\n[----] EZsetup           501 5.5.2 Syntax error in parameters or arguments\n[----] OutOfBox          501 5.5.2 Syntax error in parameters or arguments\n[----] root              501 5.5.2 Syntax error in parameters or arguments\n```\n\nLooks like the usernames also need to be wrapped in `\u003c` and `\u003e` to satisfy this specific mailserver. To do this, simply add the `-w` option:\n\n```bash\n$ smtp-user-enum -w -f '\u003cuser@example.com\u003e' -m RCPT -U /usr/share/wordlists/metasploit/unix_users.txt mail.example.tld 25\n\nConnecting to mail.example.tld 25 ...\n220 mail.example.tld ESMTP Sendmail 8.12.8/8.12.8; Wed, 22 Jan 2020 19:33:07 +0200\n250 mail.example.tld Hello [10.0.0.1], pleased to meet you\n250 2.1.0 Sender \u003cuser@example.com\u003e OK\nStart enumerating users with RCPT mode ...\n[SUCC] 4Dgifts           250 2.1.5 Recipient \u003c4Dgifts@localhost\u003e OK\n[SUCC] EZsetup           250 2.1.5 Recipient \u003cEZsetup@localhost\u003e OK\n[SUCC] OutOfBox          250 2.1.5 Recipient \u003cOutOfBox@localhost\u003e OK\n[SUCC] root              250 2.1.5 Recipient \u003croot@localhost\u003e OK\n[SUCC] adm               250 2.1.5 Recipient \u003cadm@localhost\u003e OK\n[SUCC] admin             250 2.1.5 Recipient \u003cadmin@localhost\u003e OK\n[SUCC] administrator     250 2.1.5 Recipient \u003cadministrator@localhost\u003e OK\n[SUCC] anon              250 2.1.5 Recipient \u003canon@localhost\u003e OK\n[SUCC] auditor           250 2.1.5 Recipient \u003cauditor@localhost\u003e OK\n```\n\nUnfortunately this yields to false positives again as it seems to be an open relay.\nHowever, lessons learned from this is to use the `-V` option in case of issues to troubleshoot what is going on.\nMaybe the open relay is another vector to hunt down.\n\n\n## :cop: Mitigation\n\nNow that you've seen how easy it could be to enumerate usernames on systems, you should ensure that your servers are hardened against this technique.\n\n### VRFY and EXPN\n\n#### Postfix\n\nOn Postfix `VRFY` seems to be not disabled by default as shown by [their documentation](http://www.postfix.org/postconf.5.html#disable_vrfy_command). It also looks like Postfix did not implement the `EXPN` command, so only `VRFY` needs to be disabled.\n\n`main.cf`:\n```ini\ndisable_vrfy_command = yes\n```\n\n#### Sendmail\n\nOn Sendmail you will have to adjust the privacy settings and reload its configuration afterwards in order to disable `VRFY` and `EXPN`.\n\n`sendmail.cf`:\n```diff\n- O PrivacyOptions=\n+ O PrivacyOptions=noexpn novrfy\n```\nor\n```diff\n- O PrivacyOptions=\n+ O PrivacyOptions=goaway\n```\n\n#### Exim\n\nOn Exim you should check if those values have already been disabled and then disable them accordingly. For the `EXPN` directive, ensure to either comment it out or set it to `localhost` only.\n\n`exim.conf`:\n```diff\n- smtp_verify = true\n+ smtp_verify = false\n\n- smtp_expn_hosts = ...\n+ smtp_expn_hosts = localhost\n```\n\n### RCPT TO\n\nThe `RCPT TO` command cannot be disabled without breaking a mail server. What you should do instead is to require authentication:\n\n* [Postifx SASL](http://www.postfix.org/SASL_README.html)\n* [Sendmail SASL](https://www.sendmail.org/~ca/email/auth.html)\n* [Exim SASL](https://www.exim.org/exim-html-current/doc/html/spec_html/ch-the_cyrussasl_authenticator.html)\n\n\n## :lock: [cytopia](https://github.com/cytopia) sec tools\n\nBelow is a list of sec tools and docs I am maintaining.\n\n| Name                 | Category             | Language   | Description |\n|----------------------|----------------------|------------|-------------|\n| **[offsec]**         | Documentation        | Markdown   | Offsec checklist, tools and examples |\n| **[header-fuzz]**    | Enumeration          | Bash       | Fuzz HTTP headers |\n| **[smtp-user-enum]** | Enumeration          | Python 2+3 | SMTP users enumerator |\n| **[urlbuster]**      | Enumeration          | Python 2+3 | Mutable web directory fuzzer |\n| **[pwncat]**         | Pivoting             | Python 2+3 | Cross-platform netcat on steroids |\n| **[badchars]**       | Reverse Engineering  | Python 2+3 | Badchar generator |\n| **[fuzza]**          | Reverse Engineering  | Python 2+3 | TCP fuzzing tool |\n\n[offsec]: https://github.com/cytopia/offsec\n[header-fuzz]: https://github.com/cytopia/header-fuzz\n[smtp-user-enum]: https://github.com/cytopia/smtp-user-enum\n[urlbuster]: https://github.com/cytopia/urlbuster\n[pwncat]: https://github.com/cytopia/pwncat\n[badchars]: https://github.com/cytopia/badchars\n[fuzza]: https://github.com/cytopia/fuzza\n\n\n## :octocat: Contributing\n\nSee **[Contributing guidelines](CONTRIBUTING.md)** to help to improve this project.\n\n\n## :exclamation: Disclaimer\n\nThis tool may be used for legal purposes only. Users take full responsibility for any actions performed using this tool. The author accepts no liability for damage caused by this tool. If these terms are not acceptable to you, then do not use this tool.\n\n\n## :page_facing_up: License\n\n**[MIT License](LICENSE.txt)**\n\nCopyright (c) 2020 **[cytopia](https://github.com/cytopia)**\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcytopia%2Fsmtp-user-enum","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcytopia%2Fsmtp-user-enum","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcytopia%2Fsmtp-user-enum/lists"}