Posted on Monday, 18th July 2011 by Michael
Simple Ruby banner grabber and port checker:
This is a simple script I wrote in ruby to scan ports to see if they are open and grab the banner of the service. The script has error handling built in so it is able to continue on to the next port if the port before is closed. Port banners are displayed to the screen. If you want to log them to a file just alter the print statement to redirect to a file. To change the port ranges to scan alter the line where the “for loop” is 0…65536. This script will only do tcp and not udp. The script was written for fun but when you are doing an actual audit sometimes you cannot install tools on the machines or with in the network you are auditing. This will allow you to use a piece of software that is installed on most new Linux machines.
#!/usr/bin/ruby
#Simple Ruby Banner Graber
#Created by Mike @ digitaloffensive.com
#######################################
require 'socket'
puts "Enter the IP to scan: "
bIps = gets
puts "Now scanning #{bIps} for open ports"
for sPorts in 0...65536
begin
bcon = TCPsocket.new("#{bIps}", "#{sPorts}")
bcon.puts("get / HTTP/1.1 \n\n\n\n\n") #http is picky
bhead = bcon.recv(100)
bcon.close
print bhead
rescue
puts "#{sPorts} is not open, continuing"
end
end
Posted in Code | Comments (0)