curl / Mailing Lists / curl-library / Single Mail

curl-library

Ubiquiti

From: Greg Stewart via curl-library <curl-library_at_cool.haxx.se>
Date: Tue, 18 Apr 2017 09:51:53 -0600

On Tue, Apr 18, 2017 at 07:52:35AM -0600, Greg Stewart via curl-library
wrote:
> I am working with Ubiquiti airMax products. I'm trying to get logged in
and
> change the device configuration.

I actually had to do exactly that a few weeks ago. What I ended up doing is:
> COOKIEFILE=$(mktemp)
> curl -s -k -b $COOKIEFILE -c $COOKIEFILE -o /dev/null
> https://192.168.1.20/
> curl -s -k -b $COOKIEFILE -c $COOKIEFILE -o /dev/null -H 'Expect:' -F
> uri=/ -F username=ubnt -F password=ubnt -F country=56 -F ui_language=en_US
> -F lang_changed=no https://192.168.1.20/login.cgi
> cat picostation.cfg | curl -s -k -b $COOKIEFILE -c $COOKIEFILE -o
> /dev/null --referer 'https://192.168.1.20/system.cgi' -H 'Expect:' -F
> update_status=enabled -F 'hostname=PicoStation M2' -F adminname=ubnt -F
> cfgfile=@- -F cfgupload=Upload -F action=cfgupload
> https://192.168.1.20/system.cgi
> curl -s -k -b $COOKIEFILE -c $COOKIEFILE -o /dev/null
> https://192.168.1.20/apply.cgi
> (the "cat picostation.cfg" is different, as we partly generate the config
> from another script)

This worked for me:

> nano cookie.txt

curl -s -k -b cookie.txt -c cookie.txt -o /dev/null https://192.168.135.22/

curl -s -k -b cookie.txt -c cookie.txt -o /dev/null -H 'Expect:' -F uri=/
> -F username=ubnt -F password=ubnt -F country=56 -F ui_language=en_US -F
> lang_changed=no https://192.168.135.22/login.cgi

cat picostation.cfg | curl -s -k -b cookie.txt -c cookie.txt -o /dev/null
> --referer 'https://192.168.135.22/system.cgi' -H 'Expect:' -F
> update_status=enabled -F 'hostname=PicoStation M2' -F adminname=ubnt -F
> cfgfile=@- -F cfgupload=Upload -F action=cfgupload
> https://192.168.135.22/system.cgi

curl -s -k -b cookie.txt -c cookie.txt -o /dev/null
> https://192.168.135.22/apply.cgi

 I now need to get this working with libcurl with c code. This will run on
an ESP32, so I can't write to files to save the cookie, but I can store it
in a string. Same with the picostation.cfg file. I won't be able to store
the file on the ESP32, but I can store strings. I'm not sure I can create a
string that long (5259 characters).

-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2017-04-18