+ Reply to Thread
Results 1 to 2 of 2

Thread: POST with google captcha

  1. #1

    POST with google captcha

    Hello.
    I want to create a user registration bot for a website , but the problem is that there is always a recaptcha image that has to be filled.
    And i must pass my POST Data with Recaptcha challenge and response.
    Last edited by csharpmaster; 11-08-2012 at 11:40 PM.

  2. #2
    Junior Member
    Join Date
    Jan 2012
    Posts
    22
    Here is what u need to do :
    1) Fetch source code using CURL
    2) place it on a webbrowser
    3) search for google captcha iframe tag
    4) take the links which has the challenge and in the same time is the image link

    I Already discussed how to send POST using Curl and you can visit it from HERE

    Now it is the time for coding :

    Code:
    using SeasideResearch.LibCurlNet;
    Code:
            WebBrowser TESTwebbrowser = new WebBrowser();
    
            string HTML_TEXT_VALUE;
    1) Fetch source code using CURL
    Code:
                Curl.GlobalInit((int)CURLinitFlag.CURL_GLOBAL_ALL);
    
                Easy e = new Easy();
                Easy.WriteFunction wf = MyWriteFunction;
    
                e.SetOpt(CURLoption.CURLOPT_URL, url);
                e.SetOpt(CURLoption.CURLOPT_WRITEFUNCTION, wf);
                e.Perform();
                e.Cleanup();
    Then Write the source code into variable HTML_TEXT_VALUE , and that can be done using a writefunction :
    Code:
            private int MyWriteFunction(byte[] buf, int size, int nmemb, Object extraData)
            {
                foreach (byte b in buf)
                    HTML_TEXT_VALUE += (((char)b).ToString());
    
    
                return buf.Length;
            }
    2) place it on a webbrowser
    Code:
                TESTwebbrowser.DocumentText = HTML_TEXT_VALUE;
    3) search for google captcha iframe tag
    Code:
                    HtmlElementCollection htmlelements = TESTwebbrowser.Document.GetElementsByTagName("img");
    
                    foreach (HtmlElement current in htmlelements)
                    {
                        FETCH_IMAGES.Add(current.GetAttribute("src"));
                    }
    
                    foreach (var item in FETCH_IMAGES)
                    {
                        if (item.Contains("http://www.google.com/recaptcha/api/image?c="))
                        {
                            // Here is the captcha image and i displayed in inside picturebox
                            image_url = item;
                            pictureBox1.ImageLocation = image_url;
                            FETCH_IMAGES.Clear();
    
                            Regex r = new Regex("([^.*]=.*[^" + '"' + "])");
                            Match m = r.Match(image_url);
                            if (m.Success)
                            {
                                challenge = m.Value;  // now we got the captcha challenge text
                            }
                            HTML_TEXT_VALUE = "";
                            break;
                        }
    Finally all what you have to do is to do POST and the post will be like :

    Create Method :
    private void POST_DATA(string url, string data)
    {
    Code:
                Curl.GlobalInit((int)CURLinitFlag.CURL_GLOBAL_ALL);
    
                Easy e = new Easy();
                Easy.WriteFunction wf = MyWriteFunction;
    
                string[] header = { "HTTP/1.1 200 OK Date: Tue, 06 Mar 2012 22:28:24 GMT Server: Apache Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Set-Cookie: PHPSESSID=cq1viovgm2nvov3ovdftsfjg67; path=/ Vary: Accept-Encoding Cache-Control: max-age=600, private, must-revalidate Content-Length: 14161 Content-Type: text/html; charset=UTF-8", "content-type plain/text" };
    
                e.SetOpt(CURLoption.CURLOPT_HEADER, true);
                e.SetOpt(CURLoption.CURLOPT_HTTPHEADER, header);
                e.SetOpt(CURLoption.CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0");
                e.SetOpt(CURLoption.CURLOPT_TIMEOUT, 40);
                e.SetOpt(CURLoption.CURLOPT_URL, url);
                e.SetOpt(CURLoption.CURLOPT_POSTFIELDS, data);
                e.Perform();
                e.Cleanup();
            }
    Then Call it :
    Code:
    POST_DATA("http://www.bazeny-akce.eu/register.php", "reg_username=myusername&reg_email=myusername%40me.com&reg_password=123456&reg_password2=123456&recaptcha_challenge_field=" +challenge + "&recaptcha_response_field=" + textBox1.Text + "&submit=Create+user&regfrom=full");

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

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