Пример #1
0
        private void button_newScan_Click(object sender, RoutedEventArgs e)
        {
            if (Properties.Settings.Default.windowNotLocked)
            {
                Properties.Settings.Default.windowNotLocked = false;
                Properties.Settings.Default.Save();

                if (!(Properties.Settings.Default.overwriteIP))
                {
                    ChangeIPRange();
                }

                //now for the completely overriting the ip scan range

                //check to see if IP can be overwritten
                string defaultNMAPCommand = Properties.Settings.Default.nmapCommand;

                if (Properties.Settings.Default.overwriteIP)
                {
                    SunScan.Properties.Settings.Default.ipToScan = Properties.Settings.Default.ipToOverwrite;
                    SunScan.Properties.Settings.Default.Save();

                    NMAPScan.WriteFile(defaultNMAPCommand + Properties.Settings.Default.ipToOverwrite, "test1.txt");
                }

                setupProgressSection("Scanning " + Properties.Settings.Default.ipToScan, "Please be patient while we scan for devices. This may take a while.", true, 0);
                scanBackgroundWorker.RunWorkerAsync();
            }
        }
Пример #2
0
        private void button_saveSettings_Click(object sender, RoutedEventArgs e)
        {
            int scanRange = 0;

            Properties.Settings.Default.ipToOverwrite = overwriteIPBox.Text.ToString(); //This is the custom IP address

            scanRange = int.Parse(ipRangeBox.Text);

            Properties.Settings.Default.ipScanRange = scanRange; //This is the +/- range specified in the text box
            Properties.Settings.Default.Save();

            if (!(Properties.Settings.Default.overwriteIP))
            {
                ChangeIPRange();
            }

            //now for the completely overriting the ip scan range

            //check to see if IP can be overwritten
            string defaultNMAPCommand = Properties.Settings.Default.nmapCommand;

            if (Properties.Settings.Default.overwriteIP)
            {
                SunScan.Properties.Settings.Default.ipToScan = Properties.Settings.Default.ipToOverwrite;
                SunScan.Properties.Settings.Default.Save();

                NMAPScan.WriteFile(defaultNMAPCommand + Properties.Settings.Default.ipToOverwrite, "test1.txt");
            }

            textbox_nmapcommand.Text = Properties.Settings.Default.nmapCommand + Properties.Settings.Default.ipToScan;

            textbox_settings_saved.Visibility = Visibility.Visible;
        }
Пример #3
0
        private void button_newScan_Click(object sender, RoutedEventArgs e)
        {
            if (Properties.Settings.Default.windowNotLocked)
            {
                Properties.Settings.Default.windowNotLocked = false;
                Properties.Settings.Default.Save();

                if ((!Properties.Settings.Default.overwriteIP) && (Properties.Settings.Default.ipScanRange == 0) || !File.Exists(nmapCommandFile))
                {
                    NMAPScan.GetIPConfig(nmapCommandFile);
                }

                setupProgressSection("Scanning " + Properties.Settings.Default.ipToScan, "Please be patient while we scan for devices. This may take a while.", true, 0);
                scanBackgroundWorker.RunWorkerAsync();
            }
        }
Пример #4
0
    //this is for debugging only!
    public static void RunTests()
    {
        System.Collections.Generic.List <string> outs = new System.Collections.Generic.List <string>();

        using (System.IO.StreamReader rd = new System.IO.StreamReader("testInput.txt"))
        {
            string line = "";

            while ((line = rd.ReadLine()) != null)
            {
                string[] parts = line.Split(' ');

                outs.Add(NMAPScan.GetRange(parts[0], parts[1]));
            }
        }

        using (System.IO.StreamWriter wr = new System.IO.StreamWriter("testOutput.txt"))
        {
            foreach (string s in outs)
            {
                wr.WriteLine(s);
            }
        }
    }
Пример #5
0
        private void ChangeIPRange()
        {
            NMAPScan.GetIPConfig(nmapCommandFile);

            string defaultNMAPCommand = Properties.Settings.Default.nmapCommand;

            string ipRangeNoNmap = "";

            int range = Properties.Settings.Default.ipScanRange;

            string ip = NMAPScan.GetIPAddress();

            string[] addrParts = ip.Split('.');

            addrParts[addrParts.Length - 1] = "*";

            string rangeToChange = addrParts[addrParts.Length - 2];

            int ipconfigResult = int.Parse(rangeToChange);

            int low  = ipconfigResult - range;
            int high = ipconfigResult + range;

            if (low < 0)
            {
                low = 0;
            }

            string newIPRange = "";

            if (range == 0)
            {
                newIPRange = ipconfigResult + "";
            }
            else
            {
                newIPRange = low + "-" + high;
            }

            for (int i = 0; i < addrParts.Length; i++)
            {
                if (i == addrParts.Length - 2)
                {
                    ipRangeNoNmap += newIPRange;
                }

                else
                {
                    ipRangeNoNmap += addrParts[i];
                }

                if (i < addrParts.Length - 1)
                {
                    ipRangeNoNmap += ".";
                }
            }

            //NMAPScan.WriteFile(Properties.Settings.Default.overwriteIP + " " + Properties.Settings.Default.ipToOverwrite +  " " + newIPAddressRange, "testBoolean.txt");

            SunScan.Properties.Settings.Default.ipToScan = ipRangeNoNmap;
            SunScan.Properties.Settings.Default.Save();

            NMAPScan.WriteFile(defaultNMAPCommand + ipRangeNoNmap, "test1.txt");
        }
Пример #6
0
 private void ScanBackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
 {
     NMAPScan.ReadCommands(nmapCommandFile, nmapXMLFile);
 }