Module: Msf::Post::Hardware::RFTransceiver::RFTransceiver

Defined in:
lib/msf/core/post/hardware/rftransceiver/rftransceiver.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#indexObject

Returns the value of attribute index


9
10
11
# File 'lib/msf/core/post/hardware/rftransceiver/rftransceiver.rb', line 9

def index
  @index
end

Instance Method Details

#enable_crcBoolean

Enable packet CRC

Returns:

  • (Boolean)

    success value


145
146
147
148
149
150
# File 'lib/msf/core/post/hardware/rftransceiver/rftransceiver.rb', line 145

def enable_crc
  return false unless is_rf?
  self.index ||= 0
  r = client.rftransceiver.enable_packet_crc(self.index)
  return_success(r)
end

#enable_manchesterBoolean

Enable Manchester encoding

Returns:

  • (Boolean)

    success value


155
156
157
158
159
160
# File 'lib/msf/core/post/hardware/rftransceiver/rftransceiver.rb', line 155

def enable_manchester
  return false unless is_rf?
  self.index ||= 0
  r = client.rftransceiver.enable_manchester(self.index)
  return_success(r)
end

#get_modulationsArray

Gets supported modulations

Returns:

  • (Array)

    String list of modulations


73
74
75
76
77
# File 'lib/msf/core/post/hardware/rftransceiver/rftransceiver.rb', line 73

def get_modulations
  return [] unless is_rf?
  self.index ||= 0
  return client.rftransceiver.get_supported_modulations(self.index)
end

#get_supported_indexesArray

Returns a list of supported USB indexes by relay

Returns:

  • (Array)

    Example: [ 0, 1 ]


30
31
32
33
34
35
36
# File 'lib/msf/core/post/hardware/rftransceiver/rftransceiver.rb', line 30

def get_supported_indexes
  return [] unless is_rf?
  r = client.rftransceiver.supported_idx
  return r['indexes'] if r.has_key?('indexes')
  print_error("Invalid response from relay")
  return []
end

#is_rf?Boolean

Checks to see if this module is a RF Transceiver module

Returns:

  • (Boolean)

    true if client.rftransceiver is loaded


22
23
24
25
26
# File 'lib/msf/core/post/hardware/rftransceiver/rftransceiver.rb', line 22

def is_rf?
  return true if client.rftransceiver
  print_error("Not an RFTransceiver module")
  return false
end

#max_powerBoolean

Sets the power to max. Ensure you set the frequency first before using this

Returns:

  • (Boolean)

    success value


274
275
276
277
278
279
# File 'lib/msf/core/post/hardware/rftransceiver/rftransceiver.rb', line 274

def max_power
  return false unless is_rf?
  self.index ||= 0
  r = client.rftransceiver.set_maxpower(self.index)
  return_success(r)
end

#return_success(r) ⇒ Boolean

Validates success of a function call

Parameters:

  • r (Hash)

    A hash in expected format { "success" => true }

Returns:

  • (Boolean)

    if success is true or not, returns false if hash is wrong


14
15
16
17
18
# File 'lib/msf/core/post/hardware/rftransceiver/rftransceiver.rb', line 14

def return_success(r)
  return false unless r
  return false unless r.has_key?('success')
  return r['success']
end

#rfrecv(timeout = -1,, blocksize = -1)) ⇒ String

Receive a packet

Parameters:

  • timeout (Integer) (defaults to: -1,)

    Optional timeout value

  • blocksize (Integer) (defaults to: -1))

    Optional blocksize

Returns:

  • (String)

    Base64 decoded data, could be binary


133
134
135
136
137
138
139
140
# File 'lib/msf/core/post/hardware/rftransceiver/rftransceiver.rb', line 133

def rfrecv(timeout = -1, blocksize = -1)
  return '' unless is_rf?
  self.index ||= 0
  opts = {}
  opts['timeout'] = timeout unless timeout == -1
  opts['blocksize'] = blocksize unless blocksize == -1
  client.rftransceiver.rfrecv(self.index, opts)
end

#rfxmit(data, repeat = -1,, offset = -1)) ⇒ Boolean

Transmits a RF Packet. All data is base64 encoded before transmition to relay

Parameters:

  • data (String)

    Blog of data stored in a string. Could be binary

  • repeat (Integer) (defaults to: -1,)

    Optional Repeat transmission

  • offset (Integer) (defaults to: -1))

    Optional Offset within data section

Returns:

  • (Boolean)

    success value


118
119
120
121
122
123
124
125
126
# File 'lib/msf/core/post/hardware/rftransceiver/rftransceiver.rb', line 118

def rfxmit(data, repeat=-1, offset=-1)
  return false unless is_rf?
  self.index ||= 0
  opts = {}
  opts['repeat'] = repeat unless repeat == -1
  opts['offset'] = offset unless offset == -1
  r = client.rftransceiver.rfxmit(self.index, data, opts)
  return_success(r)
end

#set_baud(baud, mhz = -1)) ⇒ Boolean

Sets the baud rate

Parameters:

  • baud (Integer)

    baud rate

  • mhz (Integer) (defaults to: -1))

    Optional Mhz

Returns:

  • (Boolean)

    success value


215
216
217
218
219
220
221
222
# File 'lib/msf/core/post/hardware/rftransceiver/rftransceiver.rb', line 215

def set_baud(baud, mhz=-1)
  return false unless is_rf?
  self.index ||= 0
  opts = {}
  opts['mhz'] = mhz unless mhz == -1
  r = client.rftransceiver.set_baud_rate(self.index, baud, opts)
  return_success(r)
end

#set_channel(channel) ⇒ Boolean

Sets the channel

Parameters:

  • channel (Integer)

    Channel number

Returns:

  • (Boolean)

    success value


166
167
168
169
170
171
# File 'lib/msf/core/post/hardware/rftransceiver/rftransceiver.rb', line 166

def set_channel(channel)
  return false unless is_rf?
  self.index ||= 0
  r = client.rftransceiver.set_channel(self.index, channel)
  return_success(r)
end

#set_channel_bw(bandwidth, mhz = -1)) ⇒ Boolean

Sets the channel bandwidth

Parameters:

  • bandwidth (Integer)

    Bandwidth value

  • mhz (Integer) (defaults to: -1))

    Mhz

Returns:

  • (Boolean)

    success value


178
179
180
181
182
183
184
185
# File 'lib/msf/core/post/hardware/rftransceiver/rftransceiver.rb', line 178

def set_channel_bw(bandwidth, mhz=-1)
  return false unless is_rf?
  self.index ||= 0
  opts = {}
  opts['mhz'] = mhz unless mhz == -1
  r = client.rftransceiver.set_channel_bandwidth(self.index, bandwidth, opts)
  return_success(r)
end

#set_channel_spc(chanspc = -1,, chanspc_m = -1,, chanspc_e = -1,, mhz = -1)) ⇒ Boolean

Calculates the appropriate exponent and mantissa and updates the correct registers chanspc is in kHz. if you prefer, you may set the chanspc_m and chanspc_e settings directly. only use one or the other:

* chanspc
* chanspc_m and chanspc_e

Parameters:

  • chanspc (Integer) (defaults to: -1,)
  • chanspc_m (Integer) (defaults to: -1,)
  • chanspc_e (Integer) (defaults to: -1,)
  • mhz (Integer) (defaults to: -1))

    Mhz

Returns:

  • (Boolean)

    success value


198
199
200
201
202
203
204
205
206
207
208
# File 'lib/msf/core/post/hardware/rftransceiver/rftransceiver.rb', line 198

def set_channel_spc(chanspc = -1, chanspc_m = -1, chanspc_e = -1, mhz=-1)
  return false unless is_rf?
  self.index ||= 0
  opts = {}
  opts['chanspc'] = chanspc unless chanspc == -1
  opts['chanspc_m'] = chanspc_m unless chanspc_m == -1
  opts['chanspc_e'] = chanspc_e unless chanspc_e == -1
  opts['mhz'] = mhz unless mhz == -1
  r = client.rftransceiver.set_channel_spc(self.index, opts)
  return_success(r)
end

#set_deviation(deviat, mhz = -1)) ⇒ Boolean

Sets the deviation

Parameters:

  • deviat (Integer)

    deviat value

  • mhz (Integer) (defaults to: -1))

    Optional mhz

Returns:

  • (Boolean)

    success value


229
230
231
232
233
234
235
236
# File 'lib/msf/core/post/hardware/rftransceiver/rftransceiver.rb', line 229

def set_deviation(deviat, mhz=-1)
  return false unless is_rf?
  self.index ||= 0
  opts = {}
  opts['mhz'] = mhz unless mhz == -1
  r = client.rftransceiver.set_deviation(self.index, deviat, opts)
  return_success(r)
end

#set_flen(len) ⇒ Boolean

Sets packet's fixed length

Parameters:

  • len (Integer)

    Length of packet

Returns:

  • (Boolean)

    success value


94
95
96
97
98
99
# File 'lib/msf/core/post/hardware/rftransceiver/rftransceiver.rb', line 94

def set_flen(len)
  return false unless is_rf?
  self.index ||= 0
  r = client.rftransceiver.make_pkt_flen(self.index, len)
  return_success(r)
end

#set_freq(freq, mhz = -1)) ⇒ Boolean

Sets the frequency

Parameters:

  • freq (Integer)

    Example: 433000000

  • mhz (Integer) (defaults to: -1))

    Optional Mhz

Returns:

  • (Boolean)

    success value


50
51
52
53
54
55
56
57
# File 'lib/msf/core/post/hardware/rftransceiver/rftransceiver.rb', line 50

def set_freq(freq, mhz=-1)
  return false unless is_rf?
  self.index ||= 0
  opts = {}
  opts['mhz'] = mhz unless mhz == -1
  r = client.rftransceiver.set_freq(self.index, freq, opts)
  return_success(r)
end

#set_index(idx) ⇒ Object

Sets the target USB index

Parameters:

  • idx (Integer)

41
42
43
# File 'lib/msf/core/post/hardware/rftransceiver/rftransceiver.rb', line 41

def set_index(idx)
  self.index = idx
end

#set_lowballBoolean

Sets lowball. Ensure you set the frequency first before using this

Returns:

  • (Boolean)

    success value


284
285
286
287
288
289
# File 'lib/msf/core/post/hardware/rftransceiver/rftransceiver.rb', line 284

def set_lowball
  return false unless is_rf?
  self.index ||= 0
  r = client.rftransceiver.set_lowball(self.index)
  return_success(r)
end

#set_mode(mode) ⇒ Boolean

Sets the mode TX, RX or Idle

Parameters:

  • mode (String)

    Mode type TX/RX/IDLE

Returns:

  • (Boolean)

    success value


63
64
65
66
67
68
# File 'lib/msf/core/post/hardware/rftransceiver/rftransceiver.rb', line 63

def set_mode(mode)
  return false unless is_rf?
  self.index ||= 0
  r = client.rftransceiver.set_mode(self.index, mode)
  return_success(r)
end

#set_modulation(mod) ⇒ Boolean

Sets the modulation

Parameters:

  • mod (String)

    Example ASK/OOK

Returns:

  • (Boolean)

    success value


83
84
85
86
87
88
# File 'lib/msf/core/post/hardware/rftransceiver/rftransceiver.rb', line 83

def set_modulation(mod)
  return false unless is_rf?
  self.index ||= 0
  r = client.rftransceiver.set_modulation(self.index, mod)
  return_success(r)
end

#set_power(level) ⇒ Boolean

Set power level

Parameters:

  • level (Integer)

    Power level

Returns:

  • (Boolean)

    success value


295
296
297
298
299
300
# File 'lib/msf/core/post/hardware/rftransceiver/rftransceiver.rb', line 295

def set_power(level)
  return false unless is_rf?
  self.index ||= 0
  r = client.rftransceiver.set_power(self.index, level)
  return_success(r)
end

#set_preamble(bits) ⇒ Boolean

Sets the number of preamble bits

Parameters:

  • bits (Integer)

    number of preamble bits to use

Returns:

  • (Boolean)

    success value


264
265
266
267
268
269
# File 'lib/msf/core/post/hardware/rftransceiver/rftransceiver.rb', line 264

def set_preamble(bits)
  return false unless is_rf?
  self.index ||= 0
  r = client.rftransceiver.set_number_preamble(self.index, bits)
  return_success(r)
end

#set_sync_mode(mode) ⇒ Boolean

Sets the sync mode

Parameters:

  • mode (Integer)

    Mode

Returns:

  • (Boolean)

    success value


253
254
255
256
257
258
# File 'lib/msf/core/post/hardware/rftransceiver/rftransceiver.rb', line 253

def set_sync_mode(mode)
  return false unless is_rf?
  self.index ||= 0
  r = client.rftransceiver.set_sync_mode(self.index, mode)
  return_success(r)
end

#set_sync_word(word) ⇒ Boolean

Sets sync word

Parameters:

  • word (Integer)

    Sync word

Returns:

  • (Boolean)

    success value


242
243
244
245
246
247
# File 'lib/msf/core/post/hardware/rftransceiver/rftransceiver.rb', line 242

def set_sync_word(word)
  return false unless is_rf?
  self.index ||= 0
  r = client.rftransceiver.set_sync_word(self.index, word)
  return_success(r)
end

#set_vlen(len) ⇒ Boolean

Sets packet's variable length

Parameters:

  • len (Integer)

    Length of packet

Returns:

  • (Boolean)

    success value


105
106
107
108
109
110
# File 'lib/msf/core/post/hardware/rftransceiver/rftransceiver.rb', line 105

def set_vlen(len)
  return false unless is_rf?
  self.index ||= 0
  r = client.rftransceiver.make_pkt_vlen(self.index, len)
  return_success(r)
end