Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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)
            {
                LinuxSystem linuxSystem = await _unitOfWork.LinuxRepository.GetByIdAsync(user.Id);

                if (linuxSystem != null && linuxSystem.IsConnectedTheInternet)
                {
                    string[] commandParams = message.Text.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                    if (commandParams[0] == Name && !string.IsNullOrWhiteSpace(commandParams[1]) &&
                        commandParams[2] == "-P")
                    {
                        File passwordFile = await _unitOfWork.FileRepository.GetByPath(commandParams[3]);

                        if (commandParams.Length == 5)
                        {
                            string[] sshParams = commandParams[4].Split(new string[] { "//" }, StringSplitOptions.RemoveEmptyEntries);
                            if (sshParams.Length == 2)
                            {
                                if (passwordFile != null && sshParams[0] == "ssh:" && !string.IsNullOrWhiteSpace(sshParams[1]))
                                {
                                    LinuxSystem victimSystem = await _unitOfWork.LinuxRepository.GetByIP(sshParams[1]);

                                    if (victimSystem != null)
                                    {
                                        List <Vulnerability> vulnerabilities = _unitOfWork.VulnerabilityRepository.GetVulnerabilitiesByLinuxSystemId(victimSystem.Id);
                                        if (vulnerabilities.Count > 0)
                                        {
                                            foreach (var vuln in vulnerabilities)
                                            {
                                                foreach (var port in vuln.Ports)
                                                {
                                                    await client.SendTextMessageAsync(chatId, "<code>Подбор пароля...</code>", ParseMode.Html);

                                                    if (passwordFile.Text.Contains(port.Password) && commandParams[1] == port.Login)
                                                    {
                                                        await client.SendTextMessageAsync(chatId, $"<code>[22][ssh]  host: {sshParams[1]}   login: {port.Login}   password: {port.Password}</code>", ParseMode.Html);

                                                        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>Неверный IP адресс.</code>", ParseMode.Html);

                                    return(false);
                                }

                                await client.SendTextMessageAsync(chatId, "<code>Неверный IP адресс.</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);
                }

                await client.SendTextMessageAsync(chatId, "<code>Ошибка. Проверьте подключение к интернету.</code>", ParseMode.Html);

                return(false);
            }

            return(false);
        }
Ejemplo n.º 3
0
        public async Task <bool> Execute(Message message, TelegramBotClient client)
        {
            long chatId = message.Chat.Id;
            User user   = await _unitOfWork.UserAccessRepository.GetUserByChatId(chatId);

            LinuxSystem linuxSystem = await _unitOfWork.LinuxRepository.GetByIdAsync(user.Id);

            WifiModule wifiModule = await _unitOfWork.WifiModuleRepository.GetByIdAsync(linuxSystem.WifiModuleId);

            if (user != null && user.isAuthorized && wifiModule.ModuleMode == ModuleMode.Monitor)
            {
                string[]           commandParams = message.Text.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                IEnumerable <Wifi> wifis         = _unitOfWork.WifiRepository.GetByWifisModuleId(wifiModule.Id);
                bool isExist = wifis.Any(w => w.BSSID == commandParams[4]);

                if (commandParams[1] == "--deauth" && commandParams[3] == "-a" &&
                    isExist && commandParams[5] == wifiModule.Name)
                {
                    for (int i = 0; i < 8; i++)
                    {
                        await client.SendTextMessageAsync(chatId, $"<code>{DateTime.UtcNow.ToString("HH:mm:ss")}  Sending DeAuth to broadcast -- BSSID: [{commandParams[4]}]</code>", ParseMode.Html);

                        Thread.Sleep(1000);
                    }

                    user.CountOfCrackWifi++;
                    await _unitOfWork.SaveAsync();

                    Wifi wifi = wifis.FirstOrDefault(w => w.BSSID == commandParams[4]);

                    if (wifi != null)
                    {
                        CurrentDirectory currentDirectory = await _unitOfWork.CurrentDirectoryRepository.GetByIdAsync(linuxSystem.CurrentDirectoryId);

                        if (currentDirectory != null)
                        {
                            Directory directory = _unitOfWork.DirectoryRepository.GetInDirectory
                                                      (await _unitOfWork.DirectoryRepository.GetByIdAsync(currentDirectory.DirectoryId));
                            List <File> curDirFiles = directory.Files.ToList();

                            File file = new File()
                            {
                                Name           = $"Wifi-Crack{user.CountOfCrackWifi}.cap",
                                Size           = new Random().Next(100, 500),
                                TimeOfCreating = DateTime.UtcNow,
                                Text           = Convert.ToBase64String(Encoding.UTF8.GetBytes(wifi.Password))
                            };

                            directory.Files.Add(file);

                            await _unitOfWork.SaveAsync();

                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }

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

                    return(false);
                }
            }

            return(false);
        }