3
votes

Im trying to do a post request in a shell to invoke a wordpress install, but wordpress just tells me "you must provide an e-mail address". Here is what I have:

curl -X POST -A "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:12.0) Gecko/20100101 Firefox/12.0" -e "http://dev.example.com/yeshello/wp-admin/install.php?step=2" -H "Content-Type:application/x-www-form-urlencoded" -H "Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" -H "Accept-Encoding:gzip, deflate" --data "?step=2&weblog_title=yeshello&user_name=admin&admin_password=admin&admin_password2=admin&admin_email=mathias%40example.com&Submit=Install+WordPress" http://dev.example.com/yeshello/wp-admin/install.php

Ive managed to get it to work in a Chrome plugin by the name Postman here is what I've set up there:

Headers

User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:12.0) Gecko/20100101 Firefox/12.0 Referer: http://dev.feed.no/yeshello/wp-admin/install.php?step=2 Content-Type: application/x-www-form-urlencoded Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8 Accept-Encoding: gzip, deflate

Raw

this is raw data, the plugin have a field supporting that

step=2&weblog_title=yeshello&user_name=admin&admin_password=admin&admin_password2=admin&admin_email=mathias%40feed.no&Submit=Install+WordPress

URL

and finally there is a url field

http://dev.example.com/yeshello/wp-admin/install.php?step=2&weblog_title=yeshello&user_name=admin&admin_password=admin&admin_password2=admin&[email protected]&Submit=Install+WordPress

2

2 Answers

3
votes

And by the time I wrote the URL heading I tried use the whole url in the curl command, like this:

curl -X POST -A "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:12.0) Gecko/20100101 Firefox/12.0" -e "http://dev.example.com/yeshello/wp-admin/install.php?step=2" -H "Content-Type:application/x-www-form-urlencoded" -H "Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" -H "Accept-Encoding:gzip, deflate" --data "?step=2&weblog_title=yeshello&user_name=admin&admin_password=admin&admin_password2=admin&admin_email=mathias%40example.com&Submit=Install+WordPress" http://dev.example.com/yeshello/wp-admin/install.php?step=2&weblog_title=yeshello&user_name=admin&admin_password=admin&admin_password2=admin&[email protected]&Submit=Install+WordPress

And it worked :) But I fugured, why not post this anyways. Hope it helps someone! And if anyone want to clarify why this has to be done, I would love to hear it.

1
votes

This is simplified version of original answer. Thank you for your effort, it helped. curl --data-urlencode "weblog_title=MY_BLOG_NAME" \ --data-urlencode "user_name=MYUSERNAME" \ --data-urlencode "admin_password=MYPASSWORD" \ --data-urlencode "admin_password2=MYPASSWORD" \ --data-urlencode "[email protected]" \ --data-urlencode "Submit=Install+WordPress" \ http://wordpress_host/path_if_any/wp-admin/install.php?step=2 This is the most simplified I could come up with. I don't see any reason to change user agent string, set referrer url and include all params in POST and GET data. Curl sets correct content header when using --data and/or --data-urlencode.

The interesting part actually is that step=2 should be a GET variable and everything else needs to be POST data.