Jump to content
bxdobs

Need CGI cmd to call PRESET location

Recommended Posts

Issue: NO-NAME-BRAND IPCAM PTZ camera used by an all-volunteer security team who continually keep forgetting to put the camera back in its home position 

Looking to use an autohotkey process to kick this camera back to its home position every 5 to 15 minutes.

Using Wireshark I have determined that the Web Interface sends the following CGI command

http://<ipaddress>.<port>/web/cgi-bin/hi3510/param.cgi?cmd=preset&-status=1&-number=1

Tried sending this CGI command using curl in a BAT file but expect that this fails because the camera requires authentication not present in this string

Wireshark provides some details as to how the web interface authentication is being done using GET HTTP/1.1 but not following how to include this in a one-line CGI Command

GET / HTTP/1.1
GET /web/index.html HTTP/1.1
Severity level: Chat
Group: Sequence
Host: <ipaddress>:<port>
Connection: keep-alive
Cache-Control: max-age=0
Authorization: Basic <some encrypted code>=
Credentials: <user>:<passwd>
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1823.82
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9
If-None-Match: "59a47afb.1311"
If-Modified-Since: Mon, 28 Aug 2017 13:20:11 DST

Some CGI manuals suggest the credentials can be included in the string as in &-usr=<user>&-pw=<password>

Can anyone share some Examples of how this might work?

This camera is on a public network and are not concerned about its overall security which is why it is a cheap no-name-brand just used to help our all-volunteer security team see out on extreme weather days.

Thanks in advance

Share this post


Link to post
Share on other sites

Sorry, not following your reply ... the preset/home position is already set as 1 ... there is no delay time associated with a preset on this camera ... which is why I am hoping to use autohotkey to issue a preset cgi command every 5 or 15 minutes (depending on time of day) ... currently playing with the Curl -v command and although I appear to have gotten past Authentication, the camera is refusing to accept the preset command ... I already use autohotkey to determine if this cheap camera is still online and if not kickstart it with an IP controlled remote power switch I designed. This camera has a bad habit of hanging especially if someone attempts to use the PTZ features in the dead of winter ... the motors most likely struggle in the colder weather causing inductive spikes which can be detrimental to DATA and INSTRUCTION fetches on MCU's. Using an ESP32 and a tiny relay I have implemented a way to interrupt the DC power to Cameras like this. 

Curl -v -u <user>:<pw> "HTTP://<ipaddress>:<Port>/web/cgi-bin/hi3510/param.cgi?cmd=preset&-status=1&-number=1" 

returning: Mark bundle as not supporting multiuse

expecting that this suggests authentication and preset can't be processed in the command same line? ... tried both GET and POST ... POST hangs waiting for something

In the Wireshark capture, the web service appears to use a Nailed Up Connection (Persistent or Keep-Alive) allowing for more commands without the need for further authentication(?)

Share this post


Link to post
Share on other sites

Solved:

The command I originally captured from wireshark was close but missing two key factors: home appears to be -number=0 and the preset command required an action -act=goto ... thinking the web app was taking shortcuts because I was already connected and had been sending PTZ commands prior to capturing the activity for doing a CALL (goto) 1 (home)

Here is the final solution:

curl -v -u <user:pw> "http://<ipaddress>:<port>/web/cgi-bin/hi3510/param.cgi?cmd=preset&-act=goto&-status=1&-number=0

Note: Status = 1 according to one CGI manual means Automatically Stop after Action is complete

So using an Autohotkey script that checks time in a loop and periodically launches a bat script with this curl command I can now ensure this camera is mostly pointing at home ... YES if someone is actively using another view they will be interrupted ... NOT a perfect solution BUT at least the human forgetful factor has been masked

Hope this can be of help to others ... this command now has the potential to be used to randomly patrol a 360-degree area

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×