Sha256: 1a26cdc916725e3bf062e3301fc1a37a790c3998d1446e99462733abd5dd854a

Contents?: true

Size: 1.98 KB

Versions: 242

Compression:

Stored size: 1.98 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 = browser_obj[:browser]
          puts browser.public_methods

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

          #{self}.authors
        "
      end
    end
  end
end

Version data entries

242 entries across 242 versions & 1 rubygems

Version Path
pwn-0.4.949 lib/pwn/www/checkip.rb
pwn-0.4.948 lib/pwn/www/checkip.rb
pwn-0.4.947 lib/pwn/www/checkip.rb
pwn-0.4.946 lib/pwn/www/checkip.rb
pwn-0.4.945 lib/pwn/www/checkip.rb
pwn-0.4.944 lib/pwn/www/checkip.rb
pwn-0.4.943 lib/pwn/www/checkip.rb
pwn-0.4.942 lib/pwn/www/checkip.rb
pwn-0.4.941 lib/pwn/www/checkip.rb
pwn-0.4.940 lib/pwn/www/checkip.rb
pwn-0.4.939 lib/pwn/www/checkip.rb
pwn-0.4.938 lib/pwn/www/checkip.rb
pwn-0.4.937 lib/pwn/www/checkip.rb
pwn-0.4.936 lib/pwn/www/checkip.rb
pwn-0.4.935 lib/pwn/www/checkip.rb
pwn-0.4.934 lib/pwn/www/checkip.rb
pwn-0.4.933 lib/pwn/www/checkip.rb
pwn-0.4.932 lib/pwn/www/checkip.rb
pwn-0.4.931 lib/pwn/www/checkip.rb
pwn-0.4.930 lib/pwn/www/checkip.rb