Automate User Adding with PHP cURL

Help
David B
2010-06-25
2013-06-05
  • David B

    David B - 2010-06-25

    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?

     
  • Psychon

    Psychon - 2010-06-25

    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:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    #!/bin/sh
    SITE="http://localhost:1234"
    CURL="curl --cookie-jar cookies --cookie cookies"
    USER="psy"
    PASS="psy"
    NEWUSER="foo"
    NEWPASS="bar"
    # 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"
    
     
  • David B

    David B - 2010-06-25

    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!

     
  • Psychon

    Psychon - 2010-06-25

    That shouldn't make any difference with the CSRF check, I think….

     
  • David B

    David B - 2010-06-26

    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

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks