relative / synchrony

javascript-obfuscator cleaner & deobfuscator
https://deobfuscate.relative.im/
GNU General Public License v3.0
849 stars 109 forks source link

Error: Push/shift calculation failed in StringDecoder when Simplify is disabled #21

Closed Alluseri closed 2 years ago

Alluseri commented 2 years ago

Hello. I was testing Synchrony around and I have found a minor glitch. Check this code:

(function(_0x286d49,_0x5162f9){var _0x236946=_0x286d49();while(!![]){try{var _0x43816c=-parseInt(_0x1cfb(0x0))/0x1*(-parseInt(_0x1cfb(0x1))/0x2)+parseInt(_0x1cfb(0x2))/0x3*(parseInt(_0x1cfb(0x3))/0x4)+parseInt(_0x1cfb(0x4))/0x5+parseInt(_0x1cfb(0x5))/0x6*(parseInt(_0x1cfb(0x6))/0x7)+parseInt(_0x1cfb(0x7))/0x8*(-parseInt(_0x1cfb(0x8))/0x9)+-parseInt(_0x1cfb(0x9))/0xa*(-parseInt(_0x1cfb(0xa))/0xb)+-parseInt(_0x1cfb(0xb))/0xc;if(_0x43816c===_0x5162f9){break;}else{_0x236946['push'](_0x236946['shift']());}}catch(_0xe83cd0){_0x236946['push'](_0x236946['shift']());}}}(_0x39b7,0x964fb));function _0x1cfb(_0x566bd5,_0x39b78f){var _0x1cfb8f=_0x39b7();_0x1cfb=function(_0x11715f,_0x38f407){_0x11715f=_0x11715f-0x0;var _0x1fd3b5=_0x1cfb8f[_0x11715f];if(_0x1cfb['TbWGGe']===undefined){var _0x491a23=function(_0x37dc97){var _0x4bfcd1='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';var _0x3c3d1a='';var _0x499065='';for(var _0xe233df=0x0,_0x3daea1,_0x593213,_0x17e261=0x0;_0x593213=_0x37dc97['charAt'](_0x17e261++);~_0x593213&&(_0x3daea1=_0xe233df%0x4?_0x3daea1*0x40+_0x593213:_0x593213,_0xe233df++%0x4)?_0x3c3d1a+=String['fromCharCode'](0xff&_0x3daea1>>(-0x2*_0xe233df&0x6)):0x0){_0x593213=_0x4bfcd1['indexOf'](_0x593213);}for(var _0x52ab56=0x0,_0x4be75e=_0x3c3d1a['length'];_0x52ab56<_0x4be75e;_0x52ab56++){_0x499065+='%'+('00'+_0x3c3d1a['charCodeAt'](_0x52ab56)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x499065);};_0x1cfb['VDraLp']=_0x491a23;_0x566bd5=arguments;_0x1cfb['TbWGGe']=!![];}var _0x316b46=_0x1cfb8f[0x0];var _0x159db5=_0x11715f+_0x316b46;var _0x36a59e=_0x566bd5[_0x159db5];if(!_0x36a59e){_0x1fd3b5=_0x1cfb['VDraLp'](_0x1fd3b5);_0x566bd5[_0x159db5]=_0x1fd3b5;}else{_0x1fd3b5=_0x36a59e;}return _0x1fd3b5;};return _0x1cfb(_0x566bd5,_0x39b78f);}console[_0x1cfb(0xc)](_0x1cfb(0xd));function _0x39b7(){var _0x1eb70b=['u2fTCgXLignVzguU','mtiWs1nnve5A','mZuXoeLwBNnuDa','mJC1mwXxC3DUAG','mZe4ohPdrurhsq','mtyYmdyWmhrPs3v5za','nND1DKfvBq','ndy3nZGXm1HlChLZCa','mtG1odrUyMPoy2G','mZm1n2LuuvPXtG','mtu3mtmWAMDuyw15','mJuZCgnJAMT1','otC2mJyZnKX2shH0zG','Bg9N'];_0x39b7=function(){return _0x1eb70b;};return _0x39b7();}

It's breaking on the StringDecoder transformer: Error: Push/shift calculation failed (iter=29>maxLoops=28) I caused it by disabling "Simplify" in the obfuscator.io panel, no manual changes were done to the code. Obfuscator.io setup: String Array, String Array Rotate, Compact, String Array Indexes Type = Hexadecimal Number, String Array Encoding = Base64.

relative commented 2 years ago

deobfuscated to this on latest commit

console.log('Sample code.')

Can you try deobfuscating using the latest commit on master by doing the following

npm remove --global deobfuscator # or your preferred package manager
git clone https://github.com/relative/synchrony.git synchrony-git && cd synchrony-git
npm i
npm run build
npm link # or yarn link, pnpm link --global

synchrony -v
synchrony -o script.cleaned.js script.js
cat script.cleaned.js

and attach output if it deobfuscation output is invalid or there is an error

Alluseri commented 2 years ago

Ah yes, that must be the issue. I used the website(@ synchrony.relative.im) for deobfuscation, and it's probably not been updated to the last commit. I should have specified that in the issue, but that's fine. I guess the only thing you can do here is update the website to the last synchrony version, issue closed.