[Include] SpooflessDialogs - Prevent dialog spoofing!
#1

SpooflessDialogs


Here is an include that I had originally made for personal use, and I can also say that it is my first include. His job is to prevent cheaters to do dialog spoofing.

What is dialog spoofing?
Dialog spoofing is the name given to the act of responding to dialogs that the server didn't send.

Example of a case of dialog spoofing
Imagine you have a dialog (ID 30) with the message "Press OK to get $100 for free", and you only show that dialog once for that player (for example, during the registration). A cheater could answer to that dialog as many times he wished. Here's what would happen:
  1. Cheater receives dialog ID 30 (during registration)
  2. Cheater answers to dialog ID 30 (during registration)
  3. Cheater answers to dialog ID 30
  4. Cheater answers to dialog ID 30
  5. Cheater answers to dialog ID 30
Consequence? At the end the cheater would have $400 for free, thanks to "dialog spoofing".

It's not normal for someone to do dialog spoofing, since rare are the times you can actually take advantage of it, it largely depends on your script. However, it's possible.

This include works by hooking OnDialogResponse and the function ShowPlayerDialog. He saves the ID you use in ShowPlayerDialog and compares it in OnDialogResponse.

Optional callbacks (to put in your GameMode)
Код:
public OnDialogSpoof(playerid, dialogid, SpooflessDialogs_dialogid)
{
    // What do you want to do with the cheater? Ban? Kick?
    return 0; // Prevent dialog spoof
}
You need to have the includes y_hooks (you can extract everything to your includes folder) and nhooks for this include to work!

In your GameMode:
Код:
#include <YSI\y_hooks>
#include <nhooks>
#include <SpooflessDialogs> // Put this line before any includes that make use of dialogs
In all FilterScripts that make use of dialogs:
Код:
#define FILTERSCRIPT
#include <YSI\y_hooks>
#include <nhooks>
#include <SpooflessDialogs> // Put this line before any includes that make use of dialogs
Do you like it? Any suggestions?

Edit: Dialog spoofing is not completly patched in SA-MP, see this post for more details.
Reply
#2

AFAIK dialog spoofing was patched in 0.3e RC5
Reply
#3

Quote:
Originally Posted by Ralfie
Посмотреть сообщение
AFAIK dialog spoofing was patched in 0.3e RC5
Whoops, well, I guess people can now ignore this topic... I have now read somewhere that it has been patched in 0.3e RC6. There wasn't much information about this, so I did the include.

Moderators can lock this topic, or something like that.

Edit: But does it (the SAMP server) prevent spoofing or just throws a warning into the console?

Edit 2: The comment below confirms that it's still possible to dialog spoof. Thanks for clearing up
Reply
#4

I have actually, wrote my own system to prevent dialog spoofing or sending fake response to an un-shown dialogs.
This include is pretty similar to what i've done, @Ralfie I tested the hack on my test server by myself, both 0.3z, 0.3x, 0.3.7 ( i guess ). Both had the exact same matter. The hack tool got a command to send a fake dialog response to any dialog ID. Ex: /fakeresponse <dialogid> <response> where you can respond to the register dialog many times or such. I won't use this include as i got mine working efficiently. Just though to clear up this problem.
Reply
#5

I experienced a weird issue where a user was forcing a login twice to spawn money. I still can't seem to understand whether or not the dialog spoofing issue was resolved. I read

Have you tested this with a spoofer?
Reply
#6

Quote:
Originally Posted by Lorenc_
Посмотреть сообщение
I experienced a weird issue where a user was forcing a login twice to spawn money. I still can't seem to understand whether or not the dialog spoofing issue was resolved. I read

Have you tested this with a spoofer?
It is possible to send fake packets to the server which can cause fake dialog responses too. However, these fake packets do not call the function ShowPlayerDialog, it only responds. So, by hooking both ShowPlayerDialog and OnDialogResponse, it's possible to know whether it's a spoofed response or not.

It affects on most of the servers where there are no sanity checks under dialog responses. In case if it's meant to be a response from an administrator, a normal player can perform admin actions by sending fake responses (In case if player's admin variable isn't checked under response too).

I can say that most of the administration system released here checks only the commands but not dialog responses. By viewing their source, you can easily get the dialog ID and send fake responses to servers using that script.
Reply
#7

Today I decided to perform an analysis to know if dialog spoofing was really patched or not. My conclusions is that it is partially patched. If you do ShowPlayerDialog with ID 2, the SA-MP server checks if the response is for dialog ID 2.

What a cheater can't do:
  1. Cheater receives dialog ID 2
  2. Cheater answers to dialog ID 3
What a cheater can do:
  1. Cheater receives dialog ID 2
  2. Cheater answers to dialog ID 2
  3. Cheater answers to dialog ID 2
  4. Cheater answers to dialog ID 2
This include will stop dialog spoofing completly. Here's me trying to answer to dialog ID 2 twice:

("Server sent ID -2" means the dialog sent by the server before was already answered by the client, the "-2" is set by the script).

Native dialog spoofing warnings are no longer thrown by the SA-MP server (they were in the past).
Reply
#8

How the hell does the client hook onto the dialog though? Also, how does the client force the dialog to appear more than once? If the server sends the dialog once, and receives 1 response, the server should not accept any more responses, right?
Reply
#9

Quote:
Originally Posted by Aerotactics
Посмотреть сообщение
How the hell does the client hook onto the dialog though? Also, how does the client force the dialog to appear more than once? If the server sends the dialog once, and receives 1 response, the server should not accept any more responses, right?
Good point! What you've made here OP doesn't exactly make the most sense. Aerotactics pointed out what could be a major flaw in your code. I'd suggest you go back and revise it.
Reply
#10

Quote:
Originally Posted by Aerotactics
Посмотреть сообщение
How the hell does the client hook onto the dialog though? Also, how does the client force the dialog to appear more than once? If the server sends the dialog once, and receives 1 response, the server should not accept any more responses, right?
Have you ever heard about memory hacking? With nowadays tools (most of them are even open sourced) it is so easy to spoof almost everything in SA-MP because there aren't sanity checks. (invalid vehicle mods crash is a big example)

There was a serious security flaw in pre-0.3e/x where you could have answered to any dialog even if it was never shown to players. Now it is only possible to answer multiple times to the latest shown dialog.

Example of how it works:
1. Server shows dialog ID 3
2. Player legitly answers to dialog ID 3
3. Server receives answer and validates it.
4. Player uses a hack and answers to dialog ID 3 again.
5. Server receives answer and VALIDATES it (even if it wasn't shown again)

Exemple of how it doesn't work:
1. Server shows dialog ID 3.
2. Player legitly answers to dialog ID 3
3. Server receives answer and validates it.
4. Server shows dialog ID 4.
5. Player uses a hack and answers to dialog ID 3 again.
6. Server receives answer, INVALIDATES it and prints a warning in server_log.txt (server knows that last shown dialog had ID 4, but player answered to ID 3)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)