コード例 #1
0
        /// <summary>
        /// Creates and attempts to start an AOSServer with
        /// the game specific config.
        /// </summary>
        public static bool Initialize(int maxConnections, IPEndPoint endPoint, IPEndPoint receiveEndPoint = null)
        {
            GlobalNetwork.SetupLogging();

            NetServerConfig config = new NetServerConfig();

            config.MaxConnections       = maxConnections;
            config.DontApplyPingControl = true;

            AOSServer server = new AOSServer(config);

            bool success = server.Start(endPoint);

            if (success)
            {
                GlobalNetwork.IsServer    = true;
                GlobalNetwork.IsConnected = true;
            }

            return(success);
        }
コード例 #2
0
        /// <summary>
        /// Creates and attempts to start an AOSClient with
        /// the game specific config.
        /// </summary>
        public static bool Initialize()
        {
            GlobalNetwork.SetupLogging();

            ConfigSection netSection = Program.ConfigFile.GetSection("Network");
            IPAddress     bindIp     = null;
            int?          bindPort   = null;

            if (netSection != null)
            {
                bool autoFindEndpoint = netSection.GetBoolean("auto-find-endpoint") ?? true;
                if (!autoFindEndpoint)
                {
                    IPAddress.TryParse(netSection.GetString("bind-to-ip"), out bindIp);
                    bindPort = netSection.GetInteger("bind-to-port");
                }
            }

            if (bindIp == null)
            {
                bindIp = NetHelper.GetInternalIP();
            }
            if (!bindPort.HasValue)
            {
                bindPort = 0;
            }


            NetClientConfig config = new NetClientConfig();

            config.DontApplyPingControl = true;

            AOSClient client = new AOSClient(config);

            return(client.Start(new IPEndPoint(bindIp, bindPort.Value)));
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: FarisFreak/PointBlankGSP
        public static void Main(string[] args)
        {
            Config.load();
            Console.Title = "PointBlank Server Auth";
            CLogger.getInstance().form();
            GlobalConsole.Load();
            GlobalTable.Load();
            GlobalDate.Load();
            GlobalNetwork.Load();
            while (true)
            {
                Thread.Sleep(200);
                Console.Write("> ");
                try
                {
                    string command = Console.ReadLine();
                    switch (command)
                    {
                    case "stop":
                    case "close":
                    case "exit":
                    {
                        CLogger.getInstance().write(command);
                        CLogger.getInstance().red("END OF LOG");
                        Thread.Sleep(200);
                        Process.GetCurrentProcess().CloseMainWindow();
                        break;
                    }

                    case "reload shop":
                    {
                        CLogger.getInstance().write(command);
                        CLogger.getInstance().debug("[Reload] ShopManager");
                        ShopInfoManager.getInstance();
                        Console.ResetColor();
                        break;
                    }

                    case "clear":
                    {
                        Console.Clear();
                        break;
                    }

                    case "help":
                    {
                        CLogger.getInstance().write(command);
                        CLogger.getInstance().cyan("Help Command: ");
                        CLogger.getInstance().debug("* stop / close / exit - Close Server.");
                        CLogger.getInstance().debug("* reload shop         - Reload Shop.");
                        CLogger.getInstance().debug("* clear               - Clear Console");
                        CLogger.getInstance().debug("* restart             - Restart Server.");
                        Console.ResetColor();
                        break;
                    }

                    case "restart":
                    {
                        var location = Assembly.GetExecutingAssembly().Location;
                        Process.Start(location);
                        Environment.Exit(0);
                        break;
                    }

                    default:
                    {
                        CLogger.getInstance().write(command);
                        CLogger.getInstance().warning("Invalid command!");
                        break;
                    }
                    }
                }
                catch
                {
                }
            }
        }
コード例 #4
0
        public async Task <bool> Execute(Message message, TelegramBotClient client)
        {
            long chatId = message.Chat.Id;
            User user   = await _unitOfWork.UserAccessRepository.GetUserByChatId(chatId);

            if (user != null && user.isAuthorized)
            {
                string[] parameters = message.Text.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                if (parameters[0] == Name && parameters[2] == "-w")
                {
                    LinuxSystem linuxSystem = await _unitOfWork.LinuxRepository.GetByIdAsync(user.Id);

                    CurrentDirectory currentDirectory = await _unitOfWork.CurrentDirectoryRepository.GetByIdAsync(linuxSystem.CurrentDirectoryId);

                    Directory directory     = _unitOfWork.DirectoryRepository.GetInDirectory(await _unitOfWork.DirectoryRepository.GetByIdAsync(currentDirectory.DirectoryId));
                    string    fileExtension = "";
                    string    fileName      = "";

                    if (!parameters[1].Contains("/"))
                    {
                        fileExtension = parameters[1].Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries)[1];
                        fileName      = parameters[1];
                    }
                    else
                    {
                        string filePath = parameters[1].Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries).Last();
                        fileExtension = filePath.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries)[1];
                        fileName      = filePath;
                    }


                    File handShakeFile = directory.Files.FirstOrDefault(f => f.Name == parameters[1]);
                    File passwordFile  = null;
                    if (fileExtension == "cap" && handShakeFile != null)
                    {
                        if (parameters[3].Contains("/"))
                        {
                            passwordFile = await _unitOfWork.FileRepository.GetByPath(parameters[3]);
                        }
                        else
                        {
                            passwordFile = directory.Files.FirstOrDefault(f => f.Name == parameters[3]);
                        }

                        if (passwordFile != null)
                        {
                            WifiModule wifiModule = await _unitOfWork.WifiModuleRepository.GetByIdAsync(linuxSystem.WifiModuleId);

                            IEnumerable <Wifi> wifis = _unitOfWork.WifiRepository.GetByWifisModuleId(wifiModule.Id);

                            if (wifis.Count() > 0)
                            {
                                string password = Encoding.UTF8.GetString(Convert.FromBase64String(handShakeFile.Text));
                                if (passwordFile.Text.Contains(password))
                                {
                                    Wifi attackWifi = null;
                                    foreach (var wifi in wifis)
                                    {
                                        await client.SendTextMessageAsync(chatId, $"<code>[{DateTime.UtcNow}] Подбор пароля...</code>", ParseMode.Html);

                                        if (wifi.Password == password)
                                        {
                                            attackWifi = wifi;
                                            break;
                                        }
                                    }

                                    if (attackWifi != null)
                                    {
                                        linuxSystem.IsConnectedTheInternet = true;
                                        GlobalNetwork globalNetwork = await _unitOfWork.GlobalNetworkRepository.GetByIdAsync(attackWifi.GlobalNetworkId);

                                        if (globalNetwork != null)
                                        {
                                            user.GlobalNetwork = globalNetwork;
                                            await client.SendTextMessageAsync(chatId, $"<code>Пароль успешно найден, вы подсойдены к {attackWifi.Name}\nСкорость: {attackWifi.Speed}мб/с</code>", ParseMode.Html);

                                            wifiModule.ModuleMode = ModuleMode.Managed;
                                            wifiModule.Name       = "wlan0";

                                            await _unitOfWork.SaveAsync();

                                            return(true);
                                        }
                                        else
                                        {
                                            await client.SendTextMessageAsync(chatId, $"<code>Ошибка подлючения...</code>", ParseMode.Html);

                                            return(false);
                                        }
                                    }
                                }

                                await client.SendTextMessageAsync(chatId, "<code>Пароль не найдено</code>", ParseMode.Html);
                            }

                            return(false);
                        }

                        await client.SendTextMessageAsync(chatId, "<code>Файл с паролями не найден. Перейдите в папку с этим файлом или укажите путь.</code>", ParseMode.Html);

                        return(false);
                    }
                    else
                    {
                        await client.SendTextMessageAsync(chatId, "<code>Файл не найден. Перейдите в папку с этим файлом или укажите путь..</code>", ParseMode.Html);

                        return(false);
                    }
                }
                else
                {
                    await client.SendTextMessageAsync(chatId, "<code>Неверная команда</code>", ParseMode.Html);

                    return(false);
                }
            }

            return(false);
        }