Penetration Testing with Kali Linux
PWK - Copyright © 2023 OffSec Services Limited. All rights reserved.
156
550 5.1.1
: Recipient address rejected: User unknown in local recipient
table
^C
Listing 78 - Using nc to validate SMTP users
We can observe how the success and error messages differ. The SMTP server readily verifies that
the user exists. This procedure can be used to help guess valid usernames in an automated
fashion. Next, let’s consider the following Python script, which opens a TCP socket, connects to
the SMTP server, and issues a VRFY command for a given username:
#!/usr/bin/python
import socket
import sys
if len(sys.argv) != 3:
print("Usage: vrfy.py ")
sys.exit(0)
# Create a Socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# Connect to the Server
ip = sys.argv[2]
connect = s.connect((ip,25))
# Receive the banner
banner = s.recv(1024)
print(banner)
# VRFY a user
user = (sys.argv[1]).encode()
s.send(b'VRFY ' + user + b'\r\n')
result = s.recv(1024)
print(result)
# Close the socket
s.close()
Listing 79 - Using Python to script the SMTP user enumeration
We can run the script by providing the username to be tested as a first argument and the target IP
as a second argument.
kali@kali:~/Desktop$
Yüklə
Dostları ilə paylaş: