自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Ruby實現(xiàn)端口掃描

安全
本文講述了Ruby實現(xiàn)端口掃描的方法,希望對您有所幫助.

#!/usr/bin/ruby -w

=begin

quite simple connect scanner in ruby

Shows open (reliable), close and filtered. But the reliablity

of the last two states depends of course on firewalling and the timeout

interval you can set down. Uncomment or comment states you want or don't

want to get printed on the screen.

*supports scanning mutiple hosts/IPs (like www.heise.de,www.gulli.com)

*supports multiple ports(like 12,45,53,165),ranges(like 20..85) or one single

port(like 80)

*support a ports file like http://insecure.org/nmap/data/nmap-services (just

clean it with | grep /tcp ..)

ZGlnaXRhbGJ5dGU=

=end

require 'socket'

require 'timeout'

class Scanner

def initialize

@hosts,@ports = Array($*)

end

def portarrange

case @ports

when /^.+[..]/

@ports = @ports.split("..")

@ports = @ports[0].to_i..@ports[1].to_i

when /^.+[,]/

@ports = @ports.split(",")

else

@ports = Array(@ports)

end

end

def hostarrange

case @hosts

when /^.+[,]/

@hosts = @hosts.split(",")

else

@hosts = Array(@hosts)

end

end

def output(state,port)

printed = false

portsfile = File.new("ports", "r")

scanpat = "^.+ #{port}/tcp"

begin

portsfile.each_line do |line|

if line =~ Regexp.new(scanpat)

puts "#{state} : #{line}"

printed = true

end

end

puts "#{state} : #{port}" if printed == false

ensure

portsfile.close

end

end

def scanning(hosts,ports)

hosts.each do |host|

begin

puts "scanning #{host}:"

ports.each do |port|

begin

Timeout::timeout(10){TCPSocket.new(host, port)}

rescue Timeout::Error

output("filtered",port)

rescue

# output("closed",port)

else

output("open",port)

end

end

end

end

end

end

##################### code start #####################

puts "no arguments past,correct usage:\nruby #{$0} [hosts] [ports]\n" if

!ARGV[1]

my_scanner = Scanner.new

hosts = my_scanner.hostarrange

ports = my_scanner.portarrange

my_scanner.scanning(hosts,ports)

##################### eof #####################

【編輯推薦】

  1. SNIFFER嗅探器檢測工具和對策
  2. 敏感信息檢測系統(tǒng)--UnisSISS 操作探秘
  3. 無ARP欺騙的嗅探技術(shù)
責(zé)任編輯:趙寧寧 來源: hackbase
相關(guān)推薦

2022-06-15 13:40:38

端口掃描工具開源工具

2020-12-14 10:32:28

Web安全工具多線程

2024-06-19 19:07:53

2010-09-17 09:40:16

2013-01-10 09:19:53

2024-06-28 08:00:00

端口掃描安全

2009-11-18 09:59:41

2009-01-15 09:52:00

2023-10-16 18:51:04

Masscan網(wǎng)絡(luò)安全

2010-09-13 15:55:43

制作端口掃描器

2021-05-31 08:54:30

RustScanRust端口掃描器

2010-12-22 21:57:00

Angry IP Sc

2025-01-20 13:23:17

2023-04-04 12:24:10

2015-12-14 16:03:45

LinuxUnix端口掃描

2010-09-15 15:12:49

2014-03-18 15:42:46

2013-03-22 10:07:38

2021-01-10 08:14:01

Go語言TCP掃描器

2018-11-12 08:04:15

點贊
收藏

51CTO技術(shù)棧公眾號