curl-users
POST method and HTTPS webpage
Date: Thu, 10 Jul 2003 20:29:14 -0400
Hello everyone,
first I want to thank you cURL creators for the great job they'have done.
I'm trying to log into a bankwebsite who offer online banking.The url is https://accesd.desjardins.com/cgi-bin/logon.cmd
I've take snippets of code from simplepost.c and simplessl.c to try to connect to the website, here is the source of the page:
var activeField = null;
function autoJump_onKeyDown(fieldName)
{
var field = document.form_du_bas.elements[fieldName];
activeField = field;
field.lastValue = field.value;
}
function autoJump_onKeyUp(fieldName,nextFieldName,maxLength)
{
var field = document.form_du_bas.elements[fieldName];
var nextField = document.form_du_bas.elements[nextFieldName];
if (field == activeField &&
field.value != field.lastValue &&
field.value.length >= maxLength)
nextField.focus();
activeField = null;
}
function autoFocus_onLoad()
{
var field_card_num = document.form_du_bas.elements['card_num'];
var field_passwd = document.form_du_bas.elements['passwd'];
var field_Continuer = document.form_du_bas.elements['Continuer'];
if (field_card_num.value.length < 12)
field_card_num.focus();
else if (field_passwd.value.length < 1)
field_passwd.focus();
else
field_Continuer.focus();
}
// -->
</SCRIPT>
<form Name="form_du_bas" Action="/cgi-bin/logon.cmd" Method=Post>
<input Type="hidden" Name="token" Value="">
<input Type="hidden" Name="contexte" Value="009000001020">
<input Type="hidden" Name="ongact" Value="">
<input Type="hidden" Name="id_web_serveur" Value="4">
<input Type="hidden" Name="USER_NT" Value="">
<input Type="hidden" Name="origine_org" Value="">
<input Type="hidden" Name="origine_ref" Value="">
<input Type="hidden" Name="origine_montant" Value="">
<td Align=Center ColSpan=4 Height=35>
<input Type="submit" Value=" Continuer " Name="Continuer">
</td>
I have many questions about this source. First, what variables I have to POST ? All those of the type <input> and the three javascript variables card_num, passwd and Continuer. The variable Continuer is a submit type, do I must POST or do something else on this variable ? Continuer variable is linked to a submit button.
This is my c++ code:
CURL *curl;
CURLcode res;
FILE *headerfile;
string strHTMLFile,
referer,
useragent,
cookiefile,
strURL;
float solde=0.00;
struct MemoryStruct chunk;
chunk.memory=NULL; //! we expect realloc(NULL, size) to work
chunk.size = 0; //! no data at this point
///////////////////////////////////////////////////
// HTTP POST //
///////////////////////////////////////////////////
cookiefile="tdcookie.txt";
char *postthis="card_num=123456&passwd=abcde";
useragent="internet explorer 6.0";
strURL="https://accesd.desjardins.com/cgi-bin/logon.cmd";
curl_global_init(CURL_GLOBAL_ALL);
curl = curl_easy_init();
//! set up
curl_easy_setopt(curl, CURLOPT_URL, strURL.c_str());
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, true);
//curl_easy_setopt(curl, CURLOPT_VERBOSE, true);
//curl_easy_setopt(curl, CURLOPT_HEADER, true);
curl_easy_setopt(curl, CURLOPT_USERAGENT,useragent.c_str());
curl_easy_setopt(curl, CURLOPT_COOKIEJAR,cookiefile.c_str());
curl_easy_setopt(curl, CURLOPT_COOKIEJAR,cookiefile.c_str());
curl_easy_setopt(curl, CURLOPT_POST, true);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postthis);
// if we don't provide POSTFIELDSIZE, libcurl will strlen() by itself
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, strlen(postthis));
//! Get HTML into our struct object
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
// we pass our 'chunk' struct to the callback function
curl_easy_setopt(curl, CURLOPT_FILE, (void *)&chunk);
res = curl_easy_perform(curl);
cout << "HTML code: " << chunk.memory << endl;
// always cleanup
curl_easy_cleanup(curl);
curl_global_cleanup();
Everytime I try to logon, I only post the card_num, the other variable like passwd are omitted, I don't know why. Can you help me on this one ?
Thanks a lot and again thank you,
Ron
-------------------------------------------------------
This SF.Net email sponsored by: Parasoft
Error proof Web apps, automate testing & more.
Download & eval WebKing and get a free book.
www.parasoft.com/bulletproofapps1
Received on 2003-07-11