private async void btnGO_Click(object sender, RoutedEventArgs e)
        {

            try
            {
                if (checkbox_Null.IsChecked == false)
                {
                    string[] splat = tbUsername.Text.Split('\\');
                    if (splat.Length < 2)
                    {
                        throw new Exception("Enter a Domain");
                    }
                    else if (tbUsername.Text.ToLower() == "domain\\user")
                    {
                        throw new Exception("Enter credentials");
                    }

                    AUTHLOCALLY = splat[0] == "." ? true : false;
                }

                btn_Stop.IsEnabled = true;
                btn_Stop.Visibility = Visibility.Visible;
                btnGO.Visibility = Visibility.Hidden;
                resetGUI();
                List<IPAddress> ip_list = new List<IPAddress>();

                if (useImportedIPs == true)
                {
                    ip_list = ImportedIPs;
                }
                else
                {
                    try
                    {
                        IPRange ipr = new IPRange(tbIPRange.Text.Trim());
                        ip_list = ipr.GetAllIP().ToList();
                    }
                    catch (Exception)
                    {
                        throw new Exception("Invalid IP Range Entered.");
                    }
                }

                pgbMain.Maximum = ip_list.Count;
                addLog("Starting share enumeration of " + ip_list.Count + " servers (" + _parallelOption.MaxDegreeOfParallelism + " threads)...");

                pgbMain.Visibility = Visibility.Visible;

                List<Task<List<shareStruct>>> tList = new List<Task<List<shareStruct>>>();

                try
                {
                    await Task.Run(() =>
                    {
                        Parallel.ForEach(ip_list, _parallelOption, item =>
                            tList.Add(_populateShareStructsTimeout(item.ToString())));
                    });

                    //resolve any SIDs that are necessary on the domain specified
                    if (resolveGroupSIDs == true && USERNAME != null && USERNAME != "" && AUTHLOCALLY == false && SIDsToResolve.Count > 0) //no point resolving SIDs if we are authing locally only
                    {
                        addLog("Resolving " + SIDsToResolve.Count + " Group SIDs");
                        pgbMain.Value = 0;
                        pgbMain.Maximum = SIDsToResolve.Count;


                        string domainController = "";
                       
                        NetworkCredential creds = getNetworkCredentials("doesnt matter");

                        await Task.Run(() =>
                        {
                            Dispatcher.Invoke((Action)delegate
                            {
                                if (creds.Domain != null || creds.Domain != "")
                                {
                                    addLog("Getting domain controller");
                                    domainController = getDomainControllers(creds.Domain, creds.UserName, creds.Password);
                                }
                            });

                            if (domainController != "")
                            {
                                addLog("Using domain controller " + domainController + " for LDAP lookups");
                                Parallel.ForEach(SIDsToResolve, _parallelOption, SID =>
                                    {
                                        if (logLevel < LOG_LEVEL.ERROR)
                                        {
                                            Dispatcher.Invoke((Action)delegate { addLog("Attempting to look up domain SID " + SID); });
                                        }

                                        try
                                        {
                                            string ResolvedSID = resolveDomainGroupSID(SID, domainController, creds);
                                            if (ResolvedSID != "")
                                            {
                                                if (!SIDsDict.ContainsKey(SID))
                                                {
                                                    Dispatcher.Invoke((Action)delegate { addLog("Resolved Group SID " + SID + " to " + ResolvedSID); });
                                                }

                                                SIDsDict.TryAdd(SID, ResolvedSID);
                                            }
              }
                                        catch (Exception ex)
                                        {
                                            if (logLevel < LOG_LEVEL.INTERESTINGONLY)
                                            {
                                                Dispatcher.Invoke((Action)delegate { addLog("Failed to resolve SID " + SID + " - " + ex.ToString()); });
                                            }
                                        }

                                        Dispatcher.Invoke((Action)delegate { pgbMain.Value += 1; });
                                    });
                                } //end resolve domain sids if domain is not nothing
                        });


                        addLog("Finished Resolving SIDs");
                    }
                }

                catch (OperationCanceledException)
                {
                    addLog("Threads dead, baby. Threads dead.", true);
                    btn_Stop.Visibility = Visibility.Hidden;
                    btnGO.Visibility = Visibility.Visible;
                    pgbMain.Visibility = Visibility.Hidden;
                    btn_Stop.IsEnabled = true;
                    return;
                }

                pgbMain.Visibility = Visibility.Hidden;
                addLog("Share enumeration Complete.");

                btnGO.Visibility = Visibility.Visible;

                int totalServers = all_readable_shares.Count;
                int totalShares = 0;
                int everyoneReadable = 0;
                int userReadable = 0;


                foreach (var lss in all_readable_shares.Keys)
                {
                    totalShares += all_readable_shares[lss].Count;
                    foreach (shareStruct ss in all_readable_shares[lss])
                    {
                        if (ss.everyoneCanRead == true)
                        {
                            everyoneReadable++;
                            userReadable++;
                        }
                        else if (ss.currentUserCanRead == true)
                        {
                            userReadable++;
                        }
                    }
                }

                if (totalServers > 0)
                {
                    btnFindInterestingFiles.IsEnabled = true;
                    btnGrepFiles.IsEnabled = true;
                }
                addLog(userReadable + " shares readable by current user on " + totalServers + " servers");
                addLog(everyoneReadable + " shares readable by everyone");

            }
            catch (OperationCanceledException)
            {

                addLog("Threads dead, baby. Threads dead.", true);
                btn_Stop.Visibility = Visibility.Hidden;
                btnGO.Visibility = Visibility.Visible;
                btn_Stop.IsEnabled = true;
                return;
            }

            catch (Exception ex)
            {

                if (ex.InnerException != null && ex.InnerException.Message != null && ex.InnerException.Message == "The operation was canceled.")
                {
                    addLog("Threads dead, baby. Threads dead.", true);
                    btn_Stop.Visibility = Visibility.Hidden;
                    btnGO.Visibility = Visibility.Visible;
                    btn_Stop.IsEnabled = true;
                    return;
                }

                else
                {

                    btnGO.Visibility = Visibility.Visible;
                    pgbMain.Visibility = Visibility.Hidden;
                    MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation);

                    if (logLevel < LOG_LEVEL.INFO)
                    {
                        addLog("Bad exception " + ex.Message + ex.StackTrace);
                    }
                    else
                    {
                        addLog(ex.Message);
                    }
                }
            }
            btn_Stop.Visibility = Visibility.Hidden;
        }
        private void mi_importIPs_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();

            dlg.DefaultExt = ".*";
            dlg.Filter = "Any Files (*.*)|*.*|Text Files (*.txt)|*.txt";

            bool? result = dlg.ShowDialog();

            if (result == true)
            {
                addLog("Adding IPs from " + dlg.FileName);
                resetGUI();
                useImportedIPs = true;
                tbIPRange.Text = "Using Imported";

                ImportedIPs = new List<IPAddress>();
                try
                {
                    string line;
                    int fileEntries = 0;
                    int totalEntries = 0;

                    using (StreamReader reader = new StreamReader(dlg.FileName))
                    {
                        while ((line = reader.ReadLine()) != null)
                        {
                            try
                            {
                                fileEntries++;
                                IPRange ipr = new IPRange(line);
                                foreach (IPAddress ip in ipr.GetAllIP())
                                {
                                    ImportedIPs.Add(ip);
                                    totalEntries++;
                                }

                                useImportedIPs = true;
                            }
                            catch (Exception)
                            {
                                addLog("Error - failed to parse " + line + " as a valid IP range, skipping it..");
                            }
                        }
                    }

                    addLog("Successfully added " + fileEntries + " entries, " + totalEntries + " IPs total. Hit GO to begin.");
                }
                catch (Exception ex)
                {
                    addLog("Error importing IPs " + ex.Message + "\r\n" + ex.StackTrace);
                    useImportedIPs = false;
                }

            }


        }