Here is a script which scans a subnet for SMTP servers running and returns the SMTP Banner. This is helpful in identifying possible vulnerable mail servers on a remote network.
#!/usr/bin/env perl use strict; use warnings; use Net::SMTP; use Net::IP; my $CIDR = '192.168.0.0/24'; my $domain = 'my.mail.com'; my $timeout = 10; my $ip = new Net::IP($CIDR); print "[*] Searching $CIDR for SMTP Servers... (This may take a while)\n"; while (++$ip) { my $smtp = Net::SMTP->new( Host => $ip->ip(), Hello => $domain, Timeout => $timeout ); if (defined($smtp)) { print "[+] ".$ip->ip()." @ ".$smtp->banner(); $smtp->quit(); } }
If we run the script we get the following...
root@asus:~/public_html% perl post.pl [*] Searching 192.168.0.0/24 for SMTP Servers... (This may take a while) [+] 192.168.0.38 @ asus ESMTP Postfix (Ubuntu) [+] 192.168.0.140 @ mail.acme.com Microsoft ESMTP MAIL Service ready at Sun, 11 Jun 2019 17:45:54 -0400 root@asus:~/public_html%
As you can see we identified two SMTP server on the network range 192.168.0.0.
No comments:
Post a Comment