-2

一般的な Web ブラウザー (IE9、Firefox、Chrome、Safari、Opera など) でのみ動作するようにしたい JavaScript を使用してシステムを開発しています。

まず、 Closure ライブラリ+ Closure コンパイラオプションを使用してコードを圧縮すると、ADVANCED_OPTIMIZATION少しわかりにくいコードが生成されます。残念ながら、このようなツールを使用すると、コードを美しい (そして読みやすい) ものに簡単に変換できます。

次に、読みやすいが理解しにくいアルゴリズムを選択しました。たとえば、Reed-Solomon コードをデコードするスクリプトは、そのようなアルゴリズムを開発したことがない人にとっては理解しにくいかもしれません。もちろん、この解決策は完璧ではありません。なぜなら、コードが圧縮されていてコメントがなくても、Reed-Solomon コードに深い知識を持っている人は、内部に何が書かれているかを理解できるからです。

しかし、主な問題は、 Rhino + env.jsPhantomJSなどの非 Web ブラウザー javaScript 環境にコピーして貼り付けるだけで、私の複雑なコードが簡単に実行される可能性があることです。

Web ブラウザ以外の環境が存在する場合、コードで無視するための使用可能なテクニックを教えてください。

4

3 に答える 3

3

この質問のポイントがよくわかりませんが、あなたの懸念は、サイトの一部として返す JS を他人に盗まれてほしくないということのようです。

その場合、実際の解決策は 1 つしかありません。それは、サーバー上で作業を行うことです。

于 2013-10-16T15:38:39.817 に答える
2

You can make it hard to run the code but in the end, it's source code that you give to the world. Any kind of obfuscation and encryption must be reversed before the browser can execute it which means that anyone can eventually reverse engineer the code.

If you don't want this / can't have it, then the browser isn't a suitable tool for you. You can try to write a desktop application or build an appliance (= code which is protected by hardware) but that just raises the bars for reverse engineering. People do grind off the cover off chips to find out how they work.

From my experience, you can make it somewhat hard to "steal" your valuable data but you can't prevent it. Other downsides that you should take into account:

  • Paying customers will be offended by bugs and limitations that you impose on them (pirates will simply remove your copy protection).
  • Hollywood spent millions of dollars in DVD CSS and HDMI. Both protection systems were circumvented in a relatively short time. How much money do you plan to spend?
  • Maybe your time and energy is spent better on providing a better service to customers so they don't feel any need to "steal" from you.
于 2013-10-16T15:42:26.437 に答える
0

これをスクリプトの先頭に追加します。

if(typeof window === 'undefined')
  throw new Error('This script is meant to run in a web browser');

必要に応じて難読化します。

セキュリティ目的でこれを行っている場合、それは無意味な努力です。ユーザーのブラウザーで実行する Javascript で行うことはすべて、ユーザーが読み取ったり変更したりできます。それだけでなく、そうするのはとても簡単です。ユーザーに見せたくないデータは、ブラウザーに送信しないでください。すべての処理はサーバー側で行う必要があります。

于 2013-10-16T15:33:28.613 に答える