public override void ProcessRequest(HttpContext context) { ISession s = this.CurrentSession; using (ITransaction t = s.BeginTransaction()) { Guid userID = new Guid(context.Request["UserID"]); Guid clientID = new Guid(context.Request["ClientID"]); PersistentUser user = s.Get <PersistentUser>(userID); PersistentClient client = s.Get <PersistentClient>(clientID); if (user == null || !user.HasAPIAccess) { throw new Exception("no api access"); } if (client == null || !client.HasAPIAccess) { throw new Exception("no api access"); } PersistentProfileHostVerification verification = new PersistentProfileHostVerification(); verification.SetCreationInfo(Guid.Empty); verification.VerificationData = context.Request["VerificationData"]; verification.VerificationFileName = context.Request["VerificationFileName"]; verification.WhoisEmail = context.Request["WhoisRegex"]; s.Save(verification); context.Response.Write(verification.ToBusinessXML()); } }
public override void ProcessRequest(HttpContext context) { ISession s = this.CurrentSession; using (ITransaction t = s.BeginTransaction()) { Guid userID = new Guid(context.Request["UserID"]); Guid clientID = new Guid(context.Request["ClientID"]); PersistentUser user = s.Get <PersistentUser>(userID); PersistentClient client = s.Get <PersistentClient>(clientID); if (user == null || !user.HasAPIAccess) { throw new Exception("no api access"); } if (client == null || !client.HasAPIAccess) { throw new Exception("no api access"); } } IToolOptions options = new WhoisToolOptions(); (options as WhoisToolOptions).Host = context.Request["Host"]; (options as WhoisToolOptions).Path = ConfigurationManager.AppSettings["whoisPath"]; Whois whois = new Whois(options as IToolOptions); WhoisToolResults results = whois.Run() as WhoisToolResults; context.Response.Write(results.FullOutput); }
public override void ProcessRequest(HttpContext context) { ISession sess = this.CurrentSession; PersistentUser user = sess.Get <PersistentUser>(new Guid(context.Request["UserID"])); PersistentClient client = sess.Get <PersistentClient>(new Guid(context.Request["ClientID"])); if (user == null || !user.HasAPIAccess) { throw new Exception("no api access"); } if (client == null || !client.HasAPIAccess) { throw new Exception("no api access"); } bool isActive = bool.Parse(context.Request["IsActive"]); Guid profileID = new Guid(context.Request["ProfileID"]); PersistentProfile profile = sess.Get <PersistentProfile>(profileID); string xml = profile.ToPersistentXml(); context.Response.Write(xml); }
public override void ProcessRequest(HttpContext context) { ISession sess = this.CurrentSession; PersistentUser user = sess.Get <PersistentUser>(new Guid(context.Request["UserID"])); PersistentClient client = sess.Get <PersistentClient>(new Guid(context.Request["ClientID"])); if (user == null || !user.HasAPIAccess) { throw new Exception("no api access"); } if (client == null || !client.HasAPIAccess) { throw new Exception("no api access"); } Guid hostPortID = new Guid(context.Request["HostPortID"]); bool isActive = Boolean.Parse(context.Request["IsActive"]); PersistentSQLMapResults sqlMapResults = sess.CreateCriteria <PersistentSQLMapResults>() .Add(Restrictions.Eq("ParentHostPortID", hostPortID)) .Add(Restrictions.Eq("IsActive", isActive)) .UniqueResult <PersistentSQLMapResults>(); if (sqlMapResults == null) { throw new Exception("No record found with those restrictions."); } string xml = sqlMapResults.ToPersistentXml(); context.Response.Write(xml); }
public override void ProcessRequest(HttpContext context) { ISession sess = this.CurrentSession; PersistentUser user = sess.Get <PersistentUser>(new Guid(context.Request["UserID"])); PersistentClient client = sess.Get <PersistentClient>(new Guid(context.Request["ClientID"])); if (user == null || !user.HasAPIAccess) { throw new Exception("no api access"); } if (client == null || !client.HasAPIAccess) { throw new Exception("no api access"); } using (NexposeSession nsess = new NexposeSession("" + ConfigurationManager.AppSettings["Nexpose"] + "")) { nsess.Authenticate("nexpose", "nexpose"); using (NexposeManager11 manager = new NexposeManager11(nsess)) { XmlDocument engines = manager.GetScanEngineListing(); context.Response.Write(engines.OuterXml); } } }
public Redis(int maxWritePoolSize, int maxReadPoolSize, string[] readWriteHosts, string[] readOnlyHosts, long initalDb, TimeSpan defaultExpirationTime) { try { try { var config = new RedisClientManagerConfig { MaxWritePoolSize = maxWritePoolSize, //“写”链接池链接数 MaxReadPoolSize = maxReadPoolSize, //“读”链接池链接数 AutoStart = true, }; PooledRedisClientManager.Add(initalDb, new PooledRedisClientManager(readWriteHosts, readOnlyHosts, config, initalDb, null, null)); } catch (Exception e) { //LFFK.LogManager.Error(CacheConstants.Error_Init, e); } DefaultExpirationTime = defaultExpirationTime; InitalDb = initalDb; ReadWriteHost = readWriteHosts[0]; MaxWritePoolSize = maxWritePoolSize; MaxReadPoolSize = maxReadPoolSize; ReadWriteHosts = readWriteHosts; ReadOnlyHosts = readWriteHosts; PersistentClient.Add(initalDb, new RedisClient(ReadWriteHost.Split(':')[0], Convert.ToInt32(ReadWriteHost.Split(':')[1]), db: initalDb)); } catch (Exception ex) { throw new Exception(Constants.Error_Data_InitConfigFailed, ex); } }
public override void ProcessRequest(HttpContext context) { ISession sess = this.CurrentSession; PersistentUser user = sess.Get <PersistentUser>(new Guid(context.Request["UserID"])); PersistentClient client = sess.Get <PersistentClient>(new Guid(context.Request["ClientID"])); if (user == null || !user.HasAPIAccess) { throw new Exception("no api access"); } if (client == null || !client.HasAPIAccess) { throw new Exception("no api access"); } bool isActive = bool.Parse(context.Request["IsActive"]); Guid scanID = new Guid(context.Request["ScanID"]); PersistentOpenVASTask task = sess.CreateCriteria <PersistentOpenVASTask>() .Add(Restrictions.Eq("ScanID", scanID)) .List <PersistentOpenVASTask>() .FirstOrDefault(); //in case IsActive is false and more than one scan related to profile is inactive. if (task == null) { throw new Exception("A scan with the conditions asked for doesn't exist."); } context.Response.Write(task.FullReport); }
public override void ProcessRequest(HttpContext context) { ISession s = this.CurrentSession; using (ITransaction t = s.BeginTransaction()) { Guid userID = new Guid(context.Request ["UserID"]); Guid clientID = new Guid(context.Request ["ClientID"]); PersistentUser user = s.Get <PersistentUser> (userID); PersistentClient client = s.Get <PersistentClient> (clientID); if (user == null || !user.HasAPIAccess) { throw new Exception("no api access"); } if (client == null || !client.HasAPIAccess) { throw new Exception("no api access"); } PersistentProfile p = s.Get <PersistentProfile>(new Guid(context.Request["ProfileID"])); DateTime now = DateTime.Now; PersistentProfileHost host = new PersistentProfileHost(new Guid(context.Request ["WebUserID"])); host.ParentProfile = p; host.Name = context.Request["HostSubDomain"]; host.IPv4Address = Dns.GetHostEntry(context.Request["HostSubDomain"]).AddressList [0].ToString(); host.VerifiedByFile = true; host.VerifiedByWhois = true; host.VerifiedOn = DateTime.Now; host.WasManuallyVerified = false; host.IsVerified = true; host.CreatedBy = Guid.Empty; host.CreatedOn = now; host.LastModifiedBy = Guid.Empty; host.LastModifiedOn = now; host.IsActive = true; p.Range += " " + host.IPv4Address; p.SetUpdateInfo(Guid.Empty, true); s.Save(p); s.Save(host); try { t.Commit(); } catch (Exception ex) { t.Rollback(); throw ex; } string xml = host.ToPersistentXML(false /*include nmap hosts? no, because none exist right now*/); context.Response.Write(xml); } }
public override void ProcessRequest(HttpContext context) { ISession sess = this.CurrentSession; PersistentUser user = sess.Get <PersistentUser>(new Guid(context.Request["UserID"])); PersistentClient client = sess.Get <PersistentClient>(new Guid(context.Request["ClientID"])); if (user == null || !user.HasAPIAccess) { throw new Exception("no api access"); } if (client == null || !client.HasAPIAccess) { throw new Exception("no api access"); } }
public override void ProcessRequest(HttpContext context) { Guid userID = new Guid(context.Request["UserID"]); Guid clientID = new Guid(context.Request["ClientID"]); ISession s = this.CurrentSession; PersistentUser user = s.CreateCriteria <PersistentUser>() .Add(Restrictions.Eq("ID", userID)) .Add(Restrictions.Eq("IsActive", true)) .UniqueResult <PersistentUser>(); if (user == null || !user.HasAPIAccess) { throw new Exception("no api access"); } if (!user.Client.HasAPIAccess) { throw new Exception("no api access"); } using (ITransaction trans = s.BeginTransaction()) { PersistentClient newClient = new PersistentClient(); newClient.HasAPIAccess = bool.Parse(context.Request["NewClientHasAPIAccess"]); newClient.LogoPath = context.Request["NewClientLogoPath"]; newClient.Name = context.Request["NewClientName"]; newClient.SetCreationInfo(userID); s.Save(newClient); try { trans.Commit(); } catch (Exception ex) { trans.Rollback(); throw ex; } } }
public override void ProcessRequest(HttpContext context) { ISession sess = this.CurrentSession; PersistentUser user = sess.Get <PersistentUser>(new Guid(context.Request["UserID"])); PersistentClient client = sess.Get <PersistentClient>(new Guid(context.Request["ClientID"])); if (user == null || !user.HasAPIAccess) { throw new Exception("no api access"); } if (client == null || !client.HasAPIAccess) { throw new Exception("no api access"); } string uuid = context.Request["ReportUUID"]; string hostname = context.Request["Hostname"]; int port = int.Parse(context.Request["PortNumber"]); string protocol = context.Request["Protocol"]; if (string.IsNullOrEmpty(uuid)) { throw new Exception("no uuid"); } NessusManagerSession nessusSession = new NessusManagerSession(ConfigurationManager.AppSettings["nessusHost"]); bool loggedIn = false; nessusSession.Authenticate(ConfigurationManager.AppSettings["nessusUser"], ConfigurationManager.AppSettings["nessusPass"], 1234, out loggedIn); if (!loggedIn) { throw new Exception("Invalid username/password"); } NessusObjectManager nessusManager = new NessusObjectManager(nessusSession); XmlDocument doc = nessusManager.GetReportDetailsByPortAndHost(uuid, hostname, port, protocol); context.Response.Write(doc.OuterXml); }
public override void ProcessRequest(HttpContext context) { ISession sess = this.CurrentSession; PersistentUser user = sess.Get <PersistentUser>(new Guid(context.Request["UserID"])); PersistentClient client = sess.Get <PersistentClient>(new Guid(context.Request["ClientID"])); if (user == null || !user.HasAPIAccess) { throw new Exception("no api access"); } if (client == null || !client.HasAPIAccess) { throw new Exception("no api access"); } string readableName = context.Request["ReportReadableName"]; if (string.IsNullOrEmpty(readableName)) { throw new Exception("no readable name"); } NessusManagerSession nessusSession = new NessusManagerSession("192.168.56.101"); bool loggedIn = false; nessusSession.Authenticate("nessus", "nessus", 1234, out loggedIn); if (!loggedIn) { throw new Exception("Invalid username/password"); } NessusObjectManager nessusManager = new NessusObjectManager(nessusSession); NessusReport report = nessusManager.GetReports() .Where(r => r.ReadableName == readableName) .SingleOrDefault(); context.Response.Write(report.ToBusinessXml()); }
public override void ProcessRequest(HttpContext context) { ISession sess = this.CurrentSession; PersistentUser user = sess.Get <PersistentUser>(new Guid(context.Request["UserID"])); PersistentClient client = sess.Get <PersistentClient>(new Guid(context.Request["ClientID"])); if (user == null || !user.HasAPIAccess) { throw new Exception("no api access"); } if (client == null || !client.HasAPIAccess) { throw new Exception("no api access"); } string uuid = context.Request["ReportUUID"]; if (string.IsNullOrEmpty(uuid)) { throw new Exception("no uuid"); } NessusManagerSession nessusSession = new NessusManagerSession(ConfigurationManager.AppSettings["nessusHost"]); bool loggedIn = false; nessusSession.Authenticate(ConfigurationManager.AppSettings["nessusUser"], ConfigurationManager.AppSettings["nessusPass"], 1234, out loggedIn); if (!loggedIn) { throw new Exception("Invalid username/password"); } NessusObjectManager nessusManager = new NessusObjectManager(nessusSession); var hosts = nessusManager.GetReportHosts(uuid); context.Response.Write(hosts.OuterXml); }
public override void ProcessRequest(HttpContext context) { ISession sess = this.CurrentSession; PersistentUser user = sess.Get <PersistentUser>(new Guid(context.Request["UserID"])); PersistentClient client = sess.Get <PersistentClient>(new Guid(context.Request["ClientID"])); if (user == null || !user.HasAPIAccess) { throw new Exception("no api access"); } if (client == null || !client.HasAPIAccess) { throw new Exception("no api access"); } bool isActive = bool.Parse(context.Request["IsActive"]); Guid profileID = new Guid(context.Request["ProfileID"]); PersistentScan scan = sess.CreateCriteria <PersistentScan>() .Add(Restrictions.Eq("ParentProfileID", profileID)) .Add(Restrictions.Eq("IsActive", isActive)) .SetFetchMode("ScanOptions", FetchMode.Eager) .List <PersistentScan>() .LastOrDefault(); //in case IsActive is false and more than one scan related to profile is inactive. if (scan == null) { throw new Exception("A scan with the conditions asked for doesn't exist."); } string xml = scan.ToPersistentXml(); context.Response.Write(xml); }
public override void ProcessRequest(HttpContext context) { ISession sess = this.CurrentSession; PersistentUser user = sess.Get <PersistentUser>(new Guid(context.Request["UserID"])); PersistentClient client = sess.Get <PersistentClient>(new Guid(context.Request["ClientID"])); if (user == null || !user.HasAPIAccess) { throw new Exception("no api access"); } if (client == null || !client.HasAPIAccess) { throw new Exception("no api access"); } bool isActive = bool.Parse(context.Request["IsActive"]); Guid webUserID = new Guid(context.Request["WebUserID"]); IList <PersistentProfile> profiles = sess.CreateCriteria <PersistentProfile>() .Add(Restrictions.Eq("WebUserID", webUserID)) .Add(Restrictions.Eq("IsActive", isActive)) .List <PersistentProfile>(); string xml = string.Empty; xml = xml + "<profiles>"; foreach (PersistentProfile profile in profiles) { xml = xml + profile.ToPersistentXml(); } xml = xml + "</profiles>"; context.Response.Write(xml); }
public override void ProcessRequest(HttpContext context) { ISession sess = this.CurrentSession; PersistentUser user = sess.Get <PersistentUser>(new Guid(context.Request["UserID"])); PersistentClient client = sess.Get <PersistentClient>(new Guid(context.Request["ClientID"])); if (user == null || !user.HasAPIAccess) { throw new Exception("no api access"); } if (client == null || !client.HasAPIAccess) { throw new Exception("no api access"); } Guid tid = new Guid(context.Request["TracerouteID"]); // TracerouteToolResults traceroute = this.CurrentScanSession.CreateCriteria<TracerouteToolResults>() // .Add(Restrictions.Eq("NMapHostID", tid)) // .Add(Restrictions.Eq("ProfileID", this.CurrentProfile.ProfileID)) // .UniqueResult<TracerouteToolResults>(); }
public override void ProcessRequest(HttpContext context) { ISession s = this.CurrentSession; using (ITransaction t = s.BeginTransaction()) { Console.WriteLine("fdsa"); Guid userID = new Guid(context.Request["UserID"]); Guid clientID = new Guid(context.Request["ClientID"]); PersistentUser user = s.Get <PersistentUser>(userID); PersistentClient client = s.Get <PersistentClient>(clientID); if (user == null || !user.HasAPIAccess) { throw new Exception("no api access"); } if (client == null || !client.HasAPIAccess) { throw new Exception("no api access"); } PersistentProfile profile = new PersistentProfile(); string webUserID = context.Request["WebUserID"]; profile.WebUserID = new Guid(context.Request["WebUserID"]); profile.Description = context.Request["ProfileDescription"]; profile.Name = context.Request["ProfileName"]; profile.Range = context.Request["ProfileDomain"]; profile.Domain = context.Request["ProfileDomain"]; profile.RunEvery = new TimeSpan(24 * (int.Parse(context.Request["ProfileSchedule"])), 0, 0); //30 days profile.RunAfter = DateTime.Now; profile.HasRun = false; profile.SetCreationInfo(userID); s.Save(profile); foreach (string h in profile.Range.Split(',')) { PersistentProfileHost host = new PersistentProfileHost(new Guid(context.Request["WebUserID"])); host.ParentProfile = profile; host.IPv4Address = Dns.GetHostEntry(h).AddressList[0].ToString(); host.VerifiedByFile = true; host.VerifiedByWhois = true; host.VerifiedOn = DateTime.Now; host.WasManuallyVerified = false; host.IsVerified = true; s.Save(host); } try { t.Commit(); } catch (Exception ex) { t.Rollback(); throw ex; } string xml = profile.ToPersistentXml(); context.Response.Write(xml); } }