20.01.2017, 08:50
(
Последний раз редактировалось Shetch; 20.01.2017 в 15:27.
)
Hello SA-MP forums!
Very recently, PR-RP.com experienced a big influx of item duplicating which was caused by the DialogHider.cs CLEO modification. We of course knew that the items were being duplicated, but we were not sure how. We didn't even know where to start looking. After about a week of the server being online, we received a message were a player offered to expose the duplication bug to us. He of course told us about the DialogHider.cs being used and we took action immediately.
How does it work?:
DialogHider.cs can hide dialogs shown to the player and move around while the dialog is sill being displayed on the player's screen (the server thinks it's being displayed), even though no dialog is visible for the player (client side). The dialog can then be shown again at any given moment as well as multiple responses can be sent to a single shown dialog.
1. Dialog ID 1 is show to the player: "Would you like to get $100?" "Yes" "No"
2. Player responds "Yes" to the dialog.
3. $100 is given to the player.
4. Player responds "Yes" to the dialog again, even though no dialog was displayed.
5. $100 is given to the player.
6. Player responds "Yes" to the dialog again, even though no dialog was displayed.
7. $100 is given to t... etc.
How can I prevent my server from such attacks?:
The way you fix such an exploit is very simple. You set up a single player variable called 'pDialogOpen'. When a dialog is show to the player by the server, set the variable 'pDialogOpen' to 1. When player responds to the dialog, set it back to 0. If a player responds to the dialog and 'pDialogOpen' is already 0, you know DialogHider.cs or some other dialog response hack is being used.
The code I used for our GM:
Defining a function which we will use to display dialogs:
Displaying a dialog by the server:
Responding to the shown dialogs:
Very recently, PR-RP.com experienced a big influx of item duplicating which was caused by the DialogHider.cs CLEO modification. We of course knew that the items were being duplicated, but we were not sure how. We didn't even know where to start looking. After about a week of the server being online, we received a message were a player offered to expose the duplication bug to us. He of course told us about the DialogHider.cs being used and we took action immediately.
How does it work?:
DialogHider.cs can hide dialogs shown to the player and move around while the dialog is sill being displayed on the player's screen (the server thinks it's being displayed), even though no dialog is visible for the player (client side). The dialog can then be shown again at any given moment as well as multiple responses can be sent to a single shown dialog.
1. Dialog ID 1 is show to the player: "Would you like to get $100?" "Yes" "No"
2. Player responds "Yes" to the dialog.
3. $100 is given to the player.
4. Player responds "Yes" to the dialog again, even though no dialog was displayed.
5. $100 is given to the player.
6. Player responds "Yes" to the dialog again, even though no dialog was displayed.
7. $100 is given to t... etc.
How can I prevent my server from such attacks?:
The way you fix such an exploit is very simple. You set up a single player variable called 'pDialogOpen'. When a dialog is show to the player by the server, set the variable 'pDialogOpen' to 1. When player responds to the dialog, set it back to 0. If a player responds to the dialog and 'pDialogOpen' is already 0, you know DialogHider.cs or some other dialog response hack is being used.
The code I used for our GM:
Defining a function which we will use to display dialogs:
Код:
public ShowPlayerDialogEx(playerid, dialogid, style, caption[], info[], button1[], button2[]) { ShowPlayerDialog(playerid, dialogid, style, caption, info, button1, button2); PlayerInfo[playerid][pDialogOpen] = 1; return 1; } // You can hook the ShowPlayerDialog to make it tidier.
Код:
ShowPlayerDialogEx(playerid, 1, DIALOG_STYLE_MSGBOX, "Money", "Would you like to receive $100?", "Yes", "No");
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { if(PlayerInfo[playerid][pDialogOpen] != 1) { new string[128]; format(string, sizeof(string), "AdmWarn: %s(ID: %i) is possibly dialog hacking.", PlayerInfo[playerid][pName], playerid); SendAdminMessage(COLOR_YELLOW, string); return 1; } PlayerInfo[playerid][pDialogOpen] = 0; // Here we can SAFELY respond to the dialog, because now we know the dialog was actually shown to the player BY THE SERVER. switch(dialogid) { case 1: { if(response) { GivePlayerMoney(playerid, 100); } } } return 1; }