Giter Club home page Giter Club logo

hpfeeds-collector's Introduction

hpfeeds-collector

This is a skeleton program meant for people to fork and extend in order to make generic hpfeeds log collectors.

The function in collector.py named parse should be extended. It should take a log line and produce a python dict that can be serialized into JSON (i.e. only strings, primitives, lists, and dicts as field values). If the line cannot be parsed for some reason, return None.

def parse(line):
    # TODO: extend this
    return {}

Example for honeyd (not 100% tested):

2004-01-07-14:36:58.7132 tcp(6) - 252.214.169.203 2064 192.168.27.180 21: 48 S [MacOS 8.0-8.6 OTTCP]
2004-01-07-15:26:40.0209 tcp(6) - 244.233.22.102 61891 172.162.8.180 21: 60 S [FreeBSD 5.0-5.1 ]
2004-01-07-16:48:30.1212 tcp(6) S 192.168.21.135 33395 172.162.8.91 80 [Linux 2.6 ]
2004-01-07-16:48:41.4929 tcp(6) S 10.173.240.67 22110 192.168.14.178 81 [Windows XP SP1]

Parse function:

def parse(line):
    import re
    regex = r'(?P<timestamp>\S+) (?P<proto>\S+)\(\d+\) (?P<flag>\S+) (?P<source_ip>\S+) (?P<source_port>\d+) (?P<dest_ip>\S+) (?P<dest_port>\d+)(: (?P<packet_size>\S+) (?P<tcp_flags>\S+))? \[(?P<osfp>.*)\]'                            
    mat = re.match(regex, line)
    if mat:
        rec = mat.groupdict()
        # delete empty or None values
        for name in rec.keys():
            if not rec[name]:
                del rec[name]
        return rec
    return None

hpfeeds-collector's People

Contributors

jatrost avatar s-maloney avatar

Stargazers

Roland Urbano avatar  avatar Greg Martin avatar

Watchers

Matthew Wollenweber avatar  avatar J. Elliot Taylor avatar Greg Martin avatar  avatar James Cloos avatar Shwetabh Sharan avatar Akshay Kumar avatar David Greenwood avatar Jonathan Sinclair avatar \x90\x90\x90\x90 avatar John Munro avatar Sergio avatar  avatar Ben Wu avatar Mike Forgione avatar  avatar  avatar  avatar Tie Li avatar Andrew Forth avatar chaoh avatar  avatar  avatar  avatar  avatar Wei Huang avatar  avatar  avatar  avatar jkhoury avatar Hong Yan avatar srini avatar  avatar  avatar  avatar  avatar Travis avatar Yulong Gan avatar  avatar  avatar Teng Xu avatar  avatar Peyton avatar Jui Awate avatar Ricky Chung avatar PeiGuo avatar Lex Chiang avatar Jeffrey Kubo avatar Jorge Alzati avatar  avatar  avatar  avatar  avatar Paul Sheck avatar  avatar

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.