#!/usr/bin/python
import sys

#
# Reads Nepenthes logged_submissions file and outputs data as comma-seperated value
#
# Typical usage:
#   cat logged_submissions | submissions2csv.py > outputfile.csv
#
# Author: Andrew Waite (aka RoleReversal)
# http://www.infosanity.co.uk
#


#write 'headers to stdout'
sys.stdout.write("Date,Time,Source IP Address,Malware Source,Malware MD5\n")

#read from stdin
while 1:
	line = sys.stdin.readline()
	if not line:
		break

	logData = line.split(' ');

	timestamp = logData[0].strip('[]')
	date = timestamp.split('T')[0]
	time = timestamp.split('T')[1]
	sourceIP = logData[1]
	sourceMalware = logData[4]
	malwareMD5 = logData[5]

	out = "%s,%s,%s,%s,%s" %(date, time, sourceIP, sourceMalware, malwareMD5)
	sys.stdout.write(out)

