Esempio n. 1
0
 private void OnPacketSent(IPHeader ipHeader)
 {
     if (IpPacketSent != null)
     {
         IpPacketSent(ipHeader, EventArgs.Empty);
     }
 }
Esempio n. 2
0
 private void OnReceive(IAsyncResult ar)
 {
     if (!aborted)
     {
         try {
             int    length = ipSocket.EndReceive(ar);
             byte[] packet = new byte[length];
             Array.Copy(byteData, 0, packet, 0, length);
             //ParseData(byteData, nReceived);
             IPHeader ipHeader = new IPHeader(packet, length);
             if (ipHeader.SourceAddress.Equals(IPAddress))
             {
                 OnPacketSent(ipHeader);
             }
             // if (ipHeader.DestinationAddress.Equals(IPAddress)) OnPacketReceived(ipHeader);
             // OnPacketReceived(new NetworkPacket(byteData,length));
         } catch (Exception ex) {
             // Sniffer.LogTrace(ex);
         } finally {
             byteData = new byte[128];          // set to 16276 bytes
             // continue receiving
             ipSocket.BeginReceive(byteData, 0, byteData.Length, SocketFlags.None,
                                   new AsyncCallback(OnReceive), null);
         }
     }
 }
Esempio n. 3
0
 private void OnPacketReceived(IPHeader ipHeader)
 {
     if (IpPacketReceived != null)
     {
         IpPacketReceived(ipHeader, EventArgs.Empty);
     }
 }
Esempio n. 4
0
 private void OnTrace(IPHeader tlsPackage)
 {
     if (Trace != null)
     {
         Trace(tlsPackage, EventArgs.Empty);
     }
 }
Esempio n. 5
0
        void s_IpPacketSent(object sender, EventArgs e)
        {
            IPHeader ipHeader = (IPHeader)sender;

            if (ipHeader.ProtocolType == Protocol.Tcp)
            {
                try {
                    TCPHeader tcp = new TCPHeader(ipHeader.Data, ipHeader.MessageLength);
                    int       sourcePort;
                    if (int.TryParse(tcp.SourcePort, out sourcePort))
                    {
                        if (sourcePort == ((TslSslConfig)Configuration.AgentSettings).RdpPort)
                        {
                            if (Tracing)
                            {
                                OnTrace((IPHeader)sender);
                            }
                            if (tcp.Data.Length > 0)
                            {
                                AppLayerTlsSsl tls = new AppLayerTlsSsl(tcp.Data, tcp.Data.Length);
                                if (tls.TlsHeader.MinorVersion >= 1 && tls.TlsHeader.MinorVersion < 10 && tls.TlsHeader.MajorVersion >= 1 && tls.TlsHeader.MajorVersion < 10)         // check if packet is tls/ssl
                                {
                                    if (tls.TlsHeader.ContentType == AppLayerTlsSsl.CONTENT_TYPE_ENCRYPTED_ALERT)
                                    {
                                        UnsuccessfulLogin(ipHeader.DestinationAddress.ToString());
                                    }
                                }
                            }

                            // Console.WriteLine("Flags: {0}\tAck: {1}\tSeq:{2}", tcp.Flags, tcp.AcknowledgementNumber, tcp.SequenceNumber);
                            // Console.WriteLine("Source: {0}:{1}\tDestination: {2}:{3}", ipHeader.SourceAddress, tcp.SourcePort, ipHeader.DestinationAddress, tcp.DestinationPort);
                        }
                    }
                } catch (Exception ex) {
                    Sniffer.LogTrace(ex);
                }
            }
        }