[Include] Southclaw's & Pottus's Anti-cheat patches
#41

Really Appreciate
+REP for this patching and helping us to save our server from cheaters
Reply
#42

Code:
public HealthCheck ()
{
    new Float:fhealth,health,ac_health;
    for(new i = 0;i < maxplayers;i++)
	{
	    if(PlayerAC[i][Alive]) //Will not be set for NPCs to skip AC Checks
	    {
	       	if(PlayerData[i][Disconnecting]) continue;
		    GetPlayerHealth(i,fhealth);
		    health = floatround(fhealth);
		    ac_health = floatround(PlayerAC[i][ACHealth]);
		   	if(PlayerAC[i][ACHealthSync])
		    {
		        //SYNC
		        if(health > 100)
		        {
		            if(!PlayerAC[i][GodMode])
		            {
                  		XA_Ban(i,"Health Hacks","Banned for using Health Hacks/Cheats",SERVER);
		            }
		        }
		        else if(health != ac_health)
			 	{
		      		if(!PlayerAC[i][HHNoticeGiven])
		         	{
		          		PlayerAC[i][HHNoticeGiven] = true;
	              		SendAdminNoticeMessage("%s(%d) is suspected to be using health hacks.",PlayerData[i][Name],i);
					}
		            SetPlayerHealth(i,ac_health);
		            PlayerAC[i][ACHealthSync] = false;
					if(++PlayerAC[i][HealthHackCount] > MAX_HEALTH_HACK_COUNT)
					{
         				XA_Ban(i,"Health Hacks","Banned for using Health Hacks/Cheats",SERVER);
					}
		        }
	    	}
		    else
		    {
		        //CHECK DESYNC
		        if(health!=ac_health)
				{
				   	//DESYNCED
				    new sec  = (++PlayerAC[i][ACHealthDesyncTime] / (1000/AC_HEALTH_CHECK_TIME));
				    if(sec > TIME_FOR_DESYNC_KICK)
					{
					   TimePlayer(i);
					   continue;
					}
					if(sec == (TIME_FOR_DESYNC_KICK>>2))
					{
					    SetPlayerHealth(i,ac_health);
					    PlayerAC[i][ACHealthSync] = false;
					    SendAdminNoticeMessage("PlayerDesync:%s(%d) - Health is desynced - %d seconds since desync",PlayerData[i][Name],i,(TIME_FOR_DESYNC_KICK/4));
						continue;
					}
					if(sec == (TIME_FOR_DESYNC_KICK>>1))
					{
	    				SetPlayerHealth(i,ac_health);
	    				PlayerAC[i][ACHealthSync] = false;
					    SendAdminNoticeMessage("PlayerDesync:%s(%d) - Health is desynced - %d seconds since desync",PlayerData[i][Name],i,(TIME_FOR_DESYNC_KICK/2));
						continue;
					}
				}
				else
				{
				    PlayerAC[i][ACHealthDesyncTime]  = PlayerAC[i][HealthHackCount] = 0;
				    PlayerAC[i][ACHealthSync] = true;
				}
	   		}
		}
	}
}
Concept/Idea for getting players in sync before banning them

All the health changes are server sided.

This code is from my server from 2013 so it may be outdated.
Reply
#43

Health cheating is completely obsolete dude!
https://sampforum.blast.hk/showthread.php?tid=563387

Lagcomp is annoyingly inaccurate (some shots don't do damage) any server using Lagcomp should use the weapon include or have a skinhit system with server sided health.

Reply
#44

Good job! Thanks!
Reply
#45

Boa noite
Procuro um sistema de anti-Ips do tipo:

Quando o player entra no servidor, grava o nick e o ip dele
Quando o mesmo sai e entra com um novo nick, grava o ip dele e manda uma mensagem falando de possivel ban evade.

Alguem poderia me ajuda?

Code:
english
I am looking for a good night of anti-Ips type system: When the player enters the server saves the nick and his ip When it leaves and enters with a new nickname, records the ip of it and sends a message talking about possible ban evade . Could someone help me?
Reply
#46

Efficient Simple Timer based Anti Weapon & Anti Ammo Hack
There are chances that the cheat may not be detected immediately since the code given below uses 1s timer. However, the player will eventually be identified if he is using a weapon or ammo cheat(This should happen within a few seconds). The smaller the interval, the higher is chance that every player using a weapon/ammo cheat is detected.

This code doesn't detect players who illegally get weapons unless they switch to it. In this way , this include is more efficient than the traditional weapon check methods where every slot is checked every time.

//The code can be optimized further to use char arrays
//Anti Ammo Hack works with high-fire-rate weapons

Last Updated:2013

Code:
#include <a_samp>
#include <izcmd>

#define INVALID_WEAPON 0
#define MAX_WEAPON_SLOTS 13
#define MAX_WEAPONS 47
/////////////////////////////////////////////////////////////////////////////////
static pWeaponData[MAX_PLAYERS][MAX_WEAPON_SLOTS];
static pAmmoData[MAX_PLAYERS][MAX_WEAPON_SLOTS];
static pAmmoWarns[MAX_PLAYERS];

static const WeaponSlot[MAX_WEAPONS] =
{
	0,0,1,1,1,1,1,1,1,1,10,10,10,10,10,10,8,8,8,-1,-1,-1,2,2,2,3,3,3,4,4,5,5,4,6,6,7,7,7,7,8,12,9,9,9,11,11,11
};
/////////////////////////////////////////////////////////////////////////////////
stock ac_SetPlayerAmmo(playerid,weaponslot,ammo)
{
	pAmmoData[playerid][weaponslot] = ammo;
	return SetPlayerAmmo(playerid,weaponslot,ammo);
}

#if defined _ALS_SetPlayerAmmo
    #undef SetPlayerAmmo
#else
    #define _ALS_SetPlayerAmmo
#endif
#define SetPlayerAmmo ac_SetPlayerAmmo

stock ac_GivePlayerWeapon(playerid,weaponid,ammo)
{
	pWeaponData[playerid][WeaponSlot[weaponid]] = weaponid;
	pAmmoData[playerid][WeaponSlot[weaponid]] = GetPlayerAmmo(playerid) + ammo;
	return GivePlayerWeapon(playerid,weaponid,ammo);
}

#if defined _ALS_GivePlayerWeapon
    #undef GivePlayerWeapon
#else
    #define _ALS_GivePlayerWeapon
#endif

#define GivePlayerWeapon ac_GivePlayerWeapon

stock ac_ResetPlayerWeapons(playerid)
{
	for(new i = 0; i < MAX_WEAPON_SLOTS;i++)
	{
		pWeaponData[playerid][i] = INVALID_WEAPON;
        pAmmoData[playerid][i] = 0;
	}
	return ResetPlayerWeapons(playerid);
}

#if defined _ALS_ResetPlayerWeapons
    #undef ResetPlayerWeapons
#else
    #define _ALS_ResetPlayerWeapons
#endif

#define ResetPlayerWeapons ac_ResetPlayerWeapons
/////////////////////////////////////////////////////////////////////////////////
forward WeaponCheck();
public WeaponCheck()
{
    static wid;
	for(new playerid = 0; playerid <= GetMaxPlayers(); playerid++)
	{
	    wid = GetPlayerWeapon(playerid);
	    if(wid == -1) continue; //INVALID WEAPON

		switch(GetPlayerState(playerid))
		{
		    case PLAYER_STATE_NONE,PLAYER_STATE_WASTED,PLAYER_STATE_SPAWNED: continue;
		}

     	if(pWeaponData[playerid][WeaponSlot[wid]] != wid)
		{
			new str[144],name[24],wname[24];
			GetPlayerName(playerid,name,sizeof(name));
		    GetWeaponName(wid,wname,sizeof(wname));
  			format(str,256,"%s(%d) suspected to be using Weapon Hacks (Weapon Name:%s)",name,playerid,wname);
		    SendClientMessageToAll(-1,str);
		}
		if(pAmmoData[playerid][WeaponSlot[wid]] < GetPlayerAmmo(playerid))
		{
		    if(++pAmmoWarns[playerid] == 3)
		    {
                pAmmoWarns[playerid] = 0;
			    new str[144],name[24],wname[24];
				GetPlayerName(playerid,name,sizeof(name));
			    GetWeaponName(wid,wname,sizeof(wname));
	  			format(str,256,"%s(%d) suspected to be using Ammo Hacks (Weapon Name:%s)",name,playerid,wname);
			    SendClientMessageToAll(-1,str);
			}
		}
		else pAmmoWarns[playerid] = 0;
		pAmmoData[playerid][WeaponSlot[wid]] = GetPlayerAmmo(playerid);
		continue;
	}
}
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
    pAmmoData[playerid][WeaponSlot[weaponid]]--;
    return 1;
}
/////////////////////////////////////////////////////////////////////////////////
main()
{

}
public OnGameModeInit()
{
	SetGameModeText("asdasdasd");
	AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
	SetTimer("WeaponCheck",1000,true);
	return 1;
}
public OnPlayerConnect(playerid)
{
    pAmmoWarns[playerid] = 0;
	ResetPlayerWeapons(playerid);
	return 1;
}
Reply
#47

frien i want this code - just idk where paste this code -
Reply
#48

Love this. Thanks guys, hope you will keep updating.
Reply
#49

Hi there, is anyone aware of new troll hack, which can throw players around?
Today I have enountered a cheater who used these hacks. We were having an event, when all of sudden all vehicles with players inside them started getting throwed around in insane speeds. There was a new version released which can also throw players without a vehicle.
OnPlayerStateChange dosen't detect anything, Speed Detection also comes up with nothing. It's like that hacker somehow changes velocity of other players in certain radius.
Any solution to prevent this would be helpful, because I have no idea.
Reply
#50

You can try finding out how fast the player is able to switch between enter/exit at OnPlayerUpdate.

I have a working algorithm which detects the troll which need the player to be in the vehicle. But with few modifications you can make it detect if a player enter/exits very fast.

The code is in C++.

Code:
if (PlayerList[playerid]->IsAntiCheatEnabled(CheatType::VEHICLE_TROLL_CHEAT))
	{
		switch (PlayerList[playerid]->AntiCheatStatus[CheatType::VEHICLE_TROLL_CHEAT])
		{
			case AntiCheatCommands::CHECK:
			{
				int vehicleid = GetPlayerVehicleID(playerid);
				if (vehicleid != 0)
				{
					if (PlayerList[playerid]->vehicleid != vehicleid)
					{
						int tick = GetTickCount();
						if (tick - PlayerList[playerid]->LastVehicleChangeTick < MIN_VEHICLE_SWITCH_TIME)
						{
							if (++(PlayerList[playerid]->WarningCount[CheatType::VEHICLE_TROLL_CHEAT]) >= MaxDetectionProbes[CheatType::VEHICLE_TROLL_CHEAT])
							{
								for (list <Interface *>::iterator p = InterfaceList.begin(); p != InterfaceList.end(); p++)
									(*p)->CheatCallback(playerid, CheatType::VEHICLE_TROLL_CHEAT, 0, 0, 0, 0.0);

								PlayerList[playerid]->WarningCount[CheatType::VEHICLE_TROLL_CHEAT] = 0;
							}
						}
						PlayerList[playerid]->LastVehicleChangeTick = tick;
						PlayerList[playerid]->vehicleid = vehicleid;
					}
				}
				break;
			}
			case AntiCheatCommands::SKIP:	break;
			default: PlayerList[playerid]->AntiCheatStatus[CheatType::VEHICLE_TROLL_CHEAT]--;
		}
	}
I have that in OnPlayerUpdate. The code looks huge of course but you can cut it by half (my code has alot of unnecessary stuff).

You will have to now do the tick difference checks when the vehicleid changes. My code give above does the tick difference calculations if and only if the player is in a vehicle.
Reply
#51

What does it do this protection for what is made? Or it was for 0.3x and now is unuselles?
This can be used or is old?
OnAntiCheatLagTroll
Reply
#52

The Lag Troll (don't quote me on this) CLEO still works on 0.3.7, the protection for it should still be valid.
Reply
#53

Quote:
Originally Posted by Pottus
View Post
If I see this happening on my server I will surely make a patch but it has not yet so there isn't much I want to do yet until I can confirm it myself.

@Edit 5 minute patch, make sure this is included before anything else is included in your gamemode that way this patch is first in the chain of hooks and will prevent OnPlayerConnect() from actually being processed!

pawn Code:
#include <YSI\y_iterate>

static Iterator:ConnectIter<MAX_PLAYERS>;
static LoginNames[MAX_PLAYERS][MAX_PLAYER_NAME+1];
static bool:ProcessDisconnect[MAX_PLAYERS] = { true, ...};

public OnPlayerConnect(playerid)
{
    if(Iter_Contains(ConnectIter, playerid))
    {
        // Player was already connected! (Kick, ban, etc)
        return 1;
    }
    else
    {
        Iter_Add(ConnectIter, playerid);
        GetPlayerName(playerid, LoginNames[playerid], MAX_PLAYER_NAME+1);
        foreach(new i : ConnectIter)
        {
            if(i == playerid) continue;
            if(!strcmp(LoginNames[playerid], LoginNames[i]))
            {
                // Player name was already connected! (Kick, ban, etc)
                // No need to do any disconnect code since no connection code was done
                ProcessDisconnect[playerid] = false;
                return 1;
            }
        }
    }
   
    if (funcidx("AntiDL_OnPlayerConnect") != -1) return CallLocalFunction("AntiDL_OnPlayerConnect", "i", playerid);
    return 1;
}

#if defined _ALS_OnPlayerConnect
    #undef OnPlayerConnect
#else
    #define _ALS_OnPlayerConnect
#endif
#define OnPlayerConnect AntiDL_OnPlayerConnect

forward AntiDL_OnPlayerConnect(playerid);

// Remove any iterators
public OnPlayerDisconnect(playerid, reason)
{
    Iter_Remove(ConnectIter, playerid);
    if (funcidx("AntiDL_OnPlayerDisconnect") != -1 && ProcessDisconnect[playerid] == true) return CallLocalFunction("AntiDL_OnPlayerDisconnect", "ii", playerid, reason);
    ProcessDisconnect[playerid] = true;
    return 1;
}

#if defined _ALS_OnPlayerDisconnect
    #undef OnPlayerDisconnect
#else
    #define _ALS_OnPlayerDisconnect
#endif
#define OnPlayerDisconnect AntiDL_OnPlayerDisconnect

forward AntiDL_OnPlayerDisconnect(playerid, reason);

For the guys are using Foreach
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)