Ejemplo n.º 1
0
#create the session

session = pyfixbuf.Session(infomodel)

# for exporters we need to create internal and external templates

session.add_internal_template(template_id=999, template=tmpl)
session.add_external_template(template_id=999, template=tmpl)
session.add_internal_template(template_id=1000, template=sub_tmpl)
session.add_external_template(template_id=1000, template=sub_tmpl)
session.add_internal_template(template_id=1001, template=stl_tmpl)
session.add_external_template(template_id=1001, template=stl_tmpl)

# create the record to fill to export
# we can just give it the template since we don't have duplicate elements
rec = pyfixbuf.Record(infomodel, tmpl)

#create the buffer for exporter
buf = pyfixbuf.Buffer(rec)

# make the buffer an export buffer
buf.init_export(session, exporter)

# set the internal template on the buffer
buf.set_internal_template(999)

# export the templates to the file
session.export_templates()

# now set the export template
buf.set_export_template(999)
else:
    if (len(sys.argv) > 3):
        transport = sys.argv[3]
    if (len(sys.argv) > 2):
        port = sys.argv[2]
    if (len(sys.argv) > 4):
        outFile = open(sys.argv[4], 'w')
    else:
        outFile = sys.stdout
    listener = pyfixbuf.Listener(session,
                                 hostname=sys.argv[1],
                                 transport=transport.lower(),
                                 port=sys.argv[2])

# create the input record from the input template since there are no duplicate elements
rec = pyfixbuf.Record(infomodel, tmpl)

# create buffers for input and export
if (collector):
    buf = pyfixbuf.Buffer(rec)

    buf.init_collection(session, collector)

    # set the internal template on the input buffer
    buf.set_internal_template(876)

flowcount = 0

while (1):
    if (listener):
        buf = listener.wait()
# get the file to write to from the command line arguments
exporter.init_file(sys.argv[2])

# create the sessions for the collector & exporter
session = pyfixbuf.Session(infomodel)
exsession = pyfixbuf.Session(infomodel)

# add the appropriate templates to each session
session.add_internal_template(tmpl, template_id=876)

session.add_internal_template(statstmpl, template_id=900)

exsession.add_template(exportertmpl, template_id=987)

# create the input record from the input template since there are no duplicate elements
rec = pyfixbuf.Record(infomodel, tmpl)

# we can create the export rec from the export template since there are no duplicate elements
exportrec = pyfixbuf.Record(infomodel, exportertmpl)

# create buffers for input and export
buf = pyfixbuf.Buffer(rec)
buf.init_collection(session, collector)

exbuf = pyfixbuf.Buffer(exportrec)
exbuf.init_export(exsession, exporter)

# set the internal template on the input buffer
buf.set_internal_template(876)

# export the templates
Ejemplo n.º 4
0
# Create a session

session = p.Session(infomodel)

# Add your template to the session

session.add_internal_template(tmpl, 999)

# Add the Stats Template

session.add_internal_template(stats_tmpl, 911)

# create a Record for the main template and stats template

rec = p.Record(infomodel, tmpl)

statsrec = p.Record(infomodel, stats_tmpl)

# Create a buffer to read from
buf = p.Buffer()

# Add the session and collector the buffer

buf.init_collection(session, collector)

# Set your internal template to the data template

buf.set_internal_template(999)

# open our output file
# create the collector
collector = pyfixbuf.Collector()

# get the file from the command line arguments to read
collector.init_file(sys.argv[1])

# create the sessions for the collector & exporter
session = pyfixbuf.Session(infomodel)

# add the appropriate templates to each session
session.add_internal_template(tmpl, template_id=876)

session.add_internal_template(statstmpl, template_id=900)

# create the input record from the input template since there are no duplicate elements
rec = pyfixbuf.Record(infomodel, tmpl)

# create buffers for input and export
buf = pyfixbuf.Buffer(rec)
buf.init_collection(session, collector)

# set the internal template on the input buffer
buf.set_internal_template(876)

# this record is found in the subtemplatemultilist coming from YAF
payrec = pyfixbuf.Record(infomodel)
payrec.add_element("payload")
payrec.add_element("reversePayload")

macrec = pyfixbuf.Record(infomodel)
macrec.add_element("sourceMacAddress")
# Give the collector your input file to read from

collector.init_file(sys.argv[1])

# Create a session

session = p.Session(infomodel)

# Add your template to the session

session.add_internal_template(tmpl, 999)

# create a Record for each template or subtemplate to give the buffer

rec = p.Record(infomodel, tmpl)

# Create a buffer to read from

buf = p.Buffer(rec)

# Add the session and collector the buffer

buf.init_collection(session, collector)

# Set your internal template to the data template

buf.set_internal_template(999)

# open our output file
# Create a session

session = pyfixbuf.Session(infomodel)

# Add your template to the session

session.add_internal_template(tmpl, 999)

# Add the Stats Template

session.add_internal_template(stats_tmpl, 911)

# create a Rec for each template or subtemplate to give the buffer

rec = pyfixbuf.Record(infomodel, tmpl)

statsrec = pyfixbuf.Record(infomodel, stats_tmpl)

transport = sys.argv[3]
# Create a listener

listener = pyfixbuf.Listener(session, hostname=sys.argv[1], transport=transport.lower(), port=sys.argv[2])

# open our output file
if len(sys.argv) > 4:
    outFile = open(sys.argv[4], "w")
else:
    outFile = sys.stdout

flowcount = 0
    exporter.init_file(sys.argv[2])
else:
    exporter.init_net(hostname=sys.argv[2], port=sys.argv[3], transport='tcp')

#create the session
session = pyfixbuf.Session(infomodel)

# for exporters we need to create internal and external templates
session.add_internal_template(tmpl, 999)
session.add_external_template(tmpl, 999)

session.add_internal_template(tmplaaaa, 1000)
session.add_external_template(tmplaaaa, 1000)

# create the record to fill to export
rec = pyfixbuf.Record(infomodel, tmpl)

reca = pyfixbuf.Record(infomodel, tmplaaaa)

#create the buffer for exporter
buf = pyfixbuf.Buffer(rec)

# make the buffer an export buffer
buf.init_export(session, exporter)

# set the internal template on the buffer
buf.set_internal_template(999)

# export the templates to the file
session.export_templates()