SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Includes

Reply
 
Thread Tools Display Modes
Old 03/04/2014, 12:54 AM   #1
Pottus
Godfather
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 5,316
Reputation: 1171
Default Southclaw's & Pottus's Anti-cheat patches

Anti-cheat patches


Objective:
Southclaw and I have decided to keep a resource of anti-hack patches which can be easily integrated into your script. Every patch will follow some basic guidelines for implementation, as well as a description of the cheat which the patch prevents. Please keep in mind these are not designed to be an anti-cheat system addressing a complete system is really on an individual basis and often directly needs to be integrated into the gamemode it's self instead this patches are meant to build on your anti-cheat system by providing a means of quick implementation.

Guidelines:
- Patches are to be designed to be included BEFORE YSI
- Patches will contain ALS hooking only
- Patches will contain a callback with the following prefix OnAntiCheat ..... () ex OnAntiCheatAutoAim(playerid)
- Patches will have a description outlining the anticheat
- Patches can use y_iterate

__________________________________________________ ________________________________________________

Patches
__________________________________________________ ________________________________________________


Name: Autobullet
Type: Animation / Weapon exploit
Description: Modifies the behavior of walking weapons allowing them to be used like running weapons it also skips the reload animations.
Detection Method: There is a velocity range in which this exploit happens however it is also possible to achieve the same velocity in some circumstances by using the slide-shoot-run bug that is why there is player key checks in place to make sure that does not happen. A player receiving 3 infractions will result in OnAntiCheatAutoBullet() being called.
Callback: public OnAntiCheatAutoBullet(playerid, weaponid)


Code:
// Anti autobullet exploit detection by [uL]Pottus
#define             MAX_AUTOBULLET_INFRACTIONS          3
#define             AUTOBULLET_RESET_DELAY              30

static AutoBulletInfractions[MAX_PLAYERS];
static LastInfractionTime[MAX_PLAYERS];

forward OnAntiCheatAutoBullet(playerid, weaponid);

public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
	if(!IsPlayerInAnyVehicle(playerid))
	{
		switch(weaponid)
		{
			case 27, 23, 25, 29, 30, 31, 33, 24, 38:
			{
				if(CheckSpeed(playerid))
				{
					if(gettime() - LastInfractionTime[playerid] >= AUTOBULLET_RESET_DELAY) AutoBulletInfractions[playerid] = 1;
					else AutoBulletInfractions[playerid]++;
					LastInfractionTime[playerid] = gettime();

					if(AutoBulletInfractions[playerid] == MAX_AUTOBULLET_INFRACTIONS)
					{
                        AutoBulletInfractions[playerid] = 0;
						CallLocalFunction("OnAntiCheatAutoBullet", "ii", playerid, weaponid);
						return 0;
					}
				}
			}
		}
	}
	
	if (funcidx("ACAutoB_OnPlayerWeaponShot") != -1)
  	{
    	return CallLocalFunction("ACAutoB_OnPlayerWeaponShot", "iiiifff", playerid, weaponid, hittype, hitid, fX, fY, fZ);
  	}
  	return 1;
}

#if defined _ALS_OnPlayerWeaponShot
	#undef OnPlayerWeaponShot
#else
	#define _ALS_OnPlayerWeaponShot
#endif
#define OnPlayerWeaponShot ACAutoB_OnPlayerWeaponShot

forward ACAutoB_OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ);

public OnPlayerDisconnect(playerid, reason)
{
	AutoBulletInfractions[playerid] = 0;

	if (funcidx("ACAutoB_OnPlayerDisconnect") != -1)
  	{
    	return CallLocalFunction("ACAutoB_OnPlayerDisconnect", "ii", playerid, reason);
  	}
  	return 1;
}

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

forward ACAutoB_OnPlayerDisconnect(playerid, reason);


static CheckSpeed(playerid)
{
    new Keys,ud,lr;
    GetPlayerKeys(playerid,Keys,ud,lr);

	if(ud == KEY_UP && lr != KEY_LEFT && lr != KEY_RIGHT)
	{
		new Float:Velocity[3];
		GetPlayerVelocity(playerid, Velocity[0], Velocity[1], Velocity[2]);
	    Velocity[0] = floatsqroot( (Velocity[0]*Velocity[0])+(Velocity[1]*Velocity[1])+(Velocity[2]*Velocity[2]));
		if(Velocity[0] >= 0.11 && Velocity[0] <= 0.13) return 1;
	}
	return 0;
}

Name: Connection spoofing
Type: Server exploit
Description: It was possible in 0.3x to spoof a connection to a server when a player is already connected, this will result in the players name being changed to the spoofed name unprotected servers could potentially have player accounts overwritten. It is currently unknown if this exploit exists in 0.3z however it assumed that it still could potentially happen in any case this patch provides protection by preventing OnPlayerConnect() from being called to the rest of the script. IMPORTANT Make sure this is placed before any other includes that use OnPlayerConnect!!!!
Detection Method: When a player connects a variable is set that they are connected, if another connection happens on the same ID while they are still connected this is considered a spoof.
Callback: public OnAntiCheatPlayerSpoof(playerid)

Edit - I have confirmed this as still possible.


Code:
// Anti connection spoofing patch by [uL]Pottus

forward OnAntiCheatPlayerSpoof(playerid);

static bool:PlayerConnected[MAX_PLAYERS];
static PlayerNames[MAX_PLAYERS][MAX_PLAYER_NAME];

public OnPlayerConnect(playerid)
{
	// User was already connected cheat detected
	if(PlayerConnected[playerid])
	{
		SetPlayerName(playerid, PlayerNames[playerid]);
		CallLocalFunction("OnAntiCheatPlayerSpoof", "i", playerid);
		return 1;
	}
	else
	{
		GetPlayerName(playerid, PlayerNames[playerid], MAX_PLAYER_NAME);
		PlayerConnected[playerid] = true;
	}

	if (funcidx("AntiSpoof_OnPlayerConnect") != -1)
  	{
    	return CallLocalFunction("AntiSpoof_OnPlayerConnect", "i", playerid);
  	}
  	return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
	PlayerConnected[playerid] = false;

	if (funcidx("AntiSpoof_OnPlayerDisconnect") != -1)
  	{
    	return CallLocalFunction("AntiSpoof_OnPlayerDisconnect", "ii", playerid, reason);
  	}
  	return 1;
}


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

forward AntiSpoof_OnPlayerConnect(playerid);

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

forward AntiSpoof_OnPlayerDisconnect(playerid, reason);

Name: NPC Connection spoofing
Type: Server exploit
Description: This is very similar to connection spoofing and was an issue in 0.3x it is assumed that it is still possible in the new SAMP version. It will result in faked NPC connections to the server. IMPORTANT Make sure this is placed before any other includes that use OnPlayerConnect!!!!
Detection Method: All real NPC connections can only occur on IP: 127.0.0.1 if the IP is different then it is a spoofed NPC connection
Callback: public OnAntiCheatNPCSpoof(playerid)


Code:
// Anti NPC spoof by [uL]Pottus

forward OnAntiCheatNPCSpoof(playerid);

public OnPlayerConnect(playerid)
{
	if(IsPlayerNPC(playerid))
	{
		new ip[16];
		GetPlayerIp(playerid, ip, sizeof(ip));
		if (!!strcmp(ip, "127.0.0.1"))
		{
			new name[MAX_PLAYER_NAME];
			format(name, sizeof(name), "%i", gettime());
			SetPlayerName(playerid, name);
			CallLocalFunction("OnAntiCheatNPCSpoof", "i", playerid);
			return 1;
		}
	}
	if (funcidx("AntiNPC_OnPlayerConnect") != -1)
  	{
    	return CallLocalFunction("AntiNPC_OnPlayerConnect", "i", playerid);
  	}
  	return 1;
}

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

forward AntiNPC_OnPlayerConnect(playerid);

Name: Lag Troll
Type: Vehicle Cheat
Description: This cheat appears to send fake packets to the server in rapid succession by copying the position of the targeted vehicle the result is a lag type effect.
Callback: public OnAntiCheatLagTroll(playerid)


Code:
#define         MAX_VEHICLE_ID_CHANGES          5

static LastVehicleID[MAX_PLAYERS];
static VehicleIDChanges[MAX_PLAYERS];
static VehicleIDChangeTime[MAX_PLAYERS];

forward OnAntiCheatLagTroll(playerid);

public OnPlayerUpdate(playerid)
{
	new vid = GetPlayerVehicleID(playerid);
	if(vid > 0)
	{
	    if(vid != LastVehicleID[playerid])
	    {
			if(GetTickCount() - VehicleIDChangeTime[playerid] < 5000)
			{
	        	VehicleIDChanges[playerid]++;
	            if(VehicleIDChanges[playerid] > MAX_VEHICLE_ID_CHANGES)
	            {
                    CallLocalFunction("OnAntiCheatLagTroll", "i", playerid);
					return 0;
	            }
			}
			else VehicleIDChanges[playerid] = 1;
	    }
	    LastVehicleID[playerid] = vid;
        VehicleIDChangeTime[playerid] = GetTickCount();
    }

    if (funcidx("AntiLT_OnPlayerUpdate") != -1)
    {
        return CallLocalFunction("AntiLT_OnPlayerUpdate", "i", playerid);
    }
    return 1;
}

#if defined _ALS_OnPlayerUpdate
    #undef OnPlayerUpdate
#else
    #define _ALS_OnPlayerUpdate
#endif
#define OnPlayerUpdate AntiLT_OnPlayerUpdate

forward AntiLT_OnPlayerUpdate(playerid);




Name: Server Freezer - Obsolete download the new SAMP server update
http://forum.sa-mp.com/showthread.php?t=506214

Last edited by Pottus; 01/11/2014 at 06:33 AM.
Pottus is offline   Reply With Quote
Old 03/04/2014, 02:36 AM   #2
RenovanZ
Gangsta
 
RenovanZ's Avatar
 
Join Date: Jul 2012
Location: Jogjakarta, Indonesia
Posts: 599
Reputation: 32
Default Re: Southclaw's & Pottus's Anti-cheat patches

Really Nice! Good Job, Southclaw & Pottus!
Gonna use this.
__________________
__________________________________________________
My Work(s)
__________________________________________________

RenovanZ is offline   Reply With Quote
Old 03/04/2014, 02:42 AM   #3
Whitetiger
Huge Clucker
 
Whitetiger's Avatar
 
Join Date: Nov 2007
Location: Greenville, NC, USA
Posts: 462
Reputation: 130
Default Re: Southclaw's & Pottus's Anti-cheat patches

you should make this a community driven solution on github, with changes encouraged by the community (see fixes.Inc). can make a quick include to patch a bunch of hacks
__________________
GitHub

Author of SA-MP AC

Whitetiger is offline   Reply With Quote
Old 03/04/2014, 02:57 AM   #4
Pottus
Godfather
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 5,316
Reputation: 1171
Default Re: Southclaw's & Pottus's Anti-cheat patches

Quote:
Originally Posted by Whitetiger View Post
you should make this a community driven solution on github, with changes encouraged by the community (see fixes.Inc). can make a quick include to patch a bunch of hacks
That is a good idea, but the issue with that is implementation, were not really releasing a full AC system rather patches to integrate into gamemodes. It will be up to the scripter to determine how they want to handle specific events. I still have a lot of patches to put up yet
Pottus is offline   Reply With Quote
Old 03/04/2014, 04:50 AM   #5
awsomedude
Big Clucker
 
awsomedude's Avatar
 
Join Date: Oct 2011
Posts: 193
Reputation: 38
Default Re: Southclaw's & Pottus's Anti-cheat patches

Good job both of you
awsomedude is offline   Reply With Quote
Old 03/04/2014, 04:54 AM   #6
Niko_boy
High-roller
 
Niko_boy's Avatar
 
Join Date: Aug 2010
Location: Somewhere i belong
Posts: 1,435
Reputation: 138
Default Re: Southclaw's & Pottus's Anti-cheat patches

Nice work guys.
__________________
$$$ If anyone NEED A SCRIPTER for:
  • DM/TDM/Freeroam/Stunt server, filterscripts or Bug fixing.or some general mapping. Above all any of the logos and banners or signature sorta stuff aswell.At some cheap and worth-full prices.
can Contact me for more info or a deal.
•••[CLOSED]LCS•Freeroam•DM•Stunts•••AutoArena [0.3z][No SkinShot][sixtytiger.com]Want a decent Attack Defend Gamemode?
N/A176.31.229.148:7830Get This! Attack-Defend(v2.3.1)
Niko_boy is offline   Reply With Quote
Old 03/04/2014, 07:07 AM   #7
Lorenc_
High-roller
 
Lorenc_'s Avatar
 
Join Date: Jan 2010
Location: Australia
Posts: 4,278
Reputation: 1115
Default Re: Southclaw's & Pottus's Anti-cheat patches

Nice job!

Never encountered the second one, but that's a strange but effective fix.
__________________


Join the best Cops And Robbers in SA-MP, today. svr.irresistiblegaming.com:7777
Lorenc_ is offline   Reply With Quote
Old 03/04/2014, 09:12 AM   #8
iZN
High-roller
 
Join Date: Jun 2010
Location: Pakistan
Posts: 2,469
Reputation: 565
Default Re: Southclaw's & Pottus's Anti-cheat patches

Ah, you were discussing at the IRC about the patches. Nice work!
__________________
iZN is offline   Reply With Quote
Old 03/04/2014, 01:36 PM   #9
Kar
High-roller
 
Kar's Avatar
 
Join Date: May 2010
Location: Black Asylum
Posts: 3,154
Reputation: 450
Default Re: Southclaw's & Pottus's Anti-cheat patches

Sorry guys, the first one has ALOT of false alarms.

All you have to do to throw the auto bullet thing

is keep firing your weapon and move left and right around constantly and it throws the autobullet detection

Tested with deagle and combat shotgun
Kar is offline   Reply With Quote
Old 03/04/2014, 02:03 PM   #10
Pottus
Godfather
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 5,316
Reputation: 1171
Default Re: Southclaw's & Pottus's Anti-cheat patches

Quote:
Originally Posted by Kar View Post
Sorry guys, the first one has ALOT of false alarms.

All you have to do to throw the auto bullet thing

is keep firing your weapon and move left and right around constantly and it throws the autobullet detection

Tested with deagle and combat shotgun
Thanks, I'll test it out again and see if I can get it to happen going to comment it out for the time being. Okay now I see how that happens
Pottus is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] [Anti-Cheat]HP,Money Cheat and Armour Cheat Meow22 Filterscripts 23 03/03/2014 03:38 PM
[FilterScript] [K.A.S] Knight's Anti Cheat (Anti: Armas, Spam, DB, MaxPing, Palavrões, Money Hack) The Knight Lançamentos/Releases 5 05/05/2011 04:41 AM


All times are GMT. The time now is 05:09 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.