Skip to content

e.replace is not a function #590

Closed

Description

@aceimnorstuvwxz

/Users/chenbingfeng/freeprojects/openwebmonitor-real/node_modules/javascript-obfuscator/dist/webpack:/JavaScriptObfuscator/src/code-transformers/preparing-transformers/HashbangOperatorTransformer.ts:39
.replace(/^#!.$(\r?\n)/m, (substring) => {
^
TypeError: e.replace is not a function

Activity

  1. sanex3339 commented on Apr 4, 2020

    @sanex3339
    Member

    Need more info. Show your source code

  2. sanex3339 commented on Apr 10, 2020

    @sanex3339
    Member

    ping

  3. aceimnorstuvwxz commented on Apr 12, 2020

    @aceimnorstuvwxz
    Author

    `
    // obfuscate js code
    const JavaScriptObfuscator = require('javascript-obfuscator');
    const fs = require('fs')
    const path = require('path')

    const what_to_obfuscate = [
    'super-source', 'super-module', 'main', 'recording', 'index', 'constants', 'browser', 'utils', 'vip_renew', 'winmgr',
    'libopenlog'
    ]

    what_to_obfuscate.forEach(fn=>{
    let full_path = path.join(__dirname, ${fn}.js)
    console.log(full_path)
    let raw_data = fs.readFileSync(full_path)

    let obfuscationResult = JavaScriptObfuscator.obfuscate(
        raw_data,
        {
            compact: false,
            controlFlowFlattening: true
        }
    );
    
    fs.writeFileSync(full_path, obfuscationResult.getObfuscatedCode())
    

    })
    `

  4. aceimnorstuvwxz commented on Apr 12, 2020

    @aceimnorstuvwxz
    Author

    Read a js file, and obs them, then write back.

  5. aceimnorstuvwxz commented on Apr 12, 2020

    @aceimnorstuvwxz
    Author

    Above error happens when using the lastest version. when changed to old version "javascript-obfuscator": "~0.19.4" it disappears.

  6. sanex3339 commented on Apr 12, 2020

    @sanex3339
    Member

    Are you sure that raw_data for each file is string and not undefined?

  7. aceimnorstuvwxz commented on Apr 12, 2020

    @aceimnorstuvwxz
    Author

    yes, if file not exist, exception will happen when read. Im sure, that all raw_data are a string,

  8. aceimnorstuvwxz commented on Apr 12, 2020

    @aceimnorstuvwxz
    Author

    For be sure, I will check it doubel later

  9. sanex3339 commented on Apr 12, 2020

    @sanex3339
    Member

    Check it please. Because this error can happen if source code is not a string.

    From my side i should add exception from the obfuscator side if input source code is not a string

  10. sanex3339 commented on Apr 12, 2020

    @sanex3339
    Member

    So, i got this error, when i passed number as source code.

    JavaScriptObfuscator.obfuscate(1).getObfuscatedCode();
    
  11. added a commit that references this issue on Apr 12, 2020
  12. sanex3339 commented on Apr 13, 2020

    @sanex3339
    Member

    Released as 0.27.4
    Now if source code is not a string, it will be normalized to an empty string.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions