Example #1
0
 public LimiterClass(Device device)
 {
     this.device   = device;
     capturedevice = CaptureDeviceList.New()[Properties.Settings.Default.AdapterName];
     TargetMAC     = GetClientList.GetMACString(device.MAC);
     GatewayMAC    = GetClientList.GetMACString(device.GatewayMAC);
 }
Example #2
0
        private void metroTile1_Click(object sender, EventArgs e)
        {
            try
            {
                if (fastObjectListView1.SelectedObjects.Count == 0)
                {
                    throw new ArgumentException();
                }

                var selectedDevice = fastObjectListView1.SelectedObject as Device;

                if (!selectedDevice.Redirected && !(selectedDevice.IsGateway || selectedDevice.IsLocalDevice))
                {
                    throw new RedirectionNotActiveException();
                }


                new Thread(() =>
                {
                    loading = new Loading();
                    loading.ShowDialog();
                }).Start();

                SnifferStarted = true;
                GetReady();
                Sniffer sniff = new Sniffer(selectedDevice.IP.ToString(), GetClientList.GetMACString(selectedDevice.MAC), GetClientList.GetMACString(GetGatewayMAC()), GetGatewayIP().ToString(), loading);//for the berkeley packet filter macs should have ':' separating each hex number
                sniff.ShowDialog(this);
                fastObjectListView1.SelectedObjects.Clear();
                sniff.Dispose();
                SnifferStarted = false;

                fastObjectListView1.UpdateObject(selectedDevice);
            }
            catch (ArgumentException)
            {
                MetroMessageBox.Show(this, "Select a device first!", "Error", MessageBoxButtons.OK,
                                     MessageBoxIcon.Error);
            }
            catch (OperationInProgressException)
            {
                MetroMessageBox.Show(this, "The Packet Sniffer can't be used while the limiter is active!", "Error", MessageBoxButtons.OK,
                                     MessageBoxIcon.Error);
            }
            catch (RedirectionNotActiveException)
            {
                MetroMessageBox.Show(this, "Redirection must be active for this device!", "Error", MessageBoxButtons.OK,
                                     MessageBoxIcon.Error);
            }
        }