Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TB_Netrange1_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                mTargetRecord.Clear();
                setARPScanBTOnStarted();

                try
                {
                    ARPScanConfig lARPConf = new ARPScanConfig()
                    {
                        InterfaceID      = mIfcID,
                        GatewayIP        = mGatewayIP,
                        LocalIP          = mLocalIP,
                        StartIP          = mStartIP,
                        StopIP           = mStopIP,
                        OnDataReceived   = updateTextBox,
                        OnARPScanStopped = setARPScanBTOnStopped,
                        IsDebuggingOn    = Simsang.Config.DebugOn()
                    };
                    cTaskARPScan.startARPScan(lARPConf);
                }
                catch (Exception lEx)
                {
                    LogConsole.Main.LogConsole.pushMsg(String.Format("ARPScan : {0}", lEx.Message));
                    MessageBox.Show(lEx.Message, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    setARPScanBTOnStopped();
                }
            } // if (e.KeyCo...
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pARPConf"></param>
        public void startARPScan(ARPScanConfig pARPConfig)
        {
            IPAddress lStartIPAddr;
            IPAddress lStopIPAddr;

            /*
             * Validate input parameters.
             */
            if (String.IsNullOrEmpty(pARPConfig.InterfaceID))
            {
                throw new Exception("Something is wrong with the interface ID");
            }
            else if (!IPAddress.TryParse(pARPConfig.StartIP, out lStartIPAddr))
            {
                throw new Exception("Something is wrong with the start IP address");
            }
            else if (!IPAddress.TryParse(pARPConfig.StopIP, out lStopIPAddr))
            {
                throw new Exception("Something is wrong with the stop IP address");
            }
            else if (IPHelper.Compare(lStartIPAddr, lStopIPAddr) > 0)
            {
                throw new Exception("Start IP address is greater than stop IP address");
            }

            cInfrastructure.startARPScan(pARPConfig);
        }
Example #3
0
        public void INFRASTRUCTURE_startIP_null()
        {
            getARPScanBinary();
            ARPScanConfig lConfig = new ARPScanConfig()
            {
                InterfaceID = "our-ifc-id", StartIP = null, StopIP = "192.168.1.150", GatewayIP = "192.168.1.1", LocalIP = "192.168.1.123"
            };

            cTask.startARPScan(lConfig);
        }
Example #4
0
        public void INFRASTRUCTURE_interface_empty()
        {
            getARPScanBinary();
            ARPScanConfig lConfig = new ARPScanConfig()
            {
                InterfaceID = "", StartIP = "192.168.1.0", StopIP = "192.168.1.150", GatewayIP = "192.168.1.1", LocalIP = "192.168.1.123"
            };

            cTask.startARPScan(lConfig);
        }
Example #5
0
        public void INFRASTRUCTURE_binary_not_found()
        {
            Tools.removeFile(cARPScanPathLocal);
            ARPScanConfig lConfig = new ARPScanConfig()
            {
                InterfaceID = "our-ifc-id", StartIP = "192.168.1.0", StopIP = "192.168.1.150", GatewayIP = "192.168.1.1", LocalIP = "192.168.1.123"
            };

            cTask.startARPScan(lConfig);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="pIfcID"></param>
        /// <param name="pStartIP"></param>
        /// <param name="pStopIP"></param>
        /// <param name="pOnDataFunc"></param>
        /// <param name="pOnStop"></param>
        public void startARPScan(ARPScanConfig pARPConfig)
        {
            cARPScanConf = pARPConfig;

            if (!File.Exists(cARPScanBin))
            {
                throw new Exception("ARPscan binary not found");
            }

            cARPScanProc = new Process();
            cARPScanProc.StartInfo.FileName        = cARPScanBin;
            cARPScanProc.StartInfo.Arguments       = String.Format("{0} {1} {2}", cARPScanConf.InterfaceID, cARPScanConf.StartIP, cARPScanConf.StopIP);
            cARPScanProc.StartInfo.UseShellExecute = false;
            //cARPScanProc.StartInfo.CreateNoWindow = true;
            cARPScanProc.StartInfo.CreateNoWindow = cARPScanConf.IsDebuggingOn ? false : true;
            cARPScanProc.StartInfo.WindowStyle    = cARPScanConf.IsDebuggingOn ? ProcessWindowStyle.Normal : ProcessWindowStyle.Hidden;

            // set up output redirection
            cARPScanProc.StartInfo.RedirectStandardOutput = true;
            //cARPScanProc.StartInfo.RedirectStandardError = true;
            cARPScanProc.EnableRaisingEvents = true;

            // Set the data received handlers
            //cARPScanProc.ErrorDataReceived += onDataRecived;
            cARPScanProc.OutputDataReceived += onDataRecived;

            // Configure the process exited event
            cARPScanProc.Exited   += onARPScanExited;
            cARPScanProc.Disposed += onARPScanExited;

            cARPScanProc.Start();
            //cARPScanProc.BeginErrorReadLine();
            cARPScanProc.BeginOutputReadLine();

            Thread.Sleep(100);
        }