Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Verify mail Address. Share/Save - My123World.Com!

  1. #1
    Network Security Administrator Hackuin's Avatar
    Join Date
    Apr 2011
    Location
    10011001 10011001
    Posts
    104

    Verify mail Address.

    Recently, we had a seminar for computational criminology. And, we had collected various people e-mail, addresses and we are about have a seminar again next month. We had to send invitation to selected members, but the list go too high numbered, and to my astonishment, I had sent them email, but, mail box dumped with "Mailer Demon-Failure", to the stupidity of humans haunt us at most of the times, plenty of people have either misspelled there E-mail Addresses or supplied wrong E-mail address.

    So, to avoid, these situations again, I taught of wring a script to verify e-mail address, before sending E-mails/Just to send e-mails to valid address.

    Code:
    #!/bin/bash
    #:
    #: e-mail.verify.sh
    #:
    #: Date: 2011/23/07 08:20:58 PM IST
    #: Author: Hackuin _at_ Ymail com
    #: Discription: Verify (or) Validate the G-Mail Adresses.
    #:
    #: Copyright (c) 2011 Under GPL License.
    #:
    
    
    if [ ! $# == 1 ]
    then
    	echo "Usage: $0 Filename"
    	exit 0
    fi
    
    cd /tmp
    
    cat $1 | while read LINE; do
    {
    FILENAME="i*"
    NULL="/dev/null"
    rm -rf i*
    
    
    #: At first I tryied this URI, but, it limited to 5 mail verification
    #: per hour it seems :/
    #: wget "http://www.email-unlimited.com/tools/verify-email.aspx?Email=$LINE&B1=Verify"
    
    wget "http://my-addr.com/free-email-verification-tool/verify-email-address/reverse-email-lookup/verify_email.php/?mail=$LINE&x=15&y=13"
    grep "e-mail exist" $FILENAME >$NULL
    	if [ "$?" -eq "0" ]
    	then
    		echo -e "$LINE" > VALIDEMAIL
    	else
    		echo -e "$LINE" > $NULL
    	fi
    }
    done
    
    #: END
    However, instead of using/calling, other peoples tool, I mean the existing "my-addr.com" script, I again taught of writing our own script, verify.

    Code:
    #!/bin/bash
    #:
    #: e-mail.verify.sh
    #:
    #: Date: 2011/22/07 09:40:28 PM IST
    #: Author: Hackuin _at_ Ymail com
    #: Discription: Verify (or) Validate the G-Mail Adresses.
    #:
    #: Copyright (c) 2011 Under GPL License.
    #:
    
    
    #: First we create a Expect script to be sourced for us.
    #: 
    if [ ! $# == 1 ]
    then
    	echo "Usage: $0 Filename"
    	exit 0
    fi
    
    #: Verifying the G-mail adressess.
    #: First verify the network Connections
    
    C_R="\e[01;31m" 			## Colors
    C_B="\e[01;30m" 
    C_G="\e[01;32m" 
    C_END="\e[00m" 
    
    SMTPSERV=`host -t mx gmail.com |grep 5 |cut -d " " -f 7| sed 's/\.$//'`
    ping -c1 $SMTPSERV >/dev/null
    		if [ "$?" -eq 0 ]
    		then
    			echo -e "Internet Connection" "\t\t\t\t\t\t$C_G[ OK ]$C_END"
    			echo -e "$SMTPSERV is AVAILABLE."
    			echo -n "Verifing"
    			for (( i=0; i<5; i++ ))
    			do
    				echo -n ".."
    				sleep 1
    			done
    			echo 
    		else
    			echo -e "Internet Connection:" "\t\t\t\t\t\t$C_R[ FAIL ]$C_END" ""			
    			echo -e "$SMTPSERV is Unavialable."
    			echo -e "Check your Network settings."
    			exit 0
    		fi
    
    # Checking Expect is available or not.
    
    expect -v >/dev/null
    		if [ "$?" -eq 0 ]
    		then
    			echo -e "Expect:" "\t\t\t\t\t\t\t$C_G[ OK ]$C_END" ""
    		else
    			echo -e echo -e "Expect:" "\t\t\t\t\t\t\t$C_R[ FAIL ]$C_END" ""
    			echo -e "sudo apt-get install -y expect"
    		fi
    COUNT=0
    RM_FILE="validemails.txt"
    
    rm -rf $RM_FILE
    
    cat $1 | while read LINE; do
    {
    MAFR="MAIL FROM: <EXPECT@SCRIPT.COM>"
    MATO="RCPT TO: <$LINE>"
    
    #: ^variablies declared for not get escaped in the next cat command, where
    #: we set the $MAFR in the expect script.
    
    cat << __EOF > e-veri1
    #!/bin/expect
    #:
    #: Date: 2011/22/07 09:23:44 PM IST
    #: Author: Hackuin _at_ Ymail com
    #: Discription: Expect Script to Verify/Validate the G-Mail Adresses.
    #:
    
    
    set VMAFR "$MAFR"
    set VMATO "$MATO"
    
    	spawn nc gmail-smtp-in.l.google.com 25
    			expect "ESMTP"
    			send "HELO\r"
    			expect "service"
    			send "\$VMAFR\r"
    			expect "OK"
    			send "\$VMATO\r"
    			expect "OK"
    			send "quit\r"
    
    expect eof
    __EOF
    
    #: Running the expect script and extracting the Results.txt
    
    expect e-veri1 > Results.txt
    grep 550 Results.txt >/dev/null
    
    		if [ "$?" -eq 0 ]
    		then
    			echo -e $LINE >/dev/null	#invalid E-mails
    		else
    			echo -e "$LINE" >> validemails.txt
    		fi
    }
    done
    echo -e "Valid E-mail have been saved to $C_R[ validemails.txt ]$C_END"
    
    #: END
    Below are screen shots:



    -Hackuin
    "Free software" is a matter of liberty, not price. To understand the concept, you should think of "free" as in "free speech," not as in "free beer."
    "Microsoft is not the answer. Microsoft is the question. NO (or Linux) is the answer."
    "Ubuntu - Linux For Human Beings."

    Currently reading books:
    Integrating Forensic Investigation Methodology into eDiscovery -- by Colin Chisholm.
    Digital Forensics with Open Source Toolss -- by Cory Altheide && Harlan Carvey.

  2. #2
    InfoSec Consultant the_empty's Avatar
    Join Date
    Jul 2010
    Location
    the blue no-where
    Posts
    155
    Blog Entries
    2
    wow its really interesting. Shows the power of Bash in good hands....

    TFS
    ACCESS is GOD

  3. #3
    Security Researcher
    Join Date
    May 2011
    Location
    Pune, Maharashtra, India
    Posts
    237
    Blog Entries
    1
    If i understand the script correctly this one is for gmail only however similar checks could be implemented for other services also.

    that will be i think 2-3 more steps.

    1) extract the domain name (all i can think of is cut -f2 -d"@")
    2) extract the mx record server (nslookup or dig)
    3) connect and verify.

    Am i right.
    Website :
    To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

    Blog :
    To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

  4. #4
    Network Security Administrator Hackuin's Avatar
    Join Date
    Apr 2011
    Location
    10011001 10011001
    Posts
    104
    @Anant:
    Yep.
    As most of e-mail were of G-mail, I extracted them to a file. And, sourced it to the script.
    With the first script, you could directly supply, well know Mail Service providers, like, GMAIL-YAHOO-HOTMAIL etc.,

    For the second script.
    Just need to extract , MX records, like,
    Code:
    host -t mx google.com/hotmail.com/yahoo.com
    which gives the smtp servers. And, source the email-list file to the server and verify.
    -Hackuin
    "Free software" is a matter of liberty, not price. To understand the concept, you should think of "free" as in "free speech," not as in "free beer."
    "Microsoft is not the answer. Microsoft is the question. NO (or Linux) is the answer."
    "Ubuntu - Linux For Human Beings."

    Currently reading books:
    Integrating Forensic Investigation Methodology into eDiscovery -- by Colin Chisholm.
    Digital Forensics with Open Source Toolss -- by Cory Altheide && Harlan Carvey.

  5. #5
    Great share..!! Really, this shows the power of bash
    The three great essentials to achieve anything worth while are: Hard work, Stick-to-itiveness, and Common sense. - Thomas A. Edison
    __________________________________________________ _____________________

  6. #6
    Super Commando Dhruv abhaythehero's Avatar
    Join Date
    Sep 2010
    Location
    Lucknow/Pune,India
    Posts
    466
    Blog Entries
    2
    trivial suggestion .. won't it be better if we exit 1 instead of 0 here ...
    Code:
    else
    			echo -e "Internet Connection:" "\t\t\t\t\t\t$C_R[ FAIL ]$C_END" ""			
    			echo -e "$SMTPSERV is Unavialable."
    			echo -e "Check your Network settings."
    			exit 0
    		fi
    In the world of 0s and 1s, are you a zero or The One !

  7. #7
    Network Security Administrator Hackuin's Avatar
    Join Date
    Apr 2011
    Location
    10011001 10011001
    Posts
    104
    The whole idea of exit( ) is status of the script at the point.
    As, we are using "echo" in other words, we are displaying an error message to STDOUT. So, it doesn't matter how exit ( ) behaves.
    If we were not using "ehco", it might be helpful, even tough again, it depends on weather, we are using the EXIT STATUS again in the script referencing to it.
    "Free software" is a matter of liberty, not price. To understand the concept, you should think of "free" as in "free speech," not as in "free beer."
    "Microsoft is not the answer. Microsoft is the question. NO (or Linux) is the answer."
    "Ubuntu - Linux For Human Beings."

    Currently reading books:
    Integrating Forensic Investigation Methodology into eDiscovery -- by Colin Chisholm.
    Digital Forensics with Open Source Toolss -- by Cory Altheide && Harlan Carvey.

  8. #8

    Check hotmail list

    Its fabulous script ^_^

    Could you please advice me if i want to check list of emails at Hotmail server.

    I have been modified this part on script but it still not work for me
    Code:
    #!/bin/expect
    #:
    #: Date: 2011/22/07 09:23:44 PM IST
    #: Author: Hackuin _at_ Ymail com
    #: Discription: Expect Script to Verify/Validate the G-Mail Adresses.
    #:
    
    
    set VMAFR "$MAFR"
    set VMATO "$MATO"
             spawn nc mx1.hotmail.com 25
                            expect "Sending"
                            send "EHELO mx1.hotmail.com\r"
                            expect "OK"
                            send "\$VMAFR\r"
                            expect "OK"
                            send "\$VMATO\r"
                            expect "250"
                            send "quit\r"
    
    expect eof
    please advice ^_^

  9. #9
    Network Security Administrator Hackuin's Avatar
    Join Date
    Apr 2011
    Location
    10011001 10011001
    Posts
    104
    @louay:
    1. You need to understand the logic of the script at first place.
    2. domain doesn't accept "EHELO", try "HELO"
    3. use nc -C mx1.hotmail.com 25, as host doesn't recognize the line feed as the other domains.

    Code:
    .....
    
    spawn nc -C mx1.hotmail.com 25
                  expect "Sending"
                  send "HELO mx1.hotmail.com\r"
                  expect "OK"
                  send "\$VMAFR\r"
                  expect "OK"
                  send "\$VMATO\r"
                  expect "250"
                  send "quit\r"
    
    expect eof
    -Hackuin
    "Free software" is a matter of liberty, not price. To understand the concept, you should think of "free" as in "free speech," not as in "free beer."
    "Microsoft is not the answer. Microsoft is the question. NO (or Linux) is the answer."
    "Ubuntu - Linux For Human Beings."

    Currently reading books:
    Integrating Forensic Investigation Methodology into eDiscovery -- by Colin Chisholm.
    Digital Forensics with Open Source Toolss -- by Cory Altheide && Harlan Carvey.

  10. #10
    Quote Originally Posted by Hackuin View Post
    The whole idea of exit( ) is status of the script at the point.
    As, we are using "echo" in other words, we are displaying an error message to STDOUT. So, it doesn't matter how exit ( ) behaves.
    If we were not using "ehco", it might be helpful, even tough again, it depends on weather, we are using the EXIT STATUS again in the script referencing to it.
    Just suggestion:

    Well the point raised by abhay is regarding general good program practice. Normally it is good programing practice to exit using code 1 if due to some reason your pogram is not able to do intented work Because we dont know in advance if some one want to reffer our script in other script or not

    Overall Nice Script dude
    Last edited by neo; 12-05-2011 at 10:41 AM.
    Orkut id: neo1981
    Blog: infosec-neo.blogspot.com
    Nothing is Impossible*


    *Conditions Apply

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •