[ create a new paste ] login | about

Link: http://codepad.org/qvy2JbhP    [ raw code | output | fork ]

Ruby, pasted on Feb 20:
require 'net/https'
require 'kconv'
require 'openssl'

APPKEY='xxfvFQcOzpTBvwuwPMwwzLZxiCSaGb'
HMKEY='DgQ3aNpoluV1cl3GFJAqitBg5xKiXZ'

def authenticate()
    http = Net::HTTP.new('api.2ch.net', 443)
    http.use_ssl = true
    http.verify_mode = OpenSSL::SSL::VERIFY_NONE
    path = '/v1/auth/'
    data ={:ID=>'', :PW=>'', :KY=>APPKEY, :CT=>'',:HB=>''}
    headers = {
        'User-Agent' => '',
        'X-2ch-UA' => 'JaneStyle/3.80'
    }
    res=http.post(path, URI.encode_www_form(data), headers)
    sid=res.body.split(':')[1]
    return sid
end

def getDAT(serverName,boardName,threadId,sid)
    http = Net::HTTP.new('api.2ch.net', 443)
    http.use_ssl = true
    http.verify_mode = OpenSSL::SSL::VERIFY_NONE
    path="/v1/#{serverName}/#{boardName}/#{threadId}"
    message = "#{path}#{sid}#{APPKEY}"
    hobo=OpenSSL::HMAC::hexdigest(OpenSSL::Digest::SHA256.new, HMKEY, message)
    data="sid=#{sid}&hobo=#{hobo}&appkey=#{APPKEY}"
    headers = {
        'User-Agent' =>'Mozilla/3.0 (compatible; JaneStyle/3.80..)'
    }
    res=http.post(path, data, headers)
    return res.body.toutf8
end

sid=authenticate()
dat=getDAT('anago','software','1424327586',sid)
p dat


Output:
1
2
3
4
/usr/lib/ruby/1.8/net/https.rb:102:in `require': no such file to load -- openssl (LoadError)
	from /usr/lib/ruby/1.8/net/https.rb:102
	from t.rb:1:in `require'
	from t.rb:1


Create a new paste based on this one


Comments: