Ways to make Javascript code hacking / injection / manipulation difficult?

后端 未结 4 978
情深已故
情深已故 2021-02-06 08:37

Are there ways to prevent, or make it difficult enough, for someone to inject Javascript and manipulate the variables or access functions? A thought I had is to change all var n

4条回答
  •  深忆病人
    2021-02-06 08:51

    Any user that will really want to tamper with the client will be able to. The code is on his machine. Even if you obfuscate the client side code, there are tools out their that will help someone deobfuscate the code back in a second.

    What you need to think about though is making the site safe on the server, and safe for other users as well. This means (as a minimum):

    1. Checking/Validating every request and input parameters on the server so Users won't be able to alter any server side data by triggering 'hacked' client side functions you wrote.

    2. Check all data that you output to the screen that was originated from user input. Other users might have inserted client side scripts that are dangerous for your site, and especially dangerous to the other users on your site. (If you're using .net then check out the AntiXSS library)

提交回复
热议问题