Giter Club home page Giter Club logo

csirtg-smrt-v1's Introduction

Getting Started

Parse data using simple YAML and throw it just about anywhere.

$ [sudo] pip install csirtg-smrt
$ curl https://raw.githubusercontent.com/csirtgadgets/csirtg-smrt-py/master/examples/csirtg.yml > csirtg.yml
$ csirtg-smrt -r csirtg.yml -f port-scanners --format table|csv|bro

017-04-12 12:22:26,244 - INFO - csirtg_smrt.smrt[416] - loglevel is: INFO
2017-04-12 12:22:26,244 - INFO - csirtg_smrt.smrt[116] - processing csirtg.yml
2017-04-12 12:22:26,251 - INFO - csirtg_smrt.smrt[315] - processing: csirtg.yml - csirtg.io:port-scanners
+-------+----------+----------------------------+-----------------+-------+------------+---------+----------------------------------+-------+-----------+
|  tlp  |  group   |          lasttime          |    indicator    | count | confidence |   tags  |           description            | rdata | provider  |
+-------+----------+----------------------------+-----------------+-------+------------+---------+----------------------------------+-------+-----------+
| white | everyone | 2017-04-12T16:22:06.00000Z |   59.27.82.202  |   1   |    9.0     | scanner | sourced from firewall logs (in.. |       | csirtg.io |
| white | everyone | 2017-04-12T16:21:43.00000Z |  31.162.111.152 |   1   |    9.0     | scanner | sourced from firewall logs (in.. |       | csirtg.io |
| white | everyone | 2017-04-12T16:20:29.00000Z |    5.238.33.0   |   1   |    9.0     | scanner | sourced from firewall logs (in.. |       | csirtg.io |
...

YouTube

Getting Involved

There are many ways to get involved with the project. If you have a new and exciting feature, or even a simple bugfix, simply fork the repo, create some simple test cases, generate a pull-request and give yourself credit!

If you've never worked on a GitHub project, this is a good piece for getting started.

COPYRIGHT AND LICENCE

Copyright (C) 2018 CSIRT Gadgets Foundation

Free use of this software is granted under the terms of the Mozilla Public License (MPL2). For details see the file LICENSE included with the distribution.

csirtg-smrt-v1's People

Contributors

chodonne avatar ckrez avatar deanpemberton avatar justinazoff avatar mdavis332 avatar sfinlon avatar snyk-bot avatar tsmolka avatar wesyoung avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

csirtg-smrt-v1's Issues

syslog support

  • tail syslog file
  • parse syslog
  • listen on syslog socket

Uncaught KeyboardInterrupt during sleep

Hi,

following will cause an unclean exit while using systemd.

Nov 28 12:28:26 localhost csirtg-smrt[188175]: Traceback (most recent call last):
Nov 28 12:28:26 localhost csirtg-smrt[188175]:   File "/usr/local/bin/csirtg-smrt", line 9, in <module>
Nov 28 12:28:26 localhost csirtg-smrt[188175]:     load_entry_point('csirtg-smrt==0.0.0a12', 'console_scripts', 'csirtg-smrt')()
Nov 28 12:28:26 localhost csirtg-smrt[188175]:   File "/usr/local/lib/python2.7/dist-packages/csirtg_smrt/smrt.py", line 232, in main
Nov 28 12:28:26 localhost csirtg-smrt[188175]:     sleep((r * 60))
Nov 28 12:28:26 localhost csirtg-smrt[188175]: KeyboardInterrupt

Nov 28 12:28:26 localhost systemd[1]: csirtg-smrt.service: Main process exited, code=exited, status=1/FAILURE

Commit after IssueID

remote feed caching

in cifv2 we cache a feed appended with the feed name in the feed config. This causes us to download the same feed multiple times if we were to do something like this:

dga-feed-cryptolocker:
  remote: http://osint.bambenekconsulting.com/feeds/dga-feed.txt
  pattern: ^([^,]+)\,Domain used by (Cryptolocker[^,]+)\,([^,]+)\,([^\r\n]+)
dga-feed-p2p-gameover-zeus:
  remote: http://osint.bambenekconsulting.com/feeds/dga-feed.txt
  pattern: ^([^,]+)\,Domain used by (P2P Gameover Zeus[^,]+)\,([^,]+)\,([^\r\n]+)

This results in dga-feed.txt downloaded multiple times:

ls -lh /var/smrt/cache/osint.bambenekconsulting.com-dga*
-rw-rw-r-- 1 cif cif 83M Sep 20 20:15 /var/smrt/cache/osint.bambenekconsulting.com-dga-feed-cryptolocker
-rw-rw-r-- 1 cif cif 83M Sep 20 20:15 /var/smrt/cache/osint.bambenekconsulting.com-dga-feed-p2p-gameover-zeus

In v3 let's attempt to only download dga-feed.txt one time, cache it and then parsed the single cached feed.

csirtgadgets/bearded-avenger#16

problem: if feed site is down, wget aborts

Traceback (most recent call last):
  File "/usr/local/bin/csirtg-smrt", line 11, in <module>
    load_entry_point('csirtg-smrt==0+unknown', 'console_scripts', 'csirtg-smrt')()
  File "/usr/local/lib/python2.7/dist-packages/csirtg_smrt/smrt.py", line 328, in main
    raise e
subprocess.CalledProcessError: Command '['wget', '--header', 'User-Agent: csirtg-smrt/0+unknown (csirtgadgets.org)', '--timeout=120', '-q', 'http://data.phishtank.com/data/online-valid.json.gz', '-N', '-P', '/tmp/smrt/phishtank.com']' returned non-zero exit status 8

ability to post-process a parsed data structure

Let's use AlienVault ipv4 reputation data as an example data structure.

CSV file

60.173.9.26#3#2#Scanning Host;Malicious Host#CN#Hefei#31.863899231,117.280799866#11;3

it has multiple delimiters:

  • primary: hash
  • secondary: semi-colon.

If parsed into a key pair data structure it would look something like this:

DataStruct1

{ 
  ipv4: '60.173.9.26',
  key1: '3', 
  key2: '2',
  classification: 'Scanning Host;Malicious Host',
  CountryCode: 'CN',
  key3: 'Hefei',
  lat: '31.863899231',
  long: '117.280799866',
  key4: '11;3',
}

cif-smrt in cifv2, we could write a regex for Scanning Host;Malicious Host and replace it with a single string of our choosing. What we can't do is parse that value into multiple key-pair values and then decide to overwrite them if desired.

What would be nice in to have is, the ability to post-parse a parsed data structure a second time with cif-smrt.

CSV -> initial Data structure -> second data structure. Ideally we could go from CSV to something like this:

DataStruct2

{ 
  ipv4: '60.173.9.26',
  key1: '3', 
  key2: '2',
  classification1: 'Scanning Host',
  classification2: 'Malicious Host',
  CountryCode: 'CN',
  key3: 'Hefei',
  lat: '31.863899231',
  long: '117.280799866',
  key4: '11;3',
}

or

DataStruct2

{ 
  ipv4: '60.173.9.26',
  key1: '3', 
  key2: '2',
  classification1: 'scanners',
  classification2: 'malware',
  CountryCode: 'CN',
  key3: 'Hefei',
  lat: '31.863899231',
  long: '117.280799866',
  key4: '11;3',
}

ability to see parsed data (debug out) without submission

In CIFv2, when writing a parser for a new feed, we have debug output but that debug output is seen on submission to cifv2 as cif-smrt is tightly coupled to cifv2.

In this version, cifv2 should be a destination option. So what I guess i'm really asking for is stdout and file based output in addition to cif and csirtg

  1. stdout (csv, json, table)
  2. file (csv,json,table)
  3. cifv2, cifv3
  4. csirtg

features need to be broken up into separate issues

omni-tool (data normalization)

  • Can be run as a service/damon
  • Input: http, stdin, file, tail (file), REST API (JSON), tcp socket, syslog socket
  • Parser: csv, pipe, regex, json, delimited, rss, xml, html, text, email, syslog, stix
  • Output: csv, html, json, table, xml, stix
  • Application support (in and out):
    • CIF, csirtg, Security Onion, Suricata, Snort, Bro, HoneyDrive, Kippo, SpamAssassin, DenyHosts, Cuckoo, Logstash, CRITS, Viper, etc

problem: altid not being variablized correctly

{'tlp': 'white', 'application': '', 'asn_desc': 'TELEF\\195\\148NICA BRASIL S.A, BR', 'firsttime': '2016-12-14T17:37:41.000000Z', 'group': 'everyone', 'timezone': 'america/sao_paulo', 'version': '0.00a0', 'longitude': -43.2333, 'altid': 'https://csirtg.io/search?q=<indicator>', 'cc': 'BR', 'protocol': '6', 'city': 'Rio de Janeiro', 'portlist': '23', 'latitude': -22.9, 'asn': '18881', 'description': 'sourced from firewall logs (incomming', 'altid_tlp': 'white', 'tags': ['scanner'], 'lasttime': '2016-12-14T17:37:41.000000Z', 'peers': [{'rir': 'lacnic', 'asn': '12956', 'cc': 'BR', 'prefix': '179.178.0.0/20'}], 'provider': 'csirtg.io', 'itype': 'ipv4', 'indicator': '179.178.0.0', 'confidence': 9}

sqlite: Unicode type received for non-unicode bind

hmm... something strange for the archiver?

csirtg-smrt[95809]: /usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/sqltypes.py:185: SAWarning: Unicode type received non-unicode bind param value '170.78.158.65'. (this warning may be suppressed after 10 occurrences)

problem: feed remote doesn't support regex

for example, if a feed is dropped in a directory with a different timetamp name, there's no way to automatically figure that out.

solution: enable remote to contain regex

break by default

should submit in non-bulk mode by default, make sure things break from the get go. then do an --bulk flag to submit as bulk (max 500/batch?). mimic this in the v3 api.

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.