How to send the & (ampersand) character in the Wifi password field

Have some questions or having issues with your IP Camera(s), Post them here for the mods and other users to assist you with.
Post Reply
leoheck
Posts: 5
Joined: Sat Feb 29, 2020 2:36 pm

How to send the & (ampersand) character in the Wifi password field

Post by leoheck »

Hi, I am using the command line to set my camera wifi.

I can do that with "curl" and "httpie" successfully with:

Code: Select all


curl -s --digest \
-u admin:mycampass \
-o /tmp/response \
-w "%{http_code}\n" \
-G "http://amc03462ee3144ebb6.local/cgi-bin/configManager.cgi\
?action=setConfig \
&WLan.eth2.SSID='myWifi' \
&WLan.eth2.Keys[0]='myWifiPassword' \
&WLan.eth2.Encryption=WPA2-PSK-AES \
&WLan.eth2.KeyID=0 \
&WLan.eth2.Enable=true \
&WLan.eth2.KeyType=Hex \
&WLan.eth2.ConnectEnable=true \
&WLan.eth2.KeyFlag=true"

Code: Select all


http \
--auth admin:mycampass \
--auth-type digest \
GET http://amc03462ee3144ebb6.local/cgi-bin/configManager.cgi \
action=='setConfig' \
WLan.eth2.SSID=='myWifi' \
WLan.eth2.Keys\[0\]=='myWifiPassword' \
WLan.eth2.Encryption=='WPA2-PSK-AES' \
WLan.eth2.KeyID=='0' \
WLan.eth2.Enable=='true' \
WLan.eth2.KeyType=='Hex' \
WLan.eth2.ConnectEnable=='true' \
WLan.eth2.KeyFlag=='true'
If the Wifi network has a simple password it works just fine. However, if it has a password with the ampersand (&) character the command fails.

I believe it is due to the CGI in an Http GET method that behaves strangely with the & character. I tried many ways to encode this character and nothing seems to work. However when setting the Wifi password thought the web interface of the camera, I am able to set a password with the &.

When using &, the error I get is:

Code: Select all


Error
ErrorID=2, Detail=Invalid Request!
How can I overcome this issue?
Is it possible to change the Wifi password with an Http POST method?
Why I can set this password from the website but I can't do that with curl or httpie?
Do you know any other client/way that makes this "configManager.setConfig" request work?
leoheck
Posts: 5
Joined: Sat Feb 29, 2020 2:36 pm

Re: How to send the & (ampersand) character in the Wifi password field

Post by leoheck »

I am also wondering if this is an issue with the camera cgi itself.
jack7
Posts: 904
Joined: Tue May 29, 2018 7:46 pm

Re: How to send the & (ampersand) character in the Wifi password field

Post by jack7 »

You may have a camera firmware problem. See this thread: https://amcrest.com/forum/viewtopic.php ... fig#p28902
leoheck
Posts: 5
Joined: Sat Feb 29, 2020 2:36 pm

Re: How to send the & (ampersand) character in the Wifi password field

Post by leoheck »

I was thinking about that.

This is the current version of my cameras.

1. Software Version 2.400.AC02.15.R, Build Date: 2017-07-31
2. Software Version 2.420.AC01.3.R, Build Date: 2018-02-06

This is the firmware's version reported
I updated to the latest firmware yesterday V2.420.AC00.18.R
The numbers don't match exactly so I think I can discard this idea.

What happens, is that the & is lost/discarded when the value reaches the CGI.

If I set the WLan.eth2.ConnectEnable flag to false, I can send the data avoiding de error.
So I can check the value stored in the camera. For example, if I send the "a&b" what is stored is "ab".

However, to be honest, I was not able to see if this is a bug in curl/httpie or in the camera itself.
leoheck
Posts: 5
Joined: Sat Feb 29, 2020 2:36 pm

Re: How to send the & (ampersand) character in the Wifi password field

Post by leoheck »

It looks like a bug in the CGI itself that must decode the &.
Many passwords have this & character since the passwords generators can use it a lot.

Where do we report bugs like that?
User avatar
longedge
Site Admin
Posts: 591
Joined: Fri Mar 31, 2017 9:34 am

Re: How to send the & (ampersand) character in the Wifi password field

Post by longedge »

Just thinking out loud but since it's an http interface, is the & perhaps being interpreted as an ascii character about to be sent (which is not completed). What about trying "&#38" instead.
My AMCREST Cameras:-
2 x IP3M-941B firmware V2.620.00AC00.3.R, Build Date: 2019-12-18
1 x IP2M-841B firmware V2.420.AC00.18.R, Build Date: 2019-08-03
leoheck
Posts: 5
Joined: Sat Feb 29, 2020 2:36 pm

Re: How to send the & (ampersand) character in the Wifi password field

Post by leoheck »

Thanks for the suggestion.

But, when I use the `&` character I receive this invalid request.

Code: Select all


➜ http --auth admin:admin --auth-type digest \
http://$ip/cgi-bin/configManager.cgi \
action=='setConfig' \
WLan.eth2.SSID=='mywifi' \
WLan.eth2.Keys\[0\]=='a&b' \
WLan.eth2.Encryption=='WPA2-PSK-AES' \
WLan.eth2.KeyID=='0' \
WLan.eth2.Enable=='true' \
WLan.eth2.KeyType=='Hex' \
WLan.eth2.ConnectEnable=='false' \
WLan.eth2.KeyFlag=='true'

HTTP/1.1 200 OK
CONNECTION: close
CONTENT-LENGTH: 43
Content-type: text/plain;charset=utf-8

Error
ErrorID=2, Detail=Invalid Request!

---------------------

➜ http --auth admin:admin --auth-type digest \
http://amc03462_44ebb6.lan/cgi-bin/configManager.cgi \
action=='setConfig' \
WLan.eth2.SSID=='mywifi' \
WLan.eth2.Keys\[0\]=='a&#38b' \
WLan.eth2.Encryption=='WPA2-PSK-AES' \
WLan.eth2.KeyID=='0' \
WLan.eth2.Enable=='true' \
WLan.eth2.KeyType=='Hex' \
WLan.eth2.ConnectEnable=='false' \
WLan.eth2.KeyFlag=='true'

HTTP/1.1 200 OK
CONNECTION: close
CONTENT-LENGTH: 43
Content-type: text/plain;charset=utf-8

Error
ErrorID=2, Detail=Invalid Request!
If I encode the & by myself, it is also wrong

Code: Select all


~ 
➜ http --auth admin:admin --auth-type digest \
http://$ip/cgi-bin/configManager.cgi \
action=='setConfig' \
WLan.eth2.SSID=='mywifi' \
WLan.eth2.Keys\[0\]=='a%26b' \
WLan.eth2.Encryption=='WPA2-PSK-AES' \
WLan.eth2.KeyID=='0' \
WLan.eth2.Enable=='true' \
WLan.eth2.KeyType=='Hex' \
WLan.eth2.ConnectEnable=='false' \
WLan.eth2.KeyFlag=='true'

HTTP/1.1 200 OK
CONNECTION: close
CONTENT-LENGTH: 4
Content-type: text/plain;charset=utf-8

OK


~
➜ http \
--auth admin:admin \
--auth-type digest \
http://$ip/cgi-bin/configManager.cgi \
action==getConfig \
name==WLan

HTTP/1.1 200 OK
CONNECTION: close
CONTENT-LENGTH: 1034
Content-type: text/plain;charset=utf-8

table.WLan.eth2.Authentication=WPA/WPA2
table.WLan.eth2.ConnectEnable=false
table.WLan.eth2.DataEncryption=AES
table.WLan.eth2.EAP.AnonymousID=admin2
table.WLan.eth2.EAP.AuthType=NONE
table.WLan.eth2.EAP.CaCert=abc
table.WLan.eth2.EAP.Identity=admin
table.WLan.eth2.EAP.Method=TLS
table.WLan.eth2.EAP.Password=admin
table.WLan.eth2.EAP.UserCert=def
table.WLan.eth2.Enable=true
table.WLan.eth2.Encryption=WPA2-PSK-AES
table.WLan.eth2.KeyFlag=true
table.WLan.eth2.KeyID=0
table.WLan.eth2.KeyType=Hex
table.WLan.eth2.Keys[0]=a%26b <== WRONG_PASSWORD SHOULD BE a&b
table.WLan.eth2.Keys[1]=
table.WLan.eth2.Keys[2]=
table.WLan.eth2.Keys[3]=
table.WLan.eth2.LinkEnable=false
table.WLan.eth2.LinkMode=Auto
table.WLan.eth2.Linkable=false
table.WLan.eth2.Network.DefaultGateway=192.168.0.1
table.WLan.eth2.Network.DhcpEnable=true
table.WLan.eth2.Network.DnsServers[0]=8.8.8.8
table.WLan.eth2.Network.DnsServers[1]=8.8.4.4
table.WLan.eth2.Network.IPAddress=192.168.0.108
table.WLan.eth2.Network.SubnetMask=255.255.255.0
table.WLan.eth2.SSID=mywifi
It is also possible that the Curl and Httpie are removing the & before sending values with `&`
Post Reply