<commit_before>#!/usr/bin/env python
# -----------------------------------------------------------
# Filename      : S2D.py
# Created By    : <NAME>
# Date Created  : 16-Mar-2016 18:16
# Date Modified :
#------------------------------------------------------------
# License       : Development
#
# Description   : Network Discovery and fingerprinting tool
#
# (c) Copyright 2015, TheKillingTime all rights reserved.
#-----------------------------------------------------------

__author__  = "<NAME>"
__version__ = "1.5" 

import sys
import time
import logging
# Cleans up a little of scapy's run time mess.
logging.getLogger('scapy.runtime').setLevel(logging.ERROR)
import pygeoip
import proto_to_numbers
from netaddr import *
from scapy.all import *

# Moar scapy clean up
conf.verb=0


class Inspect_Traffic(object):

    def __init__(self, p2c, interface):
        # MaxMind GeoIP database
        self.geodb = '/usr/local/geo/GeoLiteCity.dat'
        self.count = int(p2c)
        self.interface = interface
        print "\033[32;3m[*]\033[0m Capturing %d packets to analyze on interface %s ..." % (self.count, self.interface)
        # Building timestamp 
        self.time = time.strftime("%H:%M:%S")
        self.date = (time.strftime("%m/%d/%Y "))
        self.time_stamp = self.date + self.time
        
        # To log or to print, or both 
        self.log             = True
        self.print_to_screen = False
        
        # Log to this location
        self.log_to = '/var/log/packet_direction/'
        self.log_to_file = 'network.log'<commit_msg> Added a exception handler around the imports, as there are some 3rd party libraries in there.<commit_after>#!/usr/bin/env python
# -----------------------------------------------------------
# Filename      : S2D.py
# Created By    : <NAME>
# Date Created  : 16-Mar-2016 18:16
# Date Modified :
#------------------------------------------------------------
# License       : Development
#
# Description   : Network Discovery and fingerprinting tool
#
# (c) Copyright 2015, TheKillingTime all rights reserved.
#-----------------------------------------------------------

__author__  = "<NAME>"
__version__ = "1.5" 

try:
    import sys
    import time
    import logging
    # Cleans up a little of scapy's run time mess.
    logging.getLogger('scapy.runtime').setLevel(logging.ERROR)
    import pygeoip
    import proto_to_numbers
    from netaddr import *
    from scapy.all import *
except ImportError, err:
    print "[!] ImportError: %s " % err
    sys.exit(1)

# Moar scapy clean up
conf.verb=0


class Inspect_Traffic(object):

    def __init__(self, p2c, interface):
        # MaxMind GeoIP database
        self.geodb = '/usr/local/geo/GeoLiteCity.dat'
        self.count = int(p2c)
        self.interface = interface
        print "\033[32;3m[*]\033[0m Capturing %d packets to analyze on interface %s ..." % (self.count, self.interface)
        # Building timestamp 
        self.time = time.strftime("%H:%M:%S")
        self.date = (time.strftime("%m/%d/%Y "))
        self.time_stamp = self.date + self.time
        
        # To log or to print, or both 
        self.log             = True
        self.print_to_screen = False
        
        # Log to this location
        self.log_to = '/var/log/packet_direction/'
        self.log_to_file = 'network.log'
{'fraction_non_alphanumeric': 0.2075358851674641, 'fraction_numerical': 0.01854066985645933, 'mean_word_length': 1.7667493796526055, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1701645', 'n_tokens_mistral': 1023, 'n_tokens_neox': 958, 'n_words': 260}