4 ms·
You want to see obfusication? Check out FreeSlots.com. Look at view source on one of the slot machines.[1] Can anyone decode this and figure out the odds gener
by Animats 4y ago
You want to see obfusication? Check out FreeSlots.com. Look at view source on one of the slot machines.[1] Can anyone decode this and figure out the odds generator?
[1] view-source:https://www.freeslots.com/slot515.min.js?v=84 https://www.freeslots.com/slot515.min.js?v=84
- melissalobos 4y agoTo answer your question, yes. Someone absolutely can decode that and figure out the odds. If they couldn't then there would be less obfuscation used. A browser ABSOLUTELY has to be able to run the javascript. Anyone dedicated enough can de-compile that javascript to a program. Is it easy? No, but people do it all the time. I have had to deal with client that thought they could keep some bit of code secret on a browser before. I have had to explain many many times that anything the browser can do a human can do. So if a browser can run the code, at some point a human can too.
- throwntoday 4y agoI think what the parent meant was, can someone looking at it decode what is going on. Not asking whether it is possible in general.
- michaelsbradley 4y agoThat's why they wrote "Anyone dedicated enough can de-compile that javascript..." Meaning, effectively, it can be de-obfuscated into code with control flow that's readily understood by a human, even if it would take some patience and practice (and the right tools) to perform the de-obfuscation. Re: the FreeSlots.com program, https://deobfuscate.io https://deobfuscate.io shows that most of the obfuscation is related to decoding characters per some algorithm of their devising and eventually eval'ing the string as a JS program. There are likely several tricky rounds of that technique (and others) used at layers within the obfuscated code. If the FreeSlots devs are clever, then they likely have a scheme to randomly generate the code they want (producing their desired result in terms of odds), where the random part is w.r.t. how the obfuscation layers are composed. Done well, that could make it rather difficult to mechanically de-obfuscate their code changing over time, i.e. without a human intervening to help identify the distinct layers because... parsers are hard.
- zamadatix 4y agoAs the other commenter said I think everyone understands it is feasible for someone here to accomplish de-obfuscating the code but the actual question was "Can anyone decode this and figure out the odds generator?". As in "can anyone take out the trash" like actually take the time to do the work of taking out the trash. Not as in explain that it is in fact possible for a dedicated person to tie up a bag, lift it out of the bin, take it outside, and put it in a dumpster. One of those quirks of speech. I gave it a quick shot with some spare time, was selfishly hoping someone else had done the work when I checked back :p.
- michaelsbradley 4y agoIf the economic incentive (or some other abstruse incentive) is great enough for a someone, then that someone will do it, if it's strictly possible and within the scope of their resources, i.e. because they stand to gain / be fulfilled / for the fun of it / experience fame and glory / etc.
- zamadatix 4y agoPerhaps the original ask is better explained as: a request for someone here do the actual deobfuscation.
- michaelsbradley 4y agoNice way to put it. :-) I don't feel so incentivized at present, sorry if I'm letting you down.
- gernb 4y agonothing special about code in a browser. there are regular reports from bug finders where they detail how they disassembled iOS or some native app etc and worked out how some exploit worked
- lovingCranberry 4y agoThe Hexrays decompilation plugin for ARM architecture works very fine and produces more readable code than this js :D
- lelandfe 4y agoI love all the deeply obfuscated junk and weird bitwise stuff... and then `fix_ios6`
- atwood22 4y agoWhy is the odds generator run on the client?
- zamadatix 4y agoAs long as the generator is seeded by the server and deterministic the only thing running the generator on the server for every spin would do is cost more money. In the rare situation a claim is made the server can run the spins in bulk with the same data it gave the client, if the results are different or the number of spins suspicious the claim is thrown out. If the client doesn't win anything (i.e. almost every client) the server doesn't need to do anything except serve the initial page.
- atwood22 4y agoIf the odds generator was only seeded by the server, but run on the client, you could test the next run locally before deciding to place a bet. How would that make sense?
- zamadatix 4y agoTo clarify the claim a client makes on this site is that you have been around to make enough tokens to enter your info for the $500 monthly sweepstakes. Your slot results don't actually net you direct money or even improve your chances beyond being able to enter after a relatively low bar. Any server side validation would be to check you are a person who has been seeing ads and giving a real sellable email away instead of a bot trying to game the sweepstakes and, more importantly, lowering the resale value of the email list. Doing live server side hosting of every game spin would probably cost them more than they make, I'd be surprised if they even did the full level of server side validations available.
- zamadatix 4y agoI gave it a 10 minute poke just for fun. My main enemy for the first few minutes was the browser trying to tell me I can't do things like eval/etc. Once I got that out of the way with some policy the next issue was the console not really being used to non-printable characters catching me up. In the end those two tricks (both I'm sure being a pain on purpose not by accident) netted me not getting very far as expected, I was only a couple iterations into the first method of obfuscation. I'm not sure how many levels it was applied but my general strategy on it was the first obfuscation method seemed to be an IIFE that triggers eval on a big string that has had some transformations applied which then calls eval on the next level and so on so I would take the IIFE, turn it into a function definition stuck in a variable like "decodeFunction1" so I could just recursively call directly and change the ending to return the string instead of eval it directly. There is probably something that could be done with debugger breakpoints here but I don't know enough about how that plays out inside eval. Anyways if I were evil I'd make sure at some point in this chain there is a subtle change in what's happening that breaks this approach so I wouldn't be surprised if someone told me that was the case :). It'd be interesting to see what some real JS devs could get to, both from a "how hard is it" perspective but also just to see what different obfuscations are used in the real world.
- kekebo 4y agoJSNice[0] often does a good job deobfuscating js, the statistical renaming isn't foolproof but often useful. With it I get https://ghostbin.me/62d52999cc217 https://ghostbin.me/62d52999cc217 , from there it's decoding UTF-16 and at least one more decoding step (parts of decoded UTF-16 are mangled) to get the string j and the function o and resolving the original function with it. [0] http://jsnice.org/ http://jsnice.org/
- vitus 4y agoEven easier: open up Chrome DevTools, add a breakpoint at the eval, step into function. Repeat a couple of times. Comment at the top also points to https://freeslots.com/libs/mersenne-twister.js https://freeslots.com/libs/mersenne-twister.js Using those two together to decode the RNG function, and searching around for some more local pointers (with some judicious renaming of functions for legibility, and some comments): // polyfill for IE?? function trunc(a) { return a < 0 ? Math.ceil(a) : Math.floor(a) } var genrand_res53 = function() { var a = new MersenneTwister((new Date).getTime() + Math.floor(Math.random() * Math.pow(2, 32))); return function() { // Generate a random float by varying the 53-bit mantissa. var b = genrand_int32(a) >>> 5, c = genrand_int32(a) >>> 6; // (b << 26 | c) / 2 ** 53 return (b * 67108864 + c) * 1.1102230246251565E-16 } }(); function rand_int(a, b) { var c = genrand_res53(); if (a === undefined) return c; if (b === undefined) return trunc(c * a); if (b > a) return a + trunc(c * (b - a)); return a; } function Kma() { // credits is `Lma`; if you want to cheat, you can edit that variable directly credits < 500 && (Ika = Ika - Ika % 1E6 + rand_int(890001) + 1E5) } So, we're generating a random integer from 0 to 890,000 (inclusive, with negligible chance of generating 890001) with each spin, and using that to update the state (seeded with current time; the top 1e6 of the value is determined via mixing of Date.now() and Math.random() and is fixed for a given session). There's then more to determine whether your state is a winner (based on the game mode), but I didn't feel like looking into that specifically.
- aardshark 4y agoThe code goes through a few eval steps first. Here is what is finally evaled -- you can replace the whole file with this for the same result: https://paste.ee/p/VTgj8 https://paste.ee/p/VTgj8 Figuring out the odds generator...is a task I will leave to someone else :)