Class: Rex::Post::HWBridge::Ui::Console::CommandDispatcher::RFtransceiver
- Inherits:
-
Object
- Object
- Rex::Post::HWBridge::Ui::Console::CommandDispatcher::RFtransceiver
- Defined in:
- lib/rex/post/hwbridge/ui/console/command_dispatcher/rftransceiver.rb
Overview
RF Transceiver extension - set of commands to be executed on transceivers like the TI cc11XX
Instance Attribute Summary collapse
-
#idx ⇒ Object
Returns the value of attribute idx.
Attributes included from Ui::Text::DispatcherShell::CommandDispatcher
Instance Method Summary collapse
-
#cmd_baud(*args) ⇒ Object
Set baud rate.
-
#cmd_channel(*args) ⇒ Object
Set channel.
-
#cmd_channel_bw(*args) ⇒ Object
Set channel bandwidth.
-
#cmd_deviation(*args) ⇒ Object
Set Deviation.
-
#cmd_enable_crc(*args) ⇒ Object
Enable CRC.
-
#cmd_enable_manchester(*args) ⇒ Object
Enable Manchester encoding.
-
#cmd_flen(*args) ⇒ Object
Sets the fixed length.
-
#cmd_freq(*args) ⇒ Object
Sets the frequency.
- #cmd_freq_help ⇒ Object
-
#cmd_idx(*args) ⇒ Object
Sets the USB IDS.
- #cmd_lowball(*args) ⇒ Object
- #cmd_lowball_help ⇒ Object
-
#cmd_maxpower(*args) ⇒ Object
Sets max power.
- #cmd_maxpower_help ⇒ Object
-
#cmd_modulation(*args) ⇒ Object
Sets the modulation.
- #cmd_modulation_help ⇒ Object
- #cmd_power(*args) ⇒ Object
-
#cmd_preamble(*args) ⇒ Object
Set Preamble size.
- #cmd_preamble_help ⇒ Object
-
#cmd_recv(*args) ⇒ Object
Receive data packet.
- #cmd_supported_idx ⇒ Object
-
#cmd_sync_word(*args) ⇒ Object
Set Sync word.
-
#cmd_vlen(*args) ⇒ Object
Sets the variable length.
-
#cmd_xmit(*args) ⇒ Object
Xmit packet.
-
#commands ⇒ Object
List of supported commands.
-
#name ⇒ Object
Name for this dispatcher.
-
#print_success(r) ⇒ Object
Takes the results of a client request and prints Ok on success.
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
#idx ⇒ Object
Returns the value of attribute idx.
593 594 595 |
# File 'lib/rex/post/hwbridge/ui/console/command_dispatcher/rftransceiver.rb', line 593 def idx @idx end |
Instance Method Details
#cmd_baud(*args) ⇒ Object
Set baud rate
404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 |
# File 'lib/rex/post/hwbridge/ui/console/command_dispatcher/rftransceiver.rb', line 404 def cmd_baud(*args) self.idx ||= 0 baud = -1 mhz = nil arg = {} opts = Rex::Parser::Arguments.new( '-h' => [ false, 'Help Banner' ], '-b' => [ true, 'Baud rate' ], '-m' => [ true, 'Mhz' ] ) opts.parse(args) do |opt, _idx, val| case opt when '-h' print_line("Usage: baud -b <baud rate>\n") print_line(opts.usage) return when '-b' baud = val.to_i when '-m' mhz = val.to_i end end if baud == -1 print_line("You must specify a baud rate") return end arg['mhz'] = mhz if mhz r = client.rftransceiver.set_baud_rate(idx, baud, arg) print_success(r) end |
#cmd_channel(*args) ⇒ Object
Set channel
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 |
# File 'lib/rex/post/hwbridge/ui/console/command_dispatcher/rftransceiver.rb', line 342 def cmd_channel(*args) self.idx ||= 0 channel = -1 opts = Rex::Parser::Arguments.new( '-h' => [ false, 'Help Banner' ], '-c' => [ true, 'Channel number' ] ) opts.parse(args) do |opt, _idx, val| case opt when '-h' print_line("Usage: channel -c <channel number>\n") print_line(opts.usage) return when '-c' channel = val.to_i end end if channel == -1 print_line("You must specify a channel number") return end r = client.rftransceiver.set_channel(idx, channel) print_success(r) end |
#cmd_channel_bw(*args) ⇒ Object
Set channel bandwidth
370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 |
# File 'lib/rex/post/hwbridge/ui/console/command_dispatcher/rftransceiver.rb', line 370 def cmd_channel_bw(*args) self.idx ||= 0 bandwidth = -1 mhz = nil arg = {} opts = Rex::Parser::Arguments.new( '-h' => [ false, 'Help Banner' ], '-b' => [ true, 'Bandwidth' ], '-m' => [ true, 'Mhz' ] ) opts.parse(args) do |opt, _idx, val| case opt when '-h' print_line("Usage: channel_bw -b <bandwidth>\n") print_line(opts.usage) return when '-b' bandwidth = val.to_i when '-m' mhz = val.to_i end end if bandwidth == -1 print_line("You must specify the bandwidth (-b)") return end arg['mhz'] = mhz if mhz r = client.rftransceiver.set_channel_bandwidth(idx, bandwidth, arg) print_success(r) end |
#cmd_deviation(*args) ⇒ Object
Set Deviation
438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 |
# File 'lib/rex/post/hwbridge/ui/console/command_dispatcher/rftransceiver.rb', line 438 def cmd_deviation(*args) self.idx ||= 0 deviat = -1 mhz = nil arg = {} opts = Rex::Parser::Arguments.new( '-h' => [ false, 'Help Banner' ], '-d' => [ true, 'Deviat' ], '-m' => [ true, 'Mhz' ] ) opts.parse(args) do |opt, _idx, val| case opt when '-h' print_line("Usage: deviation -d <deviat value>\n") print_line(opts.usage) return when '-d' deviat = val.to_i when '-m' mhz = val.to_i end end if deviat == -1 print_line("You must specify a deviat value") return end arg['mhz'] = mhz if mhz r = client.rftransceiver.set_deviation(idx, deviat, arg) print_success(r) end |
#cmd_enable_crc(*args) ⇒ Object
Enable CRC
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 |
# File 'lib/rex/post/hwbridge/ui/console/command_dispatcher/rftransceiver.rb', line 302 def cmd_enable_crc(*args) self.idx ||= 0 opts = Rex::Parser::Arguments.new( '-h' => [ false, 'Help Banner' ] ) opts.parse(args) do |opt, _idx, _val| case opt when '-h' print_line("Usage: enable_crc\n") print_line(opts.usage) return end end r = client.rftransceiver.enable_packet_crc(idx) print_success(r) end |
#cmd_enable_manchester(*args) ⇒ Object
Enable Manchester encoding
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 |
# File 'lib/rex/post/hwbridge/ui/console/command_dispatcher/rftransceiver.rb', line 322 def cmd_enable_manchester(*args) self.idx ||= 0 opts = Rex::Parser::Arguments.new( '-h' => [ false, 'Help Banner' ] ) opts.parse(args) do |opt, _idx, val| case opt when '-h' print_line("Usage: enable_manchester\n") print_line(opts.usage) return end end r = client.rftransceiver.enable_manchester(idx) print_success(r) end |
#cmd_flen(*args) ⇒ Object
Sets the fixed length
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/rex/post/hwbridge/ui/console/command_dispatcher/rftransceiver.rb', line 172 def cmd_flen(*args) self.idx ||= 0 flen = -1 opts = Rex::Parser::Arguments.new( '-h' => [ false, 'Help Banner' ], '-l' => [ true, 'Fixed Length' ] ) opts.parse(args) do |opt, _idx, val| case opt when '-h' print_line("Usage: flen -l <length>\n") print_line(opts.usage) return when '-l' flen = val.to_i end end if flen == -1 print_line("You must specify a length") return end r = client.rftransceiver.make_pkt_flen(idx, flen) print_success(r) end |
#cmd_freq(*args) ⇒ Object
Sets the frequency
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 |
# File 'lib/rex/post/hwbridge/ui/console/command_dispatcher/rftransceiver.rb', line 103 def cmd_freq(*args) self.idx ||= 0 freq = -1 mhz = nil arg = {} opts = Rex::Parser::Arguments.new( '-h' => [ false, 'Help Banner' ], '-f' => [ true, 'frequency to set, example: 433000000' ], '-m' => [ true, 'Mhz' ] ) opts.parse(args) do |opt, _idx, val| case opt when '-h' print_line("Usage: freq -f <frequency number>\n") print_line(opts.usage) return when '-f' freq = val.to_i when '-m' mhz = val.to_i end end if freq == -1 cmd_freq_help return end arg['mhz'] = mhz if mhz r = client.rftransceiver.set_freq(idx, freq, arg) print_success(r) end |
#cmd_freq_help ⇒ Object
83 84 85 86 87 |
# File 'lib/rex/post/hwbridge/ui/console/command_dispatcher/rftransceiver.rb', line 83 def cmd_freq_help print_line("Sets the RF Frequency\n") print_line("Usage: freq -f <frequency number>") print_line("\nExample: freq -f 433000000") end |
#cmd_idx(*args) ⇒ Object
Sets the USB IDS
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/rex/post/hwbridge/ui/console/command_dispatcher/rftransceiver.rb', line 64 def cmd_idx(*args) self.idx = 0 idx_opts = Rex::Parser::Arguments.new( '-h' => [ false, 'Help Banner' ], '-i' => [ true, 'USB index, default 0' ] ) idx_opts.parse(args) do |opt, _idx, val| case opt when '-h' print_line("Usage: idx -i <Index number>\n") print_line(idx_opts.usage) return when '-i' self.idx = val end end print_line("set index to #{self.idx}") end |
#cmd_lowball(*args) ⇒ Object
534 535 536 537 538 539 540 541 542 |
# File 'lib/rex/post/hwbridge/ui/console/command_dispatcher/rftransceiver.rb', line 534 def cmd_lowball(*args) self.idx ||= 0 if args.length > 0 cmd_lowball_help return end r = client.rftransceiver.set_lowball(idx) print_success(r) end |
#cmd_lowball_help ⇒ Object
530 531 532 |
# File 'lib/rex/post/hwbridge/ui/console/command_dispatcher/rftransceiver.rb', line 530 def cmd_lowball_help print_line("Lowball is frequency dependent. Set frequency first") end |
#cmd_maxpower(*args) ⇒ Object
Sets max power
551 552 553 554 555 556 557 558 559 |
# File 'lib/rex/post/hwbridge/ui/console/command_dispatcher/rftransceiver.rb', line 551 def cmd_maxpower(*args) self.idx ||= 0 if args.length > 0 cmd_maxpower_help return end r = client.rftransceiver.set_maxpower(idx) print_success(r) end |
#cmd_maxpower_help ⇒ Object
544 545 546 |
# File 'lib/rex/post/hwbridge/ui/console/command_dispatcher/rftransceiver.rb', line 544 def cmd_maxpower_help print_line("Max power is frequency dependent. Set frequency first") end |
#cmd_modulation(*args) ⇒ Object
Sets the modulation
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/rex/post/hwbridge/ui/console/command_dispatcher/rftransceiver.rb', line 144 def cmd_modulation(*args) self.idx ||= 0 mod = nil opts = Rex::Parser::Arguments.new( '-h' => [ false, 'Help Banner' ], '-M' => [ true, 'Modulation name, See help for options' ] ) opts.parse(args) do |opt, _idx, val| case opt when '-h' cmd_modulation_help print_line(opts.usage) return when '-M' mod = val end end unless mod cmd_modulation_help return end r = client.rftransceiver.set_modulation(idx, mod) print_success(r) end |
#cmd_modulation_help ⇒ Object
134 135 136 137 138 139 |
# File 'lib/rex/post/hwbridge/ui/console/command_dispatcher/rftransceiver.rb', line 134 def cmd_modulation_help print_line("Usage: modulation -M <Modulation name>\n") print_line("Modulation names:\n") print_line(" #{client.rftransceiver.get_supported_modulations(idx)}") print_line("\nExample: modulation -M ASK/OOK") end |
#cmd_power(*args) ⇒ Object
561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 |
# File 'lib/rex/post/hwbridge/ui/console/command_dispatcher/rftransceiver.rb', line 561 def cmd_power(*args) self.idx ||= 0 power = -1 opts = Rex::Parser::Arguments.new( '-h' => [ false, 'Help Banner' ], '-p' => [ true, 'Power level' ] ) opts.parse(args) do |opt, _idx, val| case opt when '-h' print_line("Usage: power -p <power level>\n") print_line(opts.usage) return when '-p' power = val.to_i end end if power == -1 print_line("You must specify the power level") return end r = client.rftransceiver.set_power(idx, power) print_success(r) end |
#cmd_preamble(*args) ⇒ Object
Set Preamble size
505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 |
# File 'lib/rex/post/hwbridge/ui/console/command_dispatcher/rftransceiver.rb', line 505 def cmd_preamble(*args) self.idx ||= 0 preamble = -1 opts = Rex::Parser::Arguments.new( '-h' => [ false, 'Help Banner' ], '-n' => [ true, 'Number of preamble' ] ) opts.parse(args) do |opt, _idx, val| case opt when '-h' print_line("Usage: preamble -n <number bits>\n") print_line(opts.usage) return when '-n' preamble = val.to_i end end if preamble == -1 print_line("You must specify the number of preamble bits") return end r = client.rftransceiver.set_number_preamble(idx, preamble) print_success(r) end |
#cmd_preamble_help ⇒ Object
497 498 499 500 |
# File 'lib/rex/post/hwbridge/ui/console/command_dispatcher/rftransceiver.rb', line 497 def cmd_preamble_help print_line("get the minimum number of preamble bits to be transmitted. note this is a flag, not a count") print_line("so the return value must be interpreted - e.g. 0x30 == 0x03 << 4 == MFMCFG1_NUM_PREAMBLE_6 == 6 bytes") end |
#cmd_recv(*args) ⇒ Object
Receive data packet
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 |
# File 'lib/rex/post/hwbridge/ui/console/command_dispatcher/rftransceiver.rb', line 267 def cmd_recv(*args) self.idx ||= 0 arg = {} timeout = -1 blocksize = -1 opts = Rex::Parser::Arguments.new( '-h' => [ false, 'Help Banner' ], '-t' => [ true, 'timeout' ], '-b' => [ true, 'blocksize' ] ) opts.parse(args) do |opt, _idx, val| case opt when '-h' print_line("Usage: recv\n") print_line(opts.usage) return when '-t' timeout = val.to_i when '-b' blocksize = val.to_i end end arg['blocksize'] = blocksize unless blocksize == -1 arg['timeout'] = timeout unless timeout == -1 r = client.rftransceiver.rfrecv(idx, arg) if r.key?('data') && r.key?('timestamp') print_line(" #{r['timestamp']}: #{r['data'].inspect}") else print_line("Error") end end |
#cmd_supported_idx ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/rex/post/hwbridge/ui/console/command_dispatcher/rftransceiver.rb', line 43 def cmd_supported_idx indexes = client.rftransceiver.supported_idx if !indexes || !indexes.key?('indexes') print_line("error retrieving index list") return end indexes = indexes['indexes'] unless indexes.size > 0 print_line('none') return end self.idx = indexes[0].to_i if indexes.size.zero? str = "Supported Indexes: " str << indexes.join(', ') str << "\nUse idx to set your desired bus, default is 0" print_line(str) end |
#cmd_sync_word(*args) ⇒ Object
Set Sync word
472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 |
# File 'lib/rex/post/hwbridge/ui/console/command_dispatcher/rftransceiver.rb', line 472 def cmd_sync_word(*args) self.idx ||= 0 word = -1 opts = Rex::Parser::Arguments.new( '-h' => [ false, 'Help Banner' ], '-w' => [ true, 'Sync word (Integer)' ] ) opts.parse(args) do |opt, _idx, val| case opt when '-h' print_line("Usage: sync_word -w <int>\n") print_line(opts.usage) return when '-w' word = val.to_i end end if word == -1 print_line("You must specify a sync word") return end r = client.rftransceiver.set_sync_word(idx, word) print_success(r) end |
#cmd_vlen(*args) ⇒ Object
Sets the variable length
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 |
# File 'lib/rex/post/hwbridge/ui/console/command_dispatcher/rftransceiver.rb', line 200 def cmd_vlen(*args) self.idx ||= 0 vlen = -1 opts = Rex::Parser::Arguments.new( '-h' => [ false, 'Help Banner' ], '-l' => [ true, 'Variable Length' ] ) opts.parse(args) do |opt, _idx, val| case opt when '-h' print_line("Usage: vlen -l <length>\n") print_line(opts.usage) return when '-l' vlen = val.to_i end end if vlen == -1 print_line("You must specify a length") return end r = client.rftransceiver.make_pkt_vlen(idx, vlen) print_success(r) end |
#cmd_xmit(*args) ⇒ Object
Xmit packet
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 |
# File 'lib/rex/post/hwbridge/ui/console/command_dispatcher/rftransceiver.rb', line 228 def cmd_xmit(*args) self.idx ||= 0 data = nil repeat = -1 offset = -1 arg = {} opts = Rex::Parser::Arguments.new( '-h' => [ false, 'Help Banner' ], '-d' => [ true, 'Variable Length' ], '-r' => [ true, 'Repeat' ], '-o' => [ true, 'Data offset' ] ) opts.parse(args) do |opt, _idx, val| case opt when '-h' print_line("Usage: xmit -d <data>\n") print_line(opts.usage) return when '-d' data = val when '-r' repeat = val.to_i when '-o' offset = val.to_i end end unless data print_line("You must specify the data argument (-d)") return end arg['repeat'] = repeat unless repeat == -1 arg['offset'] = offset unless offset == -1 r = client.rftransceiver.rfxmit(idx, data, arg) print_success(r) end |
#commands ⇒ Object
List of supported commands.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rex/post/hwbridge/ui/console/command_dispatcher/rftransceiver.rb', line 17 def commands all = { 'supported_idx' => 'suppored USB indexes', 'idx' => 'sets an active idx', 'freq' => 'sets the frequency', 'modulation' => 'sets the modulation', 'flen' => 'sets the fixed length packet size', 'vlen' => 'sets the variable length packet size', 'xmit' => 'transmits some data', 'recv' => 'receive a packet of data', 'enable_crc' => 'enables crc', 'enable_manchester' => 'enables manchester encoding', 'channel' => 'sets channel', 'channel_bw' => 'sets the channel bandwidth', 'baud' => 'sets the baud rate', 'deviation' => 'sets the deviation', 'sync_word' => 'sets the sync word', 'preamble' => 'sets the preamble number', 'lowball' => 'sets lowball', 'power' => 'sets the power level', 'maxpower' => 'sets max power' } all end |
#name ⇒ Object
Name for this dispatcher
589 590 591 |
# File 'lib/rex/post/hwbridge/ui/console/command_dispatcher/rftransceiver.rb', line 589 def name 'RFtransceiver' end |
#print_success(r) ⇒ Object
Takes the results of a client request and prints Ok on success
92 93 94 95 96 97 98 |
# File 'lib/rex/post/hwbridge/ui/console/command_dispatcher/rftransceiver.rb', line 92 def print_success(r) if r.key?('success') && r['success'] == true print_line("Ok") else print_line("Error") end end |