Skip to content

Instantly share code, notes, and snippets.

View hillar's full-sized avatar

Hillar hillar

View GitHub Profile
unsigned int ip_total_len = (unsigned int)ntohs((ip_hdr->ip_len));
unsigned int real_len = 14 + ip_total_len;
unsigned int dif = (*pkthdr)->caplen - real_len;
if (dif > 0 && dif < 32)
{
(*pkthdr)->caplen -= dif;
(*pkthdr)->len -= dif;
}
@hillar
hillar / sample.bash
Created May 12, 2016 07:15
elasticsearch unassigned shard
curl -XPOST '10.242.11.3:9200/_cluster/reroute' -d '{
"commands" : [
{
"allocate" : {
"index" : "sessions-160420h14", "shard" : 1, "node" : "es-1-data2-c"
}
}
]
}'
@hillar
hillar / apache2elastic.py
Created April 27, 2016 17:52
load & parse zip'ed apache logs and pump to elasticsearch
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
from os import listdir
from os.path import isfile, join
import gzip
import apache_log_parser
from elasticsearch import Elasticsearch
from elasticsearch.helpers import bulk
@hillar
hillar / README.md
Last active March 4, 2016 06:34
suricata plugin for telegraf

Telegraf Plugin: Suricata

Plugin arguments:

  • socket []string: socket name
  • zeros boolean: If false, it will not send measurments with value 0

Description

The Suricata plugin sends dump-counters command to Suricata unix socket Threads are used as tags

@hillar
hillar / hello.go
Last active September 24, 2015 07:16
failed to parse certificate: x509: RSA modulus is not a positive number or not minimal
package main
import "fmt"
import "encoding/pem"
import "encoding/asn1"
import "math/big"
import "time"
import "os"
import "io/ioutil"
@hillar
hillar / dnsqrparser.py
Last active November 25, 2016 17:20
read and parse dnsqr messages from nsmg files created by sie-dns-sensor
import nmsg
import wdns
import re
def _parse_DKIM(data):
if not re.search(r'v\=DKIM', data):
return None
ret = dict()
# A bot that joins channels and send the events is sees to elasticsearch.
# in bulks ;)
'''
curl -XPUT "http://localhost:9200/_template/abuh" -d ' {
"template": "*@conference*",
"settings": {
"index.refresh_interval": "5s",
"index.number_of_shards": 1,
@hillar
hillar / test_idiokit_unified2_reader.py
Last active August 29, 2015 14:23
test unified2 reader, see idstools, idiokit, abusehelper
"""
! testing without XMPP server
for real life use:
from idstools import unified2
import idiokit
from abusehelper.core import bot
class Unified2Bot(bot.FeedBot):
@hillar
hillar / molo2midi.js
Last active May 13, 2016 08:21
moloch sessions to midi
// ES6
/*
moloch sessions.csv field names
[ 'Protocol',
' First Packet',
' Last Packet',
' Source IP',
digraph G {
subgraph cluster_cap{
softflow;
suricata;
bro;
moloch_cap;
}
{rank=same; softflow,suricata,bro,moloch_cap }