NexiusTailer / Nex-AC

Anticheat system
https://pawn.wiki/index.php?/topic/27641-nex-ac/
GNU Lesser General Public License v3.0
214 stars 155 forks source link

NOP And Freeze Sync Packet #156

Closed erfanasbari closed 4 years ago

erfanasbari commented 4 years ago

Hi, I Have A Race System That Freeze The Player And Put Him In A Vehicle Using PutPlayerInvehicle But there Is A Problem And That Is The AC Detects PutPlayerInvehicle NOP And I Think It's Because The AC Use FreezeSyncPacket(playerid, E_ALL_SYNC, true) And It Will Cause That Because The Packets Freezes When The Player Is Out Of Vehicle And AC Detects NOP ;D

NOTE: My Race System Is A FS And I Use CallRemoteFunction To Use AC Functions Such As SetPlayerPos.

Example: CallRemoteFunction("ac_TogglePlayerControllable", "ii", playerid, 1);

Note: I Use ac_TogglePlayerControllable A Second After PutPlayerInvehicle But Sometimes It Detects NOP Cuz Of Lag

Sorry For My Bad English

NexiusTailer commented 4 years ago

Well then it would be better to disable anti-unfreeze protection as it's done by default (unfreeze actually detects by anti-airbreak as the speed isn't syncing when you're frozen, so you don't lose any important protection check).

Moreover, you shouldn't use CallRemoteFunction("ac_TogglePlayerControllable", "ii", playerid, 1); or ac_TogglePlayerControllable, just use the original function name and call it directly, as it is already hooked.

erfanasbari commented 4 years ago

Well then it would be better to disable anti-unfreeze protection as it's done by default

It's not related to anti-unfreeze. When you call ac_TogglePlayerControllable if the SKY plugin is included (In my case it is) the ac will use FreezeSyncPacket(playerid, E_ALL_SYNC, true) and the data freezes and when i use putplayerin vehicle the packets will modify by SKY Plugin And The AC Thinks That Player Is Not In Vehicle And Detects NOP :| Anyway Anti-unfreeze is not enabled.

I Replaced every #if defined FreezeSyncPacket to #if defined FreezeSyncPackete (because we don't have anything called FreezeSyncPackete and the function won't call) and the problem never happened again :|

NexiusTailer commented 4 years ago

Look at this line. Any sync will be frozen only if you have anti-unfreeze enabled. However I think it's pretty possible that FreezeSyncPacket broke something just by its presence no matter you freeze the sync or unfreeze it... So I will be glad if you make some final tests to confirm for sure that the problem is in SKY's function itself, and if so, I'll probably remove it in next version.

erfanasbari commented 4 years ago

Look at this line. Any sync will be frozen only if you have anti-unfreeze enabled.

Omg. Looks Like I was wrong =(( Thank You for notice that to me ;D

So I will be glad if you make some final tests to confirm for sure that the problem is in SKY's function itself, and if so, I'll probably remove it in next version.

I Will Record Some Short Video For it ;D

Sorry I Closed This Issue accidentally =((

erfanasbari commented 4 years ago

Hi again.

anti-unfreeze is on in this test and if anti-unfreeze is off there will be no problem

As you can see in This Video The Whole Server Thinks That i'm not in the vehicle and the AC detects NOP because of FreezeSyncPacket:

[26/05/2020 19:58:16] [Nex-AC debug] ID 1 Az NOP PutPlayerInVehicle Estefade Kard
[26/05/2020 19:58:16] [Nex-AC debug] AC veh: 410, veh: 0, AC seat: 0, seatid: -1

and even my friend in the race is not streaming for me (he must be beside me in the map).

and when the race starts server unfreezed me and and the FreezeSyncPacket disabled and when i updated the server that i am in a vehicle, AC detects Teleport Between Vehicle and Set my position to When The AC thinks i was (AntiCheatGetPos)

[26/05/2020 19:58:45] [Nex-AC debug] Entered veh: 0, veh: 410, entered seat: -1, seat: 0, veh model: 560, enter time: 1115323290

And this is a video of a normal race. As You Can See In This Video my friend is streaming for me in the map

NexiusTailer commented 4 years ago

This was clear from the very beginning and I was interested in a little different thing.

The fact that the enabled FreezeSyncPacket function causes desync and anti-nop detections on the player are logical consequences of its use, as it's intended for desynchronize the player sync. And it was added in order to solve previous complaints about the "sandglass" over the players during their freeze, when without connecting SKY plugin the server desync the player itself just by returning 0 in OnPlayerUpdate (and using FreezeSyncPacket I really solved the problem with sandglass & the fact that frozen cheaters could teleport somewhere and continue to stay in different place without kick after unfreeze, but at the same time it brought a new problem with anti-nops detection if you applied something on a frozen player). So the whole idea of anti-unfreeze was always a thing that protection is just desync whole player's sync traffic (if he is frozen) so that other players wouldn't see his actions after freeze no matter he doing something being locally unfrozen or not, but that idea doesn't work well with any of the implementation way (neither with the usual server desyncing, nor with the way that enables FreezeSyncPacket when you connect the SKY plugin). So as I said in the very beginning, it is the reason why that protection is still disabled by default and why you should disable it too.

As for the thing which I was interested in, it was this message:

Well then it would be better to disable anti-unfreeze protection as it's done by default

It's not related to anti-unfreeze. When you call ac_TogglePlayerControllable if the SKY plugin is included (In my case it is) the ac will use FreezeSyncPacket(playerid, E_ALL_SYNC, true) and the data freezes and when i use putplayerin vehicle the packets will modify by SKY Plugin And The AC Thinks That Player Is Not In Vehicle And Detects NOP :| Anyway Anti-unfreeze is not enabled.

So I thought that you've still getting problems with anti-nops detection or desyncing even if you have not used anti-unfreeze code and it was disabled, but seems it was just a misunderstanding as now you wrote that you have no problems with disabled protection. So just confirm you do not have any problems if anti-unfreeze is disabled and finally disable it as it's done by default. I'll look for some other solutions, but now the measure to disable it by default will be continued.

erfanasbari commented 4 years ago

So I thought that you've still getting problems with anti-nops detection or desyncing even if you have not used anti-unfreeze code and it was disabled

I'm Sorry it was my fault i thought anti-unfreeze is disable. (because i can't remember when did i enabled it at the time)

anyway i added a function called IsSyncPacketsFreezed in my SKY.inc and used it under OnCheatDetected to ignore NOP cheat detection.

new iIsPacketsFreezed[MAX_PLAYERS];
// Keep re-sending the last recieved sync packet of a certain type
native FreezeSyncPacket(playerid, E_SYNC_TYPES:type = E_PLAYER_SYNC, bool:toggle);
stock IsSyncPacketsFreezed(playerid) return iIsPacketsFreezed[playerid];
stock FSK_FreezeSyncPacket(playerid, E_SYNC_TYPES:type = E_PLAYER_SYNC, bool:toggle)
{
    iIsPacketsFreezed[playerid] = toggle;
    return FreezeSyncPacket(playerid, type, toggle);
}
#define FreezeSyncPacket FSK_FreezeSyncPacket
NexiusTailer commented 4 years ago

Ok, I have an idea for the next release to do with FreezeSyncPacket if SKY plugin is connected. I want to disable desync as soon as the server starts waiting for applying some function and resume desync when the player seems to have received the data that was set for him. It will be done in 1.9.53 so you could test it later without your own workaround (but if any other problems will be found, you'll have to return your code or just disable anti-unfreeze).