1

After having scoured the internet, I'm finding that there's no true way to protect your source code unless you're accessing content stored on the server.

Even with an obfuscator to make your code unreadable, anyone can still copy/paste it and use it on their own site.

So what I've been trying to create is a way to redirect stolen code back to the site after it's been obfuscated/encrypted.

I've been tampering with the following code to try and make it work, but no luck quite yet.

Can anyone make this functional?

durron597
  • 31,968
  • 17
  • 99
  • 158
Michael d
  • 305
  • 2
  • 16
  • possible duplicate of [how do i hide javascript code in a webpage?](http://stackoverflow.com/questions/6869312/how-do-i-hide-javascript-code-in-a-webpage) – D.Shawley Apr 19 '13 at 00:33
  • What's to stop someone from removing *this* part of the obfuscated script? – Tim M. Apr 19 '13 at 00:39
  • @Shawley I think this is a little different in that michael is looking at some other site reusing the obfuscated code as is. As always someone determined could always figure it out. All it requires is to search for the portion that does location.href. – Krishna Apr 19 '13 at 00:40
  • @Tim, they could, if they can remove it from the rest of the encrypted code. But if it's hidden mid-page I imagine that it would be difficult unless they decrypt it. – Michael d Apr 19 '13 at 00:46
  • If people see this question, they can find the answer from the fact that Krishna answered it. Feel free to upvote their answer, but don't copy-paste their answer into your question – durron597 Sep 08 '15 at 03:20

1 Answers1

0

This is working for me:

<script type="text/javascript">
<!--
if (window.location != "http://www.google.com") {
    window.location.href = "http://www.google.com";
} 

//-->


</script>
Krishna
  • 1,871
  • 14
  • 26
  • AWESOME it works. Thank you. So anyone who wants to protect your code with obfuscation, just add this to your code and noone can copy/paste it. + my stackoverflow reputation if you like this. (I'm new here). :) Tks Krishna – Michael d Apr 19 '13 at 00:36
  • 1
    This just makes it work syntactically. But, it is not the solution to your original problem of preventing script reuse. See the comments to your question. – Krishna Apr 19 '13 at 00:42