私のウェブサイトのjavascriptでゲームを作っていますが、簡単にハックしたりSQL上で感染させたりすることができます。スクリプト、どのようにスクリプトとコードを表示および編集できないようにすることができますか?javascriptゲームを編集/ハッキングできないようにする方法
Here`s私のコード
<script>
var scoreNumber = 0;
document.getElementById('scoreLabel').value = scoreNumber;
document.getElementById("scoreLabel").innerHTML = scoreNumber;
</script>
<html>
<style>
body{
background-image: url('snow.gif');
background-size: cover;
}
</style>
<head>
<center>
<h1 id="bottom">Cilus Networks</h1>
// Anyone can change the scrollamount, which i dont want
<marquee scrollamount="20"
direction="right"
behavior="scroll">
<a href=# onclick="add()"><img id="one" src="santa.png" height="150" width="150"></a>
</marquee>
<marquee scrollamount="20"
direction="left"
behavior="scroll">
<a href=# onclick="add()"><img id="two" src="santa.png" height="150" width="150"> <source src="plimp.mp3" type="audio/mp3"></a>
</marquee>
</center>
<h1 id="scoreLabel">0</h1>
</head>
<body>
</body>
<script>
var powerup;
var lifes;
//Anyone can change this, which i also dont want.
powerup = 0;
if (powerup == 2) {
function add(){
scoreNumber = scoreNumber +1000
document.getElementById('scoreLabel').value = scoreNumber;
document.getElementById("scoreLabel").innerHTML = scoreNumber;
}
};
if (powerup == 5) {
function add(){
scoreNumber = scoreNumber +500
document.getElementById('scoreLabel').value = scoreNumber;
document.getElementById("scoreLabel").innerHTML = scoreNumber;
}
};
function add(){
scoreNumber = scoreNumber +1
document.getElementById('scoreLabel').value = scoreNumber;
document.getElementById("scoreLabel").innerHTML = scoreNumber;
setInterval(function(){ window.location.replace("http://cilusnetworks.com/thankyouMDT.php"); }, 400);}
</script>
これを行う方法上の任意のアイデア?私はsom研究をしましたが、私は何かを見つけることができません。
あなたはそれをもっと難しくすることはできません。クライアントに送信するデータはすべて読み取り、操作できます。 – Carcigenicate
まず第一に、SQLはJavascriptとは何も関係ありません。それはサーバサイドです。 Javascriptはクライアント側です。それは訪問者のPC上で実行されていることを意味します。あなたのサーバーではありません。あなたもそれを保護することはできません。自分のPC上で実行されているコードを使ってユーザーが何をするかを制御することはできません。 – icecub
JavaScriptをどのように難読化できますか?(https://stackoverflow.com/questions/194397/how-can-i-obfuscate-protect-javascript) – Emre