Sha256: b8e82666546168fe6ff3ea3ad81b505b58aa45d09d9d705d114d4eaedfb52135

Contents?: true

Size: 1.89 KB

Versions: 65

Compression:

Stored size: 1.89 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. <support@0dayinc.com>

      public_class_method def self.authors
        "AUTHOR(S):
          0day Inc. <support@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

65 entries across 65 versions & 1 rubygems

Version Path
pwn-0.5.214 lib/pwn/www/checkip.rb
pwn-0.5.213 lib/pwn/www/checkip.rb
pwn-0.5.212 lib/pwn/www/checkip.rb
pwn-0.5.211 lib/pwn/www/checkip.rb
pwn-0.5.210 lib/pwn/www/checkip.rb
pwn-0.5.209 lib/pwn/www/checkip.rb
pwn-0.5.207 lib/pwn/www/checkip.rb
pwn-0.5.206 lib/pwn/www/checkip.rb
pwn-0.5.205 lib/pwn/www/checkip.rb
pwn-0.5.204 lib/pwn/www/checkip.rb
pwn-0.5.203 lib/pwn/www/checkip.rb
pwn-0.5.202 lib/pwn/www/checkip.rb
pwn-0.5.201 lib/pwn/www/checkip.rb
pwn-0.5.200 lib/pwn/www/checkip.rb
pwn-0.5.199 lib/pwn/www/checkip.rb
pwn-0.5.198 lib/pwn/www/checkip.rb
pwn-0.5.197 lib/pwn/www/checkip.rb
pwn-0.5.196 lib/pwn/www/checkip.rb
pwn-0.5.195 lib/pwn/www/checkip.rb
pwn-0.5.194 lib/pwn/www/checkip.rb