Exemplo n.º 1
0
        private void OnSessionsDataGridViewSelectionChanged(object sender, EventArgs e)
        {
            var selectedRow = this.sessionsDataGridView.SelectedRows.Count > 0 ?
                              this.sessionsDataGridView.SelectedRows[0] : null;

            if (selectedRow is null)
            {
                return;
            }

            var session = _networkContext.NetworkSessions.Where(s =>
                                                                s.Protocol == Convert.ToString(selectedRow.Cells["Protocol"].Value) &
                                                                s.SourceIp == Convert.ToString(selectedRow.Cells["Source Ip"].Value) &
                                                                s.SourcePort.ToString() == Convert.ToString(selectedRow.Cells["Source Port"].Value) &
                                                                s.DestinationIp == Convert.ToString(selectedRow.Cells["Destination Ip"].Value) &
                                                                s.DestinationPort.ToString() == Convert.ToString(selectedRow.Cells["Destination Port"].Value))
                          .FirstOrDefault();

            if (session == null)
            {
                return;
            }

            // TODO: refactor session viewer to work with pcap processor network object
            // (after refactoring Tcp and Udp sessions to work with internet layer base class)
            if (session is PcapProcessor.TcpSession)
            {
                _sessionViewerUserControl.SetSessionView(
                    Casting.CastProcessorTcpSessionToBruteSharkDesktopTcpSession(
                        session as PcapProcessor.TcpSession));
            }
            else if (session is PcapProcessor.UdpSession)
            {
                _sessionViewerUserControl.SetSessionView(
                    Casting.CastProcessorUdpSessionToBruteSharkDesktopUdpSession(
                        session as PcapProcessor.UdpSession));
            }
        }
Exemplo n.º 2
0
        public MainForm()
        {
            InitializeComponent();

            _files       = new HashSet <string>();
            _cts         = new CancellationTokenSource();
            _connections = new HashSet <PcapAnalyzer.NetworkConnection>();

            // Create the DAL and BLL objects.
            _processor = new PcapProcessor.Processor();
            _sniffer   = new PcapProcessor.Sniffer();
            _analyzer  = new PcapAnalyzer.Analyzer();
            _processor.BuildTcpSessions = true;
            _processor.BuildUdpSessions = true;

            // Create the user controls.
            _networkMapUserControl            = new NetworkMapUserControl();
            _networkMapUserControl.Dock       = DockStyle.Fill;
            _sessionsExplorerUserControl      = new SessionsExplorerUserControl();
            _sessionsExplorerUserControl.Dock = DockStyle.Fill;
            _hashesUserControl           = new HashesUserControl();
            _hashesUserControl.Dock      = DockStyle.Fill;
            _passwordsUserControl        = new GenericTableUserControl();
            _passwordsUserControl.Dock   = DockStyle.Fill;
            _filesUserControl            = new FilesUserControl();
            _filesUserControl.Dock       = DockStyle.Fill;
            _dnsResponseUserControl      = new DnsResponseUserControl();
            _dnsResponseUserControl.Dock = DockStyle.Fill;
            _voipCallsUserControl        = new VoipCallsUserControl();
            _voipCallsUserControl.Dock   = DockStyle.Fill;

            // Contract the events.
            _sniffer.UdpPacketArived               += (s, e) => _analyzer.Analyze(CommonUi.Casting.CastProcessorUdpPacketToAnalyzerUdpPacket(e.Packet));
            _sniffer.TcpPacketArived               += (s, e) => _analyzer.Analyze(CommonUi.Casting.CastProcessorTcpPacketToAnalyzerTcpPacket(e.Packet));
            _sniffer.TcpSessionArrived             += (s, e) => _analyzer.Analyze(CommonUi.Casting.CastProcessorTcpSessionToAnalyzerTcpSession(e.TcpSession));
            _sniffer.TcpSessionArrived             += (s, e) => SwitchToMainThreadContext(() => OnSessionArived(Casting.CastProcessorTcpSessionToBruteSharkDesktopTcpSession(e.TcpSession)));
            _sniffer.UdpSessionArrived             += (s, e) => SwitchToMainThreadContext(() => OnSessionArived(Casting.CastProcessorUdpSessionToBruteSharkDesktopUdpSession(e.UdpSession)));
            _processor.UdpPacketArived             += (s, e) => _analyzer.Analyze(CommonUi.Casting.CastProcessorUdpPacketToAnalyzerUdpPacket(e.Packet));
            _processor.TcpPacketArived             += (s, e) => _analyzer.Analyze(CommonUi.Casting.CastProcessorTcpPacketToAnalyzerTcpPacket(e.Packet));
            _processor.TcpSessionArrived           += (s, e) => _analyzer.Analyze(CommonUi.Casting.CastProcessorTcpSessionToAnalyzerTcpSession(e.TcpSession));
            _processor.TcpSessionArrived           += (s, e) => SwitchToMainThreadContext(() => OnSessionArived(Casting.CastProcessorTcpSessionToBruteSharkDesktopTcpSession(e.TcpSession)));
            _processor.UdpSessionArrived           += (s, e) => SwitchToMainThreadContext(() => OnSessionArived(Casting.CastProcessorUdpSessionToBruteSharkDesktopUdpSession(e.UdpSession)));
            _processor.FileProcessingStatusChanged += (s, e) => SwitchToMainThreadContext(() => OnFileProcessingStatusChanged(s, e));
            _processor.ProcessingPrecentsChanged   += (s, e) => SwitchToMainThreadContext(() => OnProcessingPrecentsChanged(s, e));
            _processor.ProcessingFinished          += (s, e) => SwitchToMainThreadContext(() => OnProcessingFinished(s, e));
            _analyzer.ParsedItemDetected           += (s, e) => SwitchToMainThreadContext(() => OnParsedItemDetected(s, e));
            _analyzer.UpdatedItemProprertyDetected += (s, e) => SwitchToMainThreadContext(() => OnUpdatedItemProprertyDetected(s, e));

            InitilizeFilesIconsList();
            InitilizeModulesCheckedListBox();
            InitilizeInterfacesComboBox();
            this.modulesTreeView.ExpandAll();
        }
Exemplo n.º 3
0
        public MainForm()
        {
            InitializeComponent();

            _files = new HashSet <string>();

            // Create the DAL and BLL objects.
            _processor = new PcapProcessor.Processor();
            _analyzer  = new PcapAnalyzer.Analyzer();
            _processor.BuildTcpSessions = true;
            _processor.BuildUdpSessions = true;

            // Create the user controls.
            _networkMapUserControl            = new NetworkMapUserControl();
            _networkMapUserControl.Dock       = DockStyle.Fill;
            _sessionsExplorerUserControl      = new SessionsExplorerUserControl();
            _sessionsExplorerUserControl.Dock = DockStyle.Fill;
            _hashesUserControl         = new HashesUserControl();
            _hashesUserControl.Dock    = DockStyle.Fill;
            _passwordsUserControl      = new GenericTableUserControl();
            _passwordsUserControl.Dock = DockStyle.Fill;
            _filesUserControl          = new FilesUserControl();
            _filesUserControl.Dock     = DockStyle.Fill;

            // Contract the events.
            _processor.UdpPacketArived           += (s, e) => _analyzer.Analyze(Casting.CastProcessorUdpPacketToAnalyzerUdpPacket(e.Packet));
            _processor.TcpPacketArived           += (s, e) => _analyzer.Analyze(Casting.CastProcessorTcpPacketToAnalyzerTcpPacket(e.Packet));
            _processor.TcpSessionArrived         += (s, e) => _analyzer.Analyze(Casting.CastProcessorTcpSessionToAnalyzerTcpSession(e.TcpSession));
            _processor.FileProcessingStarted     += (s, e) => SwitchToMainThreadContext(() => OnFileProcessStart(s, e));
            _processor.FileProcessingEnded       += (s, e) => SwitchToMainThreadContext(() => OnFileProcessEnd(s, e));
            _processor.ProcessingPrecentsChanged += (s, e) => SwitchToMainThreadContext(() => OnProcessingPrecentsChanged(s, e));
            _analyzer.ParsedItemDetected         += (s, e) => SwitchToMainThreadContext(() => OnParsedItemDetected(s, e));
            _processor.TcpSessionArrived         += (s, e) => SwitchToMainThreadContext(() => OnSessionArived(Casting.CastProcessorTcpSessionToBruteSharkDesktopTcpSession(e.TcpSession)));
            _processor.UdpSessionArrived         += (s, e) => SwitchToMainThreadContext(() => OnSessionArived(Casting.CastProcessorUdpSessionToBruteSharkDesktopUdpSession(e.UdpSession)));
            _processor.ProcessingFinished        += (s, e) => SwitchToMainThreadContext(() => OnProcessingFinished(s, e));

            InitilizeFilesIconsList();
            InitilizeModulesCheckedListBox();
            this.modulesTreeView.ExpandAll();
        }