Class: Rex::Post::Meterpreter::Extensions::Stdapi::Mic::Mic

Inherits:
Object
  • Object
show all
Defined in:
lib/rex/post/meterpreter/extensions/stdapi/mic/mic.rb

Overview

This meterpreter extension can list and capture from microphone

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Mic

Returns a new instance of Mic.



19
20
21
# File 'lib/rex/post/meterpreter/extensions/stdapi/mic/mic.rb', line 19

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



55
56
57
# File 'lib/rex/post/meterpreter/extensions/stdapi/mic/mic.rb', line 55

def client
  @client
end

Instance Method Details

#mic_listObject

List available microphones



28
29
30
31
32
33
34
35
36
37
# File 'lib/rex/post/meterpreter/extensions/stdapi/mic/mic.rb', line 28

def mic_list
  response = client.send_request(Packet.create_request(COMMAND_ID_STDAPI_AUDIO_MIC_LIST))
  names = []
  if response.result == 0
    response.get_tlvs(TLV_TYPE_AUDIO_INTERFACE_NAME).each do |tlv|
      names << tlv.value
    end
  end
  names
end

#mic_start(device_id) ⇒ Object

Starts recording audio from microphone



40
41
42
43
44
45
46
47
# File 'lib/rex/post/meterpreter/extensions/stdapi/mic/mic.rb', line 40

def mic_start(device_id)
  request = Packet.create_request(COMMAND_ID_STDAPI_AUDIO_MIC_START)
  request.add_tlv(TLV_TYPE_AUDIO_INTERFACE_ID, device_id)
  response = client.send_request(request)
  return nil unless response.result == 0

  Channel.create(client, 'audio_mic', Rex::Post::Meterpreter::Channels::Pools::StreamPool, CHANNEL_FLAG_SYNCHRONOUS, response)
end

#mic_stopObject

Stop recording from microphone



50
51
52
53
# File 'lib/rex/post/meterpreter/extensions/stdapi/mic/mic.rb', line 50

def mic_stop
  client.send_request(Packet.create_request(COMMAND_ID_STDAPI_AUDIO_MIC_STOP))
  true
end

#sessionObject



23
24
25
# File 'lib/rex/post/meterpreter/extensions/stdapi/mic/mic.rb', line 23

def session
  @client
end