#!/bin/bash # check_mail_servers # A lame way to check what mail servers people run # Read from the uni list and run host to find the mail servers for company in `cat ./companies` do /usr/bin/host -t MX $company | head -n1 >> ./host_output done # Get the server names into a file /bin/cat ./host_output | /bin/cut -d" " -f7 > ./mail_servers # Connect to each, pull its banner, then disconect for server in `cat ./mail_servers` do /bin/nc -w5 $server 25 < ./netcat_input >> ./server_strings done # Get just the initial response from the server /bin/grep 220 server_strings > ./server_strings_refined # Get everyting else /bin/grep -v 220 server_strings > ./server_strings_chatter # Cleanup /bin/mv ./host_output ./old_host_output /bin/mv ./server_strings ./orig_server_strings