コード例 #1
0
    /// <summary>
    /// Loop through the data that we have and send it to the netflow
    /// controller if we should
    /// </summary>
    /// <param name="packetDataObj"></param>
    private IEnumerator CheckData(Packetbeat_Json_Data packetDataObj)
    {
        // ================= Check and make sure that our data is valid =====================
        // Make sure that our data is not null
        if (packetDataObj.hits.hits.Length == 0)
        {
            _UseLastSuccess = true;

            // Tell this to use the last successful query
            yield break;
        }

        // Let this know that we no longer need to bank on the last success
        if (_UseLastSuccess)
        {
            _UseLastSuccess = false;
        }

        // ============= Keep track of stuff to prevent duplicates =======================
        packetPerQuery = 0;
        // Set our latest packetbeat time to the most recent one
        _latest_time  = packetDataObj.hits.hits[packetDataObj.hits.hits.Length - 1]._source.timestamp;
        checkingState = CheckDataStates.Running;
        // ============== Actually loop through our hits data  =========================
        for (int i = 0; i < packetDataObj.hits.hits.Length; i++)
        {
            // Set the integer IP values of this object
            SetIntegerValues(packetDataObj.hits.hits[i]._source);

            // As long as what we got from those IP's is valid:
            if (packetDataObj.hits.hits[i]._source.destIpInt != 0 && packetDataObj.hits.hits[i]._source.sourceIpInt != 0)
            {
                // Change the protocol to HTTP if we want to, this is optional because
                // sometimes it is techincally incorrect
                if (assumeHttp && packetDataObj.hits.hits[i]._source.dest.port == 80 ||
                    packetDataObj.hits.hits[i]._source.dest.port == 8080)
                {
                    // This traffic is HTTP
                    packetDataObj.hits.hits[i]._source.transport = "http";
                }

                // Send the data to the netflow controller
                connectionController.CheckPacketbeatData(
                    packetDataObj.hits.hits[i]._source.sourceIpInt,
                    packetDataObj.hits.hits[i]._source.destIpInt,
                    packetDataObj.hits.hits[i]._source.transport);
                packetPerQuery++;
            }

            // Get them frames
            yield return(null);
        }
        checkingState = CheckDataStates.Done;
    }
コード例 #2
0
    /// <summary>
    /// This will start the FSM with our specific stype of data
    /// </summary>
    public override void StartMonitor()
    {
        // Make sure that the FSM knows we are starting again
        base.StartMonitor();

        // Send it packetbeat data
        _broData = new Json_Data();

        // Start the finite satate machine for the web request
        StartCoroutine(FSM(_broData));

        checkingState = CheckDataStates.Done;
    }
コード例 #3
0
    /// <summary>
    /// Start the necessary finite state machine with the
    /// specific data for this object
    /// </summary>
    public override void StartMonitor()
    {
        // Make sure that the FSM knows we are starting again
        base.StartMonitor();

        // Instantiate the data for our request
        _packetbeatJsonData = new Packetbeat_Json_Data();

        // Start the finite satate machine for the web request
        StartCoroutine(FSM(_packetbeatJsonData));


        checkingState = CheckDataStates.Done;
    }
コード例 #4
0
    /// <summary>
    /// Check the data for a Json Object
    /// </summary>
    /// <param name="dataObject"></param>
    private IEnumerator CheckData(Json_Data dataObject)
    {
        // ================= Check and make sure that our data is valid ===================== //
        // Make sure that our data is not null
        if (dataObject.hits.hits.Length == 0)
        {
            _UseLastSuccess = true;

            // Tell this to use the last successful query
            yield break; //return;
        }

        // Let this know that we no longer need to bank on the last success
        if (_UseLastSuccess)
        {
            _UseLastSuccess = false;
        }

        // ============= Keep track of stuff to prevent duplicates ===============

        // Set our latest packetbeat time to the most recent one
        _latest_time = dataObject.hits.hits[0]._source.logstash_timestamp;

        packetPerQuery++;
        // Keep track of the state of this data checking
        checkingState = CheckDataStates.Running;

        // Send the data to the game controller for all of our hits
        for (int i = 0; i < dataObject.hits.hits.Length; i++)
        {
            // Set the integer IP values if this source
            SetIntegerValues(dataObject.hits.hits[i]._source);

            // If the source or dest ip's are 0 then break
            if (dataObject.hits.hits[i]._source.sourceIpInt != 0 && dataObject.hits.hits[i]._source.destIpInt != 0)
            {
                // Send the bro data to the game controller, and add it to the network
                DeviceManager.Instance.CheckIp(dataObject.hits.hits[i]._source);
            }

            // Make sure we get them smooth frames
            yield return(null);
        }
        packetPerQuery = 0;
        // We are done chekcing this now
        checkingState = CheckDataStates.Done;
    }