Created
December 31, 2019 09:44
-
-
Save insi2304/aeefd2a4118c04a8064cedd7378d25d5 to your computer and use it in GitHub Desktop.
SMTP relay check on multiple subdomains
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
declare -a arr=("25" "465" "587" "2525") | |
for i in `cat smtp_hosts`; | |
do | |
k=`dig +short $i | tail -n1` | |
if [ -z "$k" ] | |
then | |
echo "No ip present corresponding to hostname" $i | |
else | |
for j in "${arr[@]}"; | |
do | |
echo "testing mail relay for ${i}:${j}" | |
my_email_body="Test from telnet from host ${i}:${j}" | |
mail_server_ip=$k | |
mail_server_port=$j | |
recipient="user@gmail.com" | |
sender="\"VulnDomain Support\"<support@vulndomain.com>" | |
nc ${mail_server_ip} ${mail_server_port} << EOF | |
ehlo vulndomain.com | |
mail from:${sender} | |
rcpt to:${recipient} | |
data | |
From:${sender} | |
To:${recipient} | |
subject: Telnet test | |
${my_email_body} | |
. | |
quit | |
EOF | |
done | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment