Skip to content

Domain lock not working? #117

Closed
Closed

Description

@av01d

First of all: great tool, thanks for releasing it!
I'd like to use the domain-locking feature, but can't (yet) get it to work.
I have a single (rather large) JS file, and I obfuscate it like so:

javascript-obfuscator/bin/javascript-obfuscator.js 'js/game.js' --output 'js/game.js' --compact true --selfDefending true --domainLock 'domaina.com,domainb.com'

Now, when I run the resulting JS file on domainc.com, it just works. I would expect the obfuscated JS file to generate an error or halt execution some other way.
Am I missing something? Do I need to enable another cli-option to make domain locking work?

FYI: running on node v8.9.0


I just made another boiled down test. My test.js file contains 1 line of code:
alert(123);
Now I run:
/usr/local/scripts/node_modules/javascript-obfuscator/bin/javascript-obfuscator.js test.js --domainLock 'google.com'
The resulting test-obfuscated.js file contains this:
alert(0x7b);
There is no extra code to check whether the code runs on a valid domain.
If I paste this example code (alert(123);) on https://javascriptobfuscator.herokuapp.com/ and enter the 'google.com' domain to lock to (uncheck all other options), the resulting code is much longer, as I'd expect it to be.

Either the cli-script doesn't handle lock domains well, or I need to call the cli-script with more arguments. Hope someone can tell me. Thanks!

Activity

  1. sanex3339 commented on Nov 3, 2017

    @sanex3339
    Member

    What version of javascript-obfuscator you using?

  2. av01d commented on Nov 3, 2017

    @av01d
    Author

    0.12.0

  3. added this to the 0.12.1 milestone on Nov 3, 2017
  4. sanex3339 commented on Nov 3, 2017

    @sanex3339
    Member

    Looks like commander issue, but i can easy fix it on my side. commander incorrectly parsed options with description like --reservedNames \'<list>\' (comma separated).

    If i will change it to <list>- everything is OK.

  5. sanex3339 commented on Nov 3, 2017

    @sanex3339
    Member
  6. sanex3339 commented on Nov 3, 2017

    @sanex3339
    Member

    Hi again! Check new [email protected] with fix.

  7. av01d commented on Nov 4, 2017

    @av01d
    Author

    Thanks for the quick fix, works great now!

  8. peeter2 commented on Dec 5, 2018

    @peeter2

    Hello,

    The domain lock works fine when visiting my webpage online, but it doesn't work when I download webpage to computer. So, how do I prevent the javascript from functioning on local machine?

  9. ionbara commented on Jun 14, 2022

    @ionbara

    similarly to above answer, the expected behaviour would be to not allow running from the filesystem

  10. jendretz commented on Apr 12, 2023

    @jendretz

    Hello,
    I have the same issue with the online version of 4.0.0. The domain lock works when I run my script in jsbins, but I can copy the page source and run it from an html file. Can this be fixed?

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions