Class: Rex::Post::HWBridge::Ui::Console::CommandDispatcher::Zigbee

Inherits:
Object
  • Object
show all
Includes:
Msf::Auxiliary::Report, Rex::Post::HWBridge::Ui::Console::CommandDispatcher
Defined in:
lib/rex/post/hwbridge/ui/console/command_dispatcher/zigbee.rb

Overview

Zigbee extension - set of commands to be executed on Zigbee compatible devices

Instance Attribute Summary collapse

Attributes included from Ui::Text::DispatcherShell::CommandDispatcher

#shell, #tab_complete_items

Instance Method Summary collapse

Methods included from Msf::Auxiliary::Report

#active_db?, #create_cracked_credential, #create_credential, #create_credential_and_login, #create_credential_login, #db, #db_warning_given?, #get_client, #get_host, #inside_workspace_boundary?, #invalidate_login, #mytask, #myworkspace, #myworkspace_id, #report_auth_info, #report_client, #report_exploit, #report_host, #report_loot, #report_note, #report_service, #report_vuln, #report_web_form, #report_web_page, #report_web_site, #report_web_vuln, #store_cred, #store_local, #store_loot

Methods included from Metasploit::Framework::Require

optionally, optionally_active_record_railtie, optionally_include_metasploit_credential_creation, #optionally_include_metasploit_credential_creation, optionally_require_metasploit_db_gem_engines

Methods included from Rex::Post::HWBridge::Ui::Console::CommandDispatcher

check_hash, #client, #initialize, #log_error, #msf_loaded?, set_hash

Methods included from Ui::Text::DispatcherShell::CommandDispatcher

#cmd_help, #cmd_help_help, #cmd_help_tabs, #deprecated_cmd, #deprecated_commands, #deprecated_help, #docs_dir, #help_to_s, included, #initialize, #print, #print_error, #print_good, #print_line, #print_status, #print_warning, #tab_complete_directory, #tab_complete_filenames, #tab_complete_generic, #tab_complete_source_address, #unknown_command, #update_prompt

Instance Attribute Details

#target_deviceObject

Returns the value of attribute target_device.



117
118
119
# File 'lib/rex/post/hwbridge/ui/console/command_dispatcher/zigbee.rb', line 117

def target_device
  @target_device
end

Instance Method Details

#cmd_channel(*args) ⇒ Object

Sets the channel



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/rex/post/hwbridge/ui/console/command_dispatcher/zigbee.rb', line 82

def cmd_channel(*args)
  chan = 11
  dev = self.target_device if self.target_device
  xopts = Rex::Parser::Arguments.new(
    '-h' => [ false, 'Help banner' ],
    '-d' => [ true, 'ZigBee device' ],
    '-c' => [ true, 'Channel number' ]
  )
  xopts.parse(args) do |opt, _idx, val|
    case opt
    when '-h'
      print_line("Usage: channel -c <channel number>\n")
      print_line(xopts.usage)
      return
    when '-d'
      dev = val
    when '-c'
      chan = val.to_i
    end
  end
  unless dev
    print_line("You must specify or set a target device")
    return
  end
  client.zigbee.set_channel(dev, chan)
  print_line("Device #{dev} channel set to #{chan}")
end

#cmd_supported_devicesObject

Lists all thesupported devices



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/rex/post/hwbridge/ui/console/command_dispatcher/zigbee.rb', line 39

def cmd_supported_devices
  devices = client.zigbee.supported_devices
  if !devices or !devices.has_key? "devices"
    print_line("error retrieving list of devices")
    return
  end
  devices = devices["devices"]
  unless devices.size > 0
    print_line("none")
    return
  end
  set_target_device(devices[0]) if devices.size == 1
  str = "Supported Devices: "
  str << devices.join(', ')
  str << "\nUse device name to set your desired device, default is: #{self.target_device}"
  print_line(str)
end

#cmd_target(*args) ⇒ Object

Sets the default target device



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/rex/post/hwbridge/ui/console/command_dispatcher/zigbee.rb', line 60

def cmd_target(*args)
  self.target_device = ""
  device_opts = Rex::Parser::Arguments.new(
    '-h' => [ false, 'Help banner' ],
    '-d' => [ true, 'Device ID' ]
  )
  device_opts.parse(args) do |opt, _idx, val|
    case opt
    when '-h'
      print_line("Usage: target -d <device id>\n")
      print_line(device_opts.usage)
      return
    when '-d'
      set_target_device val
    end
  end
  print_line("set target device to #{self.target_device}")
end

#commandsObject

List of supported commands.



19
20
21
22
23
24
25
26
27
# File 'lib/rex/post/hwbridge/ui/console/command_dispatcher/zigbee.rb', line 19

def commands
  all = {
    'supported_devices'   => 'Get supported ZigBee devices',
    'target' => 'Set the target device id',
    'channel' => 'Set the channel'
  }

  all
end

#nameObject

Name for this dispatcher



113
114
115
# File 'lib/rex/post/hwbridge/ui/console/command_dispatcher/zigbee.rb', line 113

def name
  'Zigbee'
end

#set_target_device(device) ⇒ Object

Sets the target device both in the UI class and in the base API

Parameters:

  • device (String)

    Device ID



31
32
33
34
# File 'lib/rex/post/hwbridge/ui/console/command_dispatcher/zigbee.rb', line 31

def set_target_device(device)
  self.target_device = device
  client.zigbee.set_target_device device
end