Jump to content

Using CURL to answer security question


a_bains

Recommended Posts

I am trying to login to the website in the below example. This script logs in using a username and password but then is directed to a page with a security question. This is where the problem is, I am unable to POST my answer on this page. The result of my output is just the page with the security question. 

$username = 'XXXX';
$password = 'XXXX';
$loginUrl = 'https://www.dandh.ca/v4/dh';

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $loginUrl);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'Login='.urlencode($username).'&PW='.urlencode($password).'&Request=Login&formName=Login&jsEnabled=0&queryString=&Platform=Full&btLogin='.urlencode('Log In'));
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, "/tmp/cookies.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, "/tmp/cookies.txt");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_exec($ch); // process main login


curl_setopt($ch, CURLOPT_POSTFIELDS, 'securityAnswer=XXXX&Request=postForm&formName=loginChallengeValidation&btContinue=Continue');

echo curl_exec($ch); // process security question


curl_close($ch);
 
 
 
Here is the source code of the security question HTML form:
<form name="securityForm" id="secForm" method="post" action="/v4/dh">
<input type="hidden" name="Request" value="postForm"><input type="hidden" name="formName" value="loginChallengeValidation">
<table border="0" align="center" cellpadding="10" cellspacing="0">
<tr>
<td><span style="font-weight:bold;">Security Response</span>
<br>
<p>
                        Please answer the following security question.  Once the answer is confirmed you can continue.
                      </p>
<p style="margin-left: 20px;">
                        Question: What is the name of your best friend from childhood?</p>
<p style="margin-left: 20px;">
                        Answer: <input type="text" id="securityAnswer" name="securityAnswer" size="50" maxlength="50">
</p>
<p style="margin-left: 20px;">
<input type="submit" name="btContinue" value="Continue">
</p>
<p>
<i>If you do not know the answer to the security question, please email <a href="mailto:passwords@dandh.com">passwords@dandh.com</a> and they will send you a temporary password.
                        <a href="/v4/dh?Request=postForm&formName=LogOut">Click here</a> to return to login page.</i>
</p>
</td>
</tr>
</table>
</form>
 
Edited by a_bains
Link to comment
Share on other sites

  • 1 month later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.