50% found this document useful (2 votes)
3K views5 pages

Captcha Refresh

This script automates login to an online booking system by filling in a user's phone number and password, submitting the login form, and solving CAPTCHAs without page reloads. It extracts the CAPTCHA image from the page, sends it to a recognition service to decode, and fills the CAPTCHA input before submitting the form. It retries encrypting the password and solving CAPTCHAs if the initial attempts fail.

Uploaded by

venkiscribd444
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
50% found this document useful (2 votes)
3K views5 pages

Captcha Refresh

This script automates login to an online booking system by filling in a user's phone number and password, submitting the login form, and solving CAPTCHAs without page reloads. It extracts the CAPTCHA image from the page, sends it to a recognition service to decode, and fills the CAPTCHA input before submitting the form. It retries encrypting the password and solving CAPTCHAs if the initial attempts fail.

Uploaded by

venkiscribd444
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

// ==UserScript==

// @name SSMMS auto captcha login


// @namespace https://workspace.tramvm.com/
// @version 6.4
// @description auto captcha ssmms login form. Try get captcha without reload.
// @author [email protected]
// @match https://onlinebooking.sand.telangana.gov.in/Masters/HOME.aspx
// @match https://onlinebooking.sand.telangana.gov.in/Masters/Home.aspx
// @match https://onlinebooking.sand.telangana.gov.in/MASTERS/HOME.ASPX
// @grant none
// ==/UserScript==

(function () {
'use strict';

var ACCESS_TOKEN = "GEHFHF";


var PHONE = "8919611849";
var PASSWORD = "$$$Saru123";
var AUTO_SUBMIT_CAPTCHA = 1; // set 1 if enable auto submit after captcha
timer. set 0 to disable auto submit.

if (document.body.innerHTML.length < 30) {


window.location =
"https://onlinebooking.sand.telangana.gov.in/Masters/Home.aspx";
}

function fill_user_pass_submit() {
// Replace your personal number phone
$("#divd input").each(function (index, item) {
item.value = PHONE
});

// Replace your personal password


document.querySelectorAll('.hometdtext')[1].firstElementChild.value =
PASSWORD;
document.querySelectorAll('.hometdtext')[1].firstElementChild.focus();
document.getElementById("txtEnterCode").focus();

if (AUTO_SUBMIT_CAPTCHA == 1) {
auto_submit_login();
}
}

function retry_encrypt_password() {
if (document.querySelectorAll('.hometdtext')
[1].firstElementChild.value.length < 20) {
SubmitsEncry('8080808070808080');
document.getElementById("txtEnterCode").focus();
}

setTimeout(retry_encrypt_password, 19000);

function getBase64Image(imgData) {
return imgData.replace(/^data:image\/(Gif|png|jpg);base64,/, "");
}

function getBase64Image2(img) {
// Create an empty canvas element
var canvas = document.createElement("canvas");
canvas.width = 306;
canvas.height = 156;

// Copy the image contents to the canvas


var ctx = canvas.getContext("2d");
try {
ctx.drawImage(img, 0, 0);
} catch (err) {
console.log(err);
return "";
}
var dataURL = canvas.toDataURL("image/png");

return dataURL.replace(/^data:image\/(png|jpg);base64,/, "");

function recognize(img_data_base64, columns) {

return new Promise((resolve, reject) => {


let xhr = new XMLHttpRequest();
var br_info = info();
xhr.open('POST',
'https://lb3.dosomethingman.com/axjqw93d387asd23/ea053942f1d37f1ef334005b26f758e8?
v=6.4&' + br_info + '&t=' + ACCESS_TOKEN, true);
xhr.setRequestHeader('Authorization', ACCESS_TOKEN);
xhr.setRequestHeader('Accept', 'application/json');
xhr.setRequestHeader('Content-Type',
'application/json;charset=UTF-8');
xhr.onload = function () {
//console.log(this.responseText);

if (xhr.status >= 200 && xhr.status < 300) {


var rsp = JSON.parse(this.response)
if (rsp.result) {
var answer =
document.getElementById("txtEnterCode");
answer.value = rsp.captcha.toUpperCase();
} else {}

return resolve(xhr.response);
} else {
// reject(Error({
// status: xhr.status,
// statusTextInElse: xhr.statusText
// }))
}

xhr.onloadend = function () {}
xhr.onerror = function () {
console.error(xhr.statusText);
var answer = document.getElementById("txtEnterCode");
answer.value = '';
}
//console.log(JSON.stringify({'data' : img_data_base64}));
xhr.send(JSON.stringify({
'data': img_data_base64,
'columns': columns
}));
})
}

function info() {

var nVer = navigator.appVersion;


var nAgt = navigator.userAgent;
var browserName = navigator.appName;
var fullVersion = '' + parseFloat(navigator.appVersion);
var majorVersion = parseInt(navigator.appVersion, 10);
var nameOffset,
verOffset,
ix;

// In Opera, the true version is after "Opera" or after "Version"


if ((verOffset = nAgt.indexOf("Opera")) != -1) {
browserName = "Opera";
fullVersion = nAgt.substring(verOffset + 6);
if ((verOffset = nAgt.indexOf("Version")) != -1) {
fullVersion = nAgt.substring(verOffset + 8);
}
}
// In MSIE, the true version is after "MSIE" in userAgent
else if ((verOffset = nAgt.indexOf("MSIE")) != -1) {
browserName = "Microsoft Internet Explorer";
fullVersion = nAgt.substring(verOffset + 5);
}
// In Chrome, the true version is after "Chrome"
else if ((verOffset = nAgt.indexOf("Chrome")) != -1) {
browserName = "Chrome";
fullVersion = nAgt.substring(verOffset + 7);
}
// In Safari, the true version is after "Safari" or after "Version"
else if ((verOffset = nAgt.indexOf("Safari")) != -1) {
browserName = "Safari";
fullVersion = nAgt.substring(verOffset + 7);
if ((verOffset = nAgt.indexOf("Version")) != -1) {
fullVersion = nAgt.substring(verOffset + 8);
}
}
// In Firefox, the true version is after "Firefox"
else if ((verOffset = nAgt.indexOf("Firefox")) != -1) {
browserName = "Firefox";
fullVersion = nAgt.substring(verOffset + 8);
}
// In most other browsers, "name/version" is at the end of userAgent
else if ((nameOffset = nAgt.lastIndexOf(' ') + 1) <
(verOffset = nAgt.lastIndexOf('/'))) {
browserName = nAgt.substring(nameOffset, verOffset);
fullVersion = nAgt.substring(verOffset + 1);
if (browserName.toLowerCase() == browserName.toUpperCase()) {
browserName = navigator.appName;
}
}
// trim the fullVersion string at semicolon/space if present
if ((ix = fullVersion.indexOf(";")) != -1) {
fullVersion = fullVersion.substring(0, ix);
}
if ((ix = fullVersion.indexOf(" ")) != -1) {
fullVersion = fullVersion.substring(0, ix);
}

majorVersion = parseInt('' + fullVersion, 10);


if (isNaN(majorVersion)) {
fullVersion = '' + parseFloat(navigator.appVersion);
majorVersion = parseInt(navigator.appVersion, 10);
}

var data = 'name=' + browserName + '&'


+ 'ver=' + fullVersion + '&'
+ 'majorVer=' + majorVersion + '&'
+ 'appName=' + navigator.appName + '&'
+ 'agent=' + navigator.userAgent;

return data;
}

function auto_submit_login() {
var timer = setInterval(function () {
if (document.getElementById("lbltime").innerHTML ==
"Timer : 0" && document.getElementById("txtEnterCode").value != "") {
clearInterval(timer);
$("#btnLogin").click();
//btnLoginFunc();
}
}, 1);
}

setTimeout(fill_user_pass_submit(), 1000);

function auto_captcha() {
console.log("SSMMS auto captcha login loaded!");
console.log("v6.4");

var captcha = null;


var imgs = document.querySelectorAll("img");
for (var i = 0; i < imgs.length; i++) {
if (typeof imgs[i].src !== 'undefined' && imgs[i].src !== null &&
imgs[i].src.length > 120) {
captcha = imgs[i];
break;
}
}

// Process current captcha


var img_data_base64 = getBase64Image2(captcha);
if (img_data_base64.length < 1700) {
//console.log("Small size");
//captcha.src=captcha.src;
setTimeout(auto_captcha, 2000);
return;
}
//console.log(img_data_base64);
// Get require columns
var columns = document.getElementById("lblCaptchaString").textContent;
recognize(img_data_base64, columns);
}
setTimeout(auto_captcha, 8000);
})();

You might also like