dongnue4923 2015-06-15 15:33
浏览 104
已采纳

保护C#和PHP之间的通信(而不是加密数据)

I'm developing an Android and iOS game, I need to call the php pages to collect and enter data into the database mysql.

Sending and reception of data works properly, the problem is that the data sent is not encrypted, but this I can solve it with the ssl certificates, in order to have all the data send encrypted.

The other problem is that with some appropriate programs (example: Charles Proxy) you can see the address pointed to my php file, and consequently you can resubmit the packet over and over again.

For example:

This is my test.php:

$code = $_POST['SecretCode'];

if($code == "secretcode")
{ 
    // Connect to DB and increment 'i' value
}

This is my C# code in Unity3D:

public IEnumerator test()
{
    WWWForm form = new WWWForm();
    form.AddField("SecretCode", secretcode);
    WWW www = new WWW("http://sitename.com/test.php", form);

    yield return www;

    if(www.text != "")
    {
        // Returned value
    } 
}

Now, if from my game I call the 'test ()' function, the php called check the security code, and if it is right, will increase the variable on the database.

While the game sends this request, Charles Proxy can see the request and therefore I can with Charles resend endlessly the request, increasing endlessly the value in the database.

To make you understand better I'll show you a picture that sums it all:

http://postimg.org/image/x3owvt5il/

Finally there is a way to make invisible the php file or make it look unknown? Or just do not change the value on the database if someone tries to repeat these requests?

  • 写回答

1条回答 默认 最新

  • dongwei3866 2015-06-30 17:44
    关注

    SOLUTION: I have found the solution! I'm not very practical in the field of connections between client and server. To protect the communication between the client and the server, just use the HTTPS protocol, and so in addition to having the data already encrypted, you also have the encrypted communication so that nobody can see your url and can not create endless request of the package that you sent previously.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!