Ejemplo n.º 1
0
 private void btAddNewTarget_Click(object sender, System.EventArgs e)
 {
     if (null == strFullPathToCurrentProject || "" == strFullPathToCurrentProject)
     {
         MessageBox.Show("There is no project selected!");
         return;
     }
     if ("" == txtNewTargetName.Text)
     {
         MessageBox.Show("New Target name cannot be empty!");
     }
     else
     {
         VulnReportHelpers.createNewTargetAndAddItToListBox(lbTargetsInCurrentProject,
                                                            txtNewTargetName.Text,
                                                            strFullPathToCurrentProject);
         txtNewTargetName.Clear();
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// This methods loads entries into the targets area based off of status up.  If the value
        /// for the host node is up then all of the hostnames will be added.
        /// </summary>
        /// <param name="xdToImport"></param>
        private void LoadTargetsFromXml(XmlDocument xdToImport)
        {
            int         iNumberOfTargetsImported   = 0;
            int         iNumberOfTargetsIgnored    = 0;
            int         iNumberOfDuplicatedTargets = 0;
            string      strNameOfDuplicateFindings = "";
            XmlNode     xnHost;
            XmlNodeList xnlHostList;

            xnlHostList = xdToImport.GetElementsByTagName("host");
            if (xnlHostList.Count == 0)
            {
                MessageBox.Show("Alert: there are no hosts to import in this file");
            }
            else
            {
                for (int i = 0; i < xnlHostList.Count; i++)
                {
                    xnHost = xnlHostList[i];
                    if (xnHost.HasChildNodes)
                    {
                        // Make sure the host was actually up when the scan was ran
                        if (null != xnHost.SelectSingleNode("status[@state='up']") || cbIgnoreStatusFlag.Checked == true)
                        {
                            XmlNodeList xnlAddresses = xnHost.SelectNodes("address");
                            if (xnlAddresses.Count > 0)
                            {
                                for (int j = 0; j < xnlAddresses.Count; j++)
                                {
                                    XmlAttribute xaAddress = (XmlAttribute)xnlAddresses[j].Attributes.GetNamedItem("addr");
                                    if (xaAddress.Value != "")
                                    {
                                        string sanitizedHost = xaAddress.Value.Replace('.', '_');
                                        if (true == lbTargetsInCurrentProject.Items.Contains(sanitizedHost))
                                        {
                                            iNumberOfDuplicatedTargets++;
                                            strNameOfDuplicateFindings += sanitizedHost + ",";
                                        }
                                        else
                                        {
                                            VulnReportHelpers.createNewTargetAndAddItToListBox(lbTargetsInCurrentProject,
                                                                                               sanitizedHost,
                                                                                               strFullPathToCurrentProject);
                                            PopulateTargetInformation(xaAddress.Value, sanitizedHost, xnHost);
                                            iNumberOfTargetsImported++;
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            iNumberOfTargetsIgnored++;
                        }
                    }
                }
                string strImportReport = "NMAP Import completed." + Environment.NewLine;
                if (iNumberOfTargetsImported > 0)
                {
                    strImportReport += string.Format(Environment.NewLine + "{0} hosts were imported", iNumberOfTargetsImported);
                }
                if (iNumberOfTargetsIgnored > 0)
                {
                    strImportReport += string.Format(Environment.NewLine + "{0} hosts were NOT imported because: null== status[@state='up']", iNumberOfTargetsIgnored);
                }
                if (iNumberOfDuplicatedTargets > 0)
                {
                    strImportReport += string.Format(Environment.NewLine + "{0} hosts were NOT imported because they were duplicate of existing targets. Here is the list of those items: {1}", iNumberOfDuplicatedTargets, strNameOfDuplicateFindings.Substring(0, strNameOfDuplicateFindings.Length - 1));
                }

                MessageBox.Show(strImportReport);
            }
        }
 private void btCancel_Click(object sender, System.EventArgs e)
 {
     VulnReportHelpers.terminateProcess();
 }