-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathway2sms_old.rb
114 lines (93 loc) · 3.33 KB
/
way2sms_old.rb
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
require "rubygems"
require "net/http"
require "net/https"
require "uri"
require "ruby-debug"
require 'cgi'
message = "Message from Ruby" ## Message to be Sent
number = '' # Receiver mobile number
cookies_jar = Array.new
referer_jar = Array.new
url = URI.parse('http://site5.way2sms.com')
regex = /http:\/\/site5.way2sms.com\/(.+)/
def set_header(cookies_jar,referer_jar)
headers = {}
cookies_jar.compact!
unless cookies_jar.last.nil?
headers = {
"Cookie" => cookies_jar.last,
"Referer" => referer_jar.last,
"Content-Type" => "application/x-www-form-urlencoded",
"User-Agent" => "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.3) Gecko/20091020 Ubuntu/9.10 (karmic) Firefox/3.5.3 GTB7.0"
}
else
headers = {
"Referer" => referer_jar.last,
"Content-Type" => "application/x-www-form-urlencoded",
"User-Agent" => "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.3) Gecko/20091020 Ubuntu/9.10 (karmic) Firefox/3.5.3 GTB7.0"
}
end
return headers
end
res = Net::HTTP.start(url.host,url.port) do |http|
http.get('/content/index.html')
end
cookies_jar << res['set-cookie']
referer_jar << "http://site5.way2sms.com/content/index.html"
headers = set_header(cookies_jar,referer_jar)
username = '' ## way2sms login
password = '' ## way2sms password
data = 'username='+username+'&password='+password+'&Submit=Sign+in'
res = Net::HTTP.start(url.host,url.port) do |http|
http.post('/auth.cl',data,headers)
end
cookies_jar << res['set-cookie']
headers = set_header(cookies_jar,referer_jar)
path = ''
redirect_to = ''
if !(res["location"].nil?) && (res.code.to_i > 299 && res.code.to_i < 400)
path = res['location'].match(regex)[1]
redirect_to = res['location']
end
if !(res["location"].nil?) && (res.code.to_i > 299 && res.code.to_i < 400)
res = Net::HTTP.start(url.host,url.port) do |http|
http.get(path,headers)
end
end
cookies_jar << res['set-cookie']
if redirect_to.empty?
referer_jar << "http://site5.way2sms.com/content/index.html"
else
referer_jar << redirect_to
end
redirect_to = ''
path = ''
headers = set_header(cookies_jar,referer_jar)
#res = Net::HTTP.start(url.host,url.port) do |http|
# http.get('/jsp/Main.jsp?id=87C4C2740DE67329769EC424E6C6B943.b501',headers)
#end
cookies_jar << res['set-cookie']
referer_jar << "http://site5.way2sms.com/jsp/InstantSMS.jsp?val=0"
headers = set_header(cookies_jar,referer_jar)
message = CGI.escape(message)
sms_data = 'custid=undefined&HiddenAction=instantsms&Action=hgfgh5656fgd&login=&pass=&MobNo='+number+'&textArea='+message
res = Net::HTTP.start(url.host,url.port) do |http|
http.post('/FirstServletsms?custid=',sms_data,headers)
end
if !(res["location"].nil?) && (res.code.to_i > 299 && res.code.to_i < 400)
path = res['location'].match(regex)[1]
redirect_to = res['location']
end
if !(res["location"].nil?) && (res.code.to_i > 299 && res.code.to_i < 400)
res = Net::HTTP.start(url.host,url.port) do |http|
http.get(path,headers)
end
end
#referer_jar << "http://site5.way2sms.com/jsp/Main.jsp?id=87C4C2740DE67329769EC424E6C6B943.b501"
#cookies_jar << res['set-cookie']
#headers = set_header(cookies_jar,referer_jar)
#res = Net::HTTP.start(url.host,url.port) do |http|
# http.get('/jsp/Main.jsp?id=87C4C2740DE67329769EC424E6C6B943.b501',headers)
#end
#puts res.body
puts "SMS Sent !!!"