Comunidad Game Maker

Ayuda => Preguntas y respuestas => Mensaje iniciado por: iNSaNiX en Enero 20, 2016, 03:12:10 PM

Título: Online Ranking que sea seguro y proteger mi juego
Publicado por: iNSaNiX en Enero 20, 2016, 03:12:10 PM
Buenas, actualmente me encuentro usando un ejemplo de CGM que este usa una .dll llamada downloaddll, lo descargue de este foro, pero no encuentro el link y eso que he estado buscando bastante, asi que dejo una foto con los archivos que venían en el ejemplo.

(http://i.epvpimg.com/du48h.png)

He subido el archivo en cuestión de highscore.php a mi web y he probado a que suba los score y tal y lo hace sin problemas, lo que me preocupa es que pueda ser vulnerable y accedan a la DB o la dañen o algo por el estilo, por eso abro el tema, si seguir usando este sistema o si no es seguro, usar otro.

Por otro lado, me gustaría proteger mi juego para que no puedan editar las variables u otros datos del juego, ya que si modifican el score, podrían joderme el ranking poniéndose los primeros con enormes cantidades de puntos, he tratado de usar el anti decompiler que hay por los foros de yoyogames, pero me dice siempre que UPX Packer dejo de funcionar, por lo que os agradecería mucho una ayudita también en protegerlo.

Muchas gracias de ante mano y un saludo.
Título: Re:Online Ranking que sea seguro y proteger mi juego
Publicado por: Clamud en Enero 20, 2016, 03:54:02 PM
Creo que esta es la dll que buscas http://gmc.yoyogames.com/index.php?showtopic=430676 (http://gmc.yoyogames.com/index.php?showtopic=430676)
Es todo lo que puedo ayudar, no tengo muchos conocimientos sobre bases de datos.
Título: Re:Online Ranking que sea seguro y proteger mi juego
Publicado por: iNSaNiX en Enero 20, 2016, 04:00:45 PM
Cita de: Clamud en Enero 20, 2016, 03:54:02 PM
Creo que esta es la dll que buscas http://gmc.yoyogames.com/index.php?showtopic=430676 (http://gmc.yoyogames.com/index.php?showtopic=430676)
Es todo lo que puedo ayudar, no tengo muchos conocimientos sobre bases de datos.

No estoy buscando una dll, mas bien pregunto si es seguro lo que estoy usando para el tema de los ranking, pero gracias ^^
Título: Re:Online Ranking que sea seguro y proteger mi juego
Publicado por: Iros en Enero 20, 2016, 04:08:50 PM
Creo que yo había subido en una época esa DLL con un ejemplo. La verdad que el "highscore.php" es demasiado vulnerable, si tenes conocimientos en PHP podes agregarle seguridad con un par de validaciones antes de agregar los datos a la DB. Si queres dejá en el mensaje el código del highscore.php y veo como agregarle algo más de seguridad.
Título: Re:Online Ranking que sea seguro y proteger mi juego
Publicado por: iNSaNiX en Enero 20, 2016, 04:17:39 PM
Cita de: Iros en Enero 20, 2016, 04:08:50 PM
Creo que yo había subido en una época esa DLL con un ejemplo. La verdad que el "highscore.php" es demasiado vulnerable, si tenes conocimientos en PHP podes agregarle seguridad con un par de validaciones antes de agregar los datos a la DB. Si queres dejá en el mensaje el código del highscore.php y veo como agregarle algo más de seguridad.

Sip, precisamente fuiste tu el que lo subio y ademas traducido, lo cual te lo agradezco bastante ya que he podido entender mejor cosas del GML que antes no sabía y me ha servido.

Te dejo el código ya que yo de PHP se cosas muy básicas

<?php

//The way this script works is pretty easy
//To make the script put or update a player in the list call the script as:    highscore.php?action=set&name=putnamehere&score=scorehere
//To make the script output the top 5 people call it either: highscore.php or highscore.php?action=top

//first connect to database

$host "localhost";
$user "user";
$pass "pass";
$scores_db "db";

$connect=mysql_connect ($host,$user,$pass) or die ('I cannot connect to the database because: ' mysql_error());
mysql_select_db ($scores_db);

//set variables for easier use inside strings
$score=$_GET["score"];
$name=$_GET["name"];

$action=$_GET["action"];

//this function is the responsible of modifing the player in the table
function modify_table()
{
//first the query try to get a riw where the name of the player is = to the name in the url
 
$query "SELECT name FROM hallelujahez WHERE name='".$_GET["name"]."'";
 
$res mysql_query($query) or die("Couldn't execute $query: ".mysql_error());
 
 
//if the query returns 0 rows the player doesn't exist, if it returns 1 the player already exists
 
if (mysql_num_rows($res)==0)
 {
  
//the query makes a new row with the player name and the score
  
$query "INSERT INTO hallelujahez VALUES('".$_GET["name"]."',".$_GET["score"].")";
  
mysql_query($query) or die("Couldn't execute $query: ".mysql_error());
 }
 else
 {
  
//the query looks for the row with name=name in the url and updates his score
  
$query "UPDATE hallelujahez SET score=".$_GET["score"]." WHERE name='".$_GET["name"]."'";
  
mysql_query($query) or die("Couldn't execute $query: ".mysql_error());
 }
}

function 
show_top()
{
 
//we make mysql return all rows in the database, but ordered descendent by the socre column and only the firt 5
 //so, the 5 highest scores will be showed, change the 5 with the number of top players you want to show
 
$query "SELECT name, score FROM hallelujahez ORDER BY score DESC LIMIT 50";
 
$res mysql_query($query) or die("Couldn't execute query: ".mysql_error());
 
 
//this echos the html code for starting a table
 
echo "Hallelujah - Easy | o3Beat Online Ranking<br>
 <br>
 <br>
 <table>
  <tr>
   <td align='center' style='font-color: white;'> <b>Name</b> </td> <td align='center' style='font-color: white;'> <b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Combo</b> </td>
  </tr>
  "
;
 while (
$user mysql_fetch_assoc($res))
 {
  
//the while loop is complicated, took me a week to fully understand how it works
  //It'll output a row with the user name and score
  
echo "<tr> 
          <td align='center' style='font-color: white;'> 
  "
.$user["name"].
  </td> <td align='center' style='font-color: white;'> 
   "
.$user["score"].
  </td> 
  </tr>"
;
 }
 echo 
" </table>.";
}

//this switch will look at the $action variable I declared
//IF action=set means the person wants to input a player score, so we call modify_table()
//If action=top means the person wants to see the top5 players
//If none of the above simply show the top players
switch ($action)
{
 case 
"set"modify_table(); break;
 case 
"top"show_top(); break;
 default: 
show_top(); break;
}

//if you want to make the show_top() function alone in one php file simply copy the code before the function modify table()
//put the function code in the middle and put mysql_close()

//close the connection, you MUSTN't forget to do this after you open a connection
mysql_close();
?>



He modificado los datos de conexión a la DB por razones obvias de seguridad xD, muchas gracias!
Título: Re:Online Ranking que sea seguro y proteger mi juego
Publicado por: Iros en Enero 20, 2016, 06:23:32 PM
Acá dejo el código algo más protegido. Es cuestión de hacer un par de validaciones y pasarle ciertas funciones PHP para que reemplace código HTML y evitar un ataque XSS.


<?php

//The way this script works is pretty easy
//To make the script put or update a player in the list call the script as:    highscore.php?action=set&name=putnamehere&score=scorehere
//To make the script output the top 5 people call it either: highscore.php or highscore.php?action=top

//first connect to database

$host = "localhost";
$user = "user";
$pass = "pass";
$scores_db = "db";

$connect=mysql_connect ($host,$user,$pass) or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ($scores_db);

//set variables for easier use inside strings
$action=$_GET["action"];

$_GET['name'] = htmlspecialchars($_GET['name']);

if (is_numeric($_GET['score'])) { //Comprobamos si SCORE es del tipo numérico, de lo contrario lo convertimos en 0.
$_GET['score'] = htmlspecialchars($_GET['score']);
else
$_GET['score'] = 0;

//this function is the responsible of modifing the player in the table
function modify_table()
{
//first the query try to get a riw where the name of the player is = to the name in the url
$query = "SELECT name FROM hallelujahez WHERE name='".mysql_escape_string($_GET["name"])."'";
$res = mysql_query($query) or die("Couldn't execute $query: ".mysql_error());

//if the query returns 0 rows the player doesn't exist, if it returns 1 the player already exists
if (mysql_num_rows($res)==0)
{
  //the query makes a new row with the player name and the score
  $query = "INSERT INTO hallelujahez VALUES('".mysql_escape_string($_GET["name"])."',".mysql_escape_string($_GET["score"]).")";
  mysql_query($query) or die("Couldn't execute $query: ".mysql_error());
}
else
{
  //the query looks for the row with name=name in the url and updates his score
  $query = "UPDATE hallelujahez SET score=".mysql_escape_string($_GET["score"])." WHERE name='".mysql_escape_string($_GET["name"])."'";
  mysql_query($query) or die("Couldn't execute $query: ".mysql_error());
}
}

function show_top()
{
//we make mysql return all rows in the database, but ordered descendent by the socre column and only the firt 5
//so, the 5 highest scores will be showed, change the 5 with the number of top players you want to show
$query = "SELECT name, score FROM hallelujahez ORDER BY score DESC LIMIT 50";
$res = mysql_query($query) or die("Couldn't execute query: ".mysql_error());

//this echos the html code for starting a table
echo "Hallelujah - Easy | o3Beat Online Ranking<br>
<br>
<br>
<table>
  <tr>
   <td align='center' style='font-color: white;'> <b>Name</b> </td> <td align='center' style='font-color: white;'> <b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Combo</b> </td>
  </tr>
  ";
while ($user = mysql_fetch_assoc($res))
{
  //the while loop is complicated, took me a week to fully understand how it works
  //It'll output a row with the user name and score
  echo "<tr>
          <td align='center' style='font-color: white;'>
  ".$user["name"]."
  </td> <td align='center' style='font-color: white;'>
   ".$user["score"]."
  </td>
  </tr>";
}
echo " </table>.";
}

//this switch will look at the $action variable I declared
//IF action=set means the person wants to input a player score, so we call modify_table()
//If action=top means the person wants to see the top5 players
//If none of the above simply show the top players
switch ($action)
{
case "set": modify_table(); break;
case "top": show_top(); break;
default: show_top(); break;
}

//if you want to make the show_top() function alone in one php file simply copy the code before the function modify table()
//put the function code in the middle and put mysql_close()

//close the connection, you MUSTN't forget to do this after you open a connection
mysql_close();
?>
Título: Re:Online Ranking que sea seguro y proteger mi juego
Publicado por: iNSaNiX en Enero 21, 2016, 05:07:23 PM
Cita de: Iros en Enero 20, 2016, 06:23:32 PM
Acá dejo el código algo más protegido. Es cuestión de hacer un par de validaciones y pasarle ciertas funciones PHP para que reemplace código HTML y evitar un ataque XSS.


<?php

//The way this script works is pretty easy
//To make the script put or update a player in the list call the script as:    highscore.php?action=set&name=putnamehere&score=scorehere
//To make the script output the top 5 people call it either: highscore.php or highscore.php?action=top

//first connect to database

$host = "localhost";
$user = "user";
$pass = "pass";
$scores_db = "db";

$connect=mysql_connect ($host,$user,$pass) or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ($scores_db);

//set variables for easier use inside strings
$action=$_GET["action"];

$_GET['name'] = htmlspecialchars($_GET['name']);

if (is_numeric($_GET['score'])) { //Comprobamos si SCORE es del tipo numérico, de lo contrario lo convertimos en 0.
$_GET['score'] = htmlspecialchars($_GET['score']);
else
$_GET['score'] = 0;

//this function is the responsible of modifing the player in the table
function modify_table()
{
//first the query try to get a riw where the name of the player is = to the name in the url
$query = "SELECT name FROM hallelujahez WHERE name='".mysql_escape_string($_GET["name"])."'";
$res = mysql_query($query) or die("Couldn't execute $query: ".mysql_error());

//if the query returns 0 rows the player doesn't exist, if it returns 1 the player already exists
if (mysql_num_rows($res)==0)
{
  //the query makes a new row with the player name and the score
  $query = "INSERT INTO hallelujahez VALUES('".mysql_escape_string($_GET["name"])."',".mysql_escape_string($_GET["score"]).")";
  mysql_query($query) or die("Couldn't execute $query: ".mysql_error());
}
else
{
  //the query looks for the row with name=name in the url and updates his score
  $query = "UPDATE hallelujahez SET score=".mysql_escape_string($_GET["score"])." WHERE name='".mysql_escape_string($_GET["name"])."'";
  mysql_query($query) or die("Couldn't execute $query: ".mysql_error());
}
}

function show_top()
{
//we make mysql return all rows in the database, but ordered descendent by the socre column and only the firt 5
//so, the 5 highest scores will be showed, change the 5 with the number of top players you want to show
$query = "SELECT name, score FROM hallelujahez ORDER BY score DESC LIMIT 50";
$res = mysql_query($query) or die("Couldn't execute query: ".mysql_error());

//this echos the html code for starting a table
echo "Hallelujah - Easy | o3Beat Online Ranking<br>
<br>
<br>
<table>
  <tr>
   <td align='center' style='font-color: white;'> <b>Name</b> </td> <td align='center' style='font-color: white;'> <b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Combo</b> </td>
  </tr>
  ";
while ($user = mysql_fetch_assoc($res))
{
  //the while loop is complicated, took me a week to fully understand how it works
  //It'll output a row with the user name and score
  echo "<tr>
          <td align='center' style='font-color: white;'>
  ".$user["name"]."
  </td> <td align='center' style='font-color: white;'>
   ".$user["score"]."
  </td>
  </tr>";
}
echo " </table>.";
}

//this switch will look at the $action variable I declared
//IF action=set means the person wants to input a player score, so we call modify_table()
//If action=top means the person wants to see the top5 players
//If none of the above simply show the top players
switch ($action)
{
case "set": modify_table(); break;
case "top": show_top(); break;
default: show_top(); break;
}

//if you want to make the show_top() function alone in one php file simply copy the code before the function modify table()
//put the function code in the middle and put mysql_close()

//close the connection, you MUSTN't forget to do this after you open a connection
mysql_close();
?>


Al usar ese código, el archivo da "error 500" y no carga nada
Título: Re:Online Ranking que sea seguro y proteger mi juego
Publicado por: bygdle en Enero 24, 2016, 06:18:32 AM
Una pregunta, ¿es absolutamente necesario hacerlo en GM8?
Porque si usaras gm studio, todo se facilitaría sin tener que usar dlls, y por ende sería mucho más seguro.
Título: Re:Online Ranking que sea seguro y proteger mi juego
Publicado por: iNSaNiX en Enero 24, 2016, 06:27:43 AM
Cita de: NiuWeb en Enero 24, 2016, 06:18:32 AM
Una pregunta, ¿es absolutamente necesario hacerlo en GM8?
Porque si usaras gm studio, todo se facilitaría sin tener que usar dlls, y por ende sería mucho más seguro.

Principalmente me gustaria hacerlo con GM8, he tratado en varias ocasiones de usar GMS y no me adapto a el, se que es mucho mejor, pero no soy capaz de adaptarme a varias cosas, podria probar a importar el proyecto y ver que tal se me da continuar en GMS si merece la pena en cuanto a seguridad se refiere.
Título: Re:Online Ranking que sea seguro y proteger mi juego
Publicado por: bygdle en Enero 24, 2016, 06:31:25 AM
Yo he hecho varias pruebas con el gms, te puedo decir que si lo sabes usas bien, no habrá problemas.
Si lo deseas puedes darle una mirada a un tutorial que hice (no estoy haciendo spam xD) que trata de sincronizar el gms con PHP y MySQL
http://www.comunidadgm.org/articulos/crea-tu-juego-online-tutorial-php-mysql-gml/
Título: Re:Online Ranking que sea seguro y proteger mi juego
Publicado por: iNSaNiX en Enero 24, 2016, 06:35:22 AM
Cita de: NiuWeb en Enero 24, 2016, 06:31:25 AM
Yo he hecho varias pruebas con el gms, te puedo decir que si lo sabes usas bien, no habrá problemas.
Si lo deseas puedes darle una mirada a un tutorial que hice (no estoy haciendo spam xD) que trata de sincronizar el gms con PHP y MySQL
http://www.comunidadgm.org/articulos/crea-tu-juego-online-tutorial-php-mysql-gml/

Pues mañana mirare el tutorial, aunque no se gran cosa de php, ahora estoy desde movil que ya me voy a dormir xD

Gracias ^^