iBotPeaches Posted June 13, 2009 Report Posted June 13, 2009 I went through about a week of making bots, and when you make a bot you have to be able to download the image from the CAPTCHA (or in this case ReCaptcha) so you can display it to the user to be entered, or send it to decaptcher for them to crack it. If you don't understand what that meant, this tutorial isn't for you. I'm just going to walk through how to pull the image from the ReCaptcha field. This tutorial assumes you have a hidden web browser in which you are using to navigate some page. This is assuming the basic GetElementByID doesn't work, since its generated dynamically per pageload. This is our code. Were using a foreach loop to go through every image in the Webbrowserforeach (HtmlElement images in webBrowser1.Document.Images) Now were doing a quick if statement to see if that image path has the URL of the recaptcha in it.if (images.GetAttribute("src").Contains("http://api.recaptcha.net/image?c=")) GetAttribute allows you to lots of things with a specific HTMLElement (in this case images) If it matches a simple line will dump that URL to an imagebox.string url = images.GetAttribute("src"); Then dump the variable url to your imagebox. Ignore the code tCount++; in there, it was part of that application. So it starts as a picture box. Assuming you grabbed the URL of the image correctly, it should show the image like so. 2
SmokiestGrunl Posted June 13, 2009 Report Posted June 13, 2009 Nice tutorial, easy to follow, but I don't know when it will come in handy for me.
Meonline Posted November 9, 2009 Report Posted November 9, 2009 First of all , thanks for this good Method iBotPeaches , but what about if i am not using the web browser and requesting the register page with http web request how i can fetch the recaptcha image, tried to generate it with the site key but alwayz the response come back with : " Sorry but your captcha input was not correct. hope you can help, Thanks!Co
iBotPeaches Posted November 9, 2009 Author Report Posted November 9, 2009 I don't know how you navigate a httpwebrequest, but if you can do a simple foreach in it to grab the URL of the image box, then you can just declare your streams and grab the image. HttpWebRequest Request; HttpWebResponse Response; Request = (HttpWebRequest)System.Net.WebRequest.Create(URL); Response = (HttpWebResponse)(WebResponse)Request.GetResponse(); return System.Drawing.Image.FromStream(Response.GetResponseStream());
derekchrisp Posted January 6, 2010 Report Posted January 6, 2010 For me your code wont work throws an exeption
iBotPeaches Posted January 6, 2010 Author Report Posted January 6, 2010 Then you typed it wrong. Unless its the code directly above your post, because I just wrote that from memory.
derekchrisp Posted January 7, 2010 Report Posted January 7, 2010 (edited) I was talking about your first post. Maybe i am doing something wrong ( im still learning all that c# stuff) but tried like this foreach (HtmlElement images in webBrowser1.Document.Images) { if (images.GetAttribute("src").Contains("http://api.recaptcha.net/image?c=")) { string url = images.GetAttribute("src"); pictureBox1.ImageLocation = url; break; } } Picture box stays empty. Not sure what im doing wrong Edited January 7, 2010 by derekchrisp
derekchrisp Posted January 7, 2010 Report Posted January 7, 2010 (edited) I think it's probably because captcha is generated dynamically it's src is not actually in html source. To get captchas location you have to get access to DOM and grab images src from there. Edited January 7, 2010 by derekchrisp
iBotPeaches Posted January 7, 2010 Author Report Posted January 7, 2010 foreach (HtmlElement images in webBrowser1.Document.Images) { if (images.GetAttribute("src").Contains("http://api.recaptcha.net/image?c=")) { string url = images.GetAttribute("src"); title = webBrowser1.Document.Title; capImage.ImageLocation = url; break; } } Just tested this code and the recaptcha popped up. So it still works this way. Add me on MSN (ibotpeaches@ibotmodz.net), and I'll try and see whats up.
derekchrisp Posted January 7, 2010 Report Posted January 7, 2010 (edited) So ok i tested following tell me what a heck im doing wrong like i said im really new with this so it makes me bit headache Testing with mixx registration page https://www.mixx.com/register using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace test2 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { foreach (HtmlElement images in webBrowser1.Document.Images) { if (images.GetAttribute("src").Contains("http://api.recaptcha.net/image?c=")) { string url = images.GetAttribute("src"); pictureBox1.ImageLocation = url; break; } } } private void goButton_Click(object sender, EventArgs e) { webBrowser1.Navigate(txtUrl.Text); } private void pictureBox1_Click(object sender, EventArgs e) { } private void txtUrl_TextChanged_1(object sender, EventArgs e) { } } } Edited January 7, 2010 by derekchrisp
iBotPeaches Posted January 7, 2010 Author Report Posted January 7, 2010 o, that site is using the recaptcha in an iframe, and it uses this url instead of the other one. https://api-secure.recaptcha.net/noscript?k=6LesGQMAAAAAAF0BRs_lsPUkSrYZ-qcgqgoiR-Mv Probably would take 10 minutes to adapt my script to make it work, so just catch me on MSN and I'll see if I can get yours working.
derekchrisp Posted January 7, 2010 Report Posted January 7, 2010 (edited) I can easily crack it through noscript solution with php . Thats not problem . But im trying to do it without noscript. Let's take Twitter . As you can see they don't offer noscript access so this is what makes me some headache.Hey i added you in msn im kaidoristm@ Edited January 7, 2010 by derekchrisp
derekchrisp Posted January 9, 2010 Report Posted January 9, 2010 Hey iBotPeaches do you know how to post form data through multipart/form-data without messing boundaryes . Not trying to upload file just post fields values.
decrypT Posted August 4, 2010 Report Posted August 4, 2010 I need some help with the captcha's How would i make the application re-grab the captcha if the page is refreshed? Also, it seems like my app doesn't grab the captcha if my bot's forms are filled. Like, my bot has textboxes that submit a form on a webpage. If my bot's textboxes are filled and sent to the webpage, it won't grab the captcha, however if the boxes are left empty, the captcha is grabbed. Any help would be awesome! --decrypT
iBotPeaches Posted August 7, 2010 Author Report Posted August 7, 2010 How would i make the application re-grab the captcha if the page is refreshed? Use the webbrowser event of like doneLoading, so anytime it is refreshed and re-loaded that portion of code will be re-ran so you then can call your reCaptcha code or just include it in there. Like, my bot has textboxes that submit a form on a webpage. If my bot's textboxes are filled and sent to the webpage, it won't grab the captcha, however if the boxes are left empty, the captcha is grabbed. Does your bot use getElementByID? I think it conflicts somewhere and there is one variable you have to re-init, but I can't remember why or which one.
decrypT Posted August 8, 2010 Report Posted August 8, 2010 (edited) Use the webbrowser event of like doneLoading, so anytime it is refreshed and re-loaded that portion of code will be re-ran so you then can call your reCaptcha code or just include it in there. Does your bot use getElementByID? I think it conflicts somewhere and there is one variable you have to re-init, but I can't remember why or which one. Yes, it uses getelementbyid and by name. Also, the doneLoading event, is that just like. if(webBrowser1.doneLoading){ Code for regrabbing the catpcha}? Thanks for the reply. Edited August 8, 2010 by decrypT
iBotPeaches Posted August 8, 2010 Author Report Posted August 8, 2010 http://i35.tinypic.com/20uy4bp.png Click on your webBrowser (If its a hidden one select it from the dropdown)Click the lightning bolt to bring up eventsDouble click on DocumentCompletedThat will move to your code and form the functionLooks like this. http://i38.tinypic.com/5bnwx5.png You cannot just type that out, you gotta do all the steps to insure the handler picks up the event.
decrypT Posted August 9, 2010 Report Posted August 9, 2010 (edited) http://i35.tinypic.com/20uy4bp.png Click on your webBrowser (If its a hidden one select it from the dropdown)Click the lightning bolt to bring up eventsDouble click on DocumentCompletedThat will move to your code and form the functionLooks like this. http://i38.tinypic.com/5bnwx5.png You cannot just type that out, you gotta do all the steps to insure the handler picks up the event. yeah i threw the getelements/names in that document completed method. webBrowser1.GetElementById("ID HERE").SetAttribute("value", fdsfs.Text); But i was wondering how i could reload the captcha after each entry. Using an if loop i guess. Edited August 14, 2010 by decrypT
ikizmert Posted November 28, 2012 Report Posted November 28, 2012 (edited) My code is not is not working, private void btnKayit_Click(object sender, EventArgs e) { webBrowser1.Navigate("http://xpblogger.com/register.php"); } foreach (HtmlElement images in webBrowser1.document.Images) { if (images.GetAttribute("src").Contains("http://api.recaptcha.net/noscript?k=")) { string url = images.GetAttribute("src"); pictureBox1.ImageLocation = url; break; } } if (images.GetAttribute("src").Contains("http://api.recaptcha...et/noscript?k=")) type is FALSEPlease help me. Thank you.. Edited November 28, 2012 by ikizmert
iBotPeaches Posted November 28, 2012 Author Report Posted November 28, 2012 My code is not is not working, private void btnKayit_Click(object sender, EventArgs e) { webBrowser1.Navigate("http://xpblogger.com/register.php"); } foreach (HtmlElement images in webBrowser1.document.Images) { if (images.GetAttribute("src").Contains("http://api.recaptcha.net/noscript?k=")) { string url = images.GetAttribute("src"); pictureBox1.ImageLocation = url; break; } } if (images.GetAttribute("src").Contains("http://api.recaptcha...et/noscript?k=")) type is FALSEPlease help me. Thank you.. It seems the recaptcha code has changed. if (images.GetAttribute("OuterHtml").Contains("http://www.google.com/recaptcha/api/image?")) { string url = images.GetAttribute("OuterHtml"); break; } That would work, but then you'll need to create some regex to pull the correct stuff out of that url var. It seems recaptcha is changing, but no offense this topic is like 3 years old.
ikizmert Posted November 28, 2012 Report Posted November 28, 2012 (edited) It seems the recaptcha code has changed. if (images.GetAttribute("OuterHtml").Contains("http://www.google.com/recaptcha/api/image?")) { string url = images.GetAttribute("OuterHtml"); break; } That would work, but then you'll need to create some regex to pull the correct stuff out of that url var. It seems recaptcha is changing, but no offense this topic is like 3 years old.(images.GetAttribute("OuterHtml").Contains("http://www.google.co...cha/api/image?") = FALSE ; its didnt work. but no offense this topic is like 3 years old. i not knowing im sorry... my english easy, i used google translate )Thank you anyway... Edited November 28, 2012 by ikizmert
iBotPeaches Posted November 29, 2012 Author Report Posted November 29, 2012 (images.GetAttribute("OuterHtml").Contains("http://www.google.co...cha/api/image?") = FALSE ; its didnt work. but no offense this topic is like 3 years old. i not knowing im sorry... my english easy, i used google translate )Thank you anyway... The code I gave you works. You just need to write regex to pull the URL out of the variable "url", as its actual the
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now