Esempio n. 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) && (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();
            }
        }
Esempio n. 2
0
        private void button_saveSettings_Click(object sender, RoutedEventArgs e)
        {
            NMAPScan.GetIPConfig(nmapCommandFile);

            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.defaultWMIUsername = wmiUsername.Text;
            Properties.Settings.Default.defaultWMIPassword = wmiPassword.Password;
            Properties.Settings.Default.defaultWMIDomain   = wmiDomain.Text;

            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;
        }
Esempio n. 3
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");
        }