/* * Invokes the specified scanner method and verifies the scanned value with the specified expected value. */ private void assertEquals <T>(string name, T expected, ScanMethod <T> scan, EqualsMethod <T> equals) { WriteLine(); WriteLine("Testovaná metoda: \"{0}\"", name); T actual; WriteLine("Očekávaná hodnota: \"{0}\"", expected); try { actual = scan(); } catch (System.Exception e) { WriteLine("CHYBA: " + e.Message); errorsInMethod++; return; } if (equals(expected, actual)) { WriteLine("OK"); } else { WriteLine("FAIL - skutečná hodnota: \"{0}\"", actual); errorsInMethod++; } }
public IntPtr Find(byte[] pattern, int patternOffset, int addressOffset, ScanMethod method) { int length = pattern.Length; int i = 0; int k = 0; int loopDist = dump.Length - length; while (i < loopDist) { if (pattern[k] == 0x00 || dump[i] == pattern[k]) { k++; if (k == length) { break; } } else { i -= k; k = 0; } i++; } int address = i - k + 1; if (address < 1) { return(IntPtr.Zero); } switch (method) { case ScanMethod.None: return((IntPtr)(address + patternOffset + addressOffset)); case ScanMethod.Add: return(baseAddress + address + patternOffset + addressOffset); case ScanMethod.Subtract: return(baseAddress - address + patternOffset + addressOffset); case ScanMethod.Read: return(memory.Read <IntPtr>(baseAddress + address + patternOffset) + addressOffset); case ScanMethod.ReadAndSubtract: return((IntPtr)((memory.Read <IntPtr>(baseAddress + address + patternOffset) + addressOffset).ToInt64() - baseAddress.ToInt64())); } return((IntPtr)address); }
private void StartScan() { scannerType = (ScannerType)comboBoxScannerType.SelectedValue; scanMethod = (ScanMethod)comboBoxScanMethod.SelectedValue; delay = Int32.Parse(textBoxDelay.Text); timeout = Int32.Parse(textBoxTimeout.Text); string[] hosts = textBoxHost.Text.Trim().Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); hostEntries = new IPHostEntry[hosts.Length]; for (int i = 0; i < hosts.Length; i++) { hostEntries[i] = Dns.GetHostEntry(hosts[i]); } fromPort = Int32.Parse(textBoxFromPort.Text); if (textBoxToPort.Visible) { toPort = Int32.Parse(textBoxToPort.Text); } device = chooseDeviceUserControl.Device; // Matching selected interface with .NET's facilities in order to get gateway's ip address // that is a property of the network interface of interest. NetworkInterface adapter = GetMatchingNetworkInterface(device.Interface, nics); if (adapter == null) { throw new Exception("Network interface not found."); } if (scanMethod == ScanMethod.SynScan) { if (device.Opened) { MessageBox.Show("The sniffing process must be stopped in order to perform SYN Scan.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } IPInterfaceProperties properties = adapter.GetIPProperties(); GatewayIPAddressInformationCollection gateways = properties.GatewayAddresses; if (gateways.Count > 0) { gateway = gateways[0].Address; } else { throw new Exception("No gateway address found."); } } textBoxScanResult.Clear(); buttonStartScan.Enabled = false; buttonSaveLog.Enabled = false; backgroundWorkerScan.RunWorkerAsync(); }
public IntPtr Find(string mask, int patternOffset, int addressOffset, ScanMethod method) { return(Find(MaskToPattern(mask), patternOffset, addressOffset, method)); }
private void btnStart_Click(object sender, EventArgs e) { var x = cbMethods.SelectedItem as ToStrinhHolder; if (x == null) return; var method = x.obj as ScanMethod; if (method == null) return; _ScannedMethod = method; panel7.Enabled = false; var path = cfg.Do(method, User); panel7.Enabled = true; }