Skip to content

Instantly share code, notes, and snippets.

@Alexey1100
Last active March 19, 2017 14:51
Show Gist options
  • Save Alexey1100/d620a622e9162438cf9e966e4be69367 to your computer and use it in GitHub Desktop.
Save Alexey1100/d620a622e9162438cf9e966e4be69367 to your computer and use it in GitHub Desktop.
TP-LINK NC200/220 (FW 2.1.7) — access from command line

Streaming

$ vlc http://login:[email protected]:8080/stream/getvideo

Logging in

$ curl --data 'Username=admin&Password=password_in_base64' http://192.168.88.11/login.fcgi  -X 'POST' -v
# < HTTP/1.1 200 OK
# < Set-Cookie: sess=vmladad0tdbos82; PATH=/; COMMENT=; DOMAIN_NAME=; MAXAGE=60; VERSION=1
# < Content-Type: text/json
# < Transfer-Encoding: chunked
# < Date: Sat, 18 Mar 2017 19:11:29 GMT
# < Server: lighttpd/1.4.32
# {"errorCode":0, "isAdmin":1, "token":"q4addy1k0d8z"}%     

Settings

Getting motion detection state

$ curl --data '' http://192.168.88.11/mdconfsettinginit.fcgi  -X 'POST' --cookie 'sess=2ypsg666ajq5hk1'
# {"errorCode":"0","is_enable":"1","precision":"1","area":[1,1,0,0,1,1,1,1,0,1,1,1,1,0,1,1,1,1,0,1,1,1,1,1,1]}%         

Setting motion detection

Based on js-sources, it should work like this, but for some reason it isn't - maybe there's a bug in the firmware, idk.

$ curl --data 'is_enable=0&precision=1&area1=1&area2=1&area3=0&area4=0&area5=1&area6=1&area7=1&area8=1&area9=0&area10=1&area11=1&area12=1&area13=1&area14=0&area15=1&area16=1&area17=1&area18=1&area19=0&area20=1&area21=1&area22=1&area23=1&area24=1&area25=1&token=vm1f2arnelkrehe' http://192.168.88.11/mdconf_set.fcgi -X 'POST' --cookie 'sess=2ypsg666ajq5hk1'

Changing notification settings

So, instead of switching motion detection we could change notification settings.

$ curl --data 'smtp_is_enable=1&smtp_to=base64_data&smtp_mailhub=base64_data&smtp_auth_user=base64_data&smtp_auth_pass=base64_data&smtp_encryption=1&smtp_send_time=60&ftp_is_enable=0&ftp_server=&ftp_port=MjE%3D&ftp_user=&ftp_password=&ftp_path=Lw%3D%3D&ftp_mode=MQ%3D%3D&token=yrhvndee0an4cyz' http://192.168.88.11/smtp_and_ftp_save.fcgi  -X 'POST' --cookie 'sess=2ypsg666ajq5ss2'
# {"errorCode":0}
$ curl --data 'smtp_is_enable=0&smtp_to=&smtp_mailhub=&smtp_auth_user=&smtp_auth_pass=&smtp_encryption=1&smtp_send_time=60&ftp_is_enable=0&ftp_server=&ftp_port=&ftp_user=&ftp_password=&ftp_path=&ftp_mode=&token=yrhvndee0an4cyz' http://192.168.88.11/smtp_and_ftp_save.fcgi  -X 'POST' --cookie 'sess=2ypsg666ajq5ss2'
# {"errorCode":0}

Getting current notification settings.

$ curl --data '' http://192.168.88.11/smtp_and_ftp_load.fcgi  -X 'POST' --cookie 'sess=2ypsg666ajq5ss2'
# {"ftp_is_enable":0,"ftp_server":"","ftp_port":"MjE=","ftp_user":"","ftp_password":"","ftp_path":"Lw==","ftp_mode":1,"smtp_is_enable":1,"smtp_from":"base64_data","smtp_to":"base64_data","smtp_mailhub":"base64_data","smtp_auth_user":"base64_data=","smtp_auth_pass":"base64_data","smtp_send_time":60,"smtp_encryption":"1"}

Viewing logs

$ curl --data 'level=8&name=ALL&line=1' http://192.168.88.11/getlog.fcgi  -X 'POST' --cookie 'sess=2ypsg666ajq5ss2'
# {"errorCode":0,"log":[{"time":"[2017-03-19/19:39:17]","module":"MotionDetection","level":"INFO","msg":"TW90aW9uIERldGVjdGlvbiwgR2V0IHNldHRpbmcgc3VjY2Vzcy4NCg=="} ]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment