我想尝试使用Imacros脚本点击这个Google recaptcha?

时间:2015-04-28 00:16:31

标签: recaptcha imacros solver

我正在使用这个脚本,虽然我的主要动机是点击复选框,将验证码捕获为图像,将其上传到验证码求解服务,然后将输出发回到谷歌回收中。

VERSION BUILD=8820413
SET !EXTRACT_TEST_POPUP NO
SET !ERRORIGNORE YES
SET !TIMEOUT_PAGE 900
SET !TIMEOUT_STEP 900

TAB T=1
URL GOTO=https://www.google.com/recaptcha/api2/demo
FILEDELETE NAME=D:\captcha.jpg
WAIT SECONDS=3
TAG POS=1 TYPE=DIV ATTR=ID:recaptcha-anchor
WAIT SECONDS=5
ONDOWNLOAD FOLDER=D:\ FILE=captcha.jpg WAIT=YES
TAG POS=1 TYPE=IMG ATTR=ID:reCAPTCHA<SP>challenge<SP>image CONTENT=EVENT:SAVE_ELEMENT_SCREENSHOT
WAIT SECONDS=3
TAB OPEN
TAB T=2
URL GOTO=http://www.9kw.eu/grafik/form.html
TAG POS=1 TYPE=INPUT ATTR=NAME:apikey CONTENT=I Put My API key here
TAG POS=1 TYPE=INPUT ATTR=NAME:prio CONTENT=0
TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ACTION:/index.cgi ATTR=NAME:selfsolve CONTENT=NO
TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ACTION:/index.cgi ATTR=NAME:confirm CONTENT=NO
TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ACTION:/index.cgi ATTR=NAME:case-sensitive CONTENT=NO
TAG POS=1 TYPE=INPUT ATTR=NAME:source CONTENT=imacros
TAG POS=1 TYPE=INPUT ATTR=NAME:file-upload-01 CONTENT=D:\captcha.jpg
TAG POS=1 TYPE=INPUT ATTR=TYPE:submit
TAG POS=1 TYPE=INPUT ATTR=NAME:result EXTRACT=TXT
TAB CLOSE

TAB T=1
TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:default-response CONTENT={{!EXTRACT}}

'Press Roll Button
TAG POS=1 TYPE=DIV ATTR=ID:recaptcha-verify-button
WAIT SECONDS=6
TAG POS=1 TYPE=BUTTON FORM=ID:form ATTR=ID:claimbtn

WAIT SECONDS=12630

1 个答案:

答案 0 :(得分:2)

将reccapcha v2的imacros作为两个文件的完整示例:

  1. recaptcha_v2.iim

    VERSION BUILD=8920312 RECORDER=FX
    SET !EXTRACT_TEST_POPUP NO
    SET !ERRORIGNORE NO
    SET !TIMEOUT_PAGE 999
    SET !TIMEOUT_STEP 999
    TAB CLOSEALLOTHERS
    '
    ' This imacros script created by 9kw.eu
    ' Find more here: http://www.9kw.eu/
    '
    ' The script fill the captcha of recaptcha v2 demo.
    '
    ' Note for users with firefox with the message "Firefox prevented this page from automatically reloading.":
    ' UNCHECK the option "warn me when pages try to redirect" in your browser
    ' You find the checkbox under Options > Advanced > General > Accessibility
    
    ' Path to the captcha image with timestamp
    ' Tempfolder like C:\ or C:\TEMP under windows or like /tmp under linux
    SET tempfolder C:\
    
    ' Tempslash (Path with slashs as tempfolder) and with the htmlfile recaptcha_v2.html
    SET tempslash C:/
    
    ' Tempfile
    SET tempfile captcha_{{!NOW:yyyymmdd_hhnnss}}.jpg
    
    ' Step 1: Config for 9kw.eu for your apikey
    SET apikey your_api_key
    'And priority (prio 1-20)
    SET prio 0
    
    ' Step 2: Save the captcha picture to local disk
    TAB T=1
    URL GOTO=https://www.google.com/recaptcha/api2/demo
    FRAME NAME=I0_*
    EVENT TYPE=CLICK SELECTOR="#recaptcha-anchor>DIV:nth-of-type(5)" BUTTON=0
    WAIT SECONDS=3
    ONDOWNLOAD FOLDER={{tempfolder}} FILE={{tempfile}} WAIT=YES
    FRAME NAME=I1_*
    TAG POS=1 TYPE=DIV ATTR=ID:rc-imageselect CONTENT=EVENT:SAVE_ELEMENT_SCREENSHOT
    WAIT SECONDS=5
    
    TAB OPEN
    TAB T=2
    URL GOTO=file:///{{tempslash}}recaptcha_v2.html?file:///{{tempslash}}{{tempfile}}
    WAIT SECONDS=5
    FILEDELETE NAME={{tempfolder}}{{tempfile}}
    TAG POS=1 TYPE=DIV ATTR=* CONTENT=EVENT:SAVE_ELEMENT_SCREENSHOT
    TAB CLOSE
    
    'Wait a random number (1 to 5) of seconds
    SET randomnumber EVAL("Math.floor(Math.random()*5 + 1);")
    WAIT SECONDS={{randomnumber}}
    
    'Syntaxcheck: API Key, prio
    SET apikey EVAL("var s=\"{{apikey}}\"; if(s.match(/^[a-zA-Z0-9]+$/) && s.length <= 50 && s.length >= 5) s; else MacroError(\"API Key is wrong.\")")
    SET prio EVAL("var s=\"{{prio}}\", d = parseFloat(s); if(d >= 0 && d <= 20) d; else MacroError(\"Value(Prio) is not in the set range.\")")
    
    'Step 3: Open the a new tab, and go to 9kw.eu, and submit the captcha picture
    TAB OPEN
    TAB T=2
    URL GOTO=http://www.9kw.eu/grafik/form.html
    'The apikey is used to identify each of our customers, which you can get from the our page. It is assigned to the CONTENT.
    TAG POS=1 TYPE=INPUT ATTR=NAME:apikey CONTENT={{apikey}}
    'Priority in our system like min. 0 to max. 20 (cost +0-20)
    TAG POS=1 TYPE=INPUT ATTR=NAME:prio CONTENT={{prio}}
    'Options for the form. See more under http://www.9kw.eu/grafik/form.html and http://www.9kw.eu/api.html
    TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ACTION:/index.cgi ATTR=NAME:selfsolve CONTENT=NO
    TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ACTION:/index.cgi ATTR=NAME:confirm CONTENT=NO
    TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ACTION:/index.cgi ATTR=NAME:case-sensitive CONTENT=NO
    TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ACTION:/index.cgi ATTR=NAME:nomd5 CONTENT=YES
    'We need only numbers for this captcha
    TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ACTION:/index.cgi ATTR=NAME:numeric CONTENT=YES
    TAG POS=1 TYPE=INPUT ATTR=NAME:source CONTENT=imacros
    'The path of the captcha picture saved is assigned to the CONTENT
    TAG POS=1 TYPE=INPUT ATTR=NAME:file-upload-01 CONTENT={{tempfolder}}{{tempfile}}
    'Submit the formdata to 9kw.eu
    TAG POS=1 TYPE=INPUT ATTR=TYPE:submit
    'Extract the captchaid from your captcha submit
    TAG POS=1 TYPE=INPUT ATTR=NAME:captchaid EXTRACT=TXT
    SET captchaid {{!EXTRACT}}
    'Clean the !EXTRACT variable for the next task
    SET !EXTRACT NULL
    'Extract the characters that are recoginzed from the picture of captcha.
    TAG POS=1 TYPE=INPUT ATTR=NAME:result EXTRACT=TXT
    'Step 4: Check the captcha answer (text or nothing like #EANF#)
    SET answer EVAL("if (\"{{!EXTRACT}}\" == \"#EANF#\") {var x = \"\";} else {var x = \"{{!EXTRACT}}\";} x;")
    'Clean the !EXTRACT variable for the next task
    SET !EXTRACT NULL
    TAB CLOSE
    
    'Display extracted data (only for debug)
    'PROMPT {{captchaid}}
    
    'Step 5: Fill the recognized characters to the verification box (Click the pictures 1..9)
    TAB T=1
    FRAME NAME="I1_*"
    SET !ERRORIGNORE YES
    SET n1 EVAL("var s=\"{{answer}}\"; if(s.match(/^[0-9]+$/) && s.length <= 9 && s.length >= 2) s.substr(0,1); else MacroError(\"Captcha answer is wrong.\")")
    TAG POS={{n1}} TYPE=IMG ATTR=SRC:https://www.google.com/recaptcha/api2/payload?c=*
    SET n2 EVAL("var s=\"{{answer}}\"; if(s.match(/^[0-9]+$/) && s.length <= 9 && s.length >= 2) s.substr(1,1); else MacroError(\"Captcha answer is wrong.\")")
    TAG POS={{n2}} TYPE=IMG ATTR=SRC:https://www.google.com/recaptcha/api2/payload?c=*
    SET n3 EVAL("var s=\"{{answer}}\"; if(s.match(/^[0-9]+$/) && s.length <= 9 && s.length >= 2) s.substr(2,1); else MacroError(\"Captcha answer is wrong.\")")
    TAG POS={{n3}} TYPE=IMG ATTR=SRC:https://www.google.com/recaptcha/api2/payload?c=*
    SET n4 EVAL("var s=\"{{answer}}\"; if(s.match(/^[0-9]+$/) && s.length <= 9 && s.length >= 2) s.substr(3,1); else MacroError(\"Captcha answer is wrong.\")")
    TAG POS={{n4}} TYPE=IMG ATTR=SRC:https://www.google.com/recaptcha/api2/payload?c=*
    SET n5 EVAL("var s=\"{{answer}}\"; if(s.match(/^[0-9]+$/) && s.length <= 9 && s.length >= 2) s.substr(4,1); else MacroError(\"Captcha answer is wrong.\")")
    TAG POS={{n5}} TYPE=IMG ATTR=SRC:https://www.google.com/recaptcha/api2/payload?c=*
    SET n6 EVAL("var s=\"{{answer}}\"; if(s.match(/^[0-9]+$/) && s.length <= 9 && s.length >= 2) s.substr(5,1); else MacroError(\"Captcha answer is wrong.\")")
    TAG POS={{n6}} TYPE=IMG ATTR=SRC:https://www.google.com/recaptcha/api2/payload?c=*
    SET n7 EVAL("var s=\"{{answer}}\"; if(s.match(/^[0-9]+$/) && s.length <= 9 && s.length >= 2) s.substr(6,1); else MacroError(\"Captcha answer is wrong.\")")
    TAG POS={{n7}} TYPE=IMG ATTR=SRC:https://www.google.com/recaptcha/api2/payload?c=*
    SET n8 EVAL("var s=\"{{answer}}\"; if(s.match(/^[0-9]+$/) && s.length <= 9 && s.length >= 2) s.substr(7,1); else MacroError(\"Captcha answer is wrong.\")")
    TAG POS={{n8}} TYPE=IMG ATTR=SRC:https://www.google.com/recaptcha/api2/payload?c=*
    SET n9 EVAL("var s=\"{{answer}}\"; if(s.match(/^[0-9]+$/) && s.length <= 9 && s.length >= 2) s.substr(8,1); else MacroError(\"Captcha answer is wrong.\")")
    TAG POS={{n9}} TYPE=IMG ATTR=SRC:https://www.google.com/recaptcha/api2/payload?c=*
    SET !ERRORIGNORE NO
    
    'Click the Verify button
    EVENT TYPE=CLICK SELECTOR="HTML>BODY>DIV>DIV>DIV:nth-of-type(3)>DIV:nth-of-type(2)>DIV>DIV:nth-of-type(2)>DIV" BUTTON=0
    WAIT SECONDS=2
    FRAME F=0
    EVENT TYPE=CLICK SELECTOR="HTML>BODY>DIV>FORM>FIELDSET>UL>LI:nth-of-type(6)>INPUT" BUTTON=0
    WAIT SECONDS=3
    
    'Step 6: Check and send the captcha feedback back to the captcha service (OK:1, NotOK:2, EN: Right/False, DE: Richtig/Falsch)
    TAG POS=1 TYPE=DIV ATTR=CLASS:recaptcha-success EXTRACT=TXT
    SET htmlcode {{!EXTRACT}}
    SET !EXTRACT NULL
    SET feedback EVAL("if (\"{{htmlcode}}\" == \"Juhu!\") {var x = \"1\";} else {var x = \"2\";} x;")
    TAB OPEN
    TAB T=2
    URL GOTO=http://www.9kw.eu/index.cgi?source=imacros&action=usercaptchacorrectback&apikey={{apikey}}&correct={{feedback}}&id={{captchaid}}
    WAIT SECONDS=2
    TAB CLOSE
    TAB T=1
    
    'Cleanup: Delete the old captcha picture
    FILEDELETE NAME={{tempfolder}}{{tempfile}}

  2. recaptcha_v2.html

    <html>
    <head>
    <style>
    .c{
    	width:392;
    	height:505px;
    	margin: -15px 0 0px -15px;
    	position: relative;
    	overflow: hidden;
    }
    .t{
    	position: absolute;
    	top: 65px;
    	left: 10px;
    	width: 62%;
    	border: 1px red solid;
    	color: rgba(255, 255, 255, 0.9);
    	background: rgba(0, 0, 0, 0.8);
    	font: bold 18px Helvetica, Sans-Serif;padding: 0px 0px 0px 8px;
    }
    .n{
    	position: absolute;
    	width: 20px;
    	border: 1px red black;
    	color:rgb(0, 0, 0);
    	background: rgba(255, 255, 255, 0.9);
    	font: bold 18px Helvetica, Sans-Serif;padding: 0px 0px 0px 8px;
    }
    .n1{
    	top: 120px;
    	left: 7px;
    }
    .n2 {
    	top:120px;
    	left:137px;
    }
    .n3 {
    	top:120px;
    	left:267px;
    }
    .n4 {
    	top:250px;
    	left:7px;
    }
    .n5 {
    	top:250px;
    	left:137px;
    }
    .n6 {
    	top:250px;
    	left:267px;
    }
    .n7 {
    	top:380px;
    	left:7px;
    }
    .n8 {
    	top:380px;
    	left:137px;
    }
    .n9 {
    	top:380px;
    	left:267px;
    }
    </style>
    <body>
    
    <div class='c'>
    	<script>
    		var href = window.location.href;
    		var queryString = href.substring( href.indexOf('?') + 1 );
    		document.write("<img src='"+queryString+"' width='400' height='600'>");
    	</script>
    	<span class='t'>Type the image numbers<br />without spaces as &quot;268&quot;</span>
    	<span class='n n1'>1</span>
    	<span class='n n2'>2</span>
    	<span class='n n3'>3</span>
    	<span class='n n4'>4</span>
    	<span class='n n5'>5</span>
    	<span class='n n6'>6</span>
    	<span class='n n7'>7</span>
    	<span class='n n8'>8</span>
    	<span class='n n9'>9</span>
    </div>
    
    </body>
    </html>

  3. 或在https://www.9kw.eu/grafik/plugins/9kweu_recaptcha_v2.zip下使用验证码服务(您可以使用任何),例如 9kw.eu,验证码叠加(作为结果的文本验证码)和验证码反馈。您可以在9kw.eu =&gt;插件下找到更多的imacros脚本,如recaptcha v1 / v2,Confident和solvemedia。