Exemplo n.º 1
0
        public override IEnumerator <ParseReport> Generate(LLnParser.ParserContext ctx, TokenStream stream)
        {
            if (paths == null)
            {
                paths = new NonTerminalPath[token.Count];
                for (int i = 0, len = token.Count; i < len; i++)
                {
                    paths[i] = new NonTerminalPath(token, i);
                }
            }

            while (index < paths.Length)
            {
                var path = paths[index];
                yield return(ParseReport.Wait(path.Generate(ctx, stream)));

                if (path.IsClosed)
                {
                    index++;
                }

                if (index >= paths.Length)
                {
                    isClosed = true;
                }

                if (ctx.PopResult())
                {
                    ctx.PushResult(true);
                    yield break;
                }
            }

            ctx.PushResult(false);
        }
Exemplo n.º 2
0
        public void ImportFromNessusFile(List <string> filenames)
        {
            DatabaseController db = new DatabaseController();

            try {
                int                  lastHostID = db.GetFirstHostIDNumber();
                List <Host>          hostsList  = new List <Host>();
                List <Vulnerability> vulnList   = new List <Vulnerability>();

                foreach (string file in filenames)
                {
                    NessusParser parser = new NessusParser(file);
                    ParseReport  report = parser.Run();

                    foreach (ParseReportHost host in report.Hosts)
                    {
                        string hostname     = host.Properties.NetBiosName;
                        string fullqualname = host.Properties.HostFqdn;

                        if (string.IsNullOrEmpty(hostname))
                        {
                            hostname = "unknown";
                        }

                        if (string.IsNullOrEmpty(fullqualname))
                        {
                            fullqualname = "unknown";
                        }

                        hostsList.Add(new Host {
                            ID              = lastHostID,
                            HostIP          = host.Properties.HostIp,
                            FQDN            = fullqualname,
                            NetBiosName     = hostname,
                            OperatingSystem = host.Properties.OperatingSystem
                        });

                        List <ParseReportHostItem> vulnItems = host.Items;

                        foreach (ParseReportHostItem vuln in vulnItems)
                        {
                            vulnList.Add(new Vulnerability {
                                PluginID     = vuln.PluginId,
                                PluginName   = vuln.PluginName,
                                PluginType   = vuln.PluginType,
                                RiskFactor   = vuln.RiskFactor,
                                Severity     = vuln.Severity,
                                Description  = vuln.Description,
                                Solution     = vuln.Solution,
                                Port         = vuln.Port.ToString(),
                                Protocol     = vuln.Protocol,
                                Synopsis     = vuln.Synopsis,
                                PluginOutput = vuln.PluginOutput,
                                HostID       = lastHostID
                            });
                        }
                        ++lastHostID;
                    }
                }
                db.PopulateDatabaseFromNessus(hostsList, vulnList);
                db.RemoveDuplicatesFromDatabase();
            }
            catch (Exception) {
                Debug.WriteLine("Error: 96589");
            }
        }
Exemplo n.º 3
0
 protected void OnParseReport(double completedPersentage)
 {
     ParseReport?.Invoke(completedPersentage);
 }
Exemplo n.º 4
0
        public override IEnumerator <ParseReport> Generate(LLnParser.ParserContext ctx, TokenStream stream)
        {
            if (nodes == null)
            {
                nodes = new ParseNode[path.Length];
                for (var i = 0; i < path.Length; i++)
                {
                    nodes[i] = path[i].CreateNode();
                }
            }

            int n;

            if (init)
            {
                init = false;
                n    = 0;
            }
            else
            {
                n = nodes.Length - 1;
                if (!BackTrace(ref n, stream))
                {
                    isClosed = true;
                    ctx.PushResult(false);
                    yield break;
                }

                for (var i = n + 1; i < nodes.Length; i++)
                {
                    nodes[i].Clear();
                }
            }

            while (n < nodes.Length)
            {
                offsets.Push(stream.Offset);
                yield return(ParseReport.Wait(nodes[n].Generate(ctx, stream)));

                if (ctx.PopResult())
                {
                    n++;
                    continue;
                }

                offsets.Pop();
                n--;
                if (!BackTrace(ref n, stream))
                {
                    isClosed = true;
                    ctx.PushResult(false);
                    yield break;
                }

                for (var i = n + 1; i < nodes.Length; i++)
                {
                    nodes[i].Clear();
                }
            }

            ctx.PushResult(true);
        }