Script to Reboot Hikvision IP Cam

Joined
May 6, 2020
Messages
3
Reaction score
3
Location
Hamburg, Germany
Hi everyone,

I have a network camera DS-2CD2185FWD-IS and it works absolutely fine !!! :)

I want to be able to reboot the cam from my ubuntu pc with a "curl"-command, but the result is every time: error 401 = no permission.
So I've installed the tool "httpie" on the ubuntu (which is similar to "curl").

This is my command:

"http --auth test2:Asdf1234 --auth-type digest PUT http://192.168.178.251/System/reboot --verbose"

And this is the result:

PUT /System/reboot HTTP/1.1
Accept: /
Accept-Encoding: gzip, deflate
Authorization: Basic dGVzdDI6QXNkZjEyMzQ=
Connection: keep-alive
Content-Length: 0
Host: 192.168.178.251
User-Agent: HTTPie/0.9.8

HTTP/1.1 401 Unauthorized
Connection: keep-alive
Content-Length: 260
Content-Type: text/html
Date: Fri, 01 May 2020 10:22:42 GMT
Keep-Alive: timeout=8, max=99
Server: webserver
WWW-Authenticate: Digest qop="auth", realm="IP Camera(D0993)", nonce="4e6a6b32597a5a6a5a57493659325a6a4d6a67784d7a513d", stale="FALSE"
WWW-Authenticate: Basic realm="IP Camera(D0993)"
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
<!DOCTYPE html>
<html><head><title>Document Error: Unauthorized</title></head>
<body><h2>Access Error: 401 -- Unauthorized</h2>
<p>Authentication Error: Your client does not have permission to get URL /System/reboot from this server.</p>
</body>
</html>

Could you please tell my what's wrong ?!?!?!?



Thanks a lot for your help and with best regards,

Matthias
 
Joined
May 6, 2020
Messages
3
Reaction score
3
Location
Hamburg, Germany
It is possible, to set 3 different access levels for the user: administrator, media user or user.
I've tried all of them without success.

On my windows PC I've installed the add-on "HTTP request maker" for firefox browser. With this add-on it is possible to make a PUT request. Mysteriously it works !!!!

One other test: I've deleted all users for CGI-Access in the cam. With HTTP request maker it works without a login. But from my ubuntu pc with "curl" or "httpie" it gives the same error as above.
 
Joined
May 6, 2020
Messages
3
Reaction score
3
Location
Hamburg, Germany
yeah - I got it.... !!!! :):):)

the correct curl command looks like:


curl -H "Content-Type: text/plain;charset=UTF-8\r\n" -H "Accept-Encoding: gzip, deflate\r\n" -H "Accept-Language: de,en-US;q=0.7,en;q=0.3\r\n" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0\r\n" --digest --http1.1 -X PUT http://<username>:<password>@<IP from cam>/System/reboot

In the cam you have to enable the "Enable Hikvision-CGI" which you can find here: "Network" - "Advanced Settings" - "Integration Protocol".
It is possible to add an user at this menü but it still doesn't work for me.

But: you have to add an user at "System" - "User Management". This user has to be "Operator" with almost the 3 authorizations: "Remote: Parameters Settings", "Remote: Shutdown/Reboot" and "Remote: Serial Port Control".
 

Xaqnazar

n3wb
Joined
Jul 1, 2022
Messages
1
Reaction score
2
Location
uzbekistan
Python:
import requests
from requests.auth import HTTPBasicAuth, HTTPDigestAuth

hi = requests.put('http://192.0.0.39/ISAPI/System/reboot/',  auth=HTTPDigestAuth('admin', 'Admin123'))
hihi = hi.text
print(hihi)
 

aidar

n3wb
Joined
Jan 16, 2024
Messages
1
Reaction score
1
Location
Russia
Python:
import requests
from requests.auth import HTTPBasicAuth, HTTPDigestAuth

hi = requests.put('http://192.0.0.39/ISAPI/System/reboot/',  auth=HTTPDigestAuth('admin', 'Admin123'))
hihi = hi.text
print(hihi)
Thank you!!!
 
Top