Skip to content
This repository has been archived by the owner on Oct 5, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1 from ashap5/gh-pages
Browse files Browse the repository at this point in the history
Merge Dev and gh-pages
  • Loading branch information
ashap5 authored Oct 1, 2023
2 parents 6ba962b + 31b3c9c commit d47bc6d
Show file tree
Hide file tree
Showing 6 changed files with 779 additions and 53 deletions.
25 changes: 25 additions & 0 deletions GetCaptchaTesting.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
async function GetCaptha()
{
const GetCapthaPage = await fetch("https://www.digitalcombatsimulator.com/en/auth/?register=yes", {
method: "GET",
headers: {
"Content-Type": "text/html",
}
});

let capthawithsid = (await GetCapthaPage.text()).match(/\?captcha_sid=\w+/);


let captchaid = capthawithsid[0].replace("?captcha_sid=", "");

const CaptchaImageLink = "https://www.digitalcombatsimulator.com/bitrix/tools/captcha.php?captcha_sid=" + captchaid;

return {captchaid : captchaid, CaptchaImageLink : CaptchaImageLink};

}
GetCaptha().then(
(r) => {
console.log(r.captchaid);
console.log(r.CaptchaImageLink);
}
)
Empty file added OTP/index.js
Empty file.
76 changes: 76 additions & 0 deletions TOTP codes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
Totp = class Totp {
// pass in the secret, code dom element, ticker dom element
constructor(expiry = 30, length = 6) {
this.expiry = expiry;
this.length = length;
// validate input
if (this.length > 8 || this.length < 6) {
throw "Error: invalid code length";
}
}

dec2hex(s) {
return (s < 15.5 ? "0" : "") + Math.round(s).toString(16);
}

hex2dec(s) {
return parseInt(s, 16);
}

base32tohex(base32) {
var base32chars, bits, chunk, hex, i, val;
base32chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
bits = "";
hex = "";
i = 0;
while (i < base32.length) {
val = base32chars.indexOf(base32.charAt(i).toUpperCase());
bits += this.leftpad(val.toString(2), 5, "0");
i++;
}
i = 0;
while (i + 4 <= bits.length) {
chunk = bits.substr(i, 4);
hex = hex + parseInt(chunk, 2).toString(16);
i += 4;
}
return hex;
}

leftpad(str, len, pad) {
if (len + 1 >= str.length) {
str = Array(len + 1 - str.length).join(pad) + str;
}
return str;
}

getOtp(secret, now = new Date().getTime()) {
var epoch, hmac, key, offset, otp, shaObj, time;
key = this.base32tohex(secret);
epoch = Math.round(now / 1000.0);
time = this.leftpad(this.dec2hex(Math.floor(epoch / this.expiry)), 16, "0");
shaObj = new jsSHA("SHA-1", "HEX");
shaObj.setHMACKey(key, "HEX");
shaObj.update(time);
hmac = shaObj.getHMAC("HEX");
// hmacObj = new jsSHA(time, "HEX") # Dependency on sha.js
// hmac = hmacObj.getHMAC(key, "HEX", "SHA-1", "HEX")
if (hmac === "KEY MUST BE IN BYTE INCREMENTS") {
throw "Error: hex key must be in byte increments";
} else {
// return null
offset = this.hex2dec(hmac.substring(hmac.length - 1));
}
otp = (this.hex2dec(hmac.substr(offset * 2, 8)) & this.hex2dec("7fffffff")) + "";
if (otp.length > this.length) {
otp = otp.substr(otp.length - this.length, this.length);
} else {
otp = this.leftpad(otp, this.length, "0");
}
return otp;
}

};
MyTotp = new Totp(30,6);
console.log(MyTotp.getOtp("6XWA C677 R6HL SQLW TJEA W2U7 QYZL W6ZV"));

Loading

0 comments on commit d47bc6d

Please sign in to comment.