public WifiModule Remove(WifiModule entity) { if (entity != null) { _db.WifiModules.Remove(entity); _db.SaveChanges(); return(entity); } return(null); }
public async Task <WifiModule> AddAsync(WifiModule entity) { if (entity != null) { await _db.WifiModules.AddAsync(entity); await _db.SaveChangesAsync(); return(entity); } return(null); }
public async Task <WifiModule> RemoveByIdAsync(int id) { WifiModule wifiModule = await _db.WifiModules.FirstOrDefaultAsync(u => u.Id == id); if (wifiModule != null) { _db.WifiModules.Remove(wifiModule); await _db.SaveChangesAsync(); return(wifiModule); } return(null); }
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) { WifiModule wifiModule = await _unitOfWork.WifiModuleRepository.GetByIdAsync(linuxSystem.WifiModuleId); if (wifiModule != null) { StringBuilder lanDetails = new StringBuilder(); lanDetails.Append("<code>lo: flags=73 UP,LOOPBACK,RUNNING mtu 1500\n" + "inet 127.0.0.1 netmask 255.0.0.0\n" + "inet6::1 prefixlen 128 scopeid 0xfe compat, link, site, host \n" + "loop(Local Loopback) </code>"); await client.SendTextMessageAsync(chatId, lanDetails.ToString(), ParseMode.Html); lanDetails.Clear(); lanDetails.Append($"<code>{wifiModule.Name}: flags=4163 UP,BROADCAST,RUNNING,MULTICAST mtu 1500\n" + $"inet {linuxSystem.IP} netmask 255.255.255.0 broadcast {linuxSystem.IP}\n" + "inet6 fe80::bd6d:680a: 8ca8: c15f prefixlen 64 scopeid 0xfd compat, link, site, host \n" + $"ether {linuxSystem.MACAddress}(Ethernet)\n" + $"Mode: {GetWifiMode(wifiModule.ModuleMode)}</code>"); await client.SendTextMessageAsync(chatId, lanDetails.ToString(), ParseMode.Html); return(true); } return(false); } return(false); } return(false); }
public async Task <bool> Execute(Message message, TelegramBotClient client) { long chatId = message.Chat.Id; User user = await _unitOfWork.UserAccessRepository.GetUserByChatId(chatId); if (user != null) { LinuxSystem linuxSystem = await _unitOfWork.LinuxRepository.GetByIdAsync(user.Id); if (linuxSystem != null) { WifiModule wifiModule = await _unitOfWork.WifiModuleRepository.GetByIdAsync(linuxSystem.WifiModuleId); if (wifiModule != null && user.isAuthorized && wifiModule.ModuleMode == ModuleMode.Monitor) { StringBuilder wifis = new StringBuilder(); List <Wifi> moduleWifis = _unitOfWork.WifiRepository.GetByWifisModuleId(wifiModule.Id).ToList(); foreach (var wifi in moduleWifis) { wifis.Append($"BSSID: {wifi.BSSID} SPEED: {wifi.Speed}мб/с CH: {wifi.Channel} CIP: {GetCipher(wifi.Cipher)} ENC: {GetEncryption(wifi.EncryptionType)} ESSID: {wifi.Name}\n"); } await client.SendTextMessageAsync(chatId, $"<code>{wifis}</code>", ParseMode.Html); return(true); } return(false); } return(false); } return(false); }
public async Task <bool> Execute(Message message, TelegramBotClient client) { long chatId = message.Chat.Id; User user = await _unitOfWork.UserAccessRepository.GetUserByChatId(chatId); if (user != null) { LinuxSystem linuxSystem = await _unitOfWork.LinuxRepository.GetByIdAsync(user.Id); if (linuxSystem != null) { WifiModule wifiModule = await _unitOfWork.WifiModuleRepository.GetByIdAsync(linuxSystem.WifiModuleId); if (wifiModule != null) { if (user.isAuthorized && wifiModule.ModuleMode == ModuleMode.Managed) { wifiModule.ModuleMode = ModuleMode.Monitor; wifiModule.Name = "wlan0mon"; await _unitOfWork.SaveAsync(); await client.SendTextMessageAsync(chatId, "<code>Режим изменён</code>", ParseMode.Html); return(true); } } return(false); } return(false); } return(false); }
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); }
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); }
public async Task <WifiModule> GetByIdAsync(int id) { WifiModule wifiModule = await _db.WifiModules.FirstOrDefaultAsync(m => m.Id == id); return(wifiModule); }