Skip to content

Instantly share code, notes, and snippets.

@picatz
Last active April 16, 2017 04:41
Show Gist options
  • Save picatz/2da22452a8443ed56f2a1c608a81003a to your computer and use it in GitHub Desktop.
Save picatz/2da22452a8443ed56f2a1c608a81003a to your computer and use it in GitHub Desktop.
Violent Ruby: Banner Grabber - Command-line Interface
require 'violent_ruby' # For the banner grabber.
require 'trollop' # For clean option parsing.
require 'colorize' # For beautiful colors.
require 'logoris' # Log to the right standard stream.
logger = Logoris.new
application_name = 'Bannner Grabber'
# Default to a help menu if no argument is given.
ARGV[0] = '-h' if ARGV.empty?
# Option parsing.
opts = Trollop::options do
banner "#{application_name}".red
version "#{application_name} CLI 1.0.0 (c) 2017 Kent 'picat' Gruber"
opt :ips, "Target IP address(es) to use", type: :strings
opt :ports, "Target port(s) to use", type: :ints
opt :Verbose, "Verbose output option", type: :bool, default: false
end
ViolentRuby::BannerGrabber.new(ips: opts[:ips], ports: opts[:ports]).grab do |result|
if result[:open]
logger.out("OPEN".green + " -- " + "#{result[:ip].bold}:#{result[:port]}" + " -- " + "#{result[:banner].strip.yellow}")
else
logger.error("CLOSED".red + " -- " + "#{result[:ip].bold}:#{result[:port]}") if opts[:Verbose]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment