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

Obfuscating client/server esbuild code #1227

Open
brokenstaterp opened this issue Jan 6, 2024 · 2 comments
Open

Obfuscating client/server esbuild code #1227

brokenstaterp opened this issue Jan 6, 2024 · 2 comments

Comments

@brokenstaterp
Copy link

So I am trying to obfuscate both my client and server side code for my fivem scripts that are made in ts and compiled to js using esbuild. The client-side builds fine, but when it tries to build the server-side I end up getting an error. Read below.

Current Behavior

Explained already above.

Your Environment

  • Obfuscator version used: Latest
  • Node version used: Latest Stable

Stack trace

C:\GTAServerFX\resources\[main]\prp-showroom\project\node_modules\javascript-obfuscator\dist\webpack:\javascript-obfuscator\src\utils\CryptUtils.ts:31
        string = encodeURIComponent(string).replace(/%([0-9A-F]{2})/g, (match, p1) => {
                 ^
URIError: URI malformed
    at encodeURIComponent (<anonymous>)
    at f.btoa (C:\GTAServerFX\resources\[main]\prp-showroom\project\node_modules\javascript-obfuscator\dist\webpack:\javascript-obfuscator\src\utils\CryptUtils.ts:31:18)
    at o.getEncodedValue (C:\GTAServerFX\resources\[main]\prp-showroom\project\node_modules\javascript-obfuscator\dist\webpack:\javascript-obfuscator\src\storages\string-array-transformers\StringArrayStorage.ts:125:69)
    at o.getOrSetIfDoesNotExist (C:\GTAServerFX\resources\[main]\prp-showroom\project\node_modules\javascript-obfuscator\dist\webpack:\javascript-obfuscator\src\storages\string-array-transformers\StringArrayStorage.ts:97:60)      
    at o.get (C:\GTAServerFX\resources\[main]\prp-showroom\project\node_modules\javascript-obfuscator\dist\webpack:\javascript-obfuscator\src\storages\string-array-transformers\StringArrayStorage.ts:51:21)
    at o.apply (C:\GTAServerFX\resources\[main]\prp-showroom\project\node_modules\javascript-obfuscator\dist\webpack:\javascript-obfuscator\src\storages\MapStorage.ts:35:28)
    at o.getOrThrow (C:\GTAServerFX\resources\[main]\prp-showroom\project\node_modules\javascript-obfuscator\dist\webpack:\javascript-obfuscator\src\decorators\Initializable.ts:61:39)
    at o.analyzeLiteralNode (C:\GTAServerFX\resources\[main]\prp-showroom\project\node_modules\javascript-obfuscator\dist\webpack:\javascript-obfuscator\src\analyzers\string-array-storage-analyzer\StringArrayStorageAnalyzer.ts:84:78)
    at Controller.enter (C:\GTAServerFX\resources\[main]\prp-showroom\project\node_modules\javascript-obfuscator\dist\webpack:\javascript-obfuscator\src\analyzers\string-array-storage-analyzer\StringArrayStorageAnalyzer.ts:67:22) 
    at Controller.__execute (C:\GTAServerFX\resources\[main]\prp-showroom\project\node_modules\estraverse\estraverse.js:332:31)

Minimal working example that will help to reproduce issue

I don't know what's causing the error in the first place.

@sanex3339
Copy link
Member

You don't need obfuscation for server code

@brokenstaterp
Copy link
Author

You don't need obfuscation for server code

I am selling my scripts, obfuscated and non versions. So they will have access to server-side.

Anyways I fixed it by modifying javascript-obfuscator's code:

CryptUtils.ts

        try {
            string = encodeURIComponent(string).replace(/%([0-9A-F]{2})/g, (match: string, p1: string) => {
                return String.fromCharCode(parseInt(`${Utils.hexadecimalPrefix}${p1}`, 16));
            });
        } catch (e) {
            output = string;
            return output;
        }

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

No branches or pull requests

2 participants