# frozen_string_literal: true require 'yaml' module PWN module WWW # This plugin supports tradingview.com actions. module CoinbasePro # Supported Method Parameters:: # browser_obj = PWN::WWW::CoinbasePro.open( # browser_type: 'optional - :firefox|:chrome|:ie|:headless (Defaults to :firefox)', # proxy: 'optional - scheme://proxy_host:port', # with_tor: 'optional - boolean (defaults to false)' # ) public_class_method def self.open(opts = {}) browser_obj = PWN::Plugins::TransparentBrowser.open(opts) browser_obj.goto('https://pro.coinbase.com') browser_obj rescue StandardError => e raise e end # Supported Method Parameters:: # browser_obj = PWN::WWW::CoinbasePro.login( # browser_obj: 'required - browser_obj returned from #open method', # username: 'required - username', # password: 'optional - passwd (will prompt if blank)' # ) public_class_method def self.login(opts = {}) browser_obj = opts[:browser_obj] username = opts[:username].to_s.scrub.strip.chomp password = opts[:password] if password.nil? password = PWN::Plugins::AuthenticationHelper.mask_password else password = opts[:password].to_s.scrub.strip.chomp end mfa = opts[:mfa] browser_obj.goto('https://pro.coinbase.com') # In case window is really small, # click on hamburger menu browser_obj.div(index: 9).click if browser_obj.div(index: 9).visible? browser_obj.span(text: 'Sign in').wait_until(&:present?).click browser_obj.text_field(name: 'email').wait_until(&:present?).set(username) browser_obj.text_field(name: 'password').wait_until(&:present?).set(password) browser_obj.button(text: 'Sign In').click! if mfa until browser_obj.url.include?('https://pro.coinbase.com') browser_obj.text_field(name: 'token').wait_until(&:present?).set(PWN::Plugins::AuthenticationHelper.mfa(prompt: 'enter mfa token')) browser_obj.button(text: 'Verify').click! sleep 3 end print "\n" end browser_obj rescue StandardError => e raise e end # Supported Method Parameters:: # browser_obj = PWN::WWW::CoinbasePro.logout( # browser_obj: 'required - browser_obj returned from #open method' # ) public_class_method def self.logout(opts = {}) browser_obj = opts[:browser_obj] browser_obj.goto('https://pro.coinbase.com/signout') browser_obj rescue StandardError => e raise e end # Supported Method Parameters:: # browser_obj = PWN::WWW::CoinbasePro.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. public_class_method def self.authors "AUTHOR(S): 0day Inc. " 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', with_tor: 'optional - boolean (defaults to false)' ) puts browser_obj.public_methods browser_obj = #{self}.login( browser_obj: 'required - browser_obj returned from #open method', username: 'required - username', password: 'optional - passwd (will prompt if blank), ) browser_obj = #{self}.logout( browser_obj: 'required - browser_obj returned from #open method' ) #{self}.close( browser_obj: 'required - browser_obj returned from #open method' ) #{self}.authors " end end end end