0

The scenario: There's this voting form (vote.php) with 3 fields where one is a hidden field containing a hash. Once you submit the form, it requests using GET to a separate script (process.php) via XHR. I am trying to simulate this via cURL but only gotten so far to getting the hash and preserving the phpsessionid using a cookie jar.

The problem: The processing script (process.php) seems to be able to detect if a request didn't push thru using XHR and will return an error if I just submit its required parameters using regular cURL GET.

So how do I simulate XHR in cURL? Or I may be even wrong in saying there's XHR in cURL so can you please advice any methods on how to achieve this.

2 Answers 2

3

There is a good chance that process.php checks for an XHR request by looking at the HTTP_X_REQUESTED_WITH header, for example:

if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH']=="XMLHttpRequest") { /* Do stuff here */ }

So you could try setting that header in your cUrl request:

curl -H "HTTP_X_REQUESTED_WITH:XMLHttpRequest"

That has a good chance of working. Good luck!

Sign up to request clarification or add additional context in comments.

Comments

2

Add the following header: X-Requested-Width: XMLHttpRequest. This is added by all major JS libraries to ease identifying such requests on the server.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.