def parser(filename, listname, date):
    with open(filename, 'r') as f:
        for line in f:
            subnet = IPy.IP(line.strip())
            for ip in subnet:
                new_entry(ip = ip.strCompressed(), source = listname,
                        timestamp = date)
    return date
Esempio n. 2
0
def parser(filename, listname, date):
    with open(filename, 'r') as f:
        for line in f:
            if line[0] != '#':
                ip = line.strip()
                if len(ip) == 0:
                    continue
                new_entry(ip=ip, source=listname, timestamp=date)
    return date
Esempio n. 3
0
def parser(filename, listname, date):
    with open(filename, 'r') as f:
        for line in f:
            if line[0] != '#':
                ip = line.strip()
                if len(ip) == 0:
                    continue
                new_entry(ip = ip, source = listname, timestamp = date)
    return date
Esempio n. 4
0
def parser(filename, listname, date):
    """
        Parse the list
    """
    with open(filename, 'r') as f :
        for line in f:
            ip = re.findall('<(?:ip|review)>((?:\d{1,3}\.){3}\d{1,3})<.*',line)
            if len(ip) == 0:
                continue
            new_entry(ip = ip[0], source = listname, timestamp = date)
    return date
Esempio n. 5
0
def parser(filename, listname, date):
    """
        Parse the list depending on the type (blocklist or ddos)
        and put the entries into redis
    """
    with open(filename, 'r') as f :
        for line in f:
            ip = re.findall('((?:\d{1,3}\.){3}\d{1,3})',line)
            if len(ip) == 0:
                continue
            new_entry(ip = ip[0], source = listname, timestamp = date)
    return date
Esempio n. 6
0
def parser(filename, listname, date):
    """
        Parse the list depending on the type (blocklist or ddos)
        and put the entries into redis
    """
    with open(filename, "r") as f:
        for line in f:
            ip = re.findall("((?:\d{1,3}\.){3}\d{1,3})", line)
            if len(ip) == 0:
                continue
            new_entry(ip=ip[0], source=listname, timestamp=date)
    return date
Esempio n. 7
0
def parser(filename, listname, date):
    """
        Parse the list depending on the type (blocklist or ddos)
        and put the entries into redis
    """
    with open(filename, 'r') as f:
        for line in f:
            splitted = line.split(' | ')
            if len(splitted) > 0:
                ip = splitted[1]
                local_date = dateutil.parser.parse(splitted[0])
                new_entry(ip = ip, source = listname, timestamp = local_date)
        return date
Esempio n. 8
0
def parser(filename, listname, date):
    with open(filename, 'r') as csvfile:
        reader = csv.reader(csvfile, delimiter=',')
        for line in reader:
            if len(line) < 3:
                continue
            ip = line[0]
            # The timestamp change many times each day.
            # It breaks the ranking
            # date = dateutil.parser.parse(line[1])
            #comment = line[2]
            new_entry(ip = ip, source = listname, timestamp = date)
    return date
Esempio n. 9
0
def parser(filename, listname, date):
    """
        Parse the list
    """
    a, b, year, month, day, hour, c = os.path.basename(filename).split('.')
    with open(filename, 'r') as f :
        for line in f:
            ip = re.findall('<(?:ip|review)>((?:\d{1,3}\.){3}\d{1,3})<.*',line)
            if len(ip) == 0:
                continue
            new_entry(ip = ip[0], source = listname, timestamp = date)
    date = datetime.datetime(int(year), int(month), int(day), int(hour))
    return date
Esempio n. 10
0
def parser(filename, listname, date):
    try:
        date = dateutil.parser.parse(re.findall('# Generated (.*)\n',
            open(filename, 'r').read())[0])
    except:
        pass
    with open(filename, 'r') as f :
        for line in f:
            ip = re.findall('((?:\d{1,3}\.){3}\d{1,3}).*',line)
            if len(ip) == 0:
                continue
            new_entry(ip = ip[0], source = listname, timestamp = date)
    return date
Esempio n. 11
0
def parser(filename, listname, date):
    with open(filename, 'r') as csvfile:
        reader = csv.reader(csvfile, delimiter=',')
        for line in reader:
            if len(line) < 3:
                continue
            ip = line[0]
            # The timestamp change many times each day.
            # It breaks the ranking
            # date = dateutil.parser.parse(line[1])
            #comment = line[2]
            new_entry(ip=ip, source=listname, timestamp=date)
    return date
Esempio n. 12
0
def parser(filename, listname, date):
    try:
        date = dateutil.parser.parse(re.findall('Last updated (.*)\n',
            open(filename, 'r').read())[0])
    except:
        pass
    with open(filename, 'r') as f :
        for line in f:
            ip = re.findall('((?:\d{1,3}\.){3}\d{1,3})[\s].*',line)
            if len(ip) == 0:
                continue
            new_entry(ip = ip[0], source = listname, timestamp = date)
    return date
Esempio n. 13
0
def parser(filename, listname, date):
    """
        Parse the list depending on the type (blocklist or ddos)
        and put the entries into redis
    """
    with open(filename, 'r') as f:
        for line in f:
            splitted = line.split(' | ')
            if len(splitted) > 0:
                ip = splitted[1]
                local_date = dateutil.parser.parse(splitted[0])
                new_entry(ip=ip, source=listname, timestamp=local_date)
        return date
Esempio n. 14
0
def parser(filename, listname, date):
    """
        Parse the list
    """
    a, b, year, month, day, hour, c = os.path.basename(filename).split('.')
    with open(filename, 'r') as f:
        for line in f:
            ip = re.findall('<(?:ip|review)>((?:\d{1,3}\.){3}\d{1,3})<.*',
                            line)
            if len(ip) == 0:
                continue
            new_entry(ip=ip[0], source=listname, timestamp=date)
    date = datetime.datetime(int(year), int(month), int(day), int(hour))
    return date