How Create Python Script For Sending SMS Using Way2Sms

Hello Friends,


                   
                                                   Today, i am going to show you how we can create an python script for sending sms.
Becasue I Surfed over Internet and found that many way2sms python script on internet are not working properly.

So, i though to create an Easy and faster python script for this purpose.

then i created this Script.

This Script is user-friendly and easy for use.


let's start step by step

first take user inputs 

        number=int(raw_input(' [+] Please Enter Your Username : '))
        password=int(getpass(' [+] Please Enter Your Password : '))
        #================   Checking Mechanizam =====================================
        if len(str(number))==10:
                pass
        else:
                print " [*] Invalid Username"
                sys.exit(0)
        if len(str(password))==10:
                pass
        else:
                print " [*] Invalid Password  "
                sys.exit(0)
        #============================================================================


second, encode user inputs


        # ***************** Login *******************************
        # ***************** Configuration  **********************       
        url='http://site24.way2sms.com/Login1.action'
        data={'username':str(number),'password':str(password)}
        data=urllib.urlencode(data)

create mechanize handler

and then open site


        # ********************************************************
        cj=cookielib.CookieJar()
        header={'User-Agent':'Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0 Iceweasel/31.8.0'}
        req=urllib2.Request(url, data, headers=header)
        opennr=urllib2.build_opener(urllib2.HTTPCookieProcessor(cj), urllib2.HTTPRedirectHandler())
        print '[+] Please Wait. Trying To Login In '
        req=opennr.open(req)
        sucess=str(req.info())
        sucess=sucess.find('Set-Cookie')
        if (sucess==-1):
                print '\n','[+] Login Successful [+]'
                pass
        else:
                print '\n','[+] Login Failed [+]'
                raw_input('')
                sys.exit(0)

now, create function for extracting tokken from cookies



        def cook(cj):
              j=str(cj)
              t2=j.find(' for ')
              t1=int(j.find('~'))+1
              tokken=str(j[t1:t2])
              return tokken   

        # ****** Tokken Receiving Mechanizem ******************
        tokken=cook(cj)
        print '\n [+] Tokken Received : ', tokken



At The End, Send Message,


        # *******************************************************************
        # ********* Sms Sending System Configuration ************************
        url='http://site24.way2sms.com/smstoss.action'
        head={'User-Agent':'Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0 Iceweasel/31.8.0','Refere':str('http://site24.way2sms.com/sendSMS?Token='+tokken)}
        mobile=int(raw_input(' [*] Please Enter Mobile Number For Sending SMS : '))
        #================   Checking Mechanizam =====================================
        if len(str(mobile))==10:
                pass
        else:
                print " [*] Invalid Username"
                sys.exit(0)


        while True:
                message_raw=str(raw_input(' [*] Please Enter Message For Sending. Note ! Not More Then 140 Words: '))
                message=message_raw.replace(' ', '+')
                msglen=140-len(message)
                if len(message)<140:
                        break
                else:
                        pass
        data='ssaction=ss&Token='+tokken+'&mobile='+str(mobile)+'&message='+str(message)+'&msgLen='+str(msglen)
        req=urllib2.Request(url, data=data, headers=head)
        print '[+] Sending SMS . Please Wait [+]'
        req=opennr.open(req)
        print '\n',' [+] Task Complete Thanks For Using [+]'
        raw_input('\n\n')

Finally, Add All Step Codes,


and

here, our final script, ready to use



 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
__author__='''
Email : surajsinghbisht054@gmail.com
Blog  : bitforestinfo.blogspot.in

'''

import urllib, urllib2, cookielib, sys
from getpass import getpass

def cook(cj):
        j=str(cj)
        t2=j.find(' for ')
        t1=int(j.find('~'))+1
        tokken=str(j[t1:t2])
        return tokken   


def main():
        print '''
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+   This is Only For Practise And Educational Purpose Only  +
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

'''
        number=int(raw_input(' [+] Please Enter Your Username : '))
        password=int(getpass(' [+] Please Enter Your Password : '))
        #================   Checking Mechanizam =====================================
        if len(str(number))==10:
                pass
        else:
                print " [*] Invalid Username"
                sys.exit(0)
        if len(str(password))==10:
                pass
        else:
                print " [*] Invalid Password  "
                sys.exit(0)
        #============================================================================
        # ***************** Login *******************************
        # ***************** Configuration  **********************       
        url='http://site24.way2sms.com/Login1.action'
        data={'username':str(number),'password':str(password)}
        data=urllib.urlencode(data)
        # ********************************************************
        cj=cookielib.CookieJar()
        header={'User-Agent':'Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0 Iceweasel/31.8.0'}
        req=urllib2.Request(url, data, headers=header)
        opennr=urllib2.build_opener(urllib2.HTTPCookieProcessor(cj), urllib2.HTTPRedirectHandler())
        print '[+] Please Wait. Trying To Login In '
        req=opennr.open(req)
        sucess=str(req.info())
        sucess=sucess.find('Set-Cookie')
        if (sucess==-1):
                print '\n','[+] Login Successful [+]'
                pass
        else:
                print '\n','[+] Login Failed [+]'
                raw_input('')
                sys.exit(0)
        # ****** Tokken Receiving Mechanizem ******************
        tokken=cook(cj)
        print '\n [+] Tokken Received : ', tokken
        # *******************************************************************
        # ********* Sms Sending System Configuration ************************
        url='http://site24.way2sms.com/smstoss.action'
        head={'User-Agent':'Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0 Iceweasel/31.8.0','Refere':str('http://site24.way2sms.com/sendSMS?Token='+tokken)}
        mobile=int(raw_input(' [*] Please Enter Mobile Number For Sending SMS : '))
        #================   Checking Mechanizam =====================================
        if len(str(mobile))==10:
                pass
        else:
                print " [*] Invalid Username"
                sys.exit(0)


        while True:
                message_raw=str(raw_input(' [*] Please Enter Message For Sending. Note ! Not More Then 140 Words: '))
                message=message_raw.replace(' ', '+')
                msglen=140-len(message)
                if len(message)<140:
                        break
                else:
                        pass
        data='ssaction=ss&Token='+tokken+'&mobile='+str(mobile)+'&message='+str(message)+'&msgLen='+str(msglen)
        req=urllib2.Request(url, data=data, headers=head)
        print '[+] Sending SMS . Please Wait [+]'
        req=opennr.open(req)
        print '\n',' [+] Task Complete Thanks For Using [+]'
        raw_input('\n\n')
if __name__=='__main__':
        main()

This is my complete Python way2sms Code.

if anyone wants to Download way2sms raw script then Click here.


thanks for visiting my blog.


For any question or Suggestion or help
Email:  surajsinghbisht054@gmail.com
Or post Comment.
please feel free to contact me.






Share this

Related Posts

Previous
Next Post »