|
|
@@ -1,20 +1,31 @@
|
|
|
#!/usr/bin/python3
|
|
|
+import typing
|
|
|
+import sys
|
|
|
|
|
|
def parse_args():
|
|
|
import argparse
|
|
|
parser = argparse.ArgumentParser(
|
|
|
description='Extract features from pcap files.')
|
|
|
- parser.add_argument('pcaps', metavar='pcaps', type=argparse.FileType('rb'),
|
|
|
- nargs='+', help='pcap from which to extract features')
|
|
|
+ parser.add_argument('match_file', metavar='match file',
|
|
|
+ type=argparse.FileType('r'), default=sys.stdin,
|
|
|
+ help='File of keylog/pcaps matchings (default: stdin)')
|
|
|
+ # parser.add_argument('pcaps', metavar='pcaps', type=argparse.FileType('rb'),
|
|
|
+ # nargs='+', help='pcap from which to extract features')
|
|
|
parser.add_argument('-o', '--outfile', type=argparse.FileType('wb'),
|
|
|
default="features.plo", help='Where to save the " \
|
|
|
"extracted features (default: features.plo)')
|
|
|
return parser.parse_args()
|
|
|
|
|
|
+def enter_data_dir(match_file: typing.TextIO):
|
|
|
+ import os
|
|
|
+ if match_file is not sys.stdin:
|
|
|
+ os.chdir(os.path.dirname(match_file.name))
|
|
|
+
|
|
|
def main():
|
|
|
args = parse_args()
|
|
|
from sample import Sample
|
|
|
- out = [Sample(pcap) for pcap in args.pcaps[0:1]];
|
|
|
+ enter_data_dir(args.match_file)
|
|
|
+ out = [Sample(*line.split(" ")) for line in args.match_file if "pcap" in line]
|
|
|
try:
|
|
|
import cPickle as pickle
|
|
|
except:
|