SMTP Enumeration

Interacting with SMTP is easy and since the protocol is straight forward.

  1. #!/usr/bin/env ruby
  2. # KING SABRI | @KINGSABRI
  3. #
  4. require 'socket'
  5. users =
  6. %w{
  7. root rubyfu www apache2 bin daemon sshd
  8. gdm nobody ftp operator postgres mysqld
  9. }
  10. found = []
  11. @s = TCPSocket.new('192.168.0.19', 25)
  12. @banner = @s.recv(1024).chomp
  13. users.each do |user|
  14. @s.send "VRFY #{user} \n\r", 0
  15. resp = @s.recv(1024).chomp
  16. found << user if resp.split[2] == user
  17. end
  18. @s.close
  19. puts "[*] Result:-"
  20. puts "[+] Banner: " + @banner
  21. puts "[+] Found users: \n#{found.join("\n")}"

Results

  1. [*] Result:-
  2. [+] Banner: 220 VulnApps.localdomain ESMTP Postfix
  3. [+] Found users:
  4. root
  5. rubyfu
  6. www
  7. bin
  8. daemon
  9. sshd
  10. gdm
  11. nobody
  12. ftp
  13. operator
  14. postgres

Your turn, there are other commands that can be used such as EXPN, RCPT. Enhance the above script to include all these commands to avoid restricted commands that might you face. Tweet your code and output to @Rubyfu.