/// <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);
    }
Пример #2
0
    /// <summary>
    /// 
    /// </summary>
    /// <param name="pARPConf"></param>
    public void startARPScan(ARPScanConfig pARPConfig)
    {
      //IPAddress lStartIP = IPAddress.Parse("10.11.12.14");
      //IPAddress lStopIP = IPAddress.Parse("10.11.12.13");

      IPAddress lStartIP;
      IPAddress lStopIP;
/*
      // Parsing start/stop ip addresses
      try
      {
          lStartIP = IPAddress.Parse(pARPConfig.StartIP);
      }
      catch (Exception lEx)
      {
          throw new Exception("Something is wrong with the start IP address");
      }

      try
      {
          lStopIP = IPAddress.Parse(pARPConfig.StopIP);
      }
      catch (Exception lEx)
      {
          throw new Exception("Something is wrong with the stop IP address");
      }
  */    

      /*
       * 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 lStartIP))
        throw new Exception("Something is wrong with the start IP address");
      else if (!IPAddress.TryParse(pARPConfig.StopIP, out lStopIP))
        throw new Exception("Something is wrong with the stop IP address");
      else if (IPHelper.Compare(lStartIP, lStopIP) > 0)
        throw new Exception("Start IP address is greater than stop IP address");

      cInfrastructure.startARPScan(pARPConfig);
    }
Пример #3
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 = (RB_Netrange.Checked == true) ? TB_Netrange1.Text.ToString() : TB_Subnet1.ToString(),
            StopIP = (RB_Netrange.Checked == true) ? TB_Netrange2.Text.ToString() : TB_Subnet2.ToString(),
//          StartIP = mStartIP,
//          StopIP = mStopIP,
            OnDataReceived = updateTextBox,
            OnARPScanStopped = setARPScanBTOnStopped,
            IsDebuggingOn = Debugging.IsDebuggingOn()
          };
          cTaskARPScan.startARPScan(lARPConf);
        }
        catch (Exception lEx)
        {
          LogConsole.Main.LogConsole.LogInstance.LogMessage(String.Format("ARPScan : {0}", lEx.Message));
          MessageBox.Show(lEx.Message, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
          setARPScanBTOnStopped();
        }
      } // if (e.KeyCo...
    }
Пример #4
0
    /// <summary>
    /// 
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void BT_Scan_Click(object sender, EventArgs e)
    {
      String lStartIP = String.Empty;
      String lStopIP = String.Empty;

      mTargetRecord.Clear();
      setARPScanBTOnStarted();


      try
      {
          // User defined net range
          if (RB_Netrange.Checked == true)
          {
            lStartIP = TB_Netrange1.Text.ToString();
            lStopIP = TB_Netrange2.Text.ToString();
          }
          else
          {
            lStartIP = TB_Subnet1.Text.ToString();
            lStopIP = TB_Subnet2.Text.ToString();
          }


        ARPScanConfig lARPConf = new ARPScanConfig()
        {
          InterfaceID = mIfcID,
          GatewayIP = mGatewayIP,
          LocalIP = mLocalIP,
          StartIP = lStartIP,
          StopIP = lStopIP,

          OnDataReceived = updateTextBox,
          OnARPScanStopped = ARPScanStopped,
          IsDebuggingOn = Debugging.IsDebuggingOn()
        };

        cTaskARPScan.startARPScan(lARPConf);
      }
      catch (Exception lEx)
      {
        LogConsole.Main.LogConsole.LogInstance.LogMessage(String.Format("ARPScan : {0}", lEx.Message));
        MessageBox.Show(lEx.Message, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
        setARPScanBTOnStopped();
      }
    }
Пример #5
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TB_Netrange2_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.KeyCod...
        }
Пример #6
0
 public void INFRASTRUCTURE_stopIP_greater_than_startIP()
 {
     getARPScanBinary();
       ARPScanConfig lConfig = new ARPScanConfig() { InterfaceID = "our-ifc-id", StartIP = "192.168.1.140", StopIP = "192.168.1.15", GatewayIP = "192.168.1.1", LocalIP = "192.168.1.123" };
       cTask.startARPScan(lConfig);
 }
Пример #7
0
 public void INFRASTRUCTURE_interface_null()
 {
     getARPScanBinary();
       ARPScanConfig lConfig = new ARPScanConfig() { InterfaceID = null, StartIP = "192.168.1.0", StopIP = "192.168.1.150", GatewayIP = "192.168.1.1", LocalIP = "192.168.1.123" };
       cTask.startARPScan(lConfig);
 }
Пример #8
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);
 }
Пример #9
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);
        }