Exemple #1
0
        private ConnectionsPayload CreateInetConnPayloadFromAuditEvent(AuditEvent auditEvent)
        {
            ConnectionsPayload connectionPayload = null;
            string             hexStringSaddr    = auditEvent.GetPropertyValue(AuditEvent.AuditMessageProperty.SocketAddress);

            try
            {
                ConnectionSaddr saddr = ConnectionSaddr.ParseSaddrToInetConnection(hexStringSaddr);
                if (!ConnectionSaddr.IsLocalIp(saddr.Ip)) //we don't send local connections
                {
                    connectionPayload = CreateConnPayloadFromAuditEvent(auditEvent);
                    connectionPayload.RemoteAddress = saddr.Ip;
                    connectionPayload.RemotePort    = saddr.Port.ToString();
                }
            }
            catch (Exception e)
            {
                SimpleLogger.Error($"Failed to parse saddr {hexStringSaddr}", exception: e);
                connectionPayload = null;
            }

            return(connectionPayload);
        }
Exemple #2
0
        /// <summary>
        /// This function recieve an event from the audit log file
        /// It filters out connections that are not relevant for security (e.g. local connects)
        /// It then returns "ConnectionCreate" event type that represent a succefull open connection from/to the internet
        /// </summary>
        /// <param name="auditEvent">A log event from the the audit event</param>
        /// <returns>A device event based on the input</returns>
        private IEvent CreateEventFromAuditRecord(AuditEvent auditEvent)
        {
            ConnectionsPayload connectionPayload = null;
            ConnectionCreate   retConnection     = null;

            string saddr = auditEvent.GetPropertyValue(AuditEvent.AuditMessageProperty.SocketAddress, throwIfNotExist: false);

            if (!string.IsNullOrEmpty(saddr))
            {
                //Check the address family of the connection - extract from the saddr
                LinuxAddressFamily family = ConnectionSaddr.ExtractFamilyFromSaddr(saddr);

                //According to the family type we create/don't create the event
                if (!family.IsToIgnore())                     //irelevant connections - don't create events
                {
                    if (ConnectionSaddr.IsInetFamliy(family)) //internet connections - create correlated event
                    {
                        connectionPayload = CreateInetConnPayloadFromAuditEvent(auditEvent);
                    }
                    else //For other famlies (non INET) that are required more investigation - send event with raw data (hex string)
                    {
                        connectionPayload = CreateNonInetConnPayloadFromAuditEvent(family, auditEvent);
                    }
                }
            }
            else
            {
                SimpleLogger.Debug($"{nameof(GetType)}: Saddr is null or empty, dropping event");
            }

            if (connectionPayload != null)
            {
                retConnection = new ConnectionCreate(Priority, connectionPayload, auditEvent.TimeUTC);
            }

            return(retConnection);
        }