Skip to content

Instantly share code, notes, and snippets.

@rickmzp
Created September 5, 2012 01:09
Show Gist options
  • Save rickmzp/3628767 to your computer and use it in GitHub Desktop.
Save rickmzp/3628767 to your computer and use it in GitHub Desktop.
require 'socket'
socket = TCPSocket.new "192.168.201.133", 1337
socket.puts "GET /8\n\n"
results = {}
total_lines = 0
begin
puts "Scanning..."
while line = socket.gets
next if line =~ /HTTP|:/ || line.strip.empty?
string = line.strip
results[string] ||= 0
results[string] += 1
total_lines += 1
end
rescue Interrupt
puts "\nstopped scanning\n\n\n"
results.each_with_index do |(data, count), index|
chance = count.to_f / total_lines.to_f
printf("%1s: %s%%\n", data, chance.round(5).to_s)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment