[Release]System antibot

11/22/2019 02:07 redbull2905#1
There may be some flaws in the code but the system is functional. Do not hesitate to improve it if it is in your skills. (code create by Worldie)

1: Opennos.GameObject.Packet.CommandPacket

Code:
using OpenNos.Core;
using OpenNos.Domain;

namespace OpenNos.GameObject.CommandPackets
{
    [PacketHeader("$Bot", PassNonParseablePacket = true, Authorities = new AuthorityType[]{ AuthorityType.User })]
    public class BotPacket : PacketDefinition
    {
        [PacketIndex(0)] public short Identificator { get; set; }

        #region Methods

        public static string ReturnHelp()
        {
            return "$Bot";
        }

        #endregion
    }

}
2:Opennos.Handler.CommandPacketHandler
Code:
        public void BotPacket(BotPacket packet)
        {
            if (Session.Character.AntiBotIdentificator == -1)
            {
                return;
            }

            if (packet.Identificator != Session.Character.AntiBotIdentificator && Session.Character.AntiBotCount > 0)
            {
                Session.Character.AntiBotCount--;

                if (Session.Character.AntiBotCount == 0)
                {
                    LogHelper.Instance.InsertAntiBotLog(Session, false);
                    Session?.Disconnect();
                    CommunicationServiceClient.Instance.KickSession(Session.Account.AccountId, Session.SessionId);
                    return;
                }

                Session.SendPacket(Session.Character.GenerateSay($"Les codes d'identification ne correspondent pas ! {Session.Character.AntiBotCount} essais restants !", 11));
                return;
            }

            Session.SendPacket($"evnt 3 1 1800 1800");
            Session.SendPacket(Session.Character.GenerateSay($"Vous pouvez continuer à jouer normalement", 12));
            Session.Character.AntiBotIdentificator = -1;
            Session.Character.AntiBotCount = ServerManager.Instance.MaxCodeAttempts;
            Session.Character.AntiBotMessageInterval?.Dispose();
            Session.Character.AntiBotObservable?.Dispose();
        }
3: Opennos.Handler.BasicPacketHandler
Code:
            if (Session.Account.Authority < AuthorityType.Administrator && ServerManager.Instance.Configuration.AntiBotEnabled)
            {
                Session.Character.AntiBotCount = ServerManager.Instance.Configuration.MaxCodeAttempts;
                Observable.Interval(TimeSpan.FromHours(ServerManager.Instance.Configuration.AutoKickInterval)).Subscribe(s =>
                {
                    Session.Character.AntiBotIdentificator = (short)ServerManager.RandomNumber(1000, 10000);
                    Session.SendPacket($"evnt 3 0 {ServerManager.Instance.Configuration.TimeBeforeAutoKick * 600} {ServerManager.Instance.Configuration.TimeBeforeAutoKick * 600}");
                    Session.SendPacket($"say 1 0 10 Entrez $Bot {Session.Character.AntiBotIdentificator} pour continuer à jouer.");
                    Session.SendPacket($"msg 2 Entrez $Bot {Session.Character.AntiBotIdentificator} pour continuer à jouer.");

                    Session.Character.AntiBotMessageInterval = Observable.Interval(TimeSpan.FromHours(1)).Subscribe(token =>
                    {
                        Session.SendPacket($"say 1 0 10 Entrez $Bot pour continuer à jouer.");
                        Session.SendPacket($"msg 2 Entrez $Bot pour continuer à jouer.");
                    });



                    Session.Character.AntiBotObservable = Observable.Timer(TimeSpan.FromMinutes(ServerManager.Instance.Configuration.TimeBeforeAutoKick)).Subscribe(ValueTuple =>
                    {
                        Session.Character.AntiBotMessageInterval?.Dispose();
                        Session?.Disconnect();
                        CommunicationServiceClient.Instance.KickSession(Session.Account.AccountId, Session.SessionId);
                    });
                });

            }
4:Opennos.Master.Server
Code:
    <!-- maximum de tentative antibot -->
    <add key="MaxCodeAttempts" value="5" />
    <!-- Intervalles d'apparition antibot -->
    <add key="AutoKickInterval" value="1" />
    <!-- Temps avant d'être kick antibot -->
    <add key="TimeBeforeAutoKick" value="10" />
    <!-- activé ou désactivé antibot -->
    <add key="AntiBotEnabled" value="true" />
5:Opennos.Master.Server.MsManager
Code:
                TimeBeforeAutoKick = byte.Parse(ConfigurationManager.AppSettings["TimeBeforeAutoKick"]),
                AutoKickInterval = byte.Parse(ConfigurationManager.AppSettings["AutoKickInterval"]),
                MaxCodeAttempts = byte.Parse(ConfigurationManager.AppSettings["MaxCodeAttempts"]),
                AntiBotEnabled = bool.Parse(ConfigurationManager.AppSettings["AntiBotEnabled"])
11/22/2019 02:19 Worldie#2
Copy pasted by Worldie dev by Elendan *
11/22/2019 02:21 MANUEL PERES#3
Here : [Only registered and activated users can see links. Click Here To Register...] :kappa:
11/22/2019 02:25 redbull2905#4
oh yeah I did not know :kappa:
11/22/2019 22:33 Limoo#5
What happens if I keep sending $bot with packetlogger?
11/23/2019 07:24 Nortank#6
=>
<add key="MaxCodeAttempts" value="5" />

The problem is that it can only block public bot, but since you are coding one by yourself, it is really simple to bypass it
11/23/2019 12:43 erixor#7
Quote:
Originally Posted by Limoo View Post
What happens if I keep sending $bot with packetlogger?
Nothing, a random value is generated each time, so you have to enter $Bot [RandomNumber]

It can easily be countered by any not public bot, just by reading the msg packet
11/26/2019 11:52 Nagisa Shiota#8
Quote:
Originally Posted by erixor View Post
Nothing, a random value is generated each time, so you have to enter $Bot [RandomNumber]

It can easily be countered by any not public bot, just by reading the msg packet
Yes but is easy to do xd
11/26/2019 12:37 erixor#9
Quote:
Originally Posted by Nagisa Shiota View Post
Yes but is easy to do xd
[Only registered and activated users can see links. Click Here To Register...]

And then you're saying it's easy to do a bot that counters this ? ._.