存档

文章标签 ‘Scanner_Linux’

Linux下多线程扫描

2011年12月6日 4 条评论
#!/usr/bin/ruby -w
require 'socket'
include Socket::Constants

ports = (1..60000).to_a
threads = []
time1 = Time.now
for port in ports
  threads << Thread.new(port) do |theport|
    begin
      sock = Socket.new(AF_INET, SOCK_STREAM, 0)
      sockaddr = Socket.pack_sockaddr_in(theport, ARGV[0])
      sock.connect(sockaddr)
      puts "Port:#{theport} is Opend!\n"
      sock.close
    rescue
      #...
    end
  end
end
threads.each {|thr| thr.join}

puts "\n共耗时:#{Time.now - time1}秒"
分类: 安全工具 标签:
普人特福的博客cnzz&51la for wordpress,cnzz for wordpress,51la for wordpress