lib/ronin/cli/commands/banner_grab.rb in ronin-2.0.0 vs lib/ronin/cli/commands/banner_grab.rb in ronin-2.0.1

- old
+ new

@@ -15,10 +15,11 @@ # You should have received a copy of the GNU General Public License # along with Ronin. If not, see <https://www.gnu.org/licenses/>. # require 'ronin/cli/value_processor_command' +require 'ronin/cli/host_and_port' require 'ronin/support/network/tcp' module Ronin class CLI @@ -40,10 +41,12 @@ # # HOST:PORT ... A TCP service to fetch the banner from. # class BannerGrab < ValueProcessorCommand + include HostAndPort + usage '[options] {HOST:PORT} ...' option :with_host_port, desc: 'Print the service with the banner' argument :service, required: true, @@ -60,21 +63,20 @@ # # @param [String] service # The `HOST:PORT` service pair. # def process_value(service) - host, port = service.split(':',2) - port = port.to_i + host, port = host_and_port(service) begin banner = Support::Network::TCP.banner(host,port) if options[:with_host_port] puts "#{service}: #{banner}" else puts banner end - rescue => error + rescue StandardError => error print_error("#{service}: #{error.message}") end end end