Results 1 to 12 of 12
Like Tree1Likes
  • 1 Post By Norm

Thread: Java and Captcha

  1. #1
    _Fede is offline Member
    Join Date
    Sep 2013
    Posts
    5
    Rep Power
    0

    Default Java and Captcha

    Hi,

    Is there a way to request a website current captcha and put it in my Jframe, so the user can submit the captcha from the GUI?

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,563
    Rep Power
    23

    Default Re: Java and Captcha

    Look at the html to see how the image is being requested from the server and use that address to load the image into your program. A good website should change the image every request to prevent the same image being loaded more than once.
    _Fede likes this.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    _Fede is offline Member
    Join Date
    Sep 2013
    Posts
    5
    Rep Power
    0

    Default Re: Java and Captcha

    When the page is being requested execute this javascript code:

    <script language="JavaScript">
    ord=Math.random();
    ord=ord*10000000000000000000;
    document.write('<img id="captcha" src="http://www.afreesms.com/image.php?o='+ord+'" align="top" />');
    </script>
    Here after the script is executed it write a line like this: <img id="captcha" src="http://www.afreesms.com/image.php?o=9503439224790782000" align="top">

    But if I try to get the image from the php link I get a different image, is there a method to get the image when the page is requested and put it in my GUI?

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,563
    Rep Power
    23

    Default Re: Java and Captcha

    If your program does an HTTP get for an html page and parses the html for the image associated with that HTTP get, it would be able to retrieve the image for that page. If another program like a browser does an HTTP get for that same page, it will probably get a different image.
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    18

    Default Re: Java and Captcha

    You also need to look at how that captcha is submitted.
    That is what does the code look like that submits the page once the user has entered the captcha value.
    Please do not ask for code as refusal often offends.

  6. #6
    _Fede is offline Member
    Join Date
    Sep 2013
    Posts
    5
    Rep Power
    0

    Default Re: Java and Captcha

    Here is the website: http://www.afreesms.com/intl/italy

    As you can see there is a captcha. I just want to request the page in Java and put the loaded captcha in my GUI.

    Thank you

  7. #7
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,563
    Rep Power
    23

    Default Re: Java and Captcha

    Does that site return a simple html file (no javascript that generates content in the browser) that can be read and parsed by a Java program?
    If so, write the program that reads and parses the html, gets the URL for the image and reads the image.
    If you don't understand my response, don't ignore it, ask a question.

  8. #8
    _Fede is offline Member
    Join Date
    Sep 2013
    Posts
    5
    Rep Power
    0

    Default Re: Java and Captcha

    As you can see the attribute "src" of the image is not a .jpg link but is a .php link so it keep on generating new captcha images

  9. #9
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    16,563
    Rep Power
    23

    Default Re: Java and Captcha

    Yes, I imagine the site will create a new image every time a user loads the html page.
    You will have to write a program that does everything a browser does: read the html and all the parts it needs including the image that you want to display.
    If you don't understand my response, don't ignore it, ask a question.

  10. #10
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    18

    Default Re: Java and Captcha

    And any javascript that interacts with that.
    Please do not ask for code as refusal often offends.

  11. #11
    _Fede is offline Member
    Join Date
    Sep 2013
    Posts
    5
    Rep Power
    0

    Default Re: Java and Captcha

    I really want to know how to do it, I tried without success..

  12. #12
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,082
    Rep Power
    4

    Default Re: Java and Captcha

    I'll be blunt: I don't think you can. This is way beyond your current knowledge level. If Javascript is involved as Tolls suggests, it is simply not an option to even want to do this.

    By the way: did you check with the owners of the site if you are allowed to abuse their site for your own purposes? Judging by this:

    Acceptable Use Policy

    I think you are not allowed to do this. There can be only one reason why you want to get this captcha: you want to use this site to send SMSes for free through your tool.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. Captcha Implementation
    By learnjava.kh in forum Forum Lobby
    Replies: 2
    Last Post: 01-20-2012, 09:40 AM
  2. Is there anyway to bypass captcha using Java code?
    By veera_bvm in forum Advanced Java
    Replies: 4
    Last Post: 07-19-2011, 04:55 PM
  3. Captcha
    By mike_ledis in forum Advanced Java
    Replies: 2
    Last Post: 05-31-2011, 09:14 AM
  4. How to create CAPTCHA in Java
    By JJay84 in forum New To Java
    Replies: 5
    Last Post: 04-03-2011, 12:59 PM
  5. Looking for an accessibly captcha (with audio support)
    By ssrc in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 09-27-2009, 02:14 AM

Posting Permissions

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