• Home
  • Releases
  • Submit Vuln
  • Press
  • About
  • PGP
  • Contact
    • Contact
    • Submit Vuln
    • VDP
  • Tutorials
    • All Posts
    • Photoshop on Linux
    • macOS on Linux
  • Supporters
  • Projects
  • Training
Sick Codes - Security Research, Hardware & Software Hacking, Consulting, Linux, IoT, Cloud, Embedded, Arch, Tweaks & Tips!
  • Home
  • Releases
  • Submit Vuln
  • Press
  • About
  • PGP
  • Contact
    • Contact
    • Submit Vuln
    • VDP
  • Tutorials
    • All Posts
    • Photoshop on Linux
    • macOS on Linux
  • Supporters
  • Projects
  • Training
No Result
View All Result
Sick Codes - Security Research, Hardware & Software Hacking, Consulting, Linux, IoT, Cloud, Embedded, Arch, Tweaks & Tips!
  • Home
  • Releases
  • Submit Vuln
  • Press
  • About
  • PGP
  • Contact
    • Contact
    • Submit Vuln
    • VDP
  • Tutorials
    • All Posts
    • Photoshop on Linux
    • macOS on Linux
  • Supporters
  • Projects
  • Training
No Result
View All Result
Sick Codes - Security Research, Hardware & Software Hacking, Consulting, Linux, IoT, Cloud, Embedded, Arch, Tweaks & Tips!
No Result
View All Result
Home Tutorials

Bash/Cron: Automatically Log Into WordPress via cURL/wget!

by Sick Codes
August 2, 2016 - Updated on June 24, 2020
in Tutorials
3
Automatically log into wordpress via curl

Being able to automate menial tasks inside your WordPress admin area, for example, pressing a button once a day via a cron job, is extremely helpful to say the least.

For this example, I will use my example of a plugin made for Shipwire that wasn’t updating inventory and tracking as it was supposed to automatically.

curl --data "log=ADMIN&pwd=PASSWORD" https://DOMAIN.COM/wp-login.php -c wpcookie.txt

Line 1 cURLs the WordPress login page and gets a session cookie and saves it (-c) as wpcookie.txt

Line 2 cURLs the WordPress login page again but posting two PHP parameters (–data), the first one log (WordPress username) and pwd (WordPress password) and saves the cookie.

I made a separate user for this, specifically with shop manager role.

You now have a file called wpcookie.txt that is a logged in user and can do anything on the site.

This is such a powerful way to enhance your website – you can use it to do pretty much anything.

Here are some examples of real word usage I am currently using this for:

Shipwire by Skyverge was not updating shipping numbers automatically. I could manually log in and press the Update Tracking button every day… or I could run a cron job every 6 hours to automate this process.

[cce_bash]
#!/bin/bash
#
# navigate to a private working directory.
cd /home/admin/web/DOMAIN.COM/private/

# get an admin session cookie
curl –data “log=USERNAME&pwd=PASSWORD” https://DOMAIN.COM/wp-login.php -c wpcookie.txt

# press the shipwire update
curl “https://DOMAIN.COM/wp-admin/admin.php?page=wc-settings&tab=shipwire&section=log&action=update_tracking” -b wpcookie.txt

# remove the cookie
rm -f wpcookie.txt

# exit the bash script
exit[/cce_bash]

UPDATE: Even better one liner of the above for the cron tab

[cce_bash]curl –data “log=USERNAME&pwd=PASSWORD” https://DOMAIN.COM/wp-login.php -c wpcookie.txt && curl “https://DOMAIN.COM/wp-admin/admin.php?page=wc-settings&tab=shipwire&section=log&action=update_tracking” -b wpcookie.txt[/cce_bash]

To do things with it, copy the URL of whatever you need pressed, or if it’s a button without a URL, press F12, open the Network tab, press the target button and then copy the GET request as a cURL or just the URL.

Next Post

iPhone/Android: Listen to Asterisk, FreePBX, AsteriskNOW call recordings on mobile phone.

Owncloud Rescan File System Cron Job - ALL Versions

Owncloud Super Easy Install Instant CentOS 7

Comments 3

  1. mrshua says:
    3 years ago

    I have been troubleshooting

    curl: (6) Could not resolve host: –data

    for the past hour… would you happen to have any insight?

    Reply
    • Sick Codes says:
      3 years ago

      I think you’re missing one `-` of `–`

      “`
      curl google.com –data
      “`

      Reply
  2. Timo says:
    5 years ago

    Hello and thank you very much. That’s exactly what I needed to do an action every few minutes in WordPress.

    Tried and works perfectly right away.

    I subscribed to your site right now, maybe I’ll find more that helps me 🙂

    Greetings Timo

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

No Result
View All Result
  • Home
  • Releases
  • Submit Vuln
  • Press
  • About
  • PGP
  • Contact
    • Contact
    • Submit Vuln
    • VDP
  • Tutorials
    • All Posts
    • Photoshop on Linux
    • macOS on Linux
  • Supporters
  • Projects
  • Training

© 2017-2021 Sick.Codes

@sickcodes

@sickcodes

@sickcodes

Discord Server

sickcodes.slack.com

t.me/sickcodeschat

./contact_form