Module: Rex::UserAgent
- Defined in:
- lib/rex/user_agent.rb
Overview
A helper module for using and referencing comming user agent strings.
Constant Summary collapse
- COMMON_AGENTS =
[ # Chrome 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 13_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36', # Edge 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36 Edg/108.0.1462.46', # Safari 'Mozilla/5.0 (iPad; CPU OS 16_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.1 Mobile/15E148 Safari/604.1', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 13_1) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.1 Safari/605.1.15', # Firefox 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:108.0) Gecko/20100101 Firefox/108.0', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 13.1; rv:108.0) Gecko/20100101 Firefox/108.0' ]
- @@session_agent =
nil
Class Method Summary collapse
-
.most_common ⇒ Object
Choose the most frequent user agent.
-
.random ⇒ Object
Pick a random agent from the common agent list.
-
.session_agent ⇒ Object
A randomly-selected agent that will be consistent for the duration of metasploit running.
-
.shortest ⇒ Object
Choose the agent with the shortest string (for use in payloads).
Class Method Details
.most_common ⇒ Object
Choose the most frequent user agent
58 59 60 |
# File 'lib/rex/user_agent.rb', line 58 def self.most_common COMMON_AGENTS[0] end |
.random ⇒ Object
Pick a random agent from the common agent list.
44 45 46 |
# File 'lib/rex/user_agent.rb', line 44 def self.random COMMON_AGENTS.sample end |
.session_agent ⇒ Object
A randomly-selected agent that will be consistent for the duration of metasploit running
31 32 33 34 35 36 37 |
# File 'lib/rex/user_agent.rb', line 31 def self.session_agent if @@session_agent @@session_agent else @@session_agent = self.random end end |
.shortest ⇒ Object
Choose the agent with the shortest string (for use in payloads)
51 52 53 |
# File 'lib/rex/user_agent.rb', line 51 def self.shortest @@shortest_agent ||= COMMON_AGENTS.min { |a, b| a.size <=> b.size } end |