Class: Ronin::Web::CLI::Commands::UserAgent Private

Inherits:
Ronin::Web::CLI::Command show all
Defined in:
lib/ronin/web/cli/commands/user_agent.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Generates a random HTTP User-Agent string.

Usage

ronin-web user_agent [options]

Options

-B, --browser chrome|firefox     The desired browser
    --chrome-version VERSION     The desired Chrome version
    --firefox-version VERSION    The desired Firefox version
-D ubuntu|fedora|arch|DISTRO,    The desired Linux distro
    --linux-distro
-A x86-64|x86|i686|aarch64|arm64|arm,
    --arch                       The desired architecture
-O, --os android|linux|windows   The desired OS
    --os-version VERSION         The desired OS version
-h, --help                       Print help information

Since:

  • 2.0.0

Instance Method Summary collapse

Instance Method Details

#random_kwargsHash{Symbol => Object}

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Generates keyword arguments for Ronin::Web::UserAgents.random, Ronin::Web::UserAgents.chrome.random, or Ronin::Web::UserAgents.firefox.random.

Returns:

  • (Hash{Symbol => Object})

    The keyword arguments for the User-Agent module's random method.

Since:

  • 2.0.0



143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# File 'lib/ronin/web/cli/commands/user_agent.rb', line 143

def random_kwargs
  kwargs = {}

  if options[:chrome_version] && options[:browser] == :chrome
    kwargs[:chrome_version] = options[:chrome_version]
  end

  if options[:firefox_version] && options[:browser] == :firefox
    kwargs[:firefox_version] = options[:firefox_version]
  end

  if options[:os]
    kwargs[:os] = options[:os]
  end

  if options[:os_version]
    kwargs[:os_version] = options[:os_version]
  end

  if options[:linux_distro]
    kwargs[:linux_distro] = options[:linux_distro]
  end

  if options[:arch]
    kwargs[:arch] = options[:arch]
  end

  return kwargs
end

#runObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Runs the ronin-web user-agent command.

Since:

  • 2.0.0



122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/ronin/web/cli/commands/user_agent.rb', line 122

def run
  case options[:browser]
  when :chrome
    puts Web::UserAgents.chrome.random(**random_kwargs)
  when :firefox
    puts Web::UserAgents.firefox.random(**random_kwargs)
  when nil
    puts Web::UserAgents.random(**random_kwargs)
  else
    raise(NotImplementedError,"unsupported browser type: #{options[:browser].inspect}")
  end
end