CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2003
    Location
    China
    Posts
    69

    How to login a website?post!

    Hi,
    I want to login a website eg aaa.com
    so I do this,
    I use SendRequest send my username an password
    pFile->AddRequestHeaders("Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, */*");
    pFile->AddRequestHeaders("Referer: http://www.boofdollars.com/index.php?view=login&");
    pFile->AddRequestHeaders("Accept-Language: zh-cn");
    pFile->AddRequestHeaders("Content-Type: application/x-www-form-urlencoded");
    pFile->AddRequestHeaders("Accept-Encoding: gzip, deflate");
    pFile->AddRequestHeaders("User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Maxthon; .NET CLR 2.0.50727)");
    pFile->AddRequestHeaders("Host: www.boofdollars.com");
    pFile->AddRequestHeaders("Content-Length: 80");
    pFile->AddRequestHeaders("Connection: Keep-Alive");
    pFile->AddRequestHeaders("Cache-Control: no-cache");
    pFile->AddRequestHeaders("Cookie: "+cookie_);
    pFile->AddRequestHeaders("returnTo=&id=&ac=stats&step=&ptype=&form_user=goodhere&form_pwd=goodhere");
    pFile->SendRequest(NULL,0,lpOptional,strlen(lpOptional));//80 bytes skipped. Reason: The content type is not captured.

    Why?
    I must creat a cookie?
    Thank you

  2. #2
    Join Date
    Dec 2007
    Posts
    30

    Re: How to login a website?post!

    you can login the website using IE,and sniff the packet,and then check your code.
    Best,
    Kevin Jo
    http://www.upredsun.com
    **Easily and automatically build tcp-based or udp-based network protocol source code**

  3. #3
    Join Date
    Jun 2006
    Posts
    61

    Re: How to login a website?post!

    listen..what i know is that its all about sessions..there r 2 ways I've seen to handle sessions
    *Cookies
    *Posted variables

    Cookies, some variables with data sent to u in the response header (Set-Cookie)
    Posted variables, when u "GET" a page with the form ur gonna fill, some hidden fields holds some values for example a variable "s" (ie session) may hold "ksudfn983pm3cc9p3" or whatever, it may look like a cookie variable

    ny way..u can let wininet handle cookies for u by NOT adding ny "Cookie" headers in ur request AND "INTERNET_FLAG_FORMS_SUBMIT" header in the CHttpConnetion::OpenRequest function

    good luck

  4. #4
    Join Date
    Jun 2006
    Posts
    61

    Re: How to login a website?post!

    and upredsun's suggestion is extremely helpful, u SHOULD do that and find a way to automate the process and utilize wininet functions

  5. #5
    Join Date
    Nov 2002
    Location
    California
    Posts
    4,556

    Re: How to login a website?post!

    To sniff the conversation between a browser and the target site, install a debugging proxy like Fiddler: www.fiddlertool.com

    Mike

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured