[Tutorial] Fight Against Undetectable weapon Hacks
#1

Update;
Quote:
Originally Posted by JaKe Elite
View Post
Thread Updated

~ Please keep in mind, If you are looking for the Anticheat for those Regular Weapon Hacks then this isn't the place for you use the SEARCH button. This anticheat only works for those Weapon Hacks which uses CLEO Mod & SAMPFUNCS.
I am not sure if this has been posted here yet but I did like to share yall something, An anti cheat against those so-called "undetectable weapon hacks". The hacks works like this they type in something which alerts the script to make their spawned hack weapons to be undetectable by the server, they then attack the players with those spawned weapons while in reality on server's perspective view they are holding nothing.

So basically, You can actually detect if they are weapon hacking and I have found my own method. You can use OnPlayerGiveDamage and check if they are giving damages to players with their bare hands if the weapons they used to give damage to the player isn't a bare hand they are possibly 99.9% weapon hacking with this so-called "undetectable weapon hack". I haven't tested this on a public server, however, I tried it on my NPC and the debug works, you may try it out yourself.

Any feedbacks are welcome, you may post your feedbacks below.

Bulleted Weapons Detection (Damage Block)

PHP Code:
public OnPlayerWeaponShot(playeridweaponidhittypehitidFloatfXFloatfYFloatfZ)
{
    
// Checks if playerid has weaponID 0, and it also checks if the weaponid OnPlayerWeaponShot.
    // If the weaponid OPWS isn't zero then they are probably hacking - CHECK IF THEY ARE DESYNC THOUGH.
    
if(GetPlayerWeapon(playerid) == && weaponid != 0)
    {
        return 
0// Blocks bullets from being sent to the server client to player client.
    
}
    return 
1;

Not Bulleted Weapons Detection (No Damage Block)
PHP Code:
public OnPlayerGiveDamage(playeriddamagedidFloat:amountweaponidbodypart)
{
    
// Checks if the playerid (The player who damages the other player) is not holding any weapon.
    // If the weaponid used to attack the other players aren't zero (null) then they are possibly weapon hacking with this undetectable weapon hack.
    
if(GetPlayerWeapon(playerid) == && weaponid != 0)
    {
        
// Your code here
    
}
    return 
1;

Reply
#2

this will prevent losers to get in a server but just to hack and other shit. Good job, Jake.
Reply
#3

GG man !
Reply
#4

Very nice hack ending.
Reply
#5

This should also be taken in consideration in next SA-MP update @Kalcor , instead of us having to code it in each gm.. Many people don't and will not know about this I believe
Reply
#6

Related: https://sampforum.blast.hk/showthread.php?tid=535559
Reply
#7

This simply disables the server from detecting spawned in weapons through GetPlayerWeapon (and other similar functions). All bullet and other data is still processed, meaning you can also detect this through OnPlayerWeaponShot for shootable weapons (although possible desync or lag should be taken into account).

Code:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float: fX, Float: fY, Float: fZ)
{
      if(GetPlayerWeapon(playerid)) != weaponid || GetPlayerWeapon(playerid) == 0)
      {
           // possibly hacking, more checks needed
           return false;
      }

      return true;
}
Reply
#8

The health & armor can be resetted back once they got the damage OnPlayerGiveDamage, though this is a bad idea on my perspective. I have chosen OnPlayerGiveDamage for a reason (none bulleted weapons doesnt get called OnPlayerWeaponShot) however OnPlayerWeaponShot could work too except that this callback gets called for bullet weapons only.
Reply
#9

Quote:
Originally Posted by JaKe Elite
View Post
The health & armor can be resetted back once they got the damage OnPlayerGiveDamage, though this is a bad idea on my perspective. I have chosen OnPlayerGiveDamage for a reason (none bulleted weapons doesnt get called OnPlayerWeaponShot) however OnPlayerWeaponShot could work too except that this callback gets called for bullet weapons only.
That's not wrong, GiveDamage could also be used for detecting melees or projectiles. The benefit of using OnPlayerWeaponShot for shootable weapons is that you can completely disregard every single bullet they shoot, meaning players won't be affected by hacked bullets at all (meaning no health or armor is ever lost). You're also able to detect hacked bullets that don't hit or damage a player as well.
Reply
#10

Quote:
Originally Posted by Abagail
View Post
That's not wrong, GiveDamage could also be used for detecting melees or projectiles. The benefit of using OnPlayerWeaponShot for shootable weapons is that you can completely disregard every single bullet they shoot, meaning players won't be affected by hacked bullets at all (meaning no health or armor is ever lost). You're also able to detect hacked bullets that don't hit or damage a player as well.
I will update the thread tomorrow with my new experiments, I will also include the OnPlayerWeaponShot callback. Any thoughts so far if this is realiable or not, well at least it worked for me.
Reply
#11

Thread Updated

~ Please keep in mind, If you are looking for the Anticheat for those Regular Weapon Hacks then this isn't the place for you use the SEARCH button. This anticheat only works for those Weapon Hacks which uses CLEO Mod & SAMPFUNCS.
Reply
#12

Another thing that slipped my mind earlier, vehicles such as the Predator, Hydra, Hunter, etc. also shoot weapons. You should incorporate this in sanity checks, e.g:
Code:
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
		    {
				new vehModel = GetVehicleModel(GetPlayerVehicleID(playerid)));
				if(vehModel == 425 || vehModel == 430 || vehModel == 447)
					return true;
			}

else
{
       // ...
Reply
#13

Also ; a simple anti cheat :
PHP Code:
public  OnPlayerWeaponShot(playeridweaponidhittypehitidFloat:fXFloat:fYFloat:fZ)
{
    
// ===================== FAKE DATA SEND ===================== // 
    
if(!(<= hittype <= 4) || !IsPlayerConnected(playerid))
    {
        
// ur code
        
return 0;
    }
    
// ==================================================== //
    // ===================== BULLET CRASHER ===================== // 
    
if(!(22 <= weaponid <= 34 || weaponid == 38))
    {
        
// ur code
        
return 0;
    } 
Reply
#14

bullet crasher was patched in 0.3.7
Reply
#15

Good share.
Reply
#16

Quote:
Originally Posted by Logic_
View Post
bullet crasher was patched in 0.3.7
This has nothing to do with bullet crasher, Player spawns a weapon on their screen but the server (& players streamed in) doesn't recognizes the weapon which makes the server thinks that the hacker is holding nothing (by passing the regular weapon anticheats)
Reply
#17

Quote:
Originally Posted by JaKe Elite
View Post
This has nothing to do with bullet crasher, Player spawns a weapon on their screen but the server (& players streamed in) doesn't recognizes the weapon which makes the server thinks that the hacker is holding nothing (by passing the regular weapon anticheats)
He answered me.
Reply
#18

If I am not wrong player weapon doesn't update if he is sitting in a vehicle.
So maybe its possible yet to sit as passenger, turn on the hack, get head out of window and start shooting?
Reply
#19

Quote:
Originally Posted by jlalt
View Post
If I am not wrong player weapon doesn't update if he is sitting in a vehicle.
So maybe its possible yet to sit as passenger, turn on the hack, get head out of window and start shooting?
That is fully correct. I had myself being banned over and over again on my test server because I didn't take into count if player is in vehicle, very important part!

The weapon that the player held before entering the vehicle will be recorded from GetPlayerWeapon. HOWEVER! I have not tested if it's valid on OnGivePlayerDamage or OnPlayerTakeDamage yet so someone feel free to shed some light here if the parameter that is passed into those callbacks are old weapon ids.
Reply
#20

Quote:
Originally Posted by jlalt
View Post
If I am not wrong player weapon doesn't update if he is sitting in a vehicle.
So maybe its possible yet to sit as passenger, turn on the hack, get head out of window and start shooting?
Quote:
Originally Posted by Hansrutger
View Post
That is fully correct. I had myself being banned over and over again on my test server because I didn't take into count if player is in vehicle, very important part!

The weapon that the player held before entering the vehicle will be recorded from GetPlayerWeapon. HOWEVER! I have not tested if it's valid on OnGivePlayerDamage or OnPlayerTakeDamage yet so someone feel free to shed some light here if the parameter that is passed into those callbacks are old weapon ids.
Surprisingly the weaponid parameters OnPlayerWeaponShot & OnPlayerGive(Take)Damage is reliable as it returns the player's correct holding weapon while they are on the vehicle.

Testing in game (with debug messages);
Note the message "Weapon I am holding" returns GetPlayerWeapon

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)