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

infinite loop? wakaru unminify runs forever #110

Open
milahu opened this issue Feb 13, 2024 · 2 comments
Open

infinite loop? wakaru unminify runs forever #110

milahu opened this issue Feb 13, 2024 · 2 comments

Comments

@milahu
Copy link

milahu commented Feb 13, 2024

Describe the bug

im trying to decompile a 3MB file

wget https://boxy-svg.com/elements/apps/bx-progressivewebapp.js
node packages/cli/dist/cli.cjs unminify bx-progressivewebapp.js

the process is using a maximum of 2GB RAM

there are 13 processes running node packages/cli/dist/cli.cjs
1 process is busy at 100% cpu
12 processes are idle at 0% cpu

wakaru runs at least 60 minutes, probably forever...

i guess that wakaru is running into some anti-debugger trap
which is causing an infinite loop, aka deadloop

Input code

No response

Reproduction

No response

Steps to reproduce

No response

Expected behavior

dont run forever

Actual behavior

No response

@pionxzh
Copy link
Owner

pionxzh commented Feb 13, 2024

This script is obfuscated. I just tried decoding it with https://github.com/j4k0xb/webcrack, and it seems to work.

Wakaru does not provide "deobfuscate" features; you can still use other tools to deobfuscate the source and use Wakaru to further improve the readability.

But I will check the performance issue and possible infinite loop. Thanks for the input. 🙏

For the process thing you mentioned, the cli can only process one file on one core; it's being used for unminifying multiple files.

@pionxzh
Copy link
Owner

pionxzh commented Feb 13, 2024

I just tried wakaru unminify with the decode code. Total time: 7m5s

Here is the stats:

┌─────────┬──────────────────────────┬────────┐
│ (index) │           key            │  time  │
├─────────┼──────────────────────────┼────────┤
│    0    │  'un-variable-merging'   │  678   │
│    1    │ 'un-assignment-merging'  │  719   │
│    2    │       'un-return'        │  793   │
│    3    │     'un-use-strict'      │  795   │
│    4    │       'un-boolean'       │  798   │
│    5    │      'un-undefined'      │  804   │
│    6    │     'un-while-loop'      │  808   │
│    7    │  'un-flip-comparisons'   │  811   │
│    8    │   'un-numeric-literal'   │  854   │
│    9    │  'un-template-literal'   │  893   │
│   10    │  'un-bracket-notation'   │  903   │
│   11    │     'module-mapping'     │  987   │
│   12    │       'un-typeof'        │  1604  │
│   13    │    'un-esmodule-flag'    │  1636  │
│   14    │      'un-infinity'       │  1677  │
│   15    │     'un-async-await'     │  1704  │
│   16    │        'un-iife'         │  1802  │
│   17    │      'smart-inline'      │  2205  │
│   18    │  'un-type-constructor'   │  2346  │
│   19    │        'un-enum'         │  2467  │
│   20    │    'un-conditionals'     │  2475  │
│   21    │    'un-export-rename'    │  2870  │
│   22    │         'un-jsx'         │  2999  │
│   23    │      'un-es6-class'      │  3237  │
│   24    │     'un-parameters'      │  4867  │
│   25    │  'un-builtin-prototype'  │  4905  │
│   26    │    'un-curly-braces'     │  5375  │
│   27    │  'un-optional-chaining'  │  7927  │
│   28    │ 'un-nullish-coalescing'  │  8042  │
│   29    │   'jscodeshift-print'    │  8323  │
│   30    │       'prettier-1'       │  9484  │
│   31    │        'prettier'        │  9545  │
│   32    │   'un-runtime-helper'    │ 20947  │
│   33    │    'un-indirect-call'    │ 22357  │
│   34    │ 'un-sequence-expression' │ 26938  │
│   35    │         'un-esm'         │ 28806  │
│   36    │      'smart-rename'      │ 34022  │
│   37    │         'lebab'          │ 39441  │
│   38    │  'un-parameters-lebab'   │ 56095  │
│   39    │   'jscodeshift-parse'    │ 100665 │
└─────────┴──────────────────────────┴────────┘

The AST parsing is super expensive, I will try to do some perf and see how to reduce the cost.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants