示例#1
0
        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);
        }
示例#2
0
    IEnumerator LoginCoroutine()
    {
        errorSubtitle.text = "";
        string encodedpw = Convert.ToBase64String(Encoding.UTF8.GetBytes(password.text));
        string url       = string.Format(LoginResult.URL, WWW.EscapeURL(username.text), WWW.EscapeURL(encodedpw));
        WWW    www       = new WWW(url);

        yield return(www);

        if (www.error != null)
        {
            errorSubtitle.text = www.error;
        }
        else
        {
            user = JsonUtility.FromJson <LoginResult>(www.text);
            if (user.error == null)
            {
                PersistentUser.Create(user);
                sceneChanger.LoadScene("Map Scene");
            }
            else
            {
                errorSubtitle.text = user.error;
            }
        }
    }
示例#3
0
        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());
            }
        }
示例#4
0
        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");
            }

            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);
        }
示例#6
0
    IEnumerator RegisterCoroutine()
    {
        errorSubtitle.text = "";
        string pwhash = PBKDF2Hash.Hash(password.text);
        string url    = string.Format(registerURL,
                                      WWW.EscapeURL(username.text),
                                      WWW.EscapeURL(pwhash),
                                      WWW.EscapeURL(email.text));
        WWW www = new WWW(url);

        yield return(www);

        if (www.error != null)
        {
            errorSubtitle.text = www.error;
        }
        else
        {
            LoginResult json = JsonUtility.FromJson <LoginResult>(www.text);
            if (json.error == null)
            {
                PersistentUser.Create(json);
                sceneChanger.LoadScene("Map Scene");
            }
            else
            {
                errorSubtitle.text = json.error;
            }
        }
    }
示例#7
0
        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);
                }
            }
        }
示例#8
0
        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);
        }
示例#9
0
        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);
            }
        }
示例#10
0
        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())
            {
                DateTime now = DateTime.Now;

                PersistentEvent e = new PersistentEvent();
                e.ID             = Guid.NewGuid();
                e.CreatedBy      = userID;
                e.CreatedOn      = now;
                e.LastModifiedBy = userID;
                e.LastModifiedOn = now;
                e.IsActive       = true;
                e.ProfileID      = new Guid(context.Request["ProfileID"]);
                e.Description    = context.Request["Description"];
                e.Severity       = int.Parse(context.Request["Severity"]);
                e.Timestamp      = now;

                s.Save(e);

                try
                {
                    trans.Commit();
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    throw ex;
                }

                context.Response.Write(e.ToPersistentXml());
            }
        }
示例#11
0
        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())
            {
                PersistentUser newUser = new PersistentUser();

                newUser.Client = s.CreateCriteria <PersistentClient>()
                                 .Add(Restrictions.Eq("ID", new Guid(context.Request["NewUserClientID"])))
                                 .Add(Restrictions.Eq("IsActive", true))
                                 .UniqueResult <PersistentClient>();

                newUser.HasAPIAccess = bool.Parse(context.Request["NewUserHasAPIAccess"]);
                newUser.FullName     = context.Request["NewUserFullName"];
                newUser.Username     = context.Request["NewUserUsername"];

                newUser.SetCreationInfo(userID);

                s.Save(newUser);

                try
                {
                    trans.Commit();
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    throw ex;
                }

                context.Response.Write(newUser.ToPersistentXml());
            }
        }
示例#12
0
        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 (NessusManagerSession session = new NessusManagerSession("https", "" + ConfigurationManager.AppSettings["nessusHost"] + "", 8834))
            {
                bool loggedIn = false;
                session.Authenticate("nessus", "nessus", 1234, out loggedIn);

                if (!loggedIn)
                {
                    throw new Exception("Not authed to nessus");
                }

                NessusObjectManager manager = new NessusObjectManager(session);

                var policies = manager.GetPolicies();

                string xml = "<nessusPolicies>";

                foreach (NessusPolicy policy in policies)
                {
                    xml = xml + policy.ToBusinessXml();
                }

                xml = xml + "</nessusPolicies>";

                context.Response.Write(xml);
            }
        }
示例#13
0
    // Use this for initialization
    void Start()
    {
#if UNITY_EDITOR
        if (PersistentUser.Instance == null)
        {
            PersistentUser.Create(new LoginResult("3fc82c00-7b92-11e8-a2a6-f04da27518b5", "alpha"));
        }
#endif

        StartCoroutine(GetItinerariesCoroutine());

        float sidebarWidth = this.RectTransform().rect.width;
        for (int i = 0; i < PagesTweens.Length; ++i)
        {
            PagesTweens[i].RectTransform().SetLocalPosX(sidebarWidth * i);
        }
    }
示例#14
0
        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)
        {
            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);
        }
示例#18
0
        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(NHibernate.Criterion.Restrictions.Eq("ID", userID))
                                  .Add(NHibernate.Criterion.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");
            }

            string xml = "<profileHosts>";

            IList <PersistentProfileHost> hosts = s.CreateCriteria <PersistentProfileHost>()
                                                  .Add(NHibernate.Criterion.Restrictions.Eq("ParentProfileID", new Guid(context.Request["ProfileID"])))
                                                  .List <PersistentProfileHost>();

            foreach (var host in hosts)
            {
                xml += host.ToPersistentXML(true);
            }

            xml += "</profileHosts>";
            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>();
        }
示例#20
0
        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);
        }
示例#21
0
        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);
        }
示例#22
0
        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);
            }
        }
示例#23
0
        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())
            {
                PersistentProfile parentProfile = s.CreateCriteria <PersistentProfile>()
                                                  .Add(Restrictions.Eq("ID", new Guid(context.Request["ParentProfileID"])))
                                                  .Add(Restrictions.Eq("IsActive", true))
                                                  .UniqueResult <PersistentProfile>();

                PersistentScan scan = new PersistentScan();
                scan.SetCreationInfo(userID);

                scan.Name          = context.Request["Name"];
                scan.ParentProfile = parentProfile;

                scan.ScanOptions = new PersistentScanOptions();
                scan.ScanOptions.SetCreationInfo(userID);
                scan.ParentProfile.VirtualMachines = new List <PersistentVirtualMachine>();

                if (context.Request["ScanVirtualMachines"] != null)
                {
                    string[] machines = context.Request["ScanVirtualMachines"].Split(',');

                    foreach (string machine in machines)
                    {
                        if (string.IsNullOrEmpty(machine))
                        {
                            continue;
                        }

                        PersistentVirtualMachine m = new PersistentVirtualMachine();
                        m.SetCreationInfo(userID);
                        m.Guid          = Guid.Parse(machine);
                        m.ParentProfile = scan.ParentProfile;
                        scan.ParentProfile.VirtualMachines.Add(m);

                        s.Update(scan.ParentProfile);
                    }
                }

                scan.ScanOptions.ParentScan = scan;

                if (context.Request["ScanIsDSXS"] != null && context.Request["ScanIsDSXS"].ToLower() == "true")
                {
                    scan.ScanOptions.IsDSXS = true;
                }
                if (context.Request["ScanIsSQLMap"] != null && context.Request["ScanIsSQLMap"].ToLower() == "true")
                {
                    scan.ScanOptions.IsSQLMap            = true;
                    scan.ScanOptions.SQLMapOptions       = new PersistentSQLMapOptions();
                    scan.ScanOptions.SQLMapOptions.Level = 2;
                    scan.ScanOptions.SQLMapOptions.SetCreationInfo(Guid.Empty);

                    s.Save(scan.ScanOptions.SQLMapOptions);
                }
                if (context.Request["ScanIsOpenVAS"] != null && context.Request["ScanIsOpenVAS"].ToLower() == "true")
                {
                    scan.ScanOptions.IsOpenVASAssessment = true;
                }
                if (context.Request["ScanIsNessus"] != null && context.Request["ScanIsNessus"].ToLower() == "true")
                {
                    scan.ScanOptions.IsNessusAssessment = true;
                }
                if (context.Request["ScanIsNexpose"] != null && context.Request["ScanIsNexpose"].ToLower() == "true")
                {
                    scan.ScanOptions.IsNexposeAssessment = true;
                }
                if (context.Request["ScanIsMetasploit"] != null && context.Request["ScanIsMetasploit"].ToLower() == "true")
                {
                    scan.ScanOptions.IsMetasploitAssessment = true;
                    scan.ScanOptions.MetasploitDiscovers    = bool.Parse(context.Request["MetasploitDiscovers"]);
                    scan.ScanOptions.MetasploitBruteforces  = bool.Parse(context.Request["MetasploitBruteforces"]);
                }
                if (context.Request["ScanIsBasicBruteforce"] != null && context.Request["ScanIsBasicBruteforce"].ToLower() == "true")
                {
                    scan.ScanOptions.IsBruteForce = true;
                }

                try
                {
                    s.Save(scan);

                    trans.Commit();
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    throw ex;
                }

                context.Response.Write(scan.ToPersistentXml());
            }
        }