<commit_before>#!/usr/bin/env python

import socket
import re
import json
import pymongo
from collections import OrderedDict

# Welcome to Gobbler, the Scapy pcap parser and dump scripts
# Part of the sniffMyPackets suite http://www.sniffmypackets.net
# Written by @catalyst256 / <EMAIL>

# Add some colouring for printing packets later
YELLOW = '\033[93m'
GREEN = '\033[92m'
END = '\033[0m'
RED = '\033[91m'

def splunk_shot_udp(splunk_server, splunk_port, s):
  try:
    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    sock.connect((splunk_server, splunk_port))
    i = ','.join("%s=%r" % (key,val) for (key,val) in s.iteritems())
    i = re.sub('\w*.\w*.\w*\[\d*\]={', ' ,', i)
    i = re.sub('\w{1,}={', '', i)
    i = i.replace('{', '').replace('}','').replace(': ', '=').replace('\'', '').replace(' , ', ' ')
    sock.send(i)
    sock.close()
  except Exception, e:
    print e

def splunk_shot_tcp(splunk_server, splunk_port, s):
  try:
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    sock.connect((splunk_server, splunk_port))
    i = ', '.join("%s=%r" % (key,val) for (key,val) in s.iteritems())
    i = re.sub('\w*.\w*.\w*\[\d*\]={', ' ,', i)
    i = re.sub('\w{1,}={', '', i)
    i = i.replace('{', '').replace('}','').replace('\'', '').replace(': ', '=').replace(' , ', ' ')
    sock.send(i)
  except Exception, e:
    print e<commit_msg>tweak to regex for splunk uploads<commit_after>#!/usr/bin/env python

import socket
import re
import json
import pymongo
from collections import OrderedDict

# Welcome to Gobbler, the Scapy pcap parser and dump scripts
# Part of the sniffMyPackets suite http://www.sniffmypackets.net
# Written by @catalyst256 / <EMAIL>

# Add some colouring for printing packets later
YELLOW = '\033[93m'
GREEN = '\033[92m'
END = '\033[0m'
RED = '\033[91m'

def splunk_shot_udp(splunk_server, splunk_port, s):
  try:
    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    sock.connect((splunk_server, splunk_port))
    i = ','.join("%s=%r" % (key,val) for (key,val) in s.iteritems())
    i = re.sub('\w*.\w*.\w*\[\d*\]={', ', ', i)
    i = re.sub('\w{1,}={', '', i)
    i = i.replace('{', '').replace('}','').replace(': ', '=').replace('\'', '').replace(' , ', ' ')
    sock.send(i)
    sock.close()
  except Exception, e:
    print e

def splunk_shot_tcp(splunk_server, splunk_port, s):
  try:
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    sock.connect((splunk_server, splunk_port))
    i = ', '.join("%s=%r" % (key,val) for (key,val) in s.iteritems())
    i = re.sub('\w*.\w*.\w*\[\d*\]={', ', ', i)
    i = re.sub('\w{1,}={', '', i)
    i = i.replace('{', '').replace('}','').replace('\'', '').replace(': ', '=').replace(' , ', ' ')
    sock.send(i)
  except Exception, e:
    print e
{'fraction_non_alphanumeric': 0.22966162706983442, 'fraction_numerical': 0.017278617710583154, 'mean_word_length': 3.631666666666667, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5875375', 'n_tokens_mistral': 1117, 'n_tokens_neox': 1090, 'n_words': 240}