2018-05-04 11:53:29 +00:00
|
|
|
#!/usr/bin/env python3
|
2016-06-30 12:38:28 +00:00
|
|
|
# -*-coding:UTF-8 -*
|
|
|
|
"""
|
2017-05-09 09:13:16 +00:00
|
|
|
The CVE Module
|
|
|
|
======================
|
|
|
|
|
|
|
|
This module is consuming the Redis-list created by the Categ module.
|
|
|
|
|
|
|
|
It apply CVE regexes on paste content and warn if a reference to a CVE is spotted.
|
|
|
|
|
2016-06-30 12:38:28 +00:00
|
|
|
"""
|
|
|
|
|
2021-09-08 08:32:47 +00:00
|
|
|
##################################
|
|
|
|
# Import External packages
|
|
|
|
##################################
|
2022-09-20 14:11:48 +00:00
|
|
|
import os
|
2016-06-30 12:38:28 +00:00
|
|
|
import re
|
2022-09-20 14:11:48 +00:00
|
|
|
import sys
|
2021-09-08 08:32:47 +00:00
|
|
|
|
2022-09-20 14:11:48 +00:00
|
|
|
sys.path.append(os.environ['AIL_BIN'])
|
2021-09-08 08:32:47 +00:00
|
|
|
##################################
|
|
|
|
# Import Project packages
|
|
|
|
##################################
|
|
|
|
from modules.abstract_module import AbstractModule
|
2022-10-25 14:25:19 +00:00
|
|
|
from lib.objects import Cves
|
2022-09-20 14:11:48 +00:00
|
|
|
from lib.objects.Items import Item
|
2016-06-30 12:38:28 +00:00
|
|
|
|
|
|
|
|
2021-09-08 08:32:47 +00:00
|
|
|
class Cve(AbstractModule):
|
|
|
|
"""
|
|
|
|
Cve module for AIL framework
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
super(Cve, self).__init__()
|
|
|
|
|
|
|
|
# regex to find CVE
|
2022-09-20 14:11:48 +00:00
|
|
|
self.reg_cve = re.compile(r'CVE-[1-2]\d{1,4}-\d{1,5}')
|
2021-09-08 08:32:47 +00:00
|
|
|
|
2022-10-25 14:25:19 +00:00
|
|
|
# Waiting time in seconds between to message processed
|
2021-09-08 08:32:47 +00:00
|
|
|
self.pending_seconds = 1
|
|
|
|
|
|
|
|
# Send module state to logs
|
|
|
|
self.redis_logger.info(f'Module {self.module_name} initialized')
|
|
|
|
|
|
|
|
def compute(self, message):
|
|
|
|
|
2022-09-20 14:11:48 +00:00
|
|
|
item_id, count = message.split()
|
|
|
|
item = Item(item_id)
|
|
|
|
item_id = item.get_id()
|
2021-09-08 08:32:47 +00:00
|
|
|
|
2022-09-20 14:11:48 +00:00
|
|
|
cves = self.regex_findall(self.reg_cve, item_id, item.get_content())
|
|
|
|
if cves:
|
2022-10-25 14:25:19 +00:00
|
|
|
print(cves)
|
|
|
|
date = item.get_date()
|
|
|
|
for cve_id in cves:
|
|
|
|
cve = Cves.Cve(cve_id)
|
|
|
|
cve.add(date, item_id)
|
|
|
|
|
2022-09-20 14:11:48 +00:00
|
|
|
warning = f'{item_id} contains CVEs {cves}'
|
2021-09-08 08:32:47 +00:00
|
|
|
print(warning)
|
|
|
|
self.redis_logger.warning(warning)
|
2022-10-25 14:25:19 +00:00
|
|
|
|
2022-09-20 14:11:48 +00:00
|
|
|
msg = f'infoleak:automatic-detection="cve";{item_id}'
|
2021-09-08 08:32:47 +00:00
|
|
|
# Send to Tags Queue
|
|
|
|
self.send_message_to_queue(msg, 'Tags')
|
2022-09-20 14:11:48 +00:00
|
|
|
|
|
|
|
|
2016-06-30 12:38:28 +00:00
|
|
|
if __name__ == '__main__':
|
2021-09-08 08:32:47 +00:00
|
|
|
|
|
|
|
module = Cve()
|
2022-10-25 14:25:19 +00:00
|
|
|
# module.run()
|
|
|
|
module.compute('crawled/2022/09/15/circl.lu1e4f9721-06dc-404f-aabf-3c3bd0b533bd 9')
|