04.02.2017, 13:13
(
Last edited by Lordzy; 02/07/2017 at 04:05 PM.
)
safeDialogs
Complete protection against spoofed dialog data (id, list-item and input-text)
Version - 1.0.3 (use v1.0.2 until a stable version is released)
Last update - 8th of February, 2017
NOTE : I've been inactive since a while. I'll be working on the include after settling few things.
IntroductionComplete protection against spoofed dialog data (id, list-item and input-text)
Version - 1.0.3 (use v1.0.2 until a stable version is released)
Last update - 8th of February, 2017
NOTE : I've been inactive since a while. I'll be working on the include after settling few things.
safeDialogs detects and prevents players sending falsified dialog responses that includes wrong dialog ID, invalid list-item or fake input-text (list-item string). Faking list-item or item string can lead to many risks of player breaking server security. It can also lead to crashes where listitem used as array index goes out of bounds. However, this include ensures that everything's safe and filtered. This include triggers a callback on player sending spoofed dialog response.How's this different from others?
I've never seen any anti-cheat or dialog include that provides protection over list items and over sending fake inputtext data for list type dialogs. This topic is what that has inspired me to create such an include to provide complete protection over dialog responses.Callbacks and Functions
Exploit Protection Spoofed dialog ids Yes Spoofed dialog list-items Yes Spoofed dialog list-item inputtext Yes Filtering user's inputtext Yes
CallbackImportant NotesFunctions - These functions can only be used under OnDialogResponse and OnDialogSpoof. Once any of these callbacks are over, they'll return their default values only.Parameters:pawn Code:public OnDialogSpoof(playerid, spooftype) {
return 0; //Return 0 to block spoofed data!
}
playerid - The player who sent spoofed data.
spooftype - Spoof type.
Spoof types:
DIALOG_SPOOFTYPE_DIALOG_ID - If dialog ID is spoofed.
DIALOG_SPOOFTYPE_LIST_ITEM - If dialog listitem is spoofed.
DIALOG_SPOOFTYPE_INPUT_TEXT - If dialog inputtext (for lists) is spoofed.
Enumerator
pawn Code:enum {
DIALOG_SPOOFTYPE_DIALOG_ID,
DIALOG_SPOOFTYPE_LIST_ITEM,
DIALOG_SPOOFTYPE_INPUT_TEXT
}
pawn Code:native GetPlayerDialog(playerid); //Returns the current dialog ID of player.
native GetPlayerDialogStyle(playerid); //Returns the current dialog style of player. (255 if invalid)
native GetPlayerDialogInfo(playerid, dest[], size = sizeof(dest)); //Stores the dialog info to "dest" array.
native GetPlayerDialogItem(playerid, listitem, dest[], bool:filter = false, size = sizeof(dest)); //Stores the dialog's list-item string to "dest" array. View change-logs (v1.0.3) below to know more.
• This include must be included on every scripts that uses dialog features.Usage
• This include must be included after a_samp to ensure any other includes using dialog features are also protected. If you're having "fixes.inc" - include this after fixes.inc to avoid the user errors by fixes.inc.
• If you're using easyDialogs, yes, this can be integrated along with it. But include safeDialogs before easyDialogs.
• If your script is having a list-item of length greater than 256, edit MAX_DIALOG_LISTITEM_LEN. Or simply do this:
pawn Code://These defines are optional. If you haven't defined, script will use it's default values.
//Before including safeDialogs
#define MAX_DIALOG_LISTITEM_LEN 300
//You can also define MAX_DIALOG_STRING (not greater than 2048 since that's a limitation on SA-MP)
#define MAX_DIALOG_STRING 2000
#include <a_samp>
#include <safeDialogs>
Using this include is very easy! A small example is given below.Changelogs
pawn Code:#include <a_samp>
#include <safeDialogs>
public OnDialogSpoof(playerid, spooftype) {
//Player is spoofing dialog!
Kick(playerid); //Kick the player.
return 0; //Block the spoofed data by returning 0. Returning other values will accept spoofed data which isn't recommended.
}
safeDialogs - v1.0.3 (optional / minor update):
- Added a static-global array to handle huge strings, thereby freeing more heap space. If you were facing any heap space related warning after including safeDialogs earlier, it should be fixed now.safeDialogs - v1.0.2:
- Improved list-item filtering. There used to be a confusion for non-hex codes between curly braces in list-item string, no more now though!
- Added new function : GetPlayerDialogItem - It stores the list-item string/data into destination. Using this function, you don't have to rely on inputtext for list-type dialogs to get their string data. In cases of DIALOG_STYLE_TABLIST or DIALOG_STYLE_TABLIST_HEADERS - it stores the complete list-item data.
To know more about this function and how it outputs - http://forum.sa-mp.com/showpost.php?...0&postcount=17pawn Code:GetPlayerDialogItem(playerid, listitem, dest[], bool:filter = false, size = sizeof(dest));
playerid - The player to obtain data from.
listitem - The listitem of which data/string has to be obtained.
dest[] - Array to store string/data.
filter = false - Whether to filter the contents in a list-item. If filter is set to true,
it will automatically remove color embedding and make it look like
how it's shown to clients / players.
If filter is set to false (by default it's false), it will show the raw data
which may or may not include color embedding, depending on how the
code is.
size = sizeof(dest) - The size of destination array.
- Fixed functions : Functions from safeDialogs can now be used under OnDialogResponse and OnDialogSpoof.
- Include initialization won't call OnPlayerConnect completely anymore, instead it only resets necessary variables. This also means that "_ALS_" hook errors upon including certain libraries along with safeDialogs, are fixed.
- Fixed false triggers for dialogs using color embedding. Thanks to GoldenLion for reporting!safeDialogs - v1.0.1:
- Include is now completely stand-alone. It no longer requires script_compatibility include since it had a problem with users using YSI.
- Fixed false triggers for DIALOG_STYLE_TABLIST and DIALOG_STYLE_TABLIST_HEADERS. Thanks to GoldenLion for reporting!safeDialogs - v1.0:
- Initial release.Download
Github : https://github.com/Lordzy/safeDialogs
Raw source : https://raw.githubusercontent.com/Lo...afeDialogs.inc