daily pastebin goal
82%
SHARE
TWEET

HAREX 1080p shapshot

a guest Aug 14th, 2016 105 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. $username = 'admin';
  4. $password = 'admin';
  5. $ip = '192.168.1.2';
  6.  
  7. $url='http://'.$ip.'/onvif/device_service';
  8.  
  9. $post_string='<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"><s:Header><Security s:mustUnderstand="1" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><UsernameToken><Username>%%USERNAME%%</Username><Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">%%PASSWORD%%</Password><Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">%%NONCE%%</Nonce><Created xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">%%CREATED%%</Created></UsernameToken></Security></s:Header><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><GetSnapshotUri xmlns="http://www.onvif.org/ver10/media/wsdl"><ProfileToken>MainStreamToken</ProfileToken></GetSnapshotUri></s:Body></s:Envelope>';
  10.  
  11. function passwordDigest( $username, $password, $timestamp = "default", $nonce = "default" ) {
  12.     if ($timestamp=='default') $timestamp=date('Y-m-d\TH:i:s.000\Z');
  13.     if ($nonce=='default') $nonce=mt_rand();
  14.     $REQ=array();
  15.     $passdigest = base64_encode(pack('H*', sha1(pack('H*', $nonce) . pack('a*',$timestamp).pack('a*',$password))));
  16.     //$passdigest=base64_encode(sha1($nonce.$timestamp.$password,true)); // alternative
  17.     $REQ['USERNAME']=$username;
  18.     $REQ['PASSDIGEST']=$passdigest;
  19.     $REQ['NONCE']=base64_encode(pack('H*', $nonce));
  20.     //$REQ['NONCE']=base64_encode($nonce); // alternative
  21.     $REQ['TIMESTAMP']=$timestamp;
  22.     return $REQ;
  23. }
  24.  
  25. function makeToken() {
  26.     global $username, $password;
  27.     $timestamp=time();
  28.     return passwordDigest($username,$password,date('Y-m-d\TH:i:s.000\Z',$timestamp));
  29. }
  30.  
  31. $REQ=makeToken();
  32.  
  33. $post_string=str_replace(array("%%USERNAME%%",
  34.         "%%PASSWORD%%",
  35.         "%%NONCE%%",
  36.         "%%CREATED%%"),
  37.     array($REQ['USERNAME'],
  38.         $REQ['PASSDIGEST'],
  39.         $REQ['NONCE'],
  40.         $REQ['TIMESTAMP']),
  41.     $post_string);
  42.  
  43.  
  44.  
  45. $soap_do = curl_init();
  46. curl_setopt($soap_do, CURLOPT_URL,            $url );
  47. curl_setopt($soap_do, CURLOPT_CONNECTTIMEOUT, 10);
  48. curl_setopt($soap_do, CURLOPT_TIMEOUT,        10);
  49. curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true );
  50. curl_setopt($soap_do, CURLOPT_POST,           true );
  51. curl_setopt($soap_do, CURLOPT_POSTFIELDS,    $post_string);
  52. curl_setopt($soap_do, CURLOPT_HTTPHEADER,     array('Content-Type: text/xml; charset=utf-8', 'Content-Length: '.strlen($post_string) ));
  53.  
  54. $result = curl_exec($soap_do);
  55.  
  56. // curl_error($ch);
  57.  
  58. var_dump($result);
  59.  
  60.  
  61.  
  62.  
  63.  
  64. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top