-
Notifications
You must be signed in to change notification settings - Fork 0
/
sequestrum.rb
79 lines (62 loc) · 1.85 KB
/
sequestrum.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
require 'net/http'
require 'uri'
require 'openssl'
require 'sidekiq'
ENV['http_proxy'] = 'http://127.0.0.1:8080'
Sidekiq.configure_server do |config|
config.logger.level = Logger::WARN
config.log_formatter = Sidekiq::Logger::Formatters::JSON.new
end
if !File.exists?(ARGV[0])
raise "File doesn't exist"
end
@method = ARGV[1] || 'GET'
class SQRequest < Net::HTTPRequest
REQUEST_HAS_BODY = false
RESPONSE_HAS_BODY = true
end
SQRequest::METHOD = @method
class Jobless
include Sidekiq::Worker
def perform(url)
uri = URI.parse(url)
request = SQRequest.new(uri)
request.content_type = "application/x-www-form-urlencoded"
request["User-Agent"] = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:84.0) Gecko/20100101 Firefox/84.0"
request["Accept"] = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"
request["Accept-Language"] = "en-US,en;q=0.5"
request["Authorization"] = "Bearer -"
# request["Content-Length"] = "169"
request["Origin"] = "http://pingb.in/"
request["Connection"] = "keep-alive"
request["Referer"] = "http://pingb.in/"
request["Upgrade-Insecure-Requests"] = "1"
# request.set_form_data(
# "password" => "",
# "username" => "",
# )
req_options = {
use_ssl: uri.scheme == "https",
verify_mode: OpenSSL::SSL::VERIFY_NONE,
}
response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
http.request(request)
end
# response.each_header do |header, values|
# puts "\t#{header}: #{values.inspect}"
# end
puts [@method, url, response.code].join(' ')
# response.body
end
end
# main
def load_urls_from_file(name)
file = File.open(name)
urls = file.readlines.map(&:chomp)
file.close
return urls
end
urls = load_urls_from_file(ARGV[0])
urls.each do |url|
Jobless.perform_async(url)
end