SMTP

Scanning for SMTP

Check if it is possible to connect to SMTP (port 25) and send VRFY command with a username to check if the user is valid.

Netcat

nc -nv <ip> 25

# wait for SMTP banner and then type:

VRFY root # verify the yser
EXPN # for for a membership of a mailing list

Python

#!/usr/bin/python3

import socket
import sys

if len(sys.argv) != 3:
    print("Usage: smtp-scan.py <ip> <username>")
    sys.exit(0)

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

connect = s.connect((sys.argv[1], 25))

banner = s.recv(1024)

print(banner)

cmd = "VRFY {}\r\n".format(sys.argv[2]);
s.send(cmd.encode())
result = s.recv(1024)

print(result)
s.close()