SA-MP Forums Archive
[Include] (sHA) Anti Health And Armour Hack - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Includes (https://sampforum.blast.hk/forumdisplay.php?fid=83)
+---- Thread: [Include] (sHA) Anti Health And Armour Hack (/showthread.php?tid=650208)



(sHA) Anti Health And Armour Hack - StrikerZ - 23.02.2018

Anti Health And Armour Hack

HIGHLY RECOMMENDED TO UPDATE TO V1.2

Код:
This include has been tested several times to detect any false detection but so far it seems fine.

If you find any bug, report it here.
Introduction:
This include is meant to detect players using health/armour hack, this includes checks for several things which when we do GTA SA sets the health, for example: Using vending machine, falling out of car and loosing health (Thanks to RougeDrifter for reminding me this)

Mechanism:
When players use health or armour hack, they set their health without calling the SetPlayerHealth/SetPlayerArmour callback, so we can update the variables with the health/armour everytime the script updates their health/armour while doing several checks for the detection.

Usage:
Two callbacks are provided for this include to give users the full control of this include.
THIS INCLUDE MUST BE INCLUDED IN ALL FILTERSCRIPTS!
Код:
OnPlayerHealthHack(playerid, Float:original, Float:anticheat)
OnPlayerArmourHack(playerid, Float:original, Float:anticheat)
Changelog:
Код:
V1.1
- Player to player damage handled in OnPlayerGiveDamage callback. (Thanks to Gammix to explain the OPTD case.)
- Self damage handled in OnPlayerTakeDamage.

V1.2
- Minor code improvements.
- Spawn check added and removed immunity from OnPlayerDeath as the spawn check will do the job.
- The health and armour has been set to 99, so if a player has 100.0 health/armour, he is either cheating or desynced. 
^ NOTE: Do not kick at sight for 100.0 health, I recommend to check if the player is desycned first and make the player timeout for this if he is desynced.
 (Yes vending machines max health to be given is also set to 99 now.)

- If health isn't set on Spawn, it'll auto set to 99.0, so that variable gets set to avoid false detection of 0.0 health

V1.3
- Fixed the case when player stops spectating, his health auto sets to 100 and anti-cheat detects him as a cheater.

V1.4
-  Fixed the case where player gets damage when he is afk and when he comes back he is detected as cheater.
-  Little optimization in the health and armour detection.
Comments:
I really thank RogueDrifter for his anti-cheat tips topic and all the help provided by him in making this include to work perfectly, without the checks provided by him it could have given false detections. But now it's perfectly fine, and more over thanks to his Immunity trick to avoid players having high ping to be detected as hackers.

Download:
GitHub
Pastebin
Attachment

(Psst: Yes I've taken permission from RogueDrifter to copy his thread style.)


Re: (sHA) Anti Health And Armour Hack - RogueDrifter - 23.02.2018

Haha, regardless of the great include it's overall a bless seeing more people getting into the AC creation as the forum really lacks that, well done now we just wait to get feedbacks to update, once i restart my server soon i'll also use this to see how it goes.


Re: (sHA) Anti Health And Armour Hack - StrikerZ - 23.02.2018

Quote:
Originally Posted by RogueDrifter
Посмотреть сообщение
Haha, regardless of the great include it's overall a bless seeing more people getting into the AC creation as the forum really lacks that, well done now we just wait to get feedbacks to update, once i restart my server soon i'll also use this to see how it goes.
Thanks and I'd like to know how it goes.


Re: (sHA) Anti Health And Armour Hack - iKarim - 23.02.2018

I've looked at the code and this won't work accurately, and will trigger false detections, since it doesn't take any checks in case of packet loss/misorder. Funny enough neither any of the recent "anti cheat" releases take that in consideration.

More info: https://sampforum.blast.hk/showthread.php?pid=876854#pid876854


Re: (sHA) Anti Health And Armour Hack - RogueDrifter - 23.02.2018

Quote:
Originally Posted by iKarim
Посмотреть сообщение
I've looked at the code and this won't work accurately, and will trigger false detections, since it doesn't take any checks in case of packet loss/misorder. Funny enough neither any of the recent "anti cheat" releases take that in consideration.

More info: https://sampforum.blast.hk/showthread.php?pid=876854#pid876854
That'll happen with every include that hooks functions server side (almost every existing anti-cheat) lol, easily fixed tho that's why i released this: https://sampforum.blast.hk/showthread.php?tid=650200

That case overall rarely happens only when the player is totally out of sync and doesn't respond to the server's commands (can also walk through walls for not being able to stream in objects and so on) that is too general to judge with upon such an include.


Re: (sHA) Anti Health And Armour Hack - iKarim - 23.02.2018

Quote:
Originally Posted by RogueDrifter
Посмотреть сообщение
That'll happen with every include that hooks functions server side (almost every existing anti-cheat) lol, easily fixed tho that's why i released this: https://sampforum.blast.hk/showthread.php?tid=650200
This include doesn't check every single packet the player sends therefore it doesn't fix the problem and will let misordered packets to pass.

Quote:
Originally Posted by RogueDrifter
Посмотреть сообщение
That case overall rarely happens only when the player is totally out of sync and doesn't respond to the server's commands (can also walk through walls for not being able to stream in objects and so on) that is too general to judge with upon such an include.
I completely disagree with you, you might want to try to get in a car with a player that has 250+ ping, you'll see how packets misorder affect the vehicle overall sync.


Re: (sHA) Anti Health And Armour Hack - RogueDrifter - 23.02.2018

Quote:
Originally Posted by iKarim
Посмотреть сообщение
This include doesn't check every single packet the player sends therefore it doesn't fix the problem and will let misordered packets to pass.



I completely disagree with you, you might want to try to get in a car with a player that has 250+ ping, you'll see how packets misorder affect the vehicle overall sync.
250+ ping? seriously did you even try or see live any of what you're saying or is that talk off the sync thread? because me and almost all of my players have over 250 ping on my server and I've had 0 problems in sync or packet-loss/mis-order (it only happens with REALLY lagging players, above 400-500 ping and a packet loss spike)

You should also review the release i made correctly as you clearly didn't understand it fully, the de-sync check works on a very smart way using OPU (jelly helped lots with this) which will detect the first hint of a packet-loss/misorder and flag the player as a desynced one.

Again that is the case with every anti cheat (all anticheats in general) that use the server sided functions, anti money cheats, weapons, health,armour,god,teleport,airbreak i can go on, you can't really judge a standalone include on such a thing, because the desync problem is too general it can mess up any system.

Not just anti-cheats, actually it can mess anything depending on the packet that gets lost.

EX: ' My armour system doesn't give armour to the player' Yes because packet loss
' My race system command doesn't return anything' Yes because a desynced player doesn't access server commands properly after his lag spikes and high packet loss rate.
'My teleport system doesn't teleport player' ... so on.


Re: (sHA) Anti Health And Armour Hack - Gammix - 23.02.2018

You cannot rely directly on "OnPlayerTakeDamage" because of this (from wiki):
Quote:

The amount is always the maximum damage the weaponid can do, even when the health left is less than that maximum damage. So when a player has 100.0 health and gets shot with a Desert Eagle which has a damage value of 46.2, it takes 3 shots to kill that player. All 3 shots will show an amount of 46.2, even though when the last shot hits, the player only has 7.6 health left.

I'd say, if you really want to make a perfect serversided health/armour system, you need to implement server-sided damage first, similar to what my HitReg does.

And another big reason to not to use OnPlayerTakeDamage is that the hacker is the one who calls the callback, because he's taking damage, so the hack easily destroys the packet tobe sent and hence OPTD isn't called in your script.


Re: (sHA) Anti Health And Armour Hack - iKarim - 23.02.2018

Quote:
Originally Posted by RogueDrifter
Посмотреть сообщение
250+ ping? seriously did you even try or see live any of what you're saying or is that talk off the sync thread? because me and almost all of my players have over 250 ping on my server and I've had 0 problems in sync or packet-loss/mis-order (it only happens with REALLY lagging players, above 400-500 ping and a packet loss spike)
I have played SA-MP in a deathmatch server for quite enough time to notice how ping affects player overall sync, even with 200 ping and low to no packet loss at all could result in a packet misorder.

Quote:
Originally Posted by RogueDrifter
Посмотреть сообщение
You should also review the release i made correctly as you clearly didn't understand it fully, the de-sync check works on a very smart way using OPU (jelly helped lots with this) which will detect the first hint of a packet-loss/misorder and flag the player as a desynced one.
Yes I did, in fact it sleeps for 2 seconds for each tick which skips about 50 update packets on average (considering OnPlayerUpdate is called 25 times a second on average)

PHP код:
#define FL_MAX_WAIT_TIME 2
if(gettime() > FLaggers_Player[playerid][FLTicks])
{
    
FLaggers_Player[playerid][FLTicks] = gettime()+FL_MAX_WAIT_TIME
Also, I am pointing out a flaw in this include, which is no way related to yours and there's no way you know that anyone will be using this will also be using your include.

Quote:
Originally Posted by RogueDrifter
Посмотреть сообщение
Again that is the case with every anti cheat (all anticheats in general) that use the server sided functions, anti money cheats, weapons, health,armour,god,teleport,airbreak i can go on, you can't really judge a standalone include on such a thing, because the desync problem is too general it can mess up any system.
The point is, you shouldn't rely on any of these scripts, especially if you will be banning players solely on it, and if you don't, that makes it some sort of an implementation of server sided handling, rather than an anti cheat.

Quote:
Originally Posted by RogueDrifter
Посмотреть сообщение
Not just anti-cheats, actually it can mess anything depending on the packet that gets lost.
Exactly, which makes anti cheats way more harder than checking if server side stored health isn't matching client's and taking action solely on that.


Re: (sHA) Anti Health And Armour Hack - N0FeaR - 23.02.2018

Awesome work keep it up! +rep


Re: (sHA) Anti Health And Armour Hack - StrikerZ - 24.02.2018

Update V1.2

(HIGHLY RECOMMENDED TO UPDATE TO V1.2)


Код:
- Minor code improvements.
- Spawn check added and removed immunity from OnPlayerDeath as the spawn check will do the job.
- The health and armour has been set to 99, so if a player has 100.0 health/armour, he is either cheating or desynced. 
^ NOTE: Do not kick at sight for 100.0 health, I recommend to check if the player is desycned first and make the player timeout for this if he is desynced.
 (Yes vending machines max health to be given is also set to 99 now.)

- If health isn't set on Spawn, it'll auto set to 99.0, so that variable gets set to avoid false detection of 0.0 health



Re: (sHA) Anti Health And Armour Hack - StrikerZ - 25.02.2018

UPDATE V1.3

Код:
- Fixed the case when player stops spectating, his health auto sets to 100 and anti-cheat detects him as a cheater.



Re: (sHA) Anti Health And Armour Hack - StrikerZ - 02.03.2018

Update V1.4
Код:

-  Fixed the case where player gets damage when he is afk and when he comes back he is detected as cheater.
-  Little optimization in the health and armour detection.