I want to access a website with jsoup, but it has a protection that is evaluated by a script. I want to know how I can get the value of ASP.KLR
"ASP.KLR =" + toHex (slowAES.decrypt (c, 2, a, b))
When I make the Jsoup request, it returns the following code
"<body>\n" +
" <div class=\"lds-grid\"> \n" +
" <div></div> \n" +
" <div></div> \n" +
" <div></div> \n" +
" <div></div> \n" +
" <div></div> \n" +
" <div></div> \n" +
" <div></div> \n" +
" <div></div> \n" +
" <div></div>\n" +
" </div> \n" +
" <script type=\"text/javascript\" src=\"https://enlineaplus.fcs-tech.com/public/js/aes.min.js\"></script>\n" +
" <script> function toNumbers(d) { var e = []; d.replace(/(..)/g, function (d) { e.push(parseInt(d, 16)); }); return e; } function toHex() { for ( var d = [], d = 1 == arguments.length && arguments[0].constructor == Array ? arguments[0] : arguments,e = \"\",f = 0;f < d.length;f++ )e += (16 > d[f] ? \"0\" : \"\") + d[f].toString(16); return e.toLowerCase(); } var a = toNumbers(\"d68d69a9a746d20032277ede658ba3ad\"), b = toNumbers(\"58c9e810e2ebcc49ae9ee28af1c6dd53\"), c = toNumbers(\"6cecb0d0211b3c563a23ae1f1b00d5a0\"); document.cookie = \"ASP.KLR=\" + toHex(slowAES.decrypt(c, 2, a, b)) + \"; expires=Session; path=/\";</script>\n" +
" </body>";
That document I want to pass it to a webview and get the value, any ideas
You'll have to solve it. You won get that value with an httpClient. I've already done this in Flutter, just do the same in your language. Any doubt write to telegram @ernestoaqs.
var href = AesEncrypt.getLocationHrefFromKLR(response.data.toString());
var a = AesEncrypt.getAFromScriptPage(response.data.toString());
var b = AesEncrypt.getBFromScriptPage(response.data.toString());
var c = AesEncrypt.getCFromScriptPage(response.data.toString());
var klrCookieString = AesEncrypt.getCookieKLR(a, b, c);
The class would then be:
class AesEncrypt {
static final key = encrypting.Key.fromLength(32);
static final iv = encrypting.IV.fromLength(16);
static final encrypter = encrypting.Encrypter(AES(key, mode: AESMode.cbc));
static int _hexToInt(String hex) {
int val = 0;
int len = hex.length;
for (int i = 0; i < len; i++) {
int hexDigit = hex.codeUnitAt(i);
if (hexDigit >= 48 && hexDigit <= 57) {
val += (hexDigit - 48) * (1 << (4 * (len - 1 - i)));
} else if (hexDigit >= 65 && hexDigit <= 70) {
val += (hexDigit - 55) * (1 << (4 * (len - 1 - i)));
} else if (hexDigit >= 97 && hexDigit <= 102) {
val += (hexDigit - 87) * (1 << (4 * (len - 1 - i)));
} else {
throw new FormatException("Invalid hexadecimal value");
}
}
return val;
}
static toNumbers(String texto) {
int indexInit = 0;
int indexEnd = 2;
List<int> arr = [];
while (indexEnd <= texto.length) {
arr.add(_hexToInt(texto.substring(indexInit, indexEnd)));
indexInit += 2;
indexEnd += 2;
}
return arr;
}
static getAFromScriptPage(String html) {
String regexStringForA = r'var a = toNumbers\("([a-z0-9]+)"';
RegExp regExpA = new RegExp(regexStringForA);
var matchesA = regExpA.allMatches(html);
var matchA = matchesA.elementAt(0);
return matchA.group(1);
}
static getBFromScriptPage(String html) {
String regexStringForB = r'b = toNumbers\("([a-z0-9]+)"';
RegExp regExpB = new RegExp(regexStringForB);
var matchesB = regExpB.allMatches(html);
var matchB = matchesB.elementAt(0);
return matchB.group(1);
}
static getCFromScriptPage(String html) {
String regexStringForC = r'c = toNumbers\("([a-z0-9]+)"';
RegExp regExpC = new RegExp(regexStringForC);
var matchesC = regExpC.allMatches(html);
var matchC = matchesC.elementAt(0);
return matchC.group(1);
}
static getLocationHrefFromKLR(String html) {
String regexStringForC =
r'location.href[ ]?=[ ]?"([. ?\%\@\#\^\-_\*\=\&a-zA-Z0-9:\/\/]+)';
RegExp regExp = new RegExp(regexStringForC);
var matches = regExp.allMatches(html);
var match = matches.elementAt(0);
return match.group(1);
}
static getCookieKLR(aa, bb, cc) {
var a = toNumbers(aa); // key
var b = toNumbers(bb); // iv
var c = toNumbers(cc); // text
Uint8List key = Uint8List.fromList(a);
Uint8List iv = Uint8List.fromList(b);
Uint8List srcData = Uint8List.fromList(c);
var crypt = AesCrypt();
AesMode mode = AesMode.cbc;
crypt.aesSetKeys(key, iv);
crypt.aesSetMode(mode);
Uint8List decryptedData = crypt.aesDecrypt(srcData);
String result = "";
decryptedData.forEach((element) {
if (element.toRadixString(16).length == 1) {
result += "0";
}
result += "${element.toRadixString(16)}";
});
return result;
}
}