public ArrayList ScanbyIP() { ArrayList systems = new ArrayList(); String[] localIPs = GetIP(Dns.GetHostName()).Split(','); String localIP = localIPs[0]; if (localIPs.Length > 1) { poshsecframework.Interface.frmScan frm = new poshsecframework.Interface.frmScan(); frm.IPs = localIPs; if (frm.ShowDialog() == DialogResult.OK) { localIP = frm.SelectedIP; } frm.Dispose(); frm = null; } if (localIP != "" && localIP != null) { String[] ipparts = localIP.Split('.'); if (ipparts != null && ipparts.Length == 4) { frm.SetProgress(0, 255); int ip = 1; do { String host = ipparts[0] + "." + ipparts[1] + "." + ipparts[2] + "." + ip.ToString(); frm.SetStatus("Scanning " + host + ", please wait..."); frm.SetProgress(ip, 255); if (Ping(host, 1, 100)) { systems.Add(host); Application.DoEvents(); } ip++; } while(ip < 255 && !frm.CancelIPScan); } } frm.HideProgress(); frm.SetStatus("Ready"); return systems; }
public void ScanbyIP() { systems.Clear(); ClearArpTable(); String[] localIPs = GetIP(Dns.GetHostName()).Split(','); String localIP = localIPs[0]; bool cancelled = false; if (localIPs.Length > 1) { poshsecframework.Interface.frmScan frm = new poshsecframework.Interface.frmScan(); frm.IPs = localIPs; frm.StartPosition = FormStartPosition.CenterScreen; if (frm.ShowDialog() == DialogResult.OK) { localIP = frm.SelectedIP; } else { cancelled = true; } frm.Dispose(); frm = null; } if (localIP != "" && localIP != null && !cancelled) { String[] ipparts = localIP.Split('.'); if (ipparts != null && ipparts.Length == 4) { if (shstatus) { frm.SetProgress(0, 255); } int ip = 1; bool cancel = false; do { String host = ipparts[0] + "." + ipparts[1] + "." + ipparts[2] + "." + ip.ToString(); if (shstatus) { frm.SetStatus("Scanning " + host + ", please wait...");} if (shstatus) { frm.SetProgress(ip, 255);} poshsecframework.Network.ScanIP scn = new poshsecframework.Network.ScanIP(); scn.IPAddress = host; scn.Index = ip; scn.ScanIPComplete += scn_ScanIPComplete; System.Threading.Thread thd = new System.Threading.Thread(scn.Scan); thds.Add(thd); thd.Start(); ip++; if (shstatus) { cancel = frm.CancelIPScan; } } while (ip < 255 && !cancel); if (shstatus) { frm.SetStatus(StringValue.WaitingForHostResp); } do { System.Threading.Thread.Sleep(100); } while (ThreadsActive()); systems.Sort(); BuildArpTable(); if (shstatus) { frm.HideProgress();} if (shstatus) { frm.SetStatus(StringValue.Ready);} OnScanComplete(new poshsecframework.Network.ScanEventArgs(systems)); } } else { OnScanCancelled(new EventArgs()); } }
public void ScanbyIP() { systems.Clear(); ClearArpTable(); String[] localIPs = GetIP(Dns.GetHostName()).Split(','); String localIP = localIPs[0]; bool cancelled = false; if (localIPs.Length > 1) { poshsecframework.Interface.frmScan frm = new poshsecframework.Interface.frmScan(); frm.IPs = localIPs; frm.StartPosition = FormStartPosition.CenterScreen; if (frm.ShowDialog() == DialogResult.OK) { localIP = frm.SelectedIP; } else { cancelled = true; } frm.Dispose(); frm = null; } if (localIP != "" && localIP != null && !cancelled) { String[] ipparts = localIP.Split('.'); if (ipparts != null && ipparts.Length == 4) { if (shstatus) { frm.SetProgress(0, 255); } int ip = 1; bool cancel = false; do { String host = ipparts[0] + "." + ipparts[1] + "." + ipparts[2] + "." + ip.ToString(); if (shstatus) { frm.SetStatus("Scanning " + host + ", please wait..."); } if (shstatus) { frm.SetProgress(ip, 255); } poshsecframework.Network.ScanIP scn = new poshsecframework.Network.ScanIP(); scn.IPAddress = host; scn.Index = ip; scn.ScanIPComplete += scn_ScanIPComplete; System.Threading.Thread thd = new System.Threading.Thread(scn.Scan); thds.Add(thd); thd.Start(); ip++; if (shstatus) { cancel = frm.CancelIPScan; } } while (ip < 255 && !cancel); if (shstatus) { frm.SetStatus(StringValue.WaitingForHostResp); } do { System.Threading.Thread.Sleep(100); } while (ThreadsActive()); systems.Sort(); BuildArpTable(); if (shstatus) { frm.HideProgress(); } if (shstatus) { frm.SetStatus(StringValue.Ready); } OnScanComplete(new poshsecframework.Network.ScanEventArgs(systems)); } } else { OnScanCancelled(new EventArgs()); } }