Module: Msf::Auxiliary::MQTT
- Defined in:
- lib/msf/core/auxiliary/mqtt.rb
Instance Method Summary collapse
- #client_id ⇒ Object
- #initialize(info = {}) ⇒ Object
-
#mqtt_client ⇒ Object
creates a new mqtt client for use against the connected socket.
- #mqtt_connect(client) ⇒ Object
- #mqtt_connect?(client) ⇒ Boolean
- #mqtt_disconnect(client) ⇒ Object
- #read_timeout ⇒ Object
- #setup ⇒ Object
Instance Method Details
#client_id ⇒ Object
38 39 40 |
# File 'lib/msf/core/auxiliary/mqtt.rb', line 38 def client_id datastore['CLIENT_ID'] || 'mqtt-' + Rex::Text.rand_text_alpha(1 + rand(10)) end |
#initialize(info = {}) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/msf/core/auxiliary/mqtt.rb', line 6 def initialize(info = {}) super ( [ Opt::RPORT(Rex::Proto::MQTT::DEFAULT_PORT) ] ) ( [ OptString.new('CLIENT_ID', [false, 'The client ID to send if necessary for bypassing clientid_prefixes']), OptInt.new('READ_TIMEOUT', [true, 'Seconds to wait while reading MQTT responses', 5]) ] ) register_autofilter_ports([Rex::Proto::MQTT::DEFAULT_PORT, Rex::Proto::MQTT::DEFAULT_SSL_PORT]) end |
#mqtt_client ⇒ Object
creates a new mqtt client for use against the connected socket
43 44 45 46 47 48 49 50 51 |
# File 'lib/msf/core/auxiliary/mqtt.rb', line 43 def mqtt_client client_opts = { client_id: client_id, username: datastore['USERNAME'], password: datastore['PASSWORD'], read_timeout: read_timeout } Rex::Proto::MQTT::Client.new(sock, client_opts) end |
#mqtt_connect(client) ⇒ Object
53 54 55 |
# File 'lib/msf/core/auxiliary/mqtt.rb', line 53 def mqtt_connect(client) client.connect end |
#mqtt_connect?(client) ⇒ Boolean
57 58 59 |
# File 'lib/msf/core/auxiliary/mqtt.rb', line 57 def mqtt_connect?(client) client.connect? end |
#mqtt_disconnect(client) ⇒ Object
61 62 63 |
# File 'lib/msf/core/auxiliary/mqtt.rb', line 61 def mqtt_disconnect(client) client.disconnect end |
#read_timeout ⇒ Object
34 35 36 |
# File 'lib/msf/core/auxiliary/mqtt.rb', line 34 def read_timeout datastore['READ_TIMEOUT'] end |
#setup ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/msf/core/auxiliary/mqtt.rb', line 25 def setup fail_with(Msf::Exploit::Failure::BadConfig, 'READ_TIMEOUT must be > 0') if read_timeout <= 0 client_id_arg = datastore['CLIENT_ID'] if client_id_arg && client_id_arg.blank? fail_with(Msf::Exploit::Failure::BadConfig, 'CLIENT_ID must be a non-empty string') end end |