Sha256: 4b9ce4f0fda771b7dab41f15bb024e8b0d93d495d215ceda75258572d67e2971

Contents?: true

Size: 1.36 KB

Versions: 173

Compression:

Stored size: 1.36 KB

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

require 'pwn'
require 'optparse'

opts = {}
OptionParser.new do |options|
  options.banner = "USAGE:
    #{$PROGRAM_NAME} [opts]
  "

  options.on('-pPROXY', '--proxy=PROXY', '<Optional - HTTP or Socks Proxy || tor>') do |p|
    opts[:proxy] = p
  end

  options.on('-i', '--[no-]ipinfo', '<Optional - Return Details about Public IP Returned from CheckIP>') do |i|
    opts[:ipinfo] = i
  end
end.parse!

proxy = opts[:proxy].to_s.scrub.strip.chomp unless opts[:proxy].nil?
ipinfo = opts[:ipinfo]

begin
  if proxy
    browser_obj = PWN::Plugins::TransparentBrowser.open(
      browser_type: :rest,
      proxy: proxy
    )
  else
    browser_obj = PWN::Plugins::TransparentBrowser.open(browser_type: :rest)
  end
  browser = browser_obj[:browser]::Request

  if proxy
    public_ip_address = browser.execute(
      method: :get,
      url: 'https://checkip.amazonaws.com',
      verify_ssl: false
    ).to_s.chomp
  else
    public_ip_address = browser.execute(
      method: :get,
      url: 'https://checkip.amazonaws.com'
    ).to_s.chomp
  end

  puts "PUBLIC IP: #{public_ip_address}"
  puts PWN::Plugins::IPInfo.get(ip_or_host: public_ip_address) unless ipinfo.nil?
rescue StandardError => e
  raise e
ensure
  if browser_obj
    browser_obj = PWN::Plugins::TransparentBrowser.close(
      browser_obj: browser_obj
    )
  end
end

Version data entries

173 entries across 173 versions & 1 rubygems

Version Path
pwn-0.4.858 bin/pwn_www_checkip
pwn-0.4.857 bin/pwn_www_checkip
pwn-0.4.856 bin/pwn_www_checkip
pwn-0.4.855 bin/pwn_www_checkip
pwn-0.4.854 bin/pwn_www_checkip
pwn-0.4.853 bin/pwn_www_checkip
pwn-0.4.852 bin/pwn_www_checkip
pwn-0.4.851 bin/pwn_www_checkip
pwn-0.4.850 bin/pwn_www_checkip
pwn-0.4.849 bin/pwn_www_checkip
pwn-0.4.848 bin/pwn_www_checkip
pwn-0.4.847 bin/pwn_www_checkip
pwn-0.4.846 bin/pwn_www_checkip
pwn-0.4.845 bin/pwn_www_checkip
pwn-0.4.844 bin/pwn_www_checkip
pwn-0.4.843 bin/pwn_www_checkip
pwn-0.4.842 bin/pwn_www_checkip
pwn-0.4.841 bin/pwn_www_checkip
pwn-0.4.840 bin/pwn_www_checkip
pwn-0.4.839 bin/pwn_www_checkip