Module: Ronin::Web::UserAgents::Firefox
- Defined in:
- lib/ronin/web/user_agents/firefox.rb
Overview
Represents all possible Firefox User-Agent
strings.
Constant Summary collapse
- DESKTOP_GECKO_VERSION =
The default
Gecko/...
version.@note: On desktop, the
Gecko/...
version is hardcoded to20100101
'20100101'
- ENCRYPTION =
Encryption Strengths.
{ usa: 'U', international: 'I', none: 'N', no: 'N', nil => nil }
- DEVICE_TYPES =
Common device types.
{ mobile: 'Mobile', tablet: 'Tablet', nil => nil }
- KNOWN_VERSIONS =
Known versions for the
rv:...
andFirefox/...
values. File.readlines( File.join(DATA_DIR,'firefox','versions.txt'), chomp: true )
- SUPPORTED_OSES =
Supported Operating Systems.
[ :windows, :macos, :linux, :android ]
- KNOWN_OS_VERSIONS =
Known OS versions grouped by OS.
{ windows: OS::Windows::VERSIONS.keys, macos: OS::MacOS::VERSIONS, linux: [], android: OS::Android::VERSIONS }
- SUPPORTED_OS_ARCHES =
Supported architectures grouped by OS.
{ windows: OS::Windows::ARCHES.keys, macos: OS::MacOS::ARCHES.keys, linux: OS::Linux::ARCHES.keys, android: OS::Android::ARCHES.keys }
- SUPPORTED_LINUX_DISTROS =
Supported Linux Distros.
OS::Linux::DISTROS.keys
- SUPPORTED_ENCRYPTION =
Supported encryption strengths.
ENCRYPTION.keys
- KNOWN_LANGS =
IETF language tags (ex:
en-GB
). File.readlines( File.join(DATA_DIR,'firefox','langs.txt'), chomp: true )
- SUPPORTED_DEVICE_TYPES =
Supported device types.
DEVICE_TYPES.keys
Class Method Summary collapse
-
.build(firefox_version:, lang: nil, encryption: nil, os:, os_version: nil, linux_distro: nil, arch: nil, device_type: nil) ⇒ String
Builds a new Firefox
User-Agent
string. -
.build_android(device_type: :mobile, firefox_version:) ⇒ String
Builds a Firefox
User-Agent
string for Android. -
.build_linux(encryption: nil, linux_distro: nil, arch: nil, lang: nil, firefox_version:) ⇒ String
Builds a Firefox
User-Agent
string for Linux. -
.build_macos(arch: :intel, macos_version:, firefox_version:) ⇒ String
Builds a Firefox
User-Agent
string for macOS. -
.build_windows(windows_version:, arch:, firefox_version:) ⇒ String
Builds a Firefox
User-Agent
string for Windows. -
.random(firefox_version: KNOWN_VERSIONS.sample, encryption: SUPPORTED_ENCRYPTION.sample, lang: KNOWN_LANGS.sample, os: SUPPORTED_OSES.sample, os_version: KNOWN_OS_VERSIONS[os].sample, linux_distro: SUPPORTED_LINUX_DISTROS.sample, arch: SUPPORTED_OS_ARCHES[os].sample, device_type: DEVICE_TYPES.keys.sample) ⇒ String
Generates a random Firefox
User-Agent
string.
Class Method Details
.build(firefox_version:, lang: nil, encryption: nil, os:, os_version: nil, linux_distro: nil, arch: nil, device_type: nil) ⇒ String
Builds a new Firefox User-Agent
string.
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/ronin/web/user_agents/firefox.rb', line 96 def self.build(firefox_version: , lang: nil, encryption: nil, os: , os_version: nil, linux_distro: nil, arch: nil, device_type: nil) case os when :windows unless os_version raise(ArgumentError,"os: :windows also requires an os_version: value") end build_windows( windows_version: os_version, arch: arch, firefox_version: firefox_version ) when :macos unless os_version raise(ArgumentError,"os: :macos also requires an os_version: value") end build_macos( arch: arch || :intel, macos_version: os_version, firefox_version: firefox_version ) when :linux build_linux( encryption: encryption, linux_distro: linux_distro, arch: arch, lang: lang, firefox_version: firefox_version ) when :android build_android( device_type: device_type || :mobile, firefox_version: firefox_version ) else raise(ArgumentError,"unsupported os: value (#{os.inspect})") end end |
.build_android(device_type: :mobile, firefox_version:) ⇒ String
Builds a Firefox User-Agent
string for Android.
345 346 347 348 349 350 351 352 |
# File 'lib/ronin/web/user_agents/firefox.rb', line 345 def self.build_android(device_type: :mobile, firefox_version: ) device_type = DEVICE_TYPES.fetch(device_type) extensions = "Android; #{device_type}" extensions << "; rv:#{firefox_version}" return "Mozilla/5.0 (#{extensions}) Gecko/#{firefox_version} Firefox/#{firefox_version}" end |
.build_linux(encryption: nil, linux_distro: nil, arch: nil, lang: nil, firefox_version:) ⇒ String
Builds a Firefox User-Agent
string for Linux.
317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 |
# File 'lib/ronin/web/user_agents/firefox.rb', line 317 def self.build_linux(encryption: nil, linux_distro: nil, arch: nil, lang: nil, firefox_version: ) encryption_flag = ENCRYPTION.fetch(encryption) linux_arch = OS::Linux::ARCHES[arch] linux_distro = OS::Linux::DISTROS.fetch(linux_distro,linux_distro) extensions = String.new("X11") extensions << "; #{encryption_flag}" if encryption_flag extensions << "; #{linux_distro}" if linux_distro extensions << "; Linux" extensions << " #{linux_arch}" if linux_arch extensions << "; #{lang}" if lang extensions << "; rv:#{firefox_version}" return "Mozilla/5.0 (#{extensions}) Gecko/#{DESKTOP_GECKO_VERSION} Firefox/#{firefox_version}" end |
.build_macos(arch: :intel, macos_version:, firefox_version:) ⇒ String
Builds a Firefox User-Agent
string for macOS.
287 288 289 290 291 292 293 294 |
# File 'lib/ronin/web/user_agents/firefox.rb', line 287 def self.build_macos(arch: :intel, macos_version: , firefox_version: ) macos_arch = OS::MacOS::ARCHES.fetch(arch) extensions = "Macintosh; #{macos_arch} Mac OS X #{macos_version}" extensions << "; rv:#{firefox_version}" return "Mozilla/5.0 (#{extensions}) Gecko/#{DESKTOP_GECKO_VERSION} Firefox/#{firefox_version}" end |
.build_windows(windows_version:, arch:, firefox_version:) ⇒ String
Builds a Firefox User-Agent
string for Windows.
261 262 263 264 265 266 267 268 269 270 |
# File 'lib/ronin/web/user_agents/firefox.rb', line 261 def self.build_windows(windows_version: , arch: , firefox_version: ) windows_version = OS::Windows::VERSIONS.fetch(windows_version,windows_version) windows_arch = OS::Windows::ARCHES.fetch(arch) extensions = "Windows NT #{windows_version}" extensions << "; #{windows_arch}" if windows_arch extensions << "; rv:#{firefox_version}" return "Mozilla/5.0 (#{extensions}) Gecko/#{DESKTOP_GECKO_VERSION} Firefox/#{firefox_version}" end |
.random(firefox_version: KNOWN_VERSIONS.sample, encryption: SUPPORTED_ENCRYPTION.sample, lang: KNOWN_LANGS.sample, os: SUPPORTED_OSES.sample, os_version: KNOWN_OS_VERSIONS[os].sample, linux_distro: SUPPORTED_LINUX_DISTROS.sample, arch: SUPPORTED_OS_ARCHES[os].sample, device_type: DEVICE_TYPES.keys.sample) ⇒ String
Generates a random Firefox User-Agent
string.
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
# File 'lib/ronin/web/user_agents/firefox.rb', line 227 def self.random(firefox_version: KNOWN_VERSIONS.sample, encryption: SUPPORTED_ENCRYPTION.sample, lang: KNOWN_LANGS.sample, os: SUPPORTED_OSES.sample, os_version: KNOWN_OS_VERSIONS[os].sample, linux_distro: SUPPORTED_LINUX_DISTROS.sample, arch: SUPPORTED_OS_ARCHES[os].sample, device_type: DEVICE_TYPES.keys.sample) build( firefox_version: firefox_version, os: os, os_version: os_version, device_type: device_type, linux_distro: linux_distro, arch: arch, lang: lang ) end |