-
Notifications
You must be signed in to change notification settings - Fork 0
/
way2sms.py
89 lines (63 loc) · 2.36 KB
/
way2sms.py
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
import os
import urllib2
import cookielib
from getpass import getpass
from urllib import urlencode
print "hello sam -sending Way2SMS message : "
def Login(user,passw,opener,cj):
url="http://site21.way2sms.com/Login1.action"
url_data = urlencode({
'username':user,
'password':passw,
})
# debug message
print url_data
try:
sock = opener.open(url, url_data)
cooki = "hey" #only one cookie in cj
for cookies in cj:
cooki = cookies.value
#print cookies
# debug message
#print usock.read()
except IOError:
return "CONNECTION_ERROR"
return cooki
def Message(opener,token) :
mobile = raw_input("receiver mobile no : ")
message = raw_input("enter message :")
url="http://site21.way2sms.com/smstoss.action"
url_data = urlencode({
'ssaction':'ss',
'mobile':mobile,
'message': message,
'msgLen' : 140-len(message),
'Token' : token
})
opener.addheaders=[('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8'
)]
opener.addheaders = [('User-Agent','Mozilla/5.0 (Ubuntu; X11; Linux x86_64; rv:8.0) Gecko/20100101 Firefox/8.0')]
opener.addheaders = [('Accept-Encoding', 'gzip, deflate'
)]
opener.addheaders = [('Cookie', 'JSESSIONID=A02~'+ token+'; _gat=1; _ga=GA1.2.1393827013.1466941873')]
opener.addheaders= [('Referer','http://site21.way2sms.com/sendSMS?Token='+token)]
opener.addheaders = [('Upgrade-Insecure-Requests',1)]
print 'http://site21.way2sms.com/sendSMS?Token='+token
print url_data
#one of these 2 will do
req = urllib2.Request(url, url_data)
#response = opener.open(url,url_data)
#print response.read()
user = raw_input("Enter username: ")
passw = getpass()
cj = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
# To fool the website as if a Web browser is visiting the site
opener.addheaders = [('User-Agent','Mozilla/5.0 (Ubuntu; X11; Linux x86_64; rv:8.0) Gecko/20100101 Firefox/8.0')]
Output = Login(user,passw,opener,cj)
if(Output == "CONNECTION_ERROR"):
print "Check your connection || network traffic"
else:
print Output[4:]
Message(opener,Output[4:])
#Message(opener)