Ejemplo n.º 1
0
    /// <summary>
    /// 
    /// </summary>
    /// <param name="pSessionName"></param>
    public AttackSession loadSession(String pSessionName)
    {
      String lSessionFilePath = String.Empty;

      try
      {
        lSessionFilePath = String.Format(@"{0}\{1}.xml", mSessionDir, pSessionName);
      }
      catch (Exception lEx)
      {
        LogConsole.Main.LogConsole.LogInstance.LogMessage(lEx.StackTrace);
      }

      /*
       * Load main GUI session data.
       */
      FileStream lFS = null;
      XmlSerializer lXMLSerial;
      AttackSession lAttackSession = new AttackSession();
      String lStartIP = String.Empty;
      String lStopIP = String.Empty;

      try
      {
        lFS = new FileStream(lSessionFilePath, FileMode.Open);
        lXMLSerial = new XmlSerializer(typeof(AttackSession));
        lAttackSession = (AttackSession) lXMLSerial.Deserialize(lFS);
      }
      catch (Exception lEx)
      {
        LogConsole.Main.LogConsole.LogInstance.LogMessage(lEx.StackTrace);
      }
      finally
      {
        if (lFS != null)
          lFS.Close();
      }

      return(lAttackSession);
    }
Ejemplo n.º 2
0
 /// <summary>
 /// 
 /// </summary>
 public void SaveSessionData(AttackSession pAttackSession)
 {
   cInfrastructure.SaveSessionData(pAttackSession);
   FindAllSessions();
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="args"></param>
        private SimsangMain(String[] args)
        {
            InitializeComponent();

              #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<UsedPlugins>();
              DGV_MainPlugins.DataSource = mUsedPlugins;

              #endregion

              //var curr = new BindingSource(list, null);
              mTargetList = new BindingList<string>();
              mInputModule = new InputModule(this);
              mPluginModule = new PluginModule(this);
              mSessionPresentationFacade = Session.Sessions.getInstance(this);
              mSessionTaskFacade = Session.TaskFacade.getInstance();
              //mCurrentSession = new AttackSession(Directory.GetCurrentDirectory() + Config.SessionDir);
              mCurrentSession = new AttackSession();
              mCurrentSession.StartTime = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");

              // Initialize log console
              LogConsole.Main.LogConsole.getInstance();

              // Check Pcap version
              try
              {
            L_PCAPVersion.Text = Config.WinPcap = Config.IsProgrammInstalled("winpcap").ToLower();
            if (Config.WinPcap == null || Config.WinPcap.Length <= 0)
            {
              String lMsg = String.Format("WinPcap is not present and {0} probably won't work as expected. You can download WinPcap under http://www.winpcap.org", Config.ToolName);
              MessageBox.Show(lMsg, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Information);
            } // if (Config.WinP...
              }
              catch (Exception)
              {
            String lMsg = String.Format("WinPcap is not present and {0} probably won't work as expected. You can download WinPcap under http://www.winpcap.org", Config.ToolName);
            MessageBox.Show(lMsg, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Information);
              }

              /*
               * Init configuration
               */
              try { Config.OS = String.Format("{0}.{1}", Environment.OSVersion.Version.Major, Environment.OSVersion.Version.Minor); }
              catch (Exception) { }
              try { Config.Architecture = Environment.Is64BitOperatingSystem ? "x64" : "x86"; }
              catch (Exception) { }
              try { Config.Language = System.Globalization.CultureInfo.CurrentCulture.ToString(); }
              catch (Exception) { }
              try { Config.Processor = System.Environment.GetEnvironmentVariable("PROCESSOR_IDENTIFIER"); }
              catch (Exception) { }
              try { Config.NumProcessors = System.Environment.GetEnvironmentVariable("NUMBER_OF_PROCESSORS"); }
              catch (Exception) { }
              try { Config.DotNetVersion = System.Runtime.InteropServices.RuntimeEnvironment.GetSystemVersion(); }
              catch (Exception) { }
              try { Config.CommonLanguateRuntime = Environment.Version.ToString(); }
              catch (Exception) { }

              // Check if an other instance is running.
              Process[] lACInstances;

              if ((lACInstances = Process.GetProcessesByName(Config.APEName)) != null && lACInstances.Length > 0)
            if (MessageBox.Show("Other Simsang instance is running. Do you want to stop that process?", "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
              foreach (Process lProc in lACInstances)
            try { lProc.Kill(); }
            catch (Exception) { }

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

              //Set right Debugging modus in GUI
              if (Config.DebugOn())
              {
            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.pushMsg(String.Format("Current directory : {0}", Directory.GetCurrentDirectory()));

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

              // Load all plugins.
              mPluginModule.LoadPlugins();

              // Tab page controler. To hide and show tab pages.
              if (mPluginModule != null)
            mTPHandler = new TabPageHandler(TC_Plugins, mPluginModule.GetPluginPosition);

              // And at last a new session
              // TB_Session.Text = GetNewSessionName();

              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.ARPScan.InitARPScan(this, Config.Interfaces[CB_Interfaces.SelectedIndex].sIfcID, TB_StartIP.Text, TB_StopIP.Text, TB_GatewayIP.Text, ref mTargetList);
              Simsang.ARPScan.Main.ARPScan.InitARPScan(this, ref mTargetList);
            }
            catch (Exception lEx)
            {
              LogConsole.Main.LogConsole.pushMsg("Main() : " + lEx.StackTrace);
              Environment.Exit(0);
            }
            mAttackStarted = false;
              }

              // Check confirmation
              String lRegistrationValue = Config.GetRegistryValue(Config.RegistryContributionKey, Config.RegistryContributionValue);
              if (String.IsNullOrEmpty(lRegistrationValue) || lRegistrationValue.ToLower() != "ok")
              {
            ContributeConfirmation lConfirmation = new ContributeConfirmation();
            lConfirmation.ShowDialog();
              }

              restrictFeaturesFacade();

              // Check if new version is available
              Thread lUpdateAvailableThread = new Thread(delegate()
              {
            if (NetworkInterface.GetAllNetworkInterfaces().Any(x => x.OperationalStatus == OperationalStatus.Up))
            {
              if (Updates.InfrastructureFacade.getInstance().IsUpdateAvailable())
              {
            Simsang.Updates.FormNewVersion lNewVersion = new Simsang.Updates.FormNewVersion();
            lNewVersion.TopMost = true;
            lNewVersion.ShowDialog();
              }
              else
            LogConsole.Main.LogConsole.pushMsg("No new updates available.");
            }
            else
              LogConsole.Main.LogConsole.pushMsg("Can't check for new updates as no internet connection is available.");
              });
              lUpdateAvailableThread.Start();

              // Donate a click if internet connection is up.
              Thread lClickDonationThread = new Thread(delegate()
              {
            if (NetworkInterface.GetAllNetworkInterfaces().Any(x => x.OperationalStatus == OperationalStatus.Up))
              WB_Ads.Navigate(Config.BuglistURL);
              });
              lClickDonationThread.Start();

              // Initialize all plugins
              mPluginModule.initAllPlugins();

              // Hide all plugins what have the status "off"
              mPluginModule.CloseInactivePlugins();

              /*
               * Load session file passed as a command line parameter.
               * 1. Import it
               * 2. Load it
               * 3. Remove session
               */
              if (args != null && args.Length > 0)
              {
            loadDefaultSession(args[0]);
              }
        }
Ejemplo n.º 4
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();
      }
    }
Ejemplo n.º 5
0
    /// <summary>
    /// 
    /// </summary>
    public void SaveSessionData(AttackSession pAttackSession)
    {
      String lSessionFile;
      XmlSerializer lSerializer;
      FileStream lFS = null;

      // Make sure session directory exists
      CreateSessionDirectory();

      // Save session data to file
      lSessionFile = String.Format(@"{0}\{1}.xml", mSessionDir, Path.GetFileNameWithoutExtension(pAttackSession.SessionFileName));
      if (File.Exists(lSessionFile))
        throw new Exception("A session with this name already exists");

      try
      {
        lSerializer = new XmlSerializer(typeof(AttackSession));
        lFS = new FileStream(lSessionFile, FileMode.Create);
        lSerializer.Serialize(lFS, pAttackSession);
      }
      catch (Exception)
      {
      }
      finally
      {
        if (lFS != null)
          lFS.Close();
      }
    }