Skip to content

Instantly share code, notes, and snippets.

@theMiddleBlue
Created October 15, 2018 13:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theMiddleBlue/fe6116c9dc56bf23bca39ee6caffb731 to your computer and use it in GitHub Desktop.
Save theMiddleBlue/fe6116c9dc56bf23bca39ee6caffb731 to your computer and use it in GitHub Desktop.
machinebox hp video rev3rse security
<?php
if(isset($_POST['photo'])) {
// echo $_POST['photo'];
file_put_contents('/usr/local/openresty/nginx/html/test.jpg', base64_decode($_POST['photo']));
exec("curl -s -X POST -F 'file=@/usr/local/openresty/nginx/html/test.jpg' http://192.168.1.4:8080/facebox/check", $a);
echo(implode('', $a));
die();
}
?>
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/webcamjs/1.0.25/webcam.min.js"></script>
</head>
<body>
<div id="utente" style="font-size:24px;">Not logged in...</div>
<div id="my_camera" style="width:320px; height:240px;"></div>
<div id="my_result"></div>
<script language="JavaScript">
Webcam.attach( '#my_camera' );
function take_snapshot() {
Webcam.snap( function(data_uri) {
document.getElementById('my_result').innerHTML = '<img src="'+data_uri+'"/>';
// console.log(data_uri);
if(/^data:image\/jpeg;base64,.+$/.test(data_uri)) {
var img = /^data:image\/jpeg;base64,(.+)$/.exec(data_uri);
// console.log(img[1]);
$.post('/tt.php', {'photo':img[1]}).done(function(d) {
// console.log(d);
res = JSON.parse(d);
// console.log(res)
if(res['success']) {
if(typeof(res['faces'][0]) !== 'undefined') {
if(res['faces'][0]['confidence'] >= 0.5) {
$('#utente').html(res['faces'][0]['name']);
} else {
$('#utente').html('Access Denied: confidence too low.');
}
} else {
$('#utente').html('Access Denied: no faces found.');
}
}
});
}
} );
}
</script>
<a href="javascript:void(take_snapshot())">Take Snapshot</a>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment