public async Task <IActionResult> Test(EditModuloVM createmodulo, string cosa, string daDove) { if (cosa == "server") { bool check = await CheckServer(createmodulo.SERVER.ServerIP, createmodulo.SERVER.Porta, createmodulo.SERVER.Https); MyLogger.Log(messaggio: $"Richiesta POST: Test verso http{(createmodulo.SERVER.Https ? "s" : "")}://{createmodulo.SERVER.ServerIP}:{createmodulo.SERVER.Porta} " + ((check) ? "up" : "down"), controller: "ModuloController", metodo: "Test"); TempData.Put("TestS", check.ToString()); TempData.Put("Anchor", "Server"); } else if (cosa == "openvas") { bool check = await CheckServer(createmodulo.OPENVAS.ServerIPOpenvas, createmodulo.OPENVAS.PortaOpenvas, true); MyLogger.Log(messaggio: $"Richiesta POST: Test verso https://{createmodulo.OPENVAS.ServerIPOpenvas}:{createmodulo.OPENVAS.PortaOpenvas} " + ((check) ? "up" : "down"), controller: "ModuloController", metodo: "Test"); TempData.Put("TestO", check.ToString()); TempData.Put("Anchor", "Openvas"); } TempData.Put("Model", createmodulo); //return View(nameof(Create),createmodulo); return(Redirect(Url.Action(daDove, "Modulo").Replace("%2F", "/"))); }
public async Task <IActionResult> Edit(int id, EditModuloVM editmodulo) { Modulo m; if (!string.IsNullOrEmpty(editmodulo.NMAP.Nome)) { m = editmodulo.NMAP; } else if (!string.IsNullOrEmpty(editmodulo.SERVER.Nome)) { m = editmodulo.SERVER; } else if (!string.IsNullOrEmpty(editmodulo.DNSRECON.Nome)) { m = editmodulo.DNSRECON; } else if (!string.IsNullOrEmpty(editmodulo.FIERCE.Nome)) { m = editmodulo.FIERCE; } else if (!string.IsNullOrEmpty(editmodulo.DROOPE.Nome)) { m = editmodulo.DROOPE; } else if (!string.IsNullOrEmpty(editmodulo.JOOMSCAN.Nome)) { m = editmodulo.JOOMSCAN; } else if (!string.IsNullOrEmpty(editmodulo.WPSCAN.Nome)) { m = editmodulo.WPSCAN; } else if (!string.IsNullOrEmpty(editmodulo.INFOGA.Nome)) { m = editmodulo.INFOGA; } else if (!string.IsNullOrEmpty(editmodulo.INFOGAEMAIL.Nome)) { m = editmodulo.INFOGAEMAIL; } else if (!string.IsNullOrEmpty(editmodulo.SUBLIST3R.Nome)) { m = editmodulo.SUBLIST3R; } else if (!string.IsNullOrEmpty(editmodulo.WASCAN.Nome)) { m = editmodulo.WASCAN; } else if (!string.IsNullOrEmpty(editmodulo.OPENDOOR.Nome)) { m = editmodulo.OPENDOOR; } else if (!string.IsNullOrEmpty(editmodulo.WAPITI.Nome)) { m = editmodulo.WAPITI; } else if (!string.IsNullOrEmpty(editmodulo.SUBLIST3R.Nome)) { m = editmodulo.SUBLIST3R; } else if (!string.IsNullOrEmpty(editmodulo.SQLMAP.Nome)) { m = editmodulo.SQLMAP; } else if (!string.IsNullOrEmpty(editmodulo.WIFITE.Nome)) { m = editmodulo.WIFITE; } else if (!string.IsNullOrEmpty(editmodulo.NOSQL.Nome)) { m = editmodulo.NOSQL; } else if (!string.IsNullOrEmpty(editmodulo.ODAT.Nome)) { m = editmodulo.ODAT; } else if (!string.IsNullOrEmpty(editmodulo.DNSENUM.Nome)) { m = editmodulo.DNSENUM; } else if (!string.IsNullOrEmpty(editmodulo.THEHARVESTER.Nome)) { m = editmodulo.THEHARVESTER; } else if (!string.IsNullOrEmpty(editmodulo.AMASS.Nome)) { m = editmodulo.AMASS; } else if (!string.IsNullOrEmpty(editmodulo.DRUPWN.Nome)) { m = editmodulo.DRUPWN; } else if (!string.IsNullOrEmpty(editmodulo.WHOIS.Nome)) { m = editmodulo.WHOIS; } else // è rimasto solo openvas, controllo dopo se m è ancora null o no { m = editmodulo.OPENVAS; } if (m == null) { MyLogger.Log(messaggio: $"ERRORE: Richiesta POST con id {id}: BadRequest", controller: "ModuloController", metodo: "Edit"); return(BadRequest()); } if (id != m.ID) { MyLogger.Log(messaggio: $"ERRORE: Richiesta POST con id {id}: Richiesta malformata", controller: "ModuloController", metodo: "Edit"); return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(m); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ModuloExists(m.ID)) { MyLogger.Log(messaggio: $"ERRORE: Richiesta POST con id {id}: Nessun modulo con questo id", controller: "ModuloController", metodo: "Edit"); return(NotFound()); } else { MyLogger.Log(messaggio: $"ERRORE CRITICO: Richiesta POST con id {id}: Errore nel DB", controller: "ModuloController", metodo: "Edit"); throw; } } MyLogger.Log(messaggio: $"Richiesta POST: \n\tModulo di tipo {m.Applicazione.ToString()} con nome: {m.Nome} modificato", controller: "ModuloController", metodo: "Edit"); return(RedirectToAction(nameof(Index))); } return(View(editmodulo)); }
public async Task <IActionResult> Create(string cosa, EditModuloVM createmodulo) { if (createmodulo.NMAP.Nome != null && cosa.Equals("nmap")) { if (ModelState.IsValid) { ModuloNMAP mod = createmodulo.NMAP; mod.Applicazione = APPLICAZIONE.NMAP; _context.Moduli.Add(mod); await _context.SaveChangesAsync(); MyLogger.Log(messaggio: $"Richiesta POST: \n\tNuovo modulo nmap con nome: {mod.Nome}", controller: "ModuloController", metodo: "Create"); return(RedirectToAction(nameof(Index))); } } else if (createmodulo.SERVER.Nome != null && cosa.Equals("server")) { { if (ModelState.IsValid) { ModuloSERVER mod = createmodulo.SERVER; mod.Applicazione = APPLICAZIONE.SERVER; _context.Moduli.Add(mod); await _context.SaveChangesAsync(); MyLogger.Log(messaggio: $"Richiesta POST: \n\tNuovo modulo Nessus con nome: {mod.Nome}", controller: "ModuloController", metodo: "Create"); return(RedirectToAction(nameof(Index))); } } } else if (createmodulo.DNSRECON.Nome != null && cosa.Equals("dnsrecon")) { { if (ModelState.IsValid) { ModuloDNSRECON mod = createmodulo.DNSRECON; mod.Applicazione = APPLICAZIONE.DNSRECON; _context.Moduli.Add(mod); await _context.SaveChangesAsync(); MyLogger.Log(messaggio: $"Richiesta POST: \n\tNuovo modulo DNSRecon con nome: {mod.Nome}", controller: "ModuloController", metodo: "Create"); return(RedirectToAction(nameof(Index))); } } } else if (createmodulo.FIERCE.Nome != null && cosa.Equals("fierce")) { { if (ModelState.IsValid) { ModuloFIERCE mod = createmodulo.FIERCE; mod.Applicazione = APPLICAZIONE.FIERCE; _context.Moduli.Add(mod); await _context.SaveChangesAsync(); MyLogger.Log(messaggio: $"Richiesta POST: \n\tNuovo modulo Fierce con nome: {mod.Nome}", controller: "ModuloController", metodo: "Create"); return(RedirectToAction(nameof(Index))); } } } else if (createmodulo.DROOPE.Nome != null && cosa.Equals("droopescan")) { { if (ModelState.IsValid) { ModuloDROOPE mod = createmodulo.DROOPE; mod.Applicazione = APPLICAZIONE.DROOPE; _context.Moduli.Add(mod); await _context.SaveChangesAsync(); MyLogger.Log(messaggio: $"Richiesta POST: \n\tNuovo modulo DroopeScan con nome: {mod.Nome}", controller: "ModuloController", metodo: "Create"); return(RedirectToAction(nameof(Index))); } } } else if (createmodulo.JOOMSCAN.Nome != null && cosa.Equals("joomscan")) { { if (ModelState.IsValid) { ModuloJOOMSCAN mod = createmodulo.JOOMSCAN; mod.Applicazione = APPLICAZIONE.JOOMSCAN; _context.Moduli.Add(mod); await _context.SaveChangesAsync(); MyLogger.Log(messaggio: $"Richiesta POST: \n\tNuovo modulo JoomScan con nome: {mod.Nome}", controller: "ModuloController", metodo: "Create"); return(RedirectToAction(nameof(Index))); } } } else if (createmodulo.WPSCAN.Nome != null && cosa.Equals("wpscan")) { { if (ModelState.IsValid) { ModuloWPSCAN mod = createmodulo.WPSCAN; mod.Applicazione = APPLICAZIONE.WPSCAN; _context.Moduli.Add(mod); await _context.SaveChangesAsync(); MyLogger.Log(messaggio: $"Richiesta POST: \n\tNuovo modulo WPScan con nome: {mod.Nome}", controller: "ModuloController", metodo: "Create"); return(RedirectToAction(nameof(Index))); } } } else if (createmodulo.INFOGA.Nome != null && cosa.Equals("infoga")) { { if (ModelState.IsValid) { ModuloINFOGA mod = createmodulo.INFOGA; mod.Applicazione = APPLICAZIONE.INFOGA; _context.Moduli.Add(mod); await _context.SaveChangesAsync(); MyLogger.Log(messaggio: $"Richiesta POST: \n\tNuovo modulo Infoga con nome: {mod.Nome}", controller: "ModuloController", metodo: "Create"); return(RedirectToAction(nameof(Index))); } } } else if (createmodulo.INFOGAEMAIL.Nome != null && cosa.Equals("infogaemail")) { { if (ModelState.IsValid) { ModuloINFOGAEMAIL mod = createmodulo.INFOGAEMAIL; mod.Applicazione = APPLICAZIONE.INFOGAEMAIL; _context.Moduli.Add(mod); await _context.SaveChangesAsync(); MyLogger.Log(messaggio: $"Richiesta POST: \n\tNuovo modulo Infoga (email) con nome: {mod.Nome}", controller: "ModuloController", metodo: "Create"); return(RedirectToAction(nameof(Index))); } } } else if (createmodulo.SUBLIST3R.Nome != null && cosa.Equals("sublist3r")) { { if (ModelState.IsValid) { ModuloSUBLIST3R mod = createmodulo.SUBLIST3R; mod.Applicazione = APPLICAZIONE.SUBLIST3R; _context.Moduli.Add(mod); await _context.SaveChangesAsync(); MyLogger.Log(messaggio: $"Richiesta POST: \n\tNuovo modulo Sublist3r con nome: {mod.Nome}", controller: "ModuloController", metodo: "Create"); return(RedirectToAction(nameof(Index))); } } } else if (createmodulo.WAPITI.Nome != null && cosa.Equals("wapiti")) { { if (ModelState.IsValid) { ModuloWAPITI mod = createmodulo.WAPITI; mod.Applicazione = APPLICAZIONE.WAPITI; _context.Moduli.Add(mod); await _context.SaveChangesAsync(); MyLogger.Log(messaggio: $"Richiesta POST: \n\tNuovo modulo Wapiti con nome: {mod.Nome}", controller: "ModuloController", metodo: "Create"); return(RedirectToAction(nameof(Index))); } } } else if (createmodulo.WASCAN.Nome != null && cosa.Equals("wascan")) { { if (ModelState.IsValid) { ModuloWASCAN mod = createmodulo.WASCAN; mod.Applicazione = APPLICAZIONE.WASCAN; _context.Moduli.Add(mod); await _context.SaveChangesAsync(); MyLogger.Log(messaggio: $"Richiesta POST: \n\tNuovo modulo Wascan con nome: {mod.Nome}", controller: "ModuloController", metodo: "Create"); return(RedirectToAction(nameof(Index))); } } } else if (createmodulo.SQLMAP.Nome != null && cosa.Equals("sqlmap")) { { if (ModelState.IsValid) { ModuloSQLMAP mod = createmodulo.SQLMAP; mod.Applicazione = APPLICAZIONE.SQLMAP; _context.Moduli.Add(mod); await _context.SaveChangesAsync(); MyLogger.Log(messaggio: $"Richiesta POST: \n\tNuovo modulo SQLMap con nome: {mod.Nome}", controller: "ModuloController", metodo: "Create"); return(RedirectToAction(nameof(Index))); } } } else if (createmodulo.WIFITE.Nome != null && cosa.Equals("wifite")) { { if (ModelState.IsValid) { ModuloWIFITE mod = createmodulo.WIFITE; mod.Applicazione = APPLICAZIONE.WIFITE; _context.Moduli.Add(mod); await _context.SaveChangesAsync(); MyLogger.Log(messaggio: $"Richiesta POST: \n\tNuovo modulo Wifite con nome: {mod.Nome}", controller: "ModuloController", metodo: "Create"); return(RedirectToAction(nameof(Index))); } } } else if (createmodulo.OPENDOOR.Nome != null && cosa.Equals("opendoor")) { { if (ModelState.IsValid) { ModuloOPENDOOR mod = createmodulo.OPENDOOR; mod.Applicazione = APPLICAZIONE.OPENDOOR; _context.Moduli.Add(mod); await _context.SaveChangesAsync(); MyLogger.Log(messaggio: $"Richiesta POST: \n\tNuovo modulo OpenDoor con nome: {mod.Nome}", controller: "ModuloController", metodo: "Create"); return(RedirectToAction(nameof(Index))); } } } else if (createmodulo.NOSQL.Nome != null && cosa.Equals("nosql")) { { if (ModelState.IsValid) { ModuloNOSQL mod = createmodulo.NOSQL; mod.Applicazione = APPLICAZIONE.NOSQL; _context.Moduli.Add(mod); await _context.SaveChangesAsync(); MyLogger.Log(messaggio: $"Richiesta POST: \n\tNuovo modulo NoSQLMap con nome: {mod.Nome}", controller: "ModuloController", metodo: "Create"); return(RedirectToAction(nameof(Index))); } } } else if (createmodulo.ODAT.Nome != null && cosa.Equals("odat")) { { if (ModelState.IsValid) { ModuloODAT mod = createmodulo.ODAT; mod.Applicazione = APPLICAZIONE.ODAT; _context.Moduli.Add(mod); await _context.SaveChangesAsync(); MyLogger.Log(messaggio: $"Richiesta POST: \n\tNuovo modulo ODAT con nome: {mod.Nome}", controller: "ModuloController", metodo: "Create"); return(RedirectToAction(nameof(Index))); } } } else if (createmodulo.DNSENUM.Nome != null && cosa.Equals("dnsEnum")) { { if (ModelState.IsValid) { ModuloDNSENUM mod = createmodulo.DNSENUM; mod.Applicazione = APPLICAZIONE.DNSENUM; _context.Moduli.Add(mod); await _context.SaveChangesAsync(); MyLogger.Log(messaggio: $"Richiesta POST: \n\tNuovo modulo DNSEnum con nome: {mod.Nome}", controller: "ModuloController", metodo: "Create"); return(RedirectToAction(nameof(Index))); } } } else if (createmodulo.OPENVAS.Nome != null && cosa.Equals("openvas")) { { if (ModelState.IsValid) { ModuloOPENVAS mod = createmodulo.OPENVAS; mod.Applicazione = APPLICAZIONE.OPENVAS; _context.Moduli.Add(mod); await _context.SaveChangesAsync(); MyLogger.Log(messaggio: $"Richiesta POST: \n\tNuovo modulo OpenVAS con nome: {mod.Nome}", controller: "ModuloController", metodo: "Create"); return(RedirectToAction(nameof(Index))); } } } else if (createmodulo.THEHARVESTER.Nome != null && cosa.Equals("theharvester")) { { if (ModelState.IsValid) { ModuloTHEHARVESTER mod = createmodulo.THEHARVESTER; mod.Applicazione = APPLICAZIONE.THEHARVESTER; _context.Moduli.Add(mod); await _context.SaveChangesAsync(); MyLogger.Log(messaggio: $"Richiesta POST: \n\tNuovo modulo TheHarvester con nome: {mod.Nome}", controller: "ModuloController", metodo: "Create"); return(RedirectToAction(nameof(Index))); } } } else if (createmodulo.AMASS.Nome != null && cosa.Equals("amass")) { { if (ModelState.IsValid) { ModuloAMASS mod = createmodulo.AMASS; mod.Applicazione = APPLICAZIONE.AMASS; _context.Moduli.Add(mod); await _context.SaveChangesAsync(); MyLogger.Log(messaggio: $"Richiesta POST: \n\tNuovo modulo Amass con nome: {mod.Nome}", controller: "ModuloController", metodo: "Create"); return(RedirectToAction(nameof(Index))); } } } else if (createmodulo.DRUPWN.Nome != null && cosa.Equals("drupwn")) { { if (ModelState.IsValid) { ModuloDRUPWN mod = createmodulo.DRUPWN; mod.Applicazione = APPLICAZIONE.DRUPWN; _context.Moduli.Add(mod); await _context.SaveChangesAsync(); MyLogger.Log(messaggio: $"Richiesta POST: \n\tNuovo modulo Drupwn con nome: {mod.Nome}", controller: "ModuloController", metodo: "Create"); return(RedirectToAction(nameof(Index))); } } } else if (createmodulo.WHOIS.Nome != null && cosa.Equals("whois")) { if (ModelState.IsValid) { ModuloWHOIS mod = createmodulo.WHOIS; mod.Applicazione = APPLICAZIONE.WHOIS; _context.Moduli.Add(mod); await _context.SaveChangesAsync(); MyLogger.Log(messaggio: $"Richiesta POST: \n\tNuovo modulo nmap con nome: {mod.Nome}", controller: "ModuloController", metodo: "Create"); return(RedirectToAction(nameof(Index))); } } else { MyLogger.Log(messaggio: $"ERRORE: Richiesta POST: BadRequest", controller: "ModuloController", metodo: "Create"); return(BadRequest()); } MyLogger.Log(messaggio: $"ERRORE: Richiesta POST: Richiesta malformata", controller: "ModuloController", metodo: "Create"); return(View(createmodulo)); }