mirror of
https://github.com/ail-project/ail-framework.git
synced 2024-11-26 15:57:16 +00:00
55 lines
1.4 KiB
Python
Executable file
55 lines
1.4 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
# -*-coding:UTF-8 -*
|
|
|
|
"""
|
|
The D4_Client Module
|
|
============================
|
|
|
|
The D4_Client modules send all DNS records to a D4 Server.
|
|
Data produced by D4 sensors are ingested into
|
|
a Passive DNS server which can be queried later to search for the Passive DNS records.
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
import time
|
|
|
|
sys.path.append(os.environ['AIL_BIN'])
|
|
##################################
|
|
# Import Project packages
|
|
#################################
|
|
from modules.abstract_module import AbstractModule
|
|
from lib import d4
|
|
|
|
# # TODO: launch me in core screen
|
|
# # TODO: check if already launched in core screen
|
|
|
|
class D4Client(AbstractModule):
|
|
"""
|
|
D4Client module for AIL framework
|
|
"""
|
|
|
|
def __init__(self):
|
|
super(D4Client, self).__init__()
|
|
|
|
self.d4_client = d4.create_d4_client()
|
|
self.last_refresh = time.time()
|
|
|
|
# Send module state to logs
|
|
self.logger.info(f'Module {self.module_name} initialized')
|
|
|
|
def compute(self, dns_record):
|
|
# Refresh D4 Client
|
|
if self.last_refresh < d4.get_config_last_update_time():
|
|
self.d4_client = d4.create_d4_client()
|
|
self.last_refresh = time.time()
|
|
print('D4 Client: config updated')
|
|
|
|
if self.d4_client:
|
|
# Send DNS Record to D4Server
|
|
self.d4_client.send_manual_data(dns_record)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
module = D4Client()
|
|
module.run()
|