Discussion:
log in website(studivz)
(too old to reply)
RiggiT
2010-03-27 16:01:01 UTC
Permalink
Hi folks,

I send a POST with some data to a login site.
I get an answer like "bad Request"

There's also a solution withe a cookie,
but i don't know how to get this coockie from
this side.
Sometimes i got no Response,
maybe because i tried too often to login.
I think the studivz page noticed that I
tried to login with no Browser.

My main Problem is the request with POST

I tried also to look up some date with wireshark
but I didn't get it.

Here is the Code
--------------------------------------
static TCHAR hdrs[] =
"Content-Type: application/x-www-form-urlencoded";
/* frmdata is urlencoded */
static TCHAR frmdata[] =

"email%3MAIL%40gmx.de%26password%3DPASS%26login%3DEinloggen%26jsEnabled%3Dfalse%26formkey%3D8191dbadb70e721fa89c742d031921d261ebaa337ba51b671ec3642e5e1eb4ac2c6848ce48f5823dfb5352b1909f7d1faf85c3c1bec782ddd53f217ae7d1c7525f4cbc273d5cd2e09b0c4e02dfdc90100ac3ee3985868d1d400ccba8ad605438%26iv%3D4b7f75f43f4830c3dc1ecd14d38b870b";
static LPSTR accept[2]={"*/*", NULL};
char cookie[]="Cookie: PHPSESSID=506825241a5e654d81908fd0348e4d33f15af56c";
HINTERNET hRequest = NULL;

unsigned long len = 0;
// for clarity, error-checking has been removed
HINTERNET hSession = InternetOpen("MyAgent",
INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);

HINTERNET hConnect = InternetConnect(hSession,
"https://secure.studivz.net",
INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 1);

if(hConnect) {
hRequest = HttpOpenRequest(hConnect, "POST",
"https://secure.studivz.net/Login", NULL, NULL, NULL/*accept*/, 0, 1);
} else {
printf("hConnect failed\n");
}
//HttpAddRequestHeaders(hRequest, cookie,(TCHAR)-1L,
HTTP_ADDREQ_FLAG_REPLACE);
printf("%s\n", cookie);
if(HttpSendRequest(hRequest, hdrs, strlen(hdrs), frmdata,
strlen(frmdata))) {
} else {
printf("SendRequest failed\n");
}
string CompleteBuffer;
do{
char antwortbuffer[10000];
InternetReadFile(hRequest, antwortbuffer, sizeof antwortbuffer,
&len);
antwortbuffer[len] = '\0';
CompleteBuffer += antwortbuffer;
} while(len);
printf("%s\n", CompleteBuffer.c_str());
ofstream outfile ("new.html",ofstream::binary); // outfile Stream
outfile.write(CompleteBuffer.c_str(), CompleteBuffer.length());
outfile.close;
InternetCloseHandle(hConnect);
InternetCloseHandle(hSession);
------------------------------------------------------------
RiggiT
2010-04-02 18:53:01 UTC
Permalink
Hi,
finally i got it 1 week away
i tried the same with www."url".net
and it works, no formacctiondata.

HINTERNET hConnect = InternetConnect(hSession,
"www.studivz.net",
INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 1);

hRequest = HttpOpenRequest(hConnect, "POST",
"", NULL, NULL, NULL/*accept*/, 0, 1);
} else {
printf("hConnect failed\n");
}

hope this helps
best regards
RiggiT

Loading...