1
mirror of https://github.com/rapid7/metasploit-framework synced 2024-11-05 14:57:30 +01:00

Bring polling back in

This commit is contained in:
dmohanty-r7 2017-06-05 15:07:17 -05:00
parent 3d51301b98
commit bd9c15713d
2 changed files with 55 additions and 63 deletions

View File

@ -36,59 +36,58 @@ module Rex
end
# Starts recording video from video source of index +cam+
def mic_start(mic)
def mic_start(mic_index=0, start_delay)
request = Packet.create_request('audio_interface_start')
request.add_tlv(TLV_TYPE_AUDIO_INTERFACE_NAME, mic)
channel_id = client.send_request(request)
# begin
# client.mic.mic_start(index)
# mic_started = true
# ::Timeout.timeout(duration) do
# ::File.open(stream_path, 'wb') do |outfd|
# numchannels = 1
# sampleratehz = 11025
# bitspersample = 16
# datasize = 2000000000
# subchunk1size = 16
# chunksize = 4 + (8 + subchunk1size) + (8 + datasize)
# byterate = sampleratehz * numchannels * bitspersample / 8
# blockalign = numchannels * bitspersample / 8
#
# BinData::Int32be.new(0x52494646).write(outfd) # ChunkID: "RIFF"
# BinData::Int32le.new(chunksize).write(outfd) # ChunkSize
# BinData::Int32be.new(0x57415645).write(outfd) # Format: "WAVE"
# BinData::Int32be.new(0x666d7420).write(outfd) # SubChunk1ID: "fmt "
# BinData::Int32le.new(16).write(outfd) # SubChunk1Size
# BinData::Int16le.new(1).write(outfd) # AudioFormat
# BinData::Int16le.new(numchannels).write(outfd) # NumChannels
# BinData::Int32le.new(sampleratehz).write(outfd) # SampleRate
# BinData::Int32le.new(byterate).write(outfd) # ByteRate
# BinData::Int16le.new(blockalign).write(outfd) # BlockAlign
# BinData::Int16le.new(bitspersample).write(outfd) # BitsPerSample
# BinData::Int32be.new(0x64617461).write(outfd) # SubChunk2ID: "data"
# BinData::Int32le.new(datasize).write(outfd) # SubChunk2Size
# end
# stream_index = 0
# while client do
# if play_audio && (stream_index == start_delay)
# cmd_listen(stream_path)
# end
# data = client.mic.mic_get_frame(quality)
# if data
# ::File.open(stream_path, 'a') do |f|
# f.write(data)
# end
# data = nil
# end
# stream_index += 1
# sleep 1
# end
# end
# rescue ::Timeout::Error
# ensure
# client.mic.mic_stop if mic_started
# end
mic_stream(channel_id)
request.add_tlv(TLV_TYPE_AUDIO_INTERFACE_NAME, mic_index)
response = client.send_request(request)
begin
client.mic.mic_start(index)
mic_started = true
::Timeout.timeout(duration) do
::File.open(stream_path, 'wb') do |outfd|
numchannels = 1
sampleratehz = 11025
bitspersample = 16
datasize = 2000000000
subchunk1size = 16
chunksize = 4 + (8 + subchunk1size) + (8 + datasize)
byterate = sampleratehz * numchannels * bitspersample / 8
blockalign = numchannels * bitspersample / 8
BinData::Int32be.new(0x52494646).write(outfd) # ChunkID: "RIFF"
BinData::Int32le.new(chunksize).write(outfd) # ChunkSize
BinData::Int32be.new(0x57415645).write(outfd) # Format: "WAVE"
BinData::Int32be.new(0x666d7420).write(outfd) # SubChunk1ID: "fmt "
BinData::Int32le.new(16).write(outfd) # SubChunk1Size
BinData::Int16le.new(1).write(outfd) # AudioFormat
BinData::Int16le.new(numchannels).write(outfd) # NumChannels
BinData::Int32le.new(sampleratehz).write(outfd) # SampleRate
BinData::Int32le.new(byterate).write(outfd) # ByteRate
BinData::Int16le.new(blockalign).write(outfd) # BlockAlign
BinData::Int16le.new(bitspersample).write(outfd) # BitsPerSample
BinData::Int32be.new(0x64617461).write(outfd) # SubChunk2ID: "data"
BinData::Int32le.new(datasize).write(outfd) # SubChunk2Size
end
stream_index = 0
while client do
if stream_index == start_delay
cmd_listen(stream_path)
end
data = client.mic.mic_get_frame(quality)
if data
::File.open(stream_path, 'a') do |f|
f.write(data)
end
data = nil
end
stream_index += 1
sleep 1
end
end
rescue ::Timeout::Error
ensure
client.mic.mic_stop if mic_started
end
end
def mic_get_frame(quality)
@ -103,13 +102,6 @@ module Rex
true
end
def mic_stream(channel_id)
## Read from channel
@channel = Channel.create(client, 'audio_interface_stream', Rex::Post::Meterpreter::Channel::Stream,
CHANNEL_FLAG_SYNCHRONOUS)
end
attr_accessor :client
end
end

View File

@ -49,7 +49,7 @@ module Rex
end
end
def cmd_mic_start(index=0, start_delay=4096, play_audio=true)
def cmd_mic_start(mic_index=0, start_delay=4096)
print_status("Streaming mic audio channel...")
if client.mic.mic_list.length == 0
@ -65,11 +65,11 @@ module Rex
print_status("Audio File: #{stream_path}")
print_status("Streaming...")
client.mic.stream
client.mic_start(mic_index, start_delay)
end
def cmd_mic_stop(index=0)
client.mic.mic_stop(index)
def cmd_mic_stop
client.mic.mic_stop
end
def cmd_listen(stream_path)