Last active
March 3, 2019 23:32
-
-
Save jjsantanna/8ea706453ef843c8494d2a184e12e858 to your computer and use it in GitHub Desktop.
getting all the last lines of multi-vector attacks logs (output from ddos_dissector) and outputting a .csv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
rm all_summaries.csv; ls |grep .log |while read file; do echo $file; tail -1 $file >> all_summaries.csv; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
import pandas as pd
import numpy as np
df = pd.read_csv("all_summaries.csv", sep=";")
df.columns = ['raw_filename','multivector_key', 'singlevector_keys', 'filters', '#_src_ips']
df.replace(np.nan, "[]", regex=True)
df['singlevector_keys'] = df['singlevector_keys'].apply(lambda x: str(x).strip('[]').split(', '))
df['filters'] = df['filters'].apply(lambda x: str(x).strip('[]').split(', '))
df['#_src_ips'] = df['#_src_ips'].apply(lambda x: str(x).strip('[]').split(', '))
singlevector_keys = df.apply(lambda x: pd.Series(x['singlevector_keys']),axis=1).stack().reset_index(level=1, drop=True)
singlevector_keys.name = 'singlevector_keys'
filters = df.apply(lambda x: pd.Series(x['filters']),axis=1).stack().reset_index(level=1, drop=True)
filters.name = 'filters'
src_ips = df.apply(lambda x: pd.Series(x['#_src_ips']),axis=1).stack().reset_index(level=1, drop=True)
src_ips.name = '#_src_ips'
df_temp = pd.DataFrame({'singlevector_key':singlevector_keys,
'filters':filters,
'#_src_ips':src_ips})
df_extended = df.drop(['singlevector_keys','filters','#_src_ips'], axis=1).join(df_temp)
df_extended.to_csv('summary.csv')