Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

control flow switch deobfuscation not triggering without string array #158

Open
Le0Developer opened this issue Mar 8, 2025 · 5 comments · May be fixed by #160
Open

control flow switch deobfuscation not triggering without string array #158

Le0Developer opened this issue Mar 8, 2025 · 5 comments · May be fixed by #160
Labels
bug Something isn't working deobfuscate

Comments

@Le0Developer
Copy link
Contributor

Le0Developer commented Mar 8, 2025

Describe the bug

I am currently trying to make a PR for this. If I don't make one within 3 days, assume I gave up. 😆

Expected Behaviour

The control flow should be resolved. The dispatcher functions are a separate issue.

Code

function gl(jd, c, f, g, h, i, j) {
  var d = "13|10|2|9|16|8|3|11|19|20|7|5|4|6|12|1|17|18|15|0|14".split("|");
  var e = 0;
  while (true) {
    switch (d[e++]) {
      case "0":
        c.egybk(fT).appendChild(gk);
        continue;
      case "1":
        h.innerHTML = i;
        continue;
      case "2":
        gk.height = c.mXvlg;
        continue;
      case "3":
        f = eN.createElement(c.vssHG);
        continue;
      case "4":
        g.className = c.PBaOx;
        continue;
      case "5":
        g = eN.createElement("span");
        continue;
      case "6":
        f.appendChild(g);
        continue;
      case "7":
        f.appendChild(j);
        continue;
      case "8":
        gk.setAttribute("role", "alert");
        continue;
      case "9":
        gk.style.display = c.Nrwph;
        continue;
      case "10":
        gk = eN.createElement("div");
        continue;
      case "11":
        f.className = c.hzxlw;
        continue;
      case "12":
        h = eN.createElement(c.OmBmS);
        continue;
      case "13":
        i = c.xRAoj(fG, c.bxfCq);
        continue;
      case "14":
        return j;
      case "15":
        gk.appendChild(f);
        continue;
      case "16":
        gk.className = "cb-c";
        continue;
      case "17":
        h.className = "cb-lb-t";
        continue;
      case "18":
        f.appendChild(h);
        continue;
      case "19":
        j = eN.createElement("input");
        continue;
      case "20":
        j.type = "checkbox";
        continue;
    }
    break;
  }
}

Logs


@Le0Developer Le0Developer added the bug Something isn't working label Mar 8, 2025
@j4k0xb
Copy link
Owner

j4k0xb commented Mar 8, 2025

(nvm ignore my comment, didn't read the code properly)

@Le0Developer
Copy link
Contributor Author

My initial assumption also was that it's due to the AssignmentExpressions instead of the VariableDeclarations but even after modifying the script to use var it's still failing.
Simplified the initial example, will tackle that in a different issue in the future.

@Le0Developer
Copy link
Contributor Author

Nvm, looks like only the web version is failing. Works locally

@j4k0xb
Copy link
Owner

j4k0xb commented Mar 8, 2025

Ok found the root cause: for optimization webcrack only runs most other deobfuscations if a string array exists:

if (!stringArray) return;

state.changes += applyTransforms(
ast,
[mergeStrings, deadCode, controlFlowObject, controlFlowSwitch],
{ noScope: true },
).changes;

If you paste a dummy one in the script it works:

function _0xa94b() { var _0x5a635b = [""]; _0xa94b = function () { return _0x5a635b; }; return _0xa94b(); }

Image

@Le0Developer
Copy link
Contributor Author

That's… funny.

@Le0Developer Le0Developer changed the title control flow switch deobfuscation not triggering control flow switch deobfuscation not triggering without string array Mar 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working deobfuscate
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants