-
Notifications
You must be signed in to change notification settings - Fork 0
/
brameczka.rb
executable file
·68 lines (56 loc) · 2.21 KB
/
brameczka.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
#!/usr/local/bin/ruby
require 'net/http'
require 'uri'
class Brameczka
HEADERS = {
'Host' => 'sms.priv.pl',
'User-Agent' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; pl; rv:1.9.0.2) Gecko/2008091618 Firefox/3.0.2',
'Referer' => 'http://sms.priv.pl/',
'Accept' => 'image/png,image/*;q=0.8,*/*;q=0.5',
'Accept-Language' => 'pl,en-us;q=0.7,en;q=0.3',
'Accept-Charset' => 'ISO-8859-2,utf-8;q=0.7,*;q=0.7',
}
class<<self
def sms(params)
dest = params[:number]
message = params[:message]
from = params[:from]
http = Net::HTTP.new('www.sms.priv.pl', 80)
# with http proxy, more: http://lista-proxy.net/proxy-lista
# http = Net::HTTP.new('www.brameczka.pl', 80, '212.241.180.239', 81)
resp, data = http.get('/', nil)
cookie = resp.response['set-cookie']
resp, data = http.get('/images/spacer.gif', HEADERS.merge({ 'Cookie' => cookie }))
magic_cookie = resp.response['set-cookie']
if magic_cookie =~ /a=(.*);/
a = $1
cookie.gsub!(/a=.*/,'a=' + a)
end
sleep 5
# escape params
val = URI.escape(message, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
data = "status=send&siec=#{dest[0..2]}&nr=&number2=#{dest[3..8]}&tresc=#{val}&od=#{from}&x=62&y=12"
resp, data = http.post('/?', data, HEADERS.merge({
'Cookie' => cookie,
'Content-Type' => 'application/x-www-form-urlencoded',
'Accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
}))
# parse output
return_hash = {}
if data =~ /<font size="\+2">(.*?)<\/font>/
# puts "Status: #{$1}"
return_hash[:status] = $1
end
if data =~ /<center>(Zosta.*?)<\/center>/
# puts $1
return_hash[:count] = $1
else
puts "Klapa"
f = File.new("log.html", "w")
f.puts data
f.close
end
return return_hash
end
end
end