Skip to content

Instantly share code, notes, and snippets.

@Antonin-Deniau
Created October 27, 2020 23:20
Show Gist options
  • Save Antonin-Deniau/e91bff8eb90360d169b90858eca0c615 to your computer and use it in GitHub Desktop.
Save Antonin-Deniau/e91bff8eb90360d169b90858eca0c615 to your computer and use it in GitHub Desktop.
var _0x5f46 = ['\x37\x3c\x30\x6c\x3c\x6e\x69\x30\x33\x3c\x6c\x3c\x6c\x3c\x33\x3e\x35\x3c\x62\x60\x3e\x64\x6b\x3e\x6a\x3b\x33\x6e\x30\x3e\x3e\x6f\x39\x6e\x30\x60\x6e\x6b\x33\x39', '\x39\x6f\x23\x6a\x7a\x51\x24\x3d\x57\x38\x73\x4e\x3e\x6e\x3f\x6b\x49\x58\x75\x49\x4d\x37\x73\x68\x36\x20\x57\x69\x6c\x62\x44\x50\x78\x60\x31\x26\x59\x46\x35\x7a', '\x6c\x65\x6e\x67\x74\x68', '\x73\x70\x6c\x69\x74', '\x63\x68\x61\x72\x41\x74', '\x6a\x6f\x69\x6e', '\x64\x5b\x63\x6e\x3f\x6b\x2b\x71\x6a\x65\x29\x2f\x4e\x7c\x74\x2e\x77\x6b\x47\x72\x5d\x72\x4f\x2b\x6b\x39\x62\x3d\x32\x79\x2c\x7d\x40\x5a\x79\x62\x3a\x38\x70\x6c\x61\x32\x27\x36\x25\x64\x6e\x29', '\x63\x68\x61\x72\x43\x6f\x64\x65\x41\x74', '\x66\x72\x6f\x6d\x43\x68\x61\x72\x43\x6f\x64\x65'];
var _0x19fd = function(_0x5f4656, _0x19fd1f) {
_0x5f4656 = _0x5f4656 - 0x0;
var _0x79ddde = _0x5f46[_0x5f4656];
return _0x79ddde;
};
function _0x10dbec(_0x1975bf) {
var _0x1b7fa0 = _0x19fd('\x30\x78\x30');
var _0x4e7c63 = 0x0;
console.log(JSON.stringify(_0x1b7fa0.split("").map(e => e.charCodeAt(0))))
var _0x6ae845 = _0x4bf1ad(_0x53e54e(_0x1975bf));
if (_0x6ae845 == _0x1b7fa0) {
_0x4e7c63 = 0x1;
} else {
_0x4e7c63 = 0x0;
}
return _0x4e7c63;
}
function _0x44d925() {
var _0x44809b = [0x2, 0x15, 0x0, 0x22, 0xb, 0x9, 0x17, 0x1e, 0xe, 0x5, 0x1d, 0x4, 0x18, 0x16, 0x8, 0x14, 0x1f, 0x11, 0x26, 0x23, 0xf, 0x1, 0xd, 0x6, 0xc, 0x1a, 0x19, 0x1b, 0x21, 0xa, 0x7, 0x10, 0x20, 0x1c, 0x3, 0x13, 0x25, 0x24, 0x12, 0x27];
return _0x44809b;
}
function _0x22f9d2() {
var _0xb974a1 = [0x0, 0x15, 0x0, 0x22, 0x4, 0x9, 0x17, 0x1e, 0xe, 0x5, 0x1d, 0x4, 0x18, 0x16, 0x8, 0x14, 0x1f, 0x11, 0x26, 0x23, 0xf, 0x1, 0xd, 0x6, 0xc, 0x1a, 0x19, 0x1b, 0x21, 0xa, 0x7, 0x10, 0x20, 0x1c, 0x3, 0x13, 0x25, 0x24, 0x12, 0x27];
return _0xb974a1;
}
function _0xdbb8b3() {
var _0x22dcfa = [0x0, 0x15, 0x0, 0x22, 0x4, 0x9, 0x17, 0x7, 0xe, 0x5, 0x1d, 0x4, 0x18, 0xd, 0x8, 0x14, 0x1f, 0x11, 0x26, 0x23, 0xf, 0x1, 0xd, 0x6, 0xc, 0x1a, 0x19, 0x1b, 0x21, 0xa, 0x7, 0x10, 0x20, 0x1c, 0x3, 0x13, 0x25, 0x24, 0x12, 0x27];
return _0x22dcfa;
}
function _0x33903e(_0x3c3da1) {
var _0x334fb8 = _0x44d925();
var _0x1ef0fc = _0x19fd('\x30\x78\x31');
var _0x242379 = 0x0;
var _0x53fbc5 = _0x1ef0fc[_0x19fd('\x30\x78\x32')];
while (_0x3c3da1[_0x19fd('\x30\x78\x32')] < 0x28) {
_0x3c3da1 += _0x1ef0fc[_0x242379++];
if (_0x242379 >= _0x53fbc5) {
_0x242379 = 0x0;
}
}
var _0x2e4ee5 = _0x3c3da1[_0x19fd('\x30\x78\x33')]('');
for (_0x242379 = 0x0; _0x242379 < _0x2e4ee5[_0x19fd('\x30\x78\x32')]; _0x242379++) {
_0x2e4ee5[_0x334fb8[_0x242379]] = _0x3c3da1[_0x19fd('\x30\x78\x34')](_0x242379);
}
return _0x2e4ee5[_0x19fd('\x30\x78\x35')]('');
}
function _0x53e54e(_0x44511f) {
var _0x4d3936 = _0x22f9d2();
var _0x5414b5 = _0x19fd('\x30\x78\x31');
var _0x1f5864 = 0x0;
var _0x564a67 = _0x5414b5[_0x19fd('\x30\x78\x32')];
while (_0x44511f[_0x19fd('\x30\x78\x32')] < 0x28) {
_0x44511f += _0x5414b5[_0x1f5864++];
if (_0x1f5864 >= _0x564a67) {
_0x1f5864 = 0x0;
}
}
var _0x505f9e = _0x44511f['\x73\x70\x6c\x69\x74']('');
for (_0x1f5864 = 0x0; _0x1f5864 < _0x505f9e['\x6c\x65\x6e\x67\x74\x68']; _0x1f5864++) {
_0x505f9e[_0x4d3936[_0x1f5864]] = _0x44511f[_0x19fd('\x30\x78\x34')](_0x1f5864);
}
return _0x505f9e['\x6a\x6f\x69\x6e']('');
}
function _0x4bf1ad(_0x350d56) {
var _0xb038d9 = _0x19fd('\x30\x78\x36');
var _0x4b4483 = _0x350d56[_0x19fd('\x30\x78\x33')]('');
var _0x7d38d1 = 0x0;
//console.log(JSON.stringify(_0xb038d9.split("").map(e => e.charCodeAt(0))))
//console.log(_0x4b4483)
for (var _0x1c9024 = 0x0; _0x1c9024 < _0x4b4483['\x6c\x65\x6e\x67\x74\x68']; _0x1c9024++) {
_0x7d38d1 = _0x350d56[_0x19fd('\x30\x78\x37')](_0x1c9024) ^ _0xb038d9[_0x19fd('\x30\x78\x37')](_0x1c9024) & 0xf;
_0x4b4483[_0x1c9024] = String[_0x19fd('\x30\x78\x38')](_0x7d38d1);
if (_0x7d38d1 < 0x20 || _0x7d38d1 > 0x7e) {}
}
return _0x4b4483[_0x19fd('\x30\x78\x35')]('');
}
// ==============================================
// ==============================================
// ==============================================
// ==============================================
function getSbox() {
let sbox = [0x0, 0x15, 0x0, 0x22, 0x4, 0x9, 0x17, 0x1e, 0xe, 0x5, 0x1d, 0x4, 0x18, 0x16, 0x8, 0x14, 0x1f, 0x11, 0x26, 0x23, 0xf, 0x1, 0xd, 0x6, 0xc, 0x1a, 0x19, 0x1b, 0x21, 0xa, 0x7, 0x10, 0x20, 0x1c, 0x3, 0x13, 0x25, 0x24, 0x12, 0x27];
let ret = new Array(sbox.length)
for (let i = 0; i < sbox.length; i++) {
if (ret[sbox[i]]) {
ret[sbox[i]].push(i)
} else {
ret[sbox[i]] = [i]
}
}
return ret
}
function encodeAll(s) {
return _0x4bf1ad(_0x53e54e(s))
}
function pencodeAll(s) {
console.log(JSON.stringify(_0x4bf1ad(_0x53e54e(s)).split("").map(e => e.charCodeAt(0))))
}
function isPassValid1() {
let input = [
83, 103, 83, 2, 3, 5, 66, 65, 89, 89,
69, 19, 34, 64, 71, 16, 66, 87, 37, 18,
99, 22, 36, 21, 1, 2, 81, 83, 2, 71,
18, 18, 121, 52, 73, 2, 84, 83, 67, 85,
];
let encoded1 = [55,60,48,108,60,110,105,48,51,60,108,60,108,60,51,62,53,60,98,96,62,100,107,62,106,59,51,110,48,62,62,111,57,110,48,96,110,107,51,57];
var resultEncodeInput = _0x4bf1ad(input.map(String.fromCharCode).join(""));
console.log("---")
console.log(JSON.stringify(encoded1.map(e => e.toString(16))))
console.log(JSON.stringify(resultEncodeInput.split("").map(e => e.charCodeAt(0)).map(e => e.toString(16))))
return resultEncodeInput === encoded1
}
function tryBruteForce() {
let encoded1 = [55,60,48,108,60,110,105,48,51,60,108,60,108,60,51,62,53,60,98,96,62,100,107,62,106,59,51,110,48,62,62,111,57,110,48,96,110,107,51,57];
let pass = "________________________________________".split("").map(e => 0);
let index = 0;
let found = 0;
while (index < 40) {
for (let x = 0; x <= 0xFF; x++) {
pass[index] = x
let inputPass = pass.map(e => String.fromCharCode(e)).join("");
let mod = encodeAll(inputPass).split("").map(e => e.charCodeAt(0))
let modified = mod.reduce((acc, arr, i) => mod[i] === encoded1[i] ? acc + 1 : acc, 0)
if (modified > found) {
found = modified
break;
}
}
index++;
}
console.log(pass.map(e => e <= 0x7F && e >= 0x20 ? String.fromCharCode(e) : e))
}
function initRepl( ) {
const repl = require('repl');
repl.start().context.encodeAll = pencodeAll
console.log(getSbox())
}
function bruteForceEncode2() {
let encoded1 = [55,60,48,108,60,110,105,48,51,60,108,60,108,60,51,62,53,60,98,96,62,100,107,62,106,59,51,110,48,62,62,111,57,110,48,96,110,107,51,57];
let encodedInput6 = [100,91,99,110,63,107,43,113,106,101,41,47,78,124,116,46,119,107,71,114,93,114,79,43,107,57,98,61,50,121,44,125,64,90,121,98,58,56,112,108,97,50,39,54,37,100,110,41];
let pass = "________________________________________".split("").map(e => 0x20);
let index = 0;
while (index < 40) {
for (let x = 0x20; x <= 0x7F; x++) {
pass[index] = x
let result = _0x4bf1ad(pass.map(e => String.fromCharCode(e)).join(""));
if (encoded1[index] === result.charCodeAt(index)) break;
}
index++;
}
console.log(JSON.stringify(pass));
console.log(pass.map(e => String.fromCharCode(e)).join(""));
//[51,55,51,98,51,101,98,49,57,57,101,51,98,48,55,48,50,55,101,98,51,102,100,53,97,50,49,99,50,55,50,98,57,100,57,98,100,99,51,53]
//373b3eb199e3b07027eb3fd5a21c272b9d9bdc35
}
console.log(tryBruteForce())
console.log(getSbox())
function bruteForceSbox() {
//_0x53e54e();
let encode2input = [51,55,51,98,51,101,98,49,57,57,101,51,98,48,55,48,50,55,101,98,51,102,100,53,97,50,49,99,50,55,50,98,57,100,57,98,100,99,51,53];
let encoded1 = [55,60,48,108,60,110,105,48,51,60,108,60,108,60,51,62,53,60,98,96,62,100,107,62,106,59,51,110,48,62,62,111,57,110,48,96,110,107,51,57];
let pass = "________________________________________".split("").map(e => 0);
let index = 0;
let found = 0;
while (index < 40) {
for (let x = 0; x <= 0xFF; x++) {
pass[index] = x
let inputPass = pass.map(e => String.fromCharCode(e)).join("");
let mod = encodeAll(inputPass).split("").map(e => e.charCodeAt(0))
let modified = mod.reduce((acc, arr, i) => mod[i] === encoded1[i] ? acc + 1 : acc, 0)
if (modified > found) {
found = modified
break;
}
}
index++;
}
console.log(pass.map(e => e <= 0x7F && e >= 0x20 ? String.fromCharCode(e) : e))
}
/*
[
255, 'f', '3', '9', 255, '9', '5',
'2', '7', 'e', '7', '3', 'a', 'd',
'9', '3', 'b', '7', '3', 'b', '0',
'7', '0', 'b', 'b', '1', '2', 'c',
'd', 'e', '1', '2', '9', '2', 'b',
'b', 'c', 'd', 'e', '5'
]
undefined
[
[ 0, 2 ], [ 21 ], <1 empty item>,
[ 34 ], [ 4, 11 ], [ 9 ],
[ 23 ], [ 30 ], [ 14 ],
[ 5 ], [ 29 ], <1 empty item>,
[ 24 ], [ 22 ], [ 8 ],
[ 20 ], [ 31 ], [ 17 ],
[ 38 ], [ 35 ], [ 15 ],
[ 1 ], [ 13 ], [ 6 ],
[ 12 ], [ 26 ], [ 25 ],
[ 27 ], [ 33 ], [ 10 ],
[ 7 ], [ 16 ], [ 32 ],
[ 28 ], [ 3 ], [ 19 ],
[ 37 ], [ 36 ], [ 18 ],
[ 39 ]
]
3f3939527e73ad93b73b070bb12cde1292bbcde5
*/
console.log([
'3', 'f', '3', '9', '3', '9', '5',
'2', '7', 'e', '7', '3', 'a', 'd',
'9', '3', 'b', '7', '3', 'b', '0',
'7', '0', 'b', 'b', '1', '2', 'c',
'd', 'e', '1', '2', '9', '2', 'b',
'b', 'c', 'd', 'e', '5'
].join(""));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment