Fix for raknet attack issues.
IRawPacket:20(playerid, BitStream:bs) {
new packetid, rpcid, NumberOfBitsOfData;
BS_ReadValue(bs, PR_UINT8, packetid, PR_UINT8, rpcid, PR_CUINT32, NumberOfBitsOfData);
if (packetid == 40 || (NumberOfBitsOfData >= 0x1FFFFF || NumberOfBitsOfData <= 0x80000000 || NumberOfBitsOfData < 0)) {
printf("Crasher Detected - RPCID: %d, NumberOfBitsOfData: %d", rpcid, NumberOfBitsOfData);
BanEx(playerid, "Raknet Bot");
return false;
}
return true;
}
OR
IRawPacket:20(playerid, BitStream:bs) {
new rpcid, numberOfBitsOfData;
BS_ReadValue(bs,
PR_IGNORE_BITS, 8,
PR_UINT8, rpcid,
PR_UINT32, numberOfBitsOfData
);
new bits;
BS_GetNumberOfBitsAllocated(bs, bits);
new diff = GetDifferenceValue(bits, numberOfBitsOfData);
if (numberOfBitsOfData > 8192 || diff > 512)
{
new blockIp[32];
GetPlayerIp(playerid, blockIp, sizeof blockIp);
printf("Blocked package: playerid: %d | rpcid: %d | bits used: %d | allocated bits: %d | diff: %d", playerid, rpcid, numberOfBitsOfData, bits, diff);
BlockIpAddress(blockIp, 60000);
return false;
}
return true;
}