Sha256: 4dac31cb23bc3e8c1e012be19e88e0360e1acaa3234d4131f223d744a8ecd766

Contents?: true

Size: 1.9 KB

Versions: 152

Compression:

Stored size: 1.9 KB

Contents

# frozen_string_literal: true

require 'ipaddress'
require 'nokogiri'

module PWN
  module WWW
    # This plugin supports Checkip actions.
    module Checkip
      # Supported Method Parameters::
      # browser_obj = PWN::WWW::Checkip.open(
      #   browser_type: 'optional - :firefox|:chrome|:ie|:headless (Defaults to :firefox)',
      #   proxy: 'optional - scheme://proxy_host:port || tor'
      # )

      public_class_method def self.open(opts = {})
        browser_obj = PWN::Plugins::TransparentBrowser.open(opts)

        browser = browser_obj[:browser]
        browser.goto('http://checkip.amazonaws.com')
        public_ip_address = Nokogiri::HTML.parse(browser.html).xpath('//pre').text.chomp
        puts "PUBLIC IP: #{public_ip_address}"

        browser_obj
      rescue StandardError => e
        raise e
      end

      # Supported Method Parameters::
      # browser_obj = PWN::WWW::Checkip.close(
      #   browser_obj: 'required - browser_obj returned from #open method',
      # )

      public_class_method def self.close(opts = {})
        browser_obj = opts[:browser_obj]
        PWN::Plugins::TransparentBrowser.close(
          browser_obj: browser_obj
        )
      rescue StandardError => e
        raise e
      end

      # Author(s):: 0day Inc. <request.pentest@0dayinc.com>

      public_class_method def self.authors
        "AUTHOR(S):
          0day Inc. <request.pentest@0dayinc.com>
        "
      end

      # Display Usage for this Module

      public_class_method def self.help
        puts "USAGE:
          browser_obj = #{self}.open(
            browser_type: 'optional :firefox|:chrome|:ie|:headless (Defaults to :firefox)',
            proxy: 'optional - scheme://proxy_host:port || tor'
          )

          browser_obj = #{self}.close(
            browser_obj: 'required - browser_obj returned from #open method',
          )

          #{self}.authors
        "
      end
    end
  end
end

Version data entries

152 entries across 152 versions & 1 rubygems

Version Path
pwn-0.5.104 lib/pwn/www/checkip.rb
pwn-0.5.103 lib/pwn/www/checkip.rb
pwn-0.5.102 lib/pwn/www/checkip.rb
pwn-0.5.101 lib/pwn/www/checkip.rb
pwn-0.5.100 lib/pwn/www/checkip.rb
pwn-0.5.99 lib/pwn/www/checkip.rb
pwn-0.5.98 lib/pwn/www/checkip.rb
pwn-0.5.97 lib/pwn/www/checkip.rb
pwn-0.5.96 lib/pwn/www/checkip.rb
pwn-0.5.95 lib/pwn/www/checkip.rb
pwn-0.5.94 lib/pwn/www/checkip.rb
pwn-0.5.93 lib/pwn/www/checkip.rb
pwn-0.5.92 lib/pwn/www/checkip.rb
pwn-0.5.91 lib/pwn/www/checkip.rb
pwn-0.5.90 lib/pwn/www/checkip.rb
pwn-0.5.89 lib/pwn/www/checkip.rb
pwn-0.5.88 lib/pwn/www/checkip.rb
pwn-0.5.87 lib/pwn/www/checkip.rb
pwn-0.5.86 lib/pwn/www/checkip.rb
pwn-0.5.85 lib/pwn/www/checkip.rb