1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

stuck at php cURL captcha and headers:(

Discussion in 'PHP & Perl' started by maximviper, Feb 11, 2011.

  1. maximviper

    maximviper BANNED BANNED

    Joined:
    Oct 25, 2010
    Messages:
    338
    Likes Received:
    86
    hello guys.

    i m new to curl . m trying to automate some logins creation

    but the website i m working with is having very complex headers,


    captcha image is :

    PHP:
    recaptcha/api/image?c=03AHJ_Vusz08Qf9z_MKUOk71WEPCJkgEEzCeB_0c52qYmDTwN6p3eaLHfeik07_T8YwT022gA0dDmn82v8vLv8nnoQrAHXPco9ZI1oXGWiz0KlMD3ujrW7xaAnRL6aBQC4gkhrWaQltylcS5bhTofD9fQ5RG2cyfEjHQ" style="display:block;">
    this is the header :
    PHP:
    Content-Length330
    Cookie
    __utma=235386264.1813212993.1297128520.1297399112.1297401711.6__utmz=235386264.1297169093.2.2.utmcsr=iwebtool.com|utmccn=(referral)|utmcmd=referral|utmcct=/backlink_checker__qca=P0-1432432680-1297128524399__gads=ID=25425b210834a4ed:T=1297155652:S=ALNI_MbB7ucClkr3Oh3MLCkeeK1czQbLoQru=%2create%2Fname%2Frutxt=create%20a%20new%20bog.; __utmc=235386264__utmb=235386264.1.10.1297401711
    Pragma
    no-cache
    Cache
    -Controlno-cache
    ajax
    =1&usname=goookokasd&usemail=goookokasd%40yahoo.com&password=mystery&password2=mystery&eula=on&recaptcha_challenge_field=03AHJ_VuuSnXX09zIJSmYjVo7OspRCgW8X12rEqkXkU7Xbof1wvku53H3jmBEfr90zD8eBWav3UkU4UfY2i-ISzYiEGMVw0ckhDJFvZErzIKbI-8LXVrE1pdpINWhQQ8MsLz4BHu9hfZmF5vhhg26jKEDpFh30bNf8_Q&recaptcha_response_field=edssss%201454
    i ahve no clue how to mimic this kind of complex headers.
    the tutorials i found have only simple headers.

    can anone please suggest me a descent source where i can learn to create such kind of headers?
     
  2. nambooooo

    nambooooo Regular Member

    Joined:
    May 21, 2009
    Messages:
    219
    Likes Received:
    71
    Location:
    GreenMTN
    What you have posted here are headers coming from the servers, which you really don't have to worry about, you set your headers to mimic a regular browser.
     
  3. dragonmath

    dragonmath Newbie

    Joined:
    Jan 25, 2011
    Messages:
    11
    Likes Received:
    0
    nambooooo thank for knowledge
     
  4. saxgod

    saxgod Regular Member

    Joined:
    Sep 19, 2010
    Messages:
    351
    Likes Received:
    337
    You do know you just posted credentials for a site on here right
     
  5. catchers

    catchers Newbie

    Joined:
    Aug 12, 2010
    Messages:
    32
    Likes Received:
    6
    PHP:
    /* STEP 2. visit the homepage to set the cookie properly */
    $ch curl_init ("http://somedomain.com/");
    curl_setopt ($chCURLOPT_COOKIEJAR$ckfile); 
    curl_setopt ($chCURLOPT_RETURNTRANSFERtrue);
    $output curl_exec ($ch);

    /* STEP 3. visit cookiepage.php */
    $ch curl_init ("http://somedomain.com/cookiepage.php");
    curl_setopt ($chCURLOPT_COOKIEFILE$ckfile); 
    curl_setopt ($chCURLOPT_RETURNTRANSFERtrue);
    $output curl_exec ($ch);
    That's some copy/paste to illustrate how to use cookies. The "cookiejar" file is the file where cookies get written to. The cookie file is the file that cookies are sent from. You can set these to the same file, so between multiple requests the cookies are taken care of for you.

    Next the last line is the content that you're posting. To do this:

    PHP:
    curl_setopt($chCURLOPT_POST      ,1);
     
    curl_setopt($chCURLOPT_POSTFIELDS    ,$POSTVARS);
    Where $postvars is a strings that looks exactly like the last line of your headers. in this line special characters must be url encoded. The email email@aol.com turns into email%40aol.com. to do this: urlencode("email@aol.com). You must set curlopt_post to 1 so it knows that it's sending a post request.

    Lastly, the header you posted is in fact a valid request header. A response header would look different. One way you can tell is a request header may have a "Cookie: " field, whereas a response header may have a "Set-Cookie: " field.
     
  6. Crazy

    Crazy Jr. Executive VIP

    Joined:
    Jun 13, 2009
    Messages:
    640
    Likes Received:
    319
    Occupation:
    VB, C#, XHTML, CSS, PHP, MySQL, JavaScript, jQuery
    Location:
    Everywhere
    ReCaptcha is a multi-step process, is that all you're having issues with? What you'll need to do is parse out the first link, which it appears you have. You'll need to hit that with cURL, parse out some additional information, and then hit the actual image URL.

    Also, what you've posted does in fact have username/password for your e-mail. I'd change it if it has sensitive information.