#!/usr/bin/python


from scapy.all import *
import os

def main():
    log_path = '/var/log/spoofer'
    logs = os.listdir(log_path)
    caps = [f for f in logs if 'cap' in f]
    bad_files = []
    
    for cap in caps:
        data = rdpcap(os.path.join(log_path, cap))
        for pack in data:
            if pack.haslayer(TCP):
  	        pl  = pack[TCP].payload
                get = str(pl).split('\n')[0]
                f = get.split(' ')
                if not len(f) <= 1:
                    dl =   f[1]
                    if not dl in bad_files: bad_files.append(dl)

    bad_f = open('/home/john.smith/bad_files', 'w')    
    for f in bad_files[1:]:
        bad_f.write(f + '\n')

if  __name__ == '__main__':
    main()
