Class: Rex::Post::HWBridge::Extensions::RFTransceiver::RFTransceiver

Inherits:
Rex::Post::HWBridge::Extension show all
Defined in:
lib/rex/post/hwbridge/extensions/rftransceiver/rftransceiver.rb

Overview

RF Transceiver extension - set of commands to be executed on transceivers like the TI cc11XX

Instance Attribute Summary

Attributes inherited from Rex::Post::HWBridge::Extension

#client, #name

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ RFTransceiver

Returns a new instance of RFTransceiver.



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/rex/post/hwbridge/extensions/rftransceiver/rftransceiver.rb', line 17

def initialize(client)
  super(client, 'rftransceiver')

  # Alias the following things on the client object so that they
  # can be directly referenced
  client.register_extension_aliases(
    [
      {
        'name' => 'rftransceiver',
        'ext'  => self
      }
    ])
end

Instance Method Details

#enable_manchester(idx) ⇒ Object



124
125
126
# File 'lib/rex/post/hwbridge/extensions/rftransceiver/rftransceiver.rb', line 124

def enable_manchester(idx)
  client.send_request("/rftransceiver/#{idx}/enable_machester")
end

#enable_packet_crc(idx) ⇒ Object



120
121
122
# File 'lib/rex/post/hwbridge/extensions/rftransceiver/rftransceiver.rb', line 120

def enable_packet_crc(idx)
  client.send_request("/rftransceiver/#{idx}/enable_packet_crc")
end

#get_supported_modulations(idx) ⇒ Array

Retrieves a list of supported Modulations

Parameters:

  • idx (Integer)

    HW Index

Returns:

  • (Array)

    of Modulation strings



50
51
52
# File 'lib/rex/post/hwbridge/extensions/rftransceiver/rftransceiver.rb', line 50

def get_supported_modulations(idx)
  client.send_request("/rftransceiver/#{idx}/get_modulations")
end

#make_pkt_flen(idx, len) ⇒ Object

Sets fixed packet len

Parameters:

  • idx (Integer)

    HW Index

  • len (Integer)

    Length to set



71
72
73
# File 'lib/rex/post/hwbridge/extensions/rftransceiver/rftransceiver.rb', line 71

def make_pkt_flen(idx, len)
  client.send_request("/rftransceiver/#{idx}/make_packet_flen?len=#{len}")
end

#make_pkt_vlen(idx, len) ⇒ Object

Sets variable packet len

Parameters:

  • idx (Integer)

    HW Index

  • len (Integer)

    Length to set



78
79
80
# File 'lib/rex/post/hwbridge/extensions/rftransceiver/rftransceiver.rb', line 78

def make_pkt_vlen(idx, len)
  client.send_request("/rftransceiver/#{idx}/make_packet_vlen?len=#{len}")
end

#rfrecv(idx, opt = {}) ⇒ Hash

Receives a packet

Parameters:

  • idx (Integer)

    HW Index

  • opt (Hash) (defaults to: {})

    Optional parameters: “timeout” => Integer, “blocksize” => Integer

Returns:

  • (Hash)

    “data” => <received data> “timestamp” => When it was received



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/rex/post/hwbridge/extensions/rftransceiver/rftransceiver.rb', line 98

def rfrecv(idx, opt={})
  request = "/rftransceiver/#{idx}/rfrecv"
  if opt.size() > 0
    first = true
    request << '?'
    if opt.has_key? 'timeout'
      request << "timeout=#{opt['timeout']}"
      first = false
    end
    if opt.has_key? 'blocksize'
      request << '&' unless first
      request << "blocksize=#{opt['blocksize']}"
    end
  end
  data = client.send_request(request)
  # Note the data is initially base64 encoded
  if data.size() > 0
    data['data'] = Base64.urlsafe_decode64(data['data']) if data.has_key? 'data'
  end
  data
end

#rfxmit(idx, data, opt = {}) ⇒ Object

Transmits data

Parameters:

  • idx (Integer)

    HW Index

  • data (String)

    Data to transmit

  • opt (Hash) (defaults to: {})

    Optional parameters: “repeat” => Integer, “offset” => Integer



86
87
88
89
90
91
92
# File 'lib/rex/post/hwbridge/extensions/rftransceiver/rftransceiver.rb', line 86

def rfxmit(idx, data, opt={})
  data = Base64.urlsafe_encode64(data)
  request = "/rftransceiver/#{idx}/rfxmit?data=#{data}"
  request << "&repeat=#{opt['repeat']}" if opt.has_key? 'repeat'
  request << "&offset=#{opt['offset']}" if opt.has_key? 'offset'
  client.send_request(request)
end

#set_baud_rate(idx, rate, opt = {}) ⇒ Object



165
166
167
168
169
# File 'lib/rex/post/hwbridge/extensions/rftransceiver/rftransceiver.rb', line 165

def set_baud_rate(idx, rate, opt={})
  request = "/rftransceiver/#{idx}/set_baud_rate?rate=#{rate}"
  request << "&mhz=#{opt['mhz']}" if opt.has_key? 'mhz'
  client.send_request(request)
end

#set_channel(idx, channel) ⇒ Object



128
129
130
# File 'lib/rex/post/hwbridge/extensions/rftransceiver/rftransceiver.rb', line 128

def set_channel(idx, channel)
  client.send_request("/rftransceiver/#{idx}/set_channel?channel=#{channel}")
end

#set_channel_bandwidth(idx, bandwidth, opt = {}) ⇒ Object



132
133
134
135
136
# File 'lib/rex/post/hwbridge/extensions/rftransceiver/rftransceiver.rb', line 132

def set_channel_bandwidth(idx, bandwidth, opt={})
  request = "/rftransceiver/#{idx}/set_channel_bandwidth?bw=#{bandwidth}"
  request << "&mhz=#{opt['mhz']}" if opt.has_key? 'mhz'
  client.send_request(request)
end

#set_channel_spc(idx, opt = {}) ⇒ Object



138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'lib/rex/post/hwbridge/extensions/rftransceiver/rftransceiver.rb', line 138

def set_channel_spc(idx, opt={})
  request = "/rftransceiver/#{idx}/set_channel_spc"
  if opt.size > 0
    request << '?'
    first = true
    if opt.has_key? 'chanspc'
      request << "chanspc=#{opt['chanspc']}"
      first = false
    end
    if opt.has_key? 'chanspc_m'
      request << '&' unless first
      request << "chanspc_m=#{opt['chanspc_m']}"
      first = false
    end
    if opt.has_key? 'chanspc_e'
      request << '&' unless first
      request << "chanspc_e=#{opt['chanspc_e']}"
      first = false
    end
    if opt.has_key? 'mhz'
      request << '&' unless first
      request << "mhz=#{opt['mhz']}"
    end
  end
  client.send_request(request)
end

#set_deviation(idx, deviat, opt = {}) ⇒ Object



171
172
173
174
175
# File 'lib/rex/post/hwbridge/extensions/rftransceiver/rftransceiver.rb', line 171

def set_deviation(idx, deviat, opt={})
  request = "/rftransceiver/#{idx}/set_deviation?deviat=#{deviat}"
  request << "&mhz=#{opt['mhz']}" if opt.has_key? 'mhz'
  client.send_request(request)
end

#set_freq(idx, freq, opt = {}) ⇒ Object

Sets the frequency

Parameters:

  • idx (Integer)

    HW Index

  • opt (Hash) (defaults to: {})

    Optional: “mhz” => 24

  • freq (Integer)

    Frequency to set



41
42
43
44
45
# File 'lib/rex/post/hwbridge/extensions/rftransceiver/rftransceiver.rb', line 41

def set_freq(idx, freq, opt={})
  request = "/rftransceiver/#{idx}/set_freq?freq=#{freq}"
  request << "&mhz=#{opt['mhz']}" if opt.has_key? 'mhz'
  client.send_request(request)
end

#set_lowball(idx) ⇒ Object



189
190
191
# File 'lib/rex/post/hwbridge/extensions/rftransceiver/rftransceiver.rb', line 189

def set_lowball(idx)
  client.send_request("/rftransceiver/#{idx}/set_lowball")
end

#set_maxpower(idx) ⇒ Object



193
194
195
# File 'lib/rex/post/hwbridge/extensions/rftransceiver/rftransceiver.rb', line 193

def set_maxpower(idx)
  client.send_request("/rftransceiver/#{idx}/set_maxpower")
end

#set_mode(idx, mode) ⇒ Object

Sets the mode

Parameters:

  • idx (Integer)

    HW Index

  • mode (String)

    Either RX, TX or IDLE



57
58
59
# File 'lib/rex/post/hwbridge/extensions/rftransceiver/rftransceiver.rb', line 57

def set_mode(idx, mode)
  client.send_request("/rftransceiver/#{idx}/set_mode?mode=#{mode}")
end

#set_modulation(idx, mod) ⇒ Object

Sets the modulation value

Parameters:

  • idx (Integer)

    HW Index

  • mod (String)

    Modulation Technique



64
65
66
# File 'lib/rex/post/hwbridge/extensions/rftransceiver/rftransceiver.rb', line 64

def set_modulation(idx, mod)
  client.send_request("/rftransceiver/#{idx}/set_modulation?mod=#{mod}")
end

#set_number_preamble(idx, num) ⇒ Object



185
186
187
# File 'lib/rex/post/hwbridge/extensions/rftransceiver/rftransceiver.rb', line 185

def set_number_preamble(idx, num)
  client.send_request("/rftransceiver/#{idx}/set_number_preamble?num=#{num}")
end

#set_power(idx, power) ⇒ Object



197
198
199
# File 'lib/rex/post/hwbridge/extensions/rftransceiver/rftransceiver.rb', line 197

def set_power(idx, power)
  client.send_request("/rftransceiver/#{idx}/set_power?power=#{power}")
end

#set_sync_mode(idx, mode) ⇒ Object



181
182
183
# File 'lib/rex/post/hwbridge/extensions/rftransceiver/rftransceiver.rb', line 181

def set_sync_mode(idx, mode)
  client.send_request("/rftransceiver/#{idx}/set_sync_mode?mode=#{mode}")
end

#set_sync_word(idx, word) ⇒ Object



177
178
179
# File 'lib/rex/post/hwbridge/extensions/rftransceiver/rftransceiver.rb', line 177

def set_sync_word(idx, word)
  client.send_request("/rftransceiver/#{idx}/set_sync_word?word=#{word}")
end

#supported_idxArray

Gets supported USB Indexes

Returns:

  • (Array)

    Indexes



33
34
35
# File 'lib/rex/post/hwbridge/extensions/rftransceiver/rftransceiver.rb', line 33

def supported_idx
  client.send_request("/rftransceiver/supported_idx")
end