lib/ronin/cli/commands/cert_grab.rb in ronin-2.0.0 vs lib/ronin/cli/commands/cert_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/ssl/mixin'
require 'uri'
module Ronin
@@ -47,10 +48,11 @@
# ronin cert-grab 93.184.216.34:443
# ronin cert-grab https://github.com/
#
class CertGrab < ValueProcessorCommand
+ include HostAndPort
include Support::Network::SSL::Mixin
usage '[options] {HOST:PORT | URL} ...'
argument :target, required: true,
@@ -61,11 +63,11 @@
description "Downloads SSL/TLS certificates"
examples [
'github.com:443',
'93.184.216.34:443',
- 'https://github.com/',
+ 'https://github.com/'
]
man_page 'ronin-cert-grab.1'
#
@@ -75,17 +77,14 @@
# The `HOST:PORT` or `URL` value to process.
#
def process_value(value)
case value
when /\A[^:]+:\d+\z/
- host, port = value.split(':',2)
- port = port.to_i
+ host, port = host_and_port(value)
grab_cert(host,port)
when /\Ahttps:/
- uri = URI.parse(value)
- host = uri.host
- port = uri.port
+ host, port = host_and_port_from_url(value)
grab_cert(host,port)
else
print_error "invalid target: must be a HOST:PORT or a URL: #{value.inspect}"
exit(1)