I'm trying to automate adding users for a free BNC service (paid job). I have tried and tried and I keep getting this error:
I have sent the _CSRF_Check variable, but something is telling me my Cookie isn't staying. Can anyone confirm this or provide an alternative method for automatically adding users?
No idea what you are doing, but works fine here. Also, you want us to do the work for which you are getting paid? Sounds like we'll need to receive a donation here… ;)
Also, if you really are losing your cookie, how could we help with that?
Anyway, this took me like 10 minutes:
CURL="curl --cookie-jar cookies --cookie cookies"
# Log us in
$CURL --data "submitted=1&user=$USER&pass=$PASS" "$SITE/login" -o /dev/null
# Get the CSRF token
CSRF=$($CURL "$SITE/mods/webadmin/adduser" | grep CSRF | cut -f 6 -d \")
# Add user
$CURL --data "_CSRF_Check=$CSRF&submitted=1&newuser=$NEWUSER&password=$NEWPASS&password2=$NEWPASS" "$SITE/mods/webadmin/adduser"
Oh I see you're logging in via the panel first. Why did I think to try that? >_>. I was originally doing http://user:pass@znc:port/. I'll give logging in a try. Though. I'll post back here with my results. Thanks!
That shouldn't make any difference with the CSRF check, I think….
Well turns out it WAS the cookie. My client was having permission issues for the cookie file so it wasn't storing the previous token. All is good now. Thank you for your help! :)
Also, when I asked for another way I was thinking if maybe a module was needed so I was sort of looking for that suggestion. :x I would never want someone to do something from me :x