Giter VIP home page Giter VIP logo

Comments (6)

jasonish avatar jasonish commented on May 28, 2024

There are 2 different data fields.. SpoolEventReader.Next returns an Event which can have a list of "packets" and "extra-data" records attached to it. Each of this have a data field. In the case of the packet, the data is the raw binary data of the packet found in the unified log file.

Likewise for extra data, the data is just the raw data from that unified record. To interpret it you need to look at the data-type field and process it accordingly. Referring to the unified2 documentation in the Snort distribution should help here.

from py-idstools.

asermam avatar asermam commented on May 28, 2024

Sorry for not specifying the field. I am looking into Events and its packets.
I saw the doc https://www.snort.org/faq/readme-unified2 . It recommends U2Spewfoo to read logs, and that's what I was using until now that I need aggregation when events appears.
So, you said data in event's packets is in raw binary, but I don't know how to process it. I have tried with some different online converters to hexadecimal without success. I have seen that this format is also used for ip's in 'destination-ip.raw' and 'source-ip.raw' fields. But I don't find the transformation relation between this format and any other that I may know. Since U2Spewfoo provides an hexadecimal packet data, there should be a direct transformation between the binary raw and hex, but I can neither find it in the source code of U2Spewfoo.

from py-idstools.

jasonish avatar jasonish commented on May 28, 2024

Look at https://github.com/jasonish/py-idstools/blob/master/idstools/scripts/u2spewfoo.py#L71, this is the function that prints the raw data as hex, with a printable section for the idstools implementation of u2spewfoo.

Basically you have to do this yourself and format how you want it. In Python its basically:

for b in raw_data:
    print("0x%02x", b)

which will print the hex value of each byte on a new line.

from py-idstools.

marcindulak avatar marcindulak commented on May 28, 2024

I think one can just use some of the code included in py-idstools, the following works for me with f6b039e:

from idstools import maps
from idstools.scripts.u2json import Formatter
from idstools import unified2

msgmap = maps.SignatureMap()
classmap = maps.ClassificationMap()
formatter = Formatter(msgmap=msgmap, classmap=classmap)

reader = unified2.SpoolRecordReader(directory='/var/log/snort',
                                   prefix='unified2.log',
                                   follow=True)

for record in reader:
        formatted = dict(formatter.format(record))
        if 'packet' in formatted:
                print(formatted['packet']['data'])

from py-idstools.

jasonish avatar jasonish commented on May 28, 2024

I wonder if it would be useful to expose some formatting/printing functions in the library.

By that I mean pulling the formatting function out of the u2spefoo script and putting it in the library for easier access from user scripts.

from py-idstools.

jasonish avatar jasonish commented on May 28, 2024

There is also now util.format_printable. Closing. Use u2json and u2eve as a reference for printing the raw data.

from py-idstools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.