relative / synchrony

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

fix: cannot find decoder, proxy functions because of some empty statements #135

Closed khanhnb closed 8 months ago

khanhnb commented 8 months ago

This PR fixes the following errors when decoder functions contain empty statements: err = TypeError: Failed to decode h, no decoder err = Error: Push/shift calculation failed (iter=25>maxLoops=24)

Input to reproduce the error:

;(function (c, d) {
  var h = b,
    e = c()
  while (!![]) {
    try {
      var f =
        (-parseInt(h(0x7a)) / 0x1) * (-parseInt(h(0x78)) / 0x2) +
        (-parseInt(h(0x7e)) / 0x3) * (parseInt(h(0x77)) / 0x4) +
        -parseInt(h(0x7b)) / 0x5 +
        (-parseInt(h(0x7c)) / 0x6) * (-parseInt(h(0x75)) / 0x7) +
        (parseInt(h(0x76)) / 0x8) * (-parseInt(h(0x79)) / 0x9) +
        -parseInt(h(0x80)) / 0xa +
        parseInt(h(0x7f)) / 0xb
      if (f === d) break
      else e["push"](e["shift"]())
    } catch (g) {
      e["push"](e["shift"]())
    }
  }
})(a, 0xa005c)
function hi() {
  var i = b
  console["log"](i(0x7d))
}
hi()
// decoder function
function b(c, d) {
  ;
  ;
  var e = a()
// proxy function
  return (
    (b = function (f, g) {
      f = f - 0x75
      var h = e[f]
      return h
    }),
    b(c, d)
  )
}
function a() {
  ;
  ;
  var j = [
    "1263720pTqteZ",
    "4UVwcYM",
    "18RZHtoU",
    "45NcPTGE",
    "21026baFKTG",
    "5959055zOefdK",
    "76746cPNlrK",
    "Hello\x20World!",
    "3670650mEfMWw",
    "49556463VXYOgg",
    "11662950XTqwOX",
    "182LySSXZ"
  ]
  a = function () {
    return j
  }
  return a()
}
relative commented 8 months ago

thank you for your pr!