防止向记分板提交欺诈性内容
我正在开发 Flash 游戏的后端,我需要保护进入记分板的数据。
该游戏将在许多网站上以横幅广告形式托管,用户将在广告中玩游戏,然后点击进入主网站以保存其详细信息。
目前我正在思考这个
- 用户玩游戏并点击提交他们的分数
- 在后台,横幅将分数和原始域发送到主站点上的脚本。
- 该脚本检查域是否是托管广告的有效域之一。
- 如果一切正常,脚本会创建此分数和域的哈希值,并将其与分数一起存储在数据库中。
- 该脚本将哈希值返回给 Flash,Flash 将其拼凑到打开主记分板的 getURL 的查询字符串中。
- 记分板页面检查引用以确保它是有效域之一。
- 如果是,则检查数据库中的哈希值,如果它是有效令牌,
- 则用户填写其详细信息,并根据哈希值更新记录
上次我检查 FLash 时没有发送引用信息,这有点麻烦进入我的计划。 那么,这种 Flash/数据库交互是否已经建立了模式?
在步骤 4 中我应该使用哪种哈希/校验和? 这种操作的正确名称是什么,是哈希、校验和还是其他什么?
我知道,作为一种客户端技术,Flash 实际上永远不会那么安全,但在我看来,类似上述的事情与破解此类应用程序一样困难。
更新:我的主要目标是让人们更难找到将分数添加到数据库的脚本的 URL,并简单地向其发送虚假分数。
谢谢, 格雷格
I'm working on the backend for a Flash game and I need to secure the data going into the scoreboard.
The game is going to be hosted on many sites in a banner ad, the user will play the game in the advert then click through to the main site to save their details.
At the moment I am thinking along the lines of this
- User plays the game and clicks to submit their score
- In the background, the banner sends the score and the originating domain to a script on the main site.
- The script check the domain is one of the valid domains the ad is being hosted on.
- If everything is right, the script creates a hash of this score and domain and stores it in the database along side the score.
- The script returns the hash to Flash which cobbles it onto the querystring of a getURL which opens the main scoreboard
- The scoreboard page checks the referer to make sure it is one of the valid domains.
- If it is it then checks the database for the hash to if it's a valid token
- the user then fills in their details and the record is updated based on the hash
Last time I checked FLash doesn't send referer info, which kinda throws a spanner into my plan. So, is there an already established pattern for this kind of Flash/Database interaction?
What sort of Hashing/Checksuming should I use in step 4? What is the correct name for this kind of operation, is it a hash, a checksum or something else?
I understand that being a clientside technology, Flash will never actually be THAT secure, but in my mind, something like the above is about as dificult as you're going to make it to hack this kind of application.
UPDATE: My main objective is to make it harder for people to find the URL of the script that adds the score to the database and simply spam it with fake scores.
Thanks,
Greg
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
本质上,您不想验证分数是否来自合法客户端,您想验证客户端是否确实玩过游戏以获得分数。 从本质上讲,你所能期望的最好的结果就是人们被要求创建一个人工智能来玩游戏。
您可以尝试以下几项操作:
Essentially you don't want to verify the score is coming from a legit client, you want to verify the client actually played the game to achieve the score. Essentially the best you can hope for is people being required to create an AI to play the game.
Here are a couple things you can try:
我之前在游戏行业工作过,也做过类似的事情。 据我所知,没有人费心去破解分数提交部分。
完成的方式是:
笔记 :
散列/校验和是使用自定义函数进行的。 不需要非常安全的东西。 它是通过对盐和分数的计算而得出的。 一些简单的数学运算,如求和、乘法和减法。
编辑:校验和的简单算法/数学
假设您的用户得分为5885。
您生成一个随机数作为 134789 的盐(恒定长度,用 0 填充)
cryptedScore = Score * Salt (您应该在这里使用更复杂的东西,但这只是一个例子)
在我们的示例中,加密分数将是: 793233265
现在对于校验和,假设您想要一个值253 作为校验和。
您将加密分数的所有数字相加 7+9+3+2+3+3+2+6+5 = 40
现在,您计算该分数的校验和值
253 - (加密分数总和 % 253)
现在,我们有以下数字:
盐 = 134789
加密分数 = 793233265
校验和 = 40
您向服务器发出请求,发送 134789793233265040 作为分数。
在分数服务器上,您可以将 793233265 除以 134789,得到 5885 并使用与之前相同的函数验证校验和。
如果校验和失败,则数字已被篡改。
你可能最终会得到更安全的东西,但它应该可以解决问题。
I have previously worked in the game industry, and did something along these lines. To my knowledge, no one ever bothered cracking the score submitting part.
The way it was done was :
Note :
The hashing / checksuming was made using a custom function. Did not need something very secure. It was made using a computation on the salt and the score. Some simple math operations like sums, multiplications and subtractions.
Edit: a simple algorithm / maths for the checksum
Lets say your user has a score of 5885.
You generate a random number as a salt of 134789 (constant length, pad with 0)
cryptedScore = Score * Salt (you should use something a bit more complex here, but it is just an exemple)
In our example, the crypted score would be : 793233265
Now for the checksum, lets say you want to have a value of 253 as a checksum.
You add all the numbers of your crypted score 7+9+3+2+3+3+2+6+5 = 40
Now, you calculate the value of your checksum for this score
253 - (Sum of crypted score numbers % 253)
Now, we have the following numbers:
the salt = 134789
the crypted score = 793233265
the checksum = 40
You make a request to the server, sending 134789793233265040 as a score.
On score server, you can divide 793233265 by 134789 giving 5885 and validate the checksum using the same function as before.
If the checksum fails, then numbers have been tampered.
you could probably end up with something much more secure, but it should do the trick.