prevent AJAX作弊网页游戏 [英] Prevent AJAX cheating on a web game

查看:111
本文介绍了prevent AJAX作弊网页游戏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

上下文

我有一个网页游戏在JavaScript中。

我在比赛中发出的分数和成就与AJAX。

所以,任何人都可以查看源$ C ​​$ C,复制这一要求,并欺骗我的比赛。

问题

  • 的任何想法如何prevent呢?
  • 从服务器令牌(我从来没有使用这个系统)?

code

  $岗位(AJAX / score.php',{伪:$伪,得分:$得分,achiev:$ achiev},
    功能(数据){
        。$('#装载机)显示()延迟(3000).fadeOut(1000);
    }
);
 

 如果(使用isset($ _ POST ['伪'])及和放大器;
    使用isset($ _ POST ['得分'])及和放大器;
    使用isset($ _ POST ['achiev'])){
    ...
}
 

解决方案

随着游戏的客户端,也没有办法,以确保它们不会骗。有一些方法可以使得更难以

  • 让所有的计算进行服务器端,并传回令牌......这是不可能的/可行的为您的游戏。
  • 更改code提供服务的每个时间,以便它需要更多的时间来破译的所有请求。
  • 混淆code ......这只是一种威慑。
  • 拥有令牌的游戏过程中发送,看看数据匹配(例如你不能赢得赛车比赛中5秒)......这也可以被欺骗的。<​​/ li>

只要游戏客户端,它不可能是安全的。

Context

I have a web game in JavaScript.

I send scores and achievements with AJAX during the game.

So anyone can view the source code, copy this request and cheat on my game.

Questions

  • Any idea of how prevent this?
  • With a token from server (I never used this system)?

Code

:

$.post('ajax/score.php', {pseudo: $pseudo, score: $score, achiev: $achiev},
    function(data) {
        $('#loader').show().delay(3000).fadeOut(1000);
    }
);

:

if (isset($_POST['pseudo']) &&
    isset($_POST['score']) && 
    isset($_POST['achiev'])) {
    ...
}

解决方案

As the game is client side, there is no way to ensure that they do not "cheat". There are ways to make it more difficult.

  • Have all calculations performed serverside, and send back tokens...this may not be possible/feasible for your game.
  • Change the code served each time so that it will require more time to "decipher" all the requests.
  • Obfuscate the code...this is only a deterrent.
  • Have "tokens" sent during the game to see if the data matches (for example you can't win the racing game in 5 sec)...this too can be spoofed.

As long as the game is client side, it cannot be "secured".

这篇关于prevent AJAX作弊网页游戏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆