mtcrackcha
Version:
a simple library that uses Gemini to solve MTCaptcha challenges
122 lines (104 loc) • 4.81 kB
JavaScript
// thanks https://github.com/kalkih/mtcaptcha-client/blob/master/src/crypto.ts
const URLSafeBase64CharCode2IntMap = [
-0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1,
-0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1,
-0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1,
-0x1, -0x1, -0x1, -0x1, -0x1, -0x1, 0x3e, -0x1, -0x1, 0x0, 0x1, 0x2, 0x3, 0x4,
0x5, 0x6, 0x7, 0x8, 0x9, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, 0xa, 0xb,
0xc, 0xd, 0xe, 0xf, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, -0x1, -0x1,
-0x1, -0x1, 0x3f, -0x1, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c,
0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
0x3a, 0x3b, 0x3c, 0x3d, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1,
-0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1,
-0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1,
-0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1,
-0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1,
-0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1,
-0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1,
-0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1,
-0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1,
-0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1,
-0x1, -0x1, -0x1, -0x1, -0x1, -0x1, -0x1
];
const URLSafeBase64Int2CharMap = [
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C',
'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c',
'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '-', '_'
];
function getKeyHist(fseed) {
const arr = new Array(fseed.length);
let hsh = URLSafeBase64CharCode2IntMap[fseed.charCodeAt(fseed.length - 0x1)];
for (let index = 0x0; index < fseed.length; index++) {
const one = fseed.charCodeAt(index);
const two = URLSafeBase64CharCode2IntMap[one];
arr[index] = two ^ hsh;
hsh = two;
}
return arr.slice(0x0, arr.length);
}
export function getKeesString(fseed) {
const keyHist = getKeyHist(fseed);
const arr = new Array(keyHist.length);
for (let index = 0; index < keyHist.length; index++) {
arr[index] = URLSafeBase64Int2CharMap[keyHist[index]];
}
return arr.join("");
}
function URLSafeBase64CharToInt(char) {
if (typeof char === 'string') char = char.charCodeAt(0x0);
const int = URLSafeBase64CharCode2IntMap[char % 0x100];
if (int < 0x0) throw 'well something broke';
return int;
}
function URLSafeBase64IntToChar(i) {
if (0 > i || i > 63) throw new ValueError('arg i must be between 0 .. 63 inclusive');
return URLSafeBase64Int2CharMap[i % 64];
}
function URLSafeBase4096IntToChar(i) {
if (0 > i || i > 4095) throw new ValueError('arg i must be between 0 .. 4095 inclusive');
return '' + URLSafeBase64IntToChar(i >> 6) + URLSafeBase64IntToChar(i & 63);
}
function URLSafeBase64Str2IntArray(string) {
const array = [];
for (let index = 0; index < string.length; index++)
array.push(URLSafeBase64CharToInt(string.charAt(index)));
return array;
}
function hashIntAry(int_array) {
let hsh = 0;
let index = 0;
for (index = 0; index < int_array.length; index++) {
hsh = (hsh << 0x5) - hsh + int_array[index];
hsh = hsh & hsh;
}
if (hsh < 0) hsh *= -0x1;
return hsh;
}
export function handleFoldChlg(fseed, fslots, fdepth) {
let hsh, int_array;
if (!fseed || fslots < 1) return '0';
const res = [];
int_array = URLSafeBase64Str2IntArray(fseed);
for (let index = 0, _pj_a = fslots; index < _pj_a; index += 1) {
int_array = foldBase64IntArray(int_array, 31);
hsh = hashIntAry(foldBase64IntArray(int_array, fdepth));
res.push(URLSafeBase4096IntToChar(hsh % 4096));
}
return res.join('');
}
function foldBase64IntArray(a1, foldCount) {
const a2 = a1.slice().reverse(), a3 = a1.slice();
let offset = 0, x = 0, y = 0, z = 0, i = 0;
for (i = 0; i < foldCount; i++) {
offset++;
for (x = 0; x < a1.length; x++) {
a3[x] = (Math.floor(((a3[x] + a2[(x + offset) % a2.length]) * 73) / 8) + y + z) % 64;
z = Math.floor(y / 2);
y = Math.floor(a3[x] / 2);
}
}
return a3;
}