Ejemplo n.º 1
0
 /// <summary>
 /// 
 /// </summary>
 /// <returns></returns>
 /// <comment>In this particular case communicating back from Task layer to Presentation
 ///          is legal. The method has to access the live DataGridView.</comment>
 public static TaskFacade getInstance(SimsangMain pParentWindow)
 {
   return cInstance ?? (cInstance = new TaskFacade(pParentWindow));
 }
Ejemplo n.º 2
0
 /// <summary>
 /// For mock testing purposes only.
 /// </summary>
 /// <param name="pParent"></param>
 /// <param name="pDGVPlugins"></param>
 /// <returns></returns>
 public static TaskFacade getInstance()
 {
   return cInstance ?? (cInstance = new TaskFacade());
 }
Ejemplo n.º 3
0
    /// <summary>
    /// 
    /// </summary>
    /// <param name="args"></param>
    private SimsangMain(String[] args)
    {
      InitializeComponent();

      // Init configuration
      Config.InitializeSimsangConfig();

      #region Datagrid header

      DataGridViewTextBoxColumn mPluginNameCol = new DataGridViewTextBoxColumn();
      mPluginNameCol.DataPropertyName = "PluginName";
      mPluginNameCol.HeaderText = "Plugin name";
      mPluginNameCol.ReadOnly = true;
      mPluginNameCol.Width = 120;
      DGV_MainPlugins.Columns.Add(mPluginNameCol);

      DataGridViewTextBoxColumn mPluginVersionCol = new DataGridViewTextBoxColumn();
      mPluginVersionCol.DataPropertyName = "PluginVersion";
      mPluginVersionCol.HeaderText = "Version";
      mPluginVersionCol.ReadOnly = true;
      DGV_MainPlugins.Columns.Add(mPluginVersionCol);

      DataGridViewCheckBoxColumn mActivatedCol = new DataGridViewCheckBoxColumn();
      mActivatedCol.DataPropertyName = "Active";
      mActivatedCol.Name = "Active";
      mActivatedCol.HeaderText = "Activated";
      mActivatedCol.FalseValue = "0";
      mActivatedCol.TrueValue = "1";
      mActivatedCol.Visible = true;
      DGV_MainPlugins.Columns.Add(mActivatedCol);

      DataGridViewTextBoxColumn mPluginDescriptionCol = new DataGridViewTextBoxColumn();
      mPluginDescriptionCol.DataPropertyName = "PluginDescription";
      mPluginDescriptionCol.HeaderText = "Description";
      mPluginDescriptionCol.ReadOnly = true;
      mPluginDescriptionCol.Width = 120;
      mPluginDescriptionCol.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
      DGV_MainPlugins.Columns.Add(mPluginDescriptionCol);

      
      mUsedPlugins = new BindingList<PluginTableRecord>();
      DGV_MainPlugins.DataSource = mUsedPlugins;

      #endregion

      cBGWorkerPluginsOnStartAttack = new BackgroundWorker() { WorkerSupportsCancellation = true };
      cBGWorkerPluginsOnStartAttack.DoWork += new DoWorkEventHandler(BGW_OnStartPlugins);

      cBGWorkerPluginsOnStopAttack = new BackgroundWorker() { WorkerSupportsCancellation = true };
      cBGWorkerPluginsOnStopAttack.DoWork += new DoWorkEventHandler(BGW_OnStopPlugins);

      cTargetList = new BindingList<String>();
      cInputModule = new InputModule(this);
      cPluginHandler = new PluginHandler(this);
      cSessionPresentationFacade = Session.Sessions.getInstance(this);
      cSessionTaskFacade = Session.TaskFacade.getInstance();
      cTemplateTaskFacade = Template.TaskFacade.getInstance(this);
      cSimsangTaskFacade = TaskFacade.getInstance(this, DGV_MainPlugins);
      cCurrentSession = new AttackSession();
      cCurrentSession.StartTime = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");

      // Initialize TabPage handler
      cTabPageHandler = new TabPageHandler(TC_Plugins, this); 

      // Initialize log console
      LogConsole.Main.LogConsole.LogInstance.InitializeLogConsole();


      // Check Pcap version
      try
      {
        L_PCAPVersion.Text = Config.WinPcap = WinPcap.getInstance().getWinPcapVersion();
      }
      catch (Exception lEx)
      {
        MessageBox.Show(lEx.Message, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Information);
      }


      // Check if an other instance is running.
      SimsangProcess.getInstance().handleRunningInstances();


      // Check if configuration is ok.
      this.ConfigOK(Directory.GetCurrentDirectory());


      // Set current Debugging mode in GUI
      if (Debugging.IsDebuggingOn())
      {
        TSMI_Debugging.Text = "Turn debugging off";
        this.setAppTitle("Debugging");
      }
      else
      {
        TSMI_Debugging.Text = "Turn debugging on";
        this.setAppTitle("");
      }

      // Populate network interface.
      this.LoadNICSettings();
      LogConsole.Main.LogConsole.LogInstance.LogMessage(String.Format("Current directory : {0}", Directory.GetCurrentDirectory()));

      // Start data input thread.
      cInputModule.startInputThread();
      

      if (CB_Interfaces.Items.Count <= 0)
      {
        MessageBox.Show("No active network adapter found!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
      }
      else
      {
        // Init ARPScan console
        try
        {
          Simsang.ARPScan.Main.ARPScan.InitARPScan(this, ref cTargetList);
        }
        catch (Exception lEx)
        {
          LogConsole.Main.LogConsole.LogInstance.LogMessage("Main() : " + lEx.StackTrace);
          Application.Exit();
          //          Environment.Exit(0);
        }
        mAttackStarted = false;
      } // if (CB_Inter...



      // Check if new Simsang version is available
      (new Thread(delegate()
      {
        Simsang.Common.Updates.CheckForSimsangUpdates();
      })).Start();
      


      //// Set .sim file extension association
      //String lSimsangFullPath = Application.ExecutablePath;
      //String lPWD = Directory.GetCurrentDirectory();
      //String lIconPath = Path.Combine(lPWD, "images", "Simsang.ico");

      //Simsang.Common.Associations.AF_FileAssociator assoc = new Simsang.Common.Associations.AF_FileAssociator(".sim");
      //try
      //{
      //  if (assoc.Exists)
      //    assoc.Delete();
      //}
      //catch (Exception lEx)
      //{
      //  LogConsole.Main.LogConsole.LogInstance.LogMessage(String.Format("Simsang.MainForm_Start(EXCEPTION): {0}", lEx.Message));
      //}


      //try
      //{
      //  assoc.Create("Simsang_250",
      //                "Simsang .sim file association",
      //                new Simsang.Common.Associations.ProgramIcon(lIconPath),
      //                new Simsang.Common.Associations.ExecApplication(lSimsangFullPath),
      //                new Simsang.Common.Associations.OpenWithList(new String[] { "Simsang_250" }));
      //}
      //catch (Exception lEx)
      //{
      //  LogConsole.Main.LogConsole.LogInstance.LogMessage(String.Format("Simsang.MainForm_Start(EXCEPTION): {0}", lEx.Message));
      //}

      //// Tell explorer the file association has been changed
      //SHChangeNotify(0x8000000, 0x1000, IntPtr.Zero, IntPtr.Zero);
      Simsang.Common.Associations.SimFiles.InstallSimFileAssociation();


      // Load and initialize all plugins
      cPluginHandler = new PluginHandler(this); //, cPluginHandler.PluginList.GetPluginPosition);
      cPluginHandler.LoadPlugins();




      // Import and load session/template file
      if (args != null && args.Length > 0)
      {
        SimsangFileType lFileType = this.DetermineFileType(args[0]);


        if (lFileType == SimsangFileType.SessionTemplateFile)
          this.cTemplateTaskFacade.LoadSessionTemplate(args[0]);
        else
          cPluginHandler.RestoreLastPluginLoadState();

//        else if (lFileType == SimsangFileType.SessionFile)
//          this.LoadDefaultSession(args[0]);

      }
      else
      {
        // Hide all plugins what have the status "off"
        cPluginHandler.RestoreLastPluginLoadState();
      }
    }