加入收藏 | 设为首页 | 会员中心 | 我要投稿 宁德站长网 (https://www.0593zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 服务器 > 安全 > 正文

Ruby达成端口扫描

发布时间:2022-04-14 14:38:28 所属栏目:安全 来源:互联网
导读:#!/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 co
        #!/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)
 
Timeout::timeout(10){TCPSocket.new(host, port)}
 
rescue Timeout::Error
 
output("filtered",port)
 
rescue
 
# output("closed",port)

(编辑:宁德站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!