Beispiel #1
0
 private void clearAllDumpsToolStripMenuItem_Click(object sender, EventArgs e)
 {
     NetFilterWrap.DeleteHttpRequestDumpFolder(netMon);
     NetFilterWrap.DeleteHttpResponseDumpFolder(netMon);
     NetFilterWrap.DeleteRawInDumpFolder(netMon);
     NetFilterWrap.DeleteRawOutDumpFolder(netMon);
 }
Beispiel #2
0
        bool RefreshSettings()
        {
            logger.write("Refreshing settings..");

            bool settingsWrited = settings.write();

            if (!settingsWrited)
            {
                logger.write("Couldn't write settings");
            }
            else
            {
                if (NetFilterWrap.Started(netMon))
                {
                    NetFilterWrap.RefreshSetting(netMon);
                    logger.write("Settings has been refreshed..");
                }
                else
                {
                    logger.write("Netfilter is not started..");
                }
            }

            return(settingsWrited);
        }
Beispiel #3
0
 private void toolStripMenuItemDeleteFile_Click(object sender, EventArgs e)
 {
     DeleteSelectedTreeItem(filteredAppsTreeView.SelectedNode);
     if (settings.TracingProcesses.Count == 0)
     {
         NetFilterStatus status = (NetFilterWrap.Started(netMon))
             ? NetFilterStatus.DisableRefreshing : NetFilterStatus.NotStarted;
         updateFormItems(status);
     }
 }
Beispiel #4
0
        private void netfilterLogToolStripMenuItem_Click(object sender, EventArgs e)
        {
            uint bufSize = 1024;

            byte[] buf = new byte[bufSize];

            NetFilterWrap.LogPath(netMon, buf, bufSize);

            string logPath = System.Text.Encoding.ASCII.GetString(buf).Split('\0')[0];

            logForm.OpenLogPath(logPath);
        }
Beispiel #5
0
        private void AddDirectoryHandler()
        {
            DialogResult dialogResult = folderBrowserDialog.ShowDialog();

            if (dialogResult == DialogResult.OK)
            {
                NetFilterStatus status = (NetFilterWrap.Started(netMon))
                    ? NetFilterStatus.Refreshed : NetFilterStatus.Ready;

                AddDirectory(folderBrowserDialog.SelectedPath);
                updateFormItems(status);
            }
        }
Beispiel #6
0
 void StartNetFilter()
 {
     if (RefreshSettings() && NetFilterWrap.Start(netMon))
     {
         updateFormItems(NetFilterStatus.Started);
         logger.write("Netfilter started..");
     }
     else
     {
         updateFormItems(NetFilterStatus.Failed);
         logger.write("Error during starting netfilter..");
     }
 }
Beispiel #7
0
        void StopNetfilter()
        {
            if (NetFilterWrap.Started(netMon))
            {
                NetFilterWrap.Stop(netMon);
                updateFormItems(NetFilterStatus.Stopped);

                logger.write("Netfilter has been stopped..");
            }
            else
            {
                logger.write("Netfilter is not started..");
            }
        }
Beispiel #8
0
        public MainForm()
        {
            InitializeComponent();
            InitializeFields();

            try
            {
                netMon = NetFilterWrap.Create();
                isInit = (netMon != IntPtr.Zero);
            }
            catch (Exception e)
            {
                logger.write(string.Format("{0} {1}", e.GetType(), e.Message));
            }
        }
Beispiel #9
0
 private void AddProcessHandler()
 {
     DialogResult dialogResult = openFileDialog.ShowDialog();
     {
         if (dialogResult == DialogResult.OK)
         {
             NetFilterStatus status = (NetFilterWrap.Started(netMon))
                 ? NetFilterStatus.Refreshed : NetFilterStatus.Ready;
             foreach (var process in openFileDialog.FileNames)
             {
                 AddProcess(process);
                 updateFormItems(status);
             }
         }
     }
 }
Beispiel #10
0
        /// <summary>
        /// Освободить все используемые ресурсы.
        /// </summary>
        /// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                #region Custom disposing
                if (netMonStarted)
                {
                    try
                    {
                        NetFilterWrap.Stop(netMon);
                    }
                    catch (Exception e)
                    {
                        logger.write(string.Format("{0} {1}", e.GetType(), e.Message));
                    }
                }

                if (netMon != null)
                {
                    try
                    {
                        NetFilterWrap.Free(netMon);
                    }
                    catch (Exception e)
                    {
                        logger.write(string.Format("{0} {1}", e.GetType(), e.Message));
                    }
                }

                netMon = IntPtr.Zero;
                #endregion

                components.Dispose();
            }
            base.Dispose(disposing);
        }
Beispiel #11
0
        private void filteredAppsTreeView_DragDrop(object sender, DragEventArgs e)
        {
            string[] draggedItems = (string[])e.Data.GetData(DataFormats.FileDrop, true);
            foreach (string item in draggedItems)
            {
                FileAttributes  attr   = File.GetAttributes(item);
                NetFilterStatus status = (NetFilterWrap.Started(netMon))
                    ? NetFilterStatus.Refreshed : NetFilterStatus.Ready;

                if ((attr & FileAttributes.Directory) == FileAttributes.Directory)
                {
                    AddDirectory(item);
                    updateFormItems(status);
                }
                else if (Path.GetExtension(item) == ".exe")
                {
                    if (!settings.isExistsTracingProcess(item))
                    {
                        AddProcess(item);
                        updateFormItems(status);
                    }
                }
            }
        }
Beispiel #12
0
 private void clearRawAllFoldersToolStripMenuItem_Click(object sender, EventArgs e)
 {
     NetFilterWrap.DeleteRawInDumpFolder(netMon);
     NetFilterWrap.DeleteRawOutDumpFolder(netMon);
 }
Beispiel #13
0
 private void clearHttpResponseToolStripMenuItem_Click(object sender, EventArgs e)
 {
     NetFilterWrap.DeleteHttpResponseDumpFolder(netMon);
 }