Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Authenticate on Wordpress with wget

I would like to login via Wget onto a Wordpress website.

I have found on StackOverflow something related to basic authentication.

wget --save-cookies cookies.txt \
--post-data 'user=foo&password=bar' \
http://server.com/auth.php

and tried this with a WordPress site but did not work.

like image 851
user3140607 Avatar asked Nov 14 '25 18:11

user3140607


1 Answers

Try this. This worked for me for one of the Drupal projects I worked on sometime ago. Its answered by asciikewl on the Drupal thread https://drupal.org/node/118759


I've managed to get it working this way, using wget's own cookie handling: I'm also referencing the /user page, not a login block (not enabled on my site)

#!/bin/sh
site=http://your site url with a slash on the end/
name=ScriptUser
pass=somethingsecure
cookies=/tmp/cron-cookies.txt
wget -O /dev/null --save-cookies /tmp/ba-cookies.txt --keep-session-cookies --load-cookies $cookies "${site}user"
wget --keep-session-cookies --save-cookies $cookies --load-cookies $cookies -O /dev/null \
    --post-data="name=$name&pass=$pass&op=Log%20in&form_id=user_login" \
    "${site}user?destination=login_redirect"
wget --keep-session-cookies --save-cookies $cookies --load-cookies $cookies "${site}login_redirect"

Maybe with the wget cookie handling you can recurse the site.

like image 131
roshan4074 Avatar answered Nov 17 '25 09:11

roshan4074



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!