[Tutorial] [0.3z] Fix for Bullet Crasher
#1

Originally posted there: http://forum.sa-mp.com/showpost.php?...4&postcount=14 .

-------------------

This fix is patching a hack which appeared few days ago. This hack crashes players when you are near them.

-------------------

I got this hack, and used it on a test server using a debug for OnPlayerWeaponShot, this is what it returned:
pawn Код:
OnPlayerWeaponShot(0,0,1,0,2004318080.000000,2004318080.000000,2004318080.000000)
See those huge numbers ? Yeah... they are reported by that hack to the server. It is sent only with hittype BULLET_HIT_TYPE_PLAYER.

This is the fix:

pawn Код:
public OnPlayerWeaponShot( playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ )
{
    if( hittype != BULLET_HIT_TYPE_NONE ) // Bullet Crashing uses just this hittype
    {
        if( !( -1000.0 <= fX <= 1000.0 ) || !( -1000.0 <= fY <= 1000.0 ) || !( -1000.0 <= fZ <= 1000.0 ) ) // a valid offset, it's impossible that a offset bigger than 1000 is legit (also less than -1000.0 is impossible, not used by this hack, but still, let's check for it, just for the future, who knows what hacks will appear). The object with biggest offset is having ~700-800 radius.
        {
            /*
                If you want, here you can kick the cheater
            */

            return 0; // let's desynchronize that bullet, so players won't crash
        }
    }
    return 1;
}
I bet this will be patched in a future Release of 0.3z, but until then, feel free to use that fix.

-------------------

It's not really a tutorial, but I posted it there because in that topic (link in the first row there) almost nobody would see it.
Reply
#2

Sweet! Thanks for the patch.
Reply
#3

Mind if I add this patch to here https://sampforum.blast.hk/showthread.php?tid=504244
Reply
#4

Well, I would add in that you highly recommend banning the player, as I would never ever do anything but deny them access from the server. I would also advise reporting debug information to the server in the rare cause that this bugs.

Anyway, nice patch.
Reply
#5

Quote:
Originally Posted by Pottus
Посмотреть сообщение
I would preffer a link to this topic.

Quote:
Originally Posted by DamonD
Посмотреть сообщение
Well, I would add in that you highly recommend banning the player, as I would never ever do anything but deny them access from the server. I would also advise reporting debug information to the server in the rare cause that this bugs.

Anyway, nice patch.
It isn't giving false positives so you can ban player everytime you want.

The player size is something like 2x1m, so in which case the offsets can be bigger than 20.0 ? no case. I think that the maximum offset can be reduced from 20 to 5 still without giving false positives. But 20 is better, just in case.

I highly recommend to every server owner to use this fix, as it can crash every player on every server.
Reply
#6

Just implemented this to my script, thanks a lot man, much appreciated.
Reply
#7

This actually do kick the crasher [ player ] but as an result of implementing this thing in our gamemode, make the bullets go useless.
The players can't give damages to each other.
Reply
#8

Quote:
Originally Posted by IstuntmanI
Посмотреть сообщение
I would preffer a link to this topic.

It isn't giving false positives so you can ban player everytime you want.
I could put a link but I need to modify the code because you didn't use any hooking.
Reply
#9

Dosent work, pls fix it asap, it sends false alarms

Код:
public OnPlayerWeaponShot( playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ )
{
    if( hittype == BULLET_HIT_TYPE_PLAYER ) // Bullet Crashing uses just this hittype
    {
        if( !( 0 <= fX <= 20.0 ) || !( 0 <= fY <= 20.0 ) || !( 0 <= fZ <= 20.0 ) ) // a valid offset, it's impossible that a offset bigger than 20 is legit (also less than 0 is impossible, not used by this hack, but still, let's check for it, just for the future, who knows what hacks will appear)
        {
          SendClientMessage(playerid, COLOR_RED, "AntiCheat: You have been kicked (Reason: crasher Detected)");
          return 0; // let's desynchronize that bullet, so players won't crash
        }
    }
    return 1;
}
i didnt used kick or ban just used a client message
and it sends me that i am using the hack
Reply
#10

@Pottus: They can add this directly in their gamemode in their OnPlayerWeaponShot callback, no need for variables or other things, it's pretty easy.

Quote:
Originally Posted by Arjanz
View Post
Dosent work, pls fix it asap, it sends false alarms

Code:
public OnPlayerWeaponShot( playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ )
{
    if( hittype == BULLET_HIT_TYPE_PLAYER ) // Bullet Crashing uses just this hittype
    {
        if( !( 0 <= fX <= 20.0 ) || !( 0 <= fY <= 20.0 ) || !( 0 <= fZ <= 20.0 ) ) // a valid offset, it's impossible that a offset bigger than 20 is legit (also less than 0 is impossible, not used by this hack, but still, let's check for it, just for the future, who knows what hacks will appear)
        {
          SendClientMessage(playerid, COLOR_RED, "AntiCheat: You have been kicked (Reason: crasher Detected)");
          return 0; // let's desynchronize that bullet, so players won't crash
        }
    }
    return 1;
}
i didnt used kick or ban just used a client message
and it sends me that i am using the hack
Quote:
Originally Posted by IstuntmanI
View Post
Can you give me a debug of OnPlayerWeaponShot's parameters when it sends false alarms ? I don't see how the offset X, Y, Z can be bigger than 20. You are the only one who said that this is giving false positives.

EDIT: I guess that the offset CAN be less than 0 (Now that I think more of it, it seems possible, the 0,0,0 is in the center of the player. I changed the minimum offsets to -20. It should work perfectly now.

http://forum.sa-mp.com/showthread.ph...26#post3186426

Yes, this is now perfect, feel free to ban them now.
Thanks for reporting.
Reply
#11

StuntMan
https://sampforum.blast.hk/showthread.php?tid=535656
Have a look here.
Reply
#12

Quote:
Originally Posted by iAnonymous
View Post
Update your code, I've updated it as I said in the last post. It is now perfect.
Reply
#13

I tested it,and now it's clearly perfect!
Reply
#14

According to me whole code is wrong....
Nice idea but some mistakes...
You say "OffSet" but its coords of bullet hit...
It worked for you beacuse you must have tested it in Blue berry farm which coords are 0.0,0.0,0.0 the code u used will work there and that not accurate
use this one instead --
pawn Code:
public OnPlayerWeaponShot( playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ )
{

    if( hittype == BULLET_HIT_TYPE_PLAYER ) // Bullet Crashing uses just this hittype
    {
new Float:pos[3];
GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
fX = pos[0] <= fX ? fX-pos[0] : fX+pos[0];
fY = pos[1] <= fY ? fY-pos[1] : fY+pos[1];
fZ= pos[2] <= fZ ? fZ-pos[2] : fZ+pos[2];

        if( !( -20.0 <= fX <= 20.0 ) || !( -20.0 <= fY <= 20.0 ) || !( -20.0 <= fZ <= 20.0 ) ) // a valid offset, it's impossible that a offset bigger than 20 is legit (also less than -20.0 is impossible, not used by this hack, but still, let's check for it, just for the future, who knows what hacks will appear)
        {
            /*
                If you want, here you can kick the cheater
            */

            return 0; // let's desynchronize that bullet, so players won't crash
        }
    }
    return 1;
}
Code needs to be tested though*
Correct me if i am wrong.....
EDIT: This is wrong ;/
Reply
#15

Quote:
Originally Posted by BroZeus
View Post
According to me whole code is wrong....
Nice idea but some mistakes...
You say "OffSet" but its coords of bullet hit...
It worked for you beacuse you must have tested it in Blue berry farm which coords are 0.0,0.0,0.0 the code u used will work there and that not accurate
use this one instead --
pawn Code:
public OnPlayerWeaponShot( playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ )
{

    if( hittype == BULLET_HIT_TYPE_PLAYER ) // Bullet Crashing uses just this hittype
    {
new Float:pos[3];
GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
fX = pos[0] <= fX ? fX-pos[0] : fX+pos[0];
fY = pos[1] <= fY ? fY-pos[1] : fY+pos[1];
fZ= pos[2] <= fZ ? fZ-pos[2] : fZ+pos[2];

        if( !( -20.0 <= fX <= 20.0 ) || !( -20.0 <= fY <= 20.0 ) || !( -20.0 <= fZ <= 20.0 ) ) // a valid offset, it's impossible that a offset bigger than 20 is legit (also less than -20.0 is impossible, not used by this hack, but still, let's check for it, just for the future, who knows what hacks will appear)
        {
            /*
                If you want, here you can kick the cheater
            */

            return 0; // let's desynchronize that bullet, so players won't crash
        }
    }
    return 1;
}
Code needs to be tested though*
Correct me if i am wrong.....
https://sampwiki.blast.hk/wiki/OnPlayerWeaponShot

Look at the first note. Before saying something, please be sure. Check the wiki first and test it yourself then.
Reply
#16

Quote:

Others: the fX, fY and fZ are offsets relative to the hitid.

Well my code is wrong didn't read the warning box..
Sorry for false post...
Reply
#17

Very useful tutorial, but i've heard that using your code won't let normal players damage each others?
Reply
#18

This hack was used a long, long time ago on our server. The corresponding log can be found here: http://pastebin.com/p4cdL9JT
I found it easier to immediately kick if weaponid is reported as 0, or if the hit positions are all reported as 0. Very rarely a false positive sneaks in, often during a gameode change, but overall it works very well.
Reply
#19

Quote:
Originally Posted by Vince
View Post
This hack was used a long, long time ago on our server. The corresponding log can be found here: http://pastebin.com/p4cdL9JT
I found it easier to immediately kick if weaponid is reported as 0, or if the hit positions are all reported as 0. Very rarely a false positive sneaks in, often during a gameode change, but overall it works very well.
I can send fake bullet data with another weapon (not only with 0), and with other shit positions, these will crash too AFAIK.
Reply
#20

Isn't there also a way to crash players with some sort of knife bullet data? Or is this what it fixes?
Reply


Forum Jump:


Users browsing this thread: 7 Guest(s)