Penetration Test - Using_Scripting_in_Pen_Testing(5)

时间:2020-12-13 20:33:49   收藏:0   阅读:36

Ruby Script

Demo

Portscan.rb

#!/usr/bin/ruby

require ‘socket‘

TARGET = ARGV[0] || ‘192.168.2.22‘
MINPORT = ARGV[1] || 22
MAXPORT = ARGV[2] || 80

$i = MINPORT.to_i
while $i <= MAXPORT.to_i do
  begin
    socket = TCPSocket.new(TARGET, $i)
    status = "open"
    puts "Port #{$i} is #{status}."
  rescue Errno::ECONNREFUSED, Errno::ETIMEDOUT
    status = "closed"
  end
  $i = $i + 1
end

Run the following commands

sudo ruby portscan.rb 192.168.2.22 22 80
sudo ruby portscan.rb 192.168.2.22 20 80

技术分享图片

QUICK REVIEW

原文:https://www.cnblogs.com/keepmoving1113/p/14129433.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!