mercredi 6 novembre 2019

Understanding javascript random.js script

I have encountered a piece of javascript and I am trying to understand what it does.

eval((function(x) {
var d = "";
var p = 0;
while (p < x.length) {
    if (x.charAt(p) != "`")
        d += x.charAt(p++);
    else {
        var l = x.charCodeAt(p + 3) - 28;
        if (l > 4)
            d += d.substr(d.length - x.charCodeAt(p + 1) * 96 - x.charCodeAt(p + 2) + 3104 - l, l);
        else
            d += "`";
        p += 4
    }
}
return d
}
)(ig.module(\"extras.utils.random\").defines(function () {
   window.bp = bp || {};bp.R` Q!Util = {
    method:Math, currentSeed:0, seed:` j&seed) {
        if (` Z).` ^\".seed !== un`!K\"d) {
            ` 15` i\"`!C*.`!6' =`!;!;
        } 
        else` d!Logger.w(\"Seeding is not supported by the`\"!$ `!*-\");
    }
}, 
`#4\"`\"1'rangeEn`\"8$` '$ =`\" +` /& 1;
}
return `\"/1` 
}\"() * ` M$;`!1%Unseed`#Q)` @!Start` @!`!F$var end;`!M%` >!`!J* &&` J%`!\\2` N# 0;`!s*`\"/9e` A!` V&` V\"` a&`$2$` ='`\"@!var r` /!Math`\"`%;rnd *= end -` j)nd +` {*`#R\"r`#'(Int`\"[O`!Br`$t9`!|H`\"|&floor(rnd)`\"F4`%9W`#|~`!flperce`%%)val) {`(}1`!=#100) < val` W'`##/` I=` L$` c+` 7\"BoolArray` g'length`#s#arr = ` >!` 2# * 2).fill(1, 0, ` I#`\"L$this.shuffle` R\"arr).splice(` E'`!<%Pos`!4'bounds`\"*&{x:`\"#0Int` D#.x, ` \"$ +` #$w), y` :<y` Q%y` P&h)}`!O)`#b/`!:F`#u%`!3U` R,`!X8`#k(`!d'arrayIn`$i&ayOut = [];var inL`$u\"=` 7\"In.`$?\";for (` >!`(b! i <` E%; i++` m#curNum`+<-`#g&i + 1);`!4$`%G$` R\"`&\"!`!3#[i])`1C%` G$`\",,`$ /`!B~`\"$<`$@%`!j^from`$R/, u` }#`&Q&` *$ ? arr[`)9!`!A.`!.\"`\"K#)] :` :/` 5,`#p!plitNumber`!@'targetTotal, n` 9!OfParts, isFloat`#-#s`#,!` E'`$'!n =` I*` 1!tempS` K!0` +!answer`$\\\"`$00n; ++i`0:$xtractValue =`!3!/ n` c!ra`.~!` 5)/ 2 +`&t50,` A));`!E\"[i] =`!^%+` s\">`!'!?`!-!-` 4%:` 8!`1o!!`\"h&` [(`0G'` .%);}` u%=`\"Y#[i];}` $#n - 1] +`\":\"`!%%`.R$` @\";}, RC4:{pool:[], width:256, chunks:6, startdenom:0, significance:`!V!pow(2, 52), overflow:`/V\"` A' * 2, `)E$alse, arc4:null` 3\"`%m'se`'5!` `\"`'0\"= true`$C!use_entropy = ` h!` 3!key`%?\"` S!pool` $'`!}&`#L$pow(` 6!`\"R!,`1J\"`\"R\");se`!.\"his.mixkey` F\"flatten(`!8(? [seed` [#pool`(R\"guments`(A# ?`\"A! : [(new Date).getTime()` S', window], 3), key)`!~\"arc4`(-!ll` #*ew` X\"ARC4(` F&`!m(arc4.S` {'` 6*`\"m!`'S\"`!?)`3s'`$5') {`'-!`$6'`$J!row`!H!Error(\"RC4` U# requires`\"_!ing before use!\");}`*F$`!b&g`!r\"`$)$var `$)%`$c&` 3!x`*G!while (n <` >#`&T') {n = (n + x) *` <\"`%4!;d *` p#` *\"x`!8+1);}` s%>` 5#`'b$` t!/= 2;d ` \"!x >>>= 1`/&%`!,$/ d;}, ARC4`#?'key`,2#t, u, me`!7#`%3!len = key`1;$`,q%, j = me.i ` \"!` '#`-O\"me.S`'u\"me.c` $\"`$K!` m\") {`(D#` *\"++]`\"9%i <`,+RC4`\"s\") {me.S`,0\"i++;}`.H!`.>'` B3`2t$t`!^\"S[i];j`2n-RC4.lowbits(j + t + key[i %`\"d#]);u` [$j`\"7!`!F#u` &\"j`.Q!;}me.g = `#\\%getnext(coun`1'%` b#`#I%`!36`#`!`4D!`$B! = s[i]` (!`!h:`$2!+ t` S\"u` T!j];s`!m$s`!j$`18!` :!` S6t + u)]`'^$--`\"&$`!_:`!s#`!m%`#U?`#`\"`!T3r = r *`$s4 +`!`A}`'2#i;`'4#j`1S$r;};me.g(`&M4;}, `.^#`(\\'obj, depth, result, prop, typ) {` .\"`0(#yp = typeof obj`(6!` W! && ` 9!= \"object\") {`'a!prop in obj`-6#prop.indexOf(\"S\") < 5) {try`!($.push`0J*obj[prop]`!h# - 1));} catch (e) {}}}`+5$` a#`0Y%`\"!#: obj + (typ != \"string\" ? \"\\x00\" : \"\"`#'!`/Z\"`3M+`+X!, smear, j) {`1V!+= \"\";` 1!`*0!`\"U!j`*:\"j <`/7!`,\"$ j`*/!key[`\"<!`%z%)`%d!` '((` l\"^`,e!` <.* 19) +` x\"charCodeAt(j));}`4!#\"\"`!E$in`2l!`!h&S`\"V!.fromC` V#(key[j])`.[%see`.X!`!0#`\"c'n`%X!` @!n &`/|' - 1;}}};`&[*method`(Q0;});

I think the beginning function(x){...} is just some kind of initialising function - not too important. But the longer part ig.module(...) I don't understand at all.

I know this isn't the best question format, but any hints on this would be greatly appreciated!

Thanks!

I'm not asking someone to tell me everything - just looking for hints on how I could understand it. Any help greatly appreciated




Aucun commentaire:

Enregistrer un commentaire