Created
August 11, 2019 18:58
-
-
Save bdwilson/a86ad67b0a392362d63b303f076291d3 to your computer and use it in GitHub Desktop.
Hikvision Camera Snapshot Auth Proxy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
# Hikvision Snapshot Proxy - authenticates session via GET request to retrieve | |
# a snapshot from an internal camera (not open to the Internet) | |
# | |
# https://yourserver/snapshot.php?auth=abcd1234&snapshot=2 | |
# https://yourserver/snapshot.php?auth=abcd1234&snapshot=1 | |
# | |
$password = "abcd1234"; | |
$user = "user"; # of your camera | |
$pass = "password"; # of your camera | |
# Update the IP's below for your internal camera IP's, add other else if's if | |
# you have more than 2 cameras, remove one if you have only 1. | |
if (preg_match('/^192.168.1.\d+$/',$_SERVER['REMOTE_ADDR'])) { | |
$auth=1; | |
} | |
if ($_REQUEST['auth'] && (!preg_match('/^[a-zA-Z0-9]+$/',$_REQUEST['auth']))) { | |
exit; | |
} | |
if ($_REQUEST['snapshot'] && (!preg_match('/^[0-9]+$/',$_REQUEST['snapshot']))) { | |
exit; | |
} | |
if (($_REQUEST['auth'] == $password) || ($auth == 1)) { | |
if ($_REQUEST['snapshot'] == 1) { | |
$url = "http://$user:$pass@192.168.2.12/Streaming/channels/1/picture"; | |
} else if ($_REQUEST['snapshot'] == 2) { | |
$url = "http://$user:$pass@192.168.2.2/Streaming/channels/1/picture"; | |
} | |
if ($url) { | |
header("Content-type: image/jpeg"); | |
$image= file_get_contents($url); | |
echo $image; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment