-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathmain.rb
41 lines (35 loc) · 827 Bytes
/
main.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
require 'tor'
require 'mechanize'
class Requester
def initialize
@agent = Mechanize.new
@agent.set_proxy("127.0.0.1", 5566)
end
def perform
i = 1
loop do
page = @agent.get("http://bot.whatismyipaddress.com")
ip_address = page.content
puts "Run request with IP : #{ip_address}"
puts "Served by : #{page.header["x-servedby"]}"
if i%10==0
puts "Changing IP address"
control_port = page.header["x-servedby"].to_i
Tor::Controller.connect(:port => control_port) do |tor|
tor.authenticate("password")
tor.signal("newnym")
sleep 10
end
end
i+=1
end
end
end
threads = []
10.times do |i|
t = Thread.new do
Requester.new.perform
end
threads << t
end
threads.each {|t| t.join}