This repository was archived by the owner on May 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 88
Expand file tree
/
Copy pathshow-agent-webcam.php
More file actions
executable file
·101 lines (94 loc) · 4.02 KB
/
show-agent-webcam.php
File metadata and controls
executable file
·101 lines (94 loc) · 4.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
// include files
require_once("includes/check-authorize.php");
require_once("includes/functions.php");
$webcam_results = "";
if(strtolower($_SERVER['REQUEST_METHOD']) == 'post')
{
if(isset($_POST['agent_name']) && strlen($_POST['agent_name'])>0)
{
$agent_name = html_entity_decode(urldecode($_POST['agent_name']));
$arr_result = show_agent_results($sess_ip, $sess_port, $sess_token, $agent_name);
$webcam_location = get_configuration($sess_ip, $sess_port, $sess_token)['config'][0]['install_path'] . 'downloads/' . $agent_name . '/WebcamRecorder/';
if ($sess_ip == "127.0.0.1") {
if(file_exists($webcam_location)) {
$webcams = glob($webcam_location . "*.avi");
$local_location = "video/" . $agent_name . "/";
if (!file_exists($local_location)) {
mkdir($local_location, 0774, true);
}
foreach ($webcams as $key => $webcam) {
$avi_location = $webcam;
$mp4_location = str_replace('.avi', '.mp4', $avi_location);
$mp4_location = str_replace($webcam_location, $local_location, $mp4_location);
if (!file_exists($mp4_location)) {
$webcam_results = shell_exec("ffmpeg -i '" . $avi_location . "' -threads 0 -c:v libx264 -preset slower -crf 19 -qmin 10 -qmax 51 -strict experimental -c:a aac -b:a 128k -y '" . $mp4_location . "'");
}
}
$webcams = glob($local_location . "*.mp4");
if (strlen(shell_exec('which ffmpeg')) > 0) {
if(!empty($webcams))
{
foreach ($webcams as $key => $webcam) {
$html_webcam = "<div class='alert alert-success' >" . $webcam . "<br><video controls><source type='video/mp4' src='data:video/mp4;base64,". base64_encode(file_get_contents($webcam)). "'></video></div>";
$webcam_results = $webcam_results . $html_webcam;
}
}
} else {
$webcam_results = "<div class='alert alert-danger'><span class='glyphicon glyphicon-remove'></span> You will need to install ffmpeg on your server.<br><pre>sudo apt-get install ffmpeg</pre></div>";
}
} else {
$webcam_results = "<div class='alert alert-danger'><span class='glyphicon glyphicon-remove'></span> No webcam clips.</div>";
}
} else {
$webcam_results = "<div class='alert alert-danger'><span class='glyphicon glyphicon-remove'></span> The webcam viewer will only work if the Empire server is on the same server hosting Empire-web. Also apache must be able to read the Empire downloads folder for it to work.</div>";
}
}
}
$empire_agents = "";
$arr_result = get_all_agents($sess_ip, $sess_port, $sess_token);
if(!empty($arr_result))
{
$empire_agents .= "<option value=''>--Choose Agent Name--</option>";
for($i=0; $i<sizeof($arr_result["agents"]); $i++)
{
$empire_agents .= "<option value='".htmlentities($arr_result["agents"][$i]["name"])."'>".htmlentities($arr_result["agents"][$i]["name"])."</option>";
}
}
else
{
$empire_agents = "<div class='alert alert-danger'><span class='glyphicon glyphicon-remove'></span> 5Unexpected response.</div>";
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Empire: Show Agent WebCam</title>
<?php @require_once("includes/head-section.php"); ?>
</head>
<body>
<div class="container">
<?php @require_once("includes/navbar.php"); ?>
<br>
<div class="panel-group">
<div class="panel panel-primary">
<div class="panel-heading">Show Agent WebCam</div>
<div class="panel-body">
<form role="form" method="post" action="show-agent-webcam.php" class="form-inline">
Retrieves webcam clips for the agent specifed by Agent Name. This may take a long time to load if you have lots of long videos.<br><br>
<div class="form-group">
<select class="form-control" id="agent-name" name="agent_name">
<?php echo $empire_agents; ?>
</select>
</div>
<button type="submit" class="btn btn-success">Show WebCams</button>
</form>
<br>
<?php echo $webcam_results; ?>
</div>
</div>
</div>
</div>
<?php @require_once("includes/footer.php"); ?>
</body>
</html>