Class: BMN

Inherits:
Object
  • Object
show all
Defined in:
lib/esearchy/bugmenot.rb

Class Method Summary collapse

Class Method Details

.decode(input, offset) ⇒ Object



4
5
6
7
# File 'lib/esearchy/bugmenot.rb', line 4

def self.decode(input, offset)
  # thanks tlrobinson @ github
  input.unpack("m*")[0][4..-1].unpack("C*").map{|c| c - offset }.pack("C*")
end

.fetch_user(domain) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/esearchy/bugmenot.rb', line 9

def self.fetch_user(domain)
  begin
    url = Net::HTTP.get URI.parse("http://www.bugmenot.com/view/#{domain}")
    key = ( url.scan(/var key =(.*);/)[0][0].to_i + 112 ) / 12
  
    user, pass = url.scan(/tr><th>Username <\/th><td><script>d\('(.*)'\);<\/script><\/td><\/tr>
[\n\s]+<tr><th>Password <\/th><td><script>d\('(.*)'\);<\/script><\/td><\/tr>/)[0]
    user = decode(user,key)
    pass = decode(pass,key)
    return user, pass
  rescue
    return nil,nil
  end
end