Dynamically Obfuscate HTML

2019-08-03 19:48发布

I was wondering if there was any way to dynamically obfuscate html on a live server but not offline, so soon as my website was visited the source would be obfuscated rather than in plain text.

5条回答
Melony?
2楼-- · 2019-08-03 20:33

Your could search for and remove all tabs, newlines, extra spaces, and comments

查看更多
干净又极端
3楼-- · 2019-08-03 20:38

Since the client (browser) will have to parse it into a sensible DOM tree, this is pretty much fruitless. These days it's a lot more common to inspect a site using Firebug/Webkit Inspector, which provides a nicely formatted, navigable tree. Most people won't even notice that the HTML is "obfuscated", much less be stopped by it.

Executable code can be obfuscated by minimizing variable names and such without changing the result. HTML is the result though, if you change anything about it, the result will change. So "obfuscation" would mostly be limited to creative use of spacing anyway.

查看更多
唯我独甜
4楼-- · 2019-08-03 20:38

The real question you should ask yourself is "why do I need to obfuscate HTML?". If you're hiding sensitive information, then you should be either encrypting that data, or never presenting it to the client.

Most sensitive information or transactions should take place on the server, and the client only receives a token, or encrypted information, or a unique transaction identifier that can be passed back and forth.

查看更多
看我几分像从前
5楼-- · 2019-08-03 20:38

Let me put it this way: There's no way to dynamically obfuscate the HTML on your site such that any reasonably competent person couldn't get it anyway.

  1. You could use JavaScript to attempt to obfuscate it, but you'd have to do it in a way that didn't actually affect the DOM.
  2. You could generate the contents of the page itself with JavaScript, but that is likely to damage accessibility, and once again the DOM will have to be in a condition the browser can use.
  3. You could insert massive amounts of whitespace into the source, but that is easily overcome as well.

All this, and you make it harder and more annoying to manage your site. Minification has its purpose, but obfuscation here is lose-lose.

查看更多
啃猪蹄的小仙女
6楼-- · 2019-08-03 20:51

If you are using php, IonCube has a plugin. it can be found here: http://www.ioncube.com/html_encoder.php it turns your html page into minified javascript.

查看更多
登录 后发表回答