No known key found for this signature in database
GPG 키 ID: 1E1B1F50D84613D0
17개의 변경된 파일과 301개의 추가작업 그리고 19개의 파일을 삭제
-
1.gitignore
-
46bin/DomClassifier.py
-
2bin/LAUNCH.sh
-
52bin/core/D4_client.py
-
74bin/lib/d4.py
-
8bin/lib/item_basic.py
-
4bin/packages/modules.cfg
-
1configs/d4client_passiveDNS_conf/destination
-
1configs/d4client_passiveDNS_conf/key
-
1configs/d4client_passiveDNS_conf/snaplen
-
1configs/d4client_passiveDNS_conf/source
-
1configs/d4client_passiveDNS_conf/type
-
1configs/d4client_passiveDNS_conf/version
-
18var/www/modules/settings/Flask_settings.py
-
98var/www/modules/settings/templates/passive_dns.html
-
BINvar/www/static/image/d4-logo.png
-
11var/www/templates/settings/menu_sidebar.html
@ -0,0 +1,52 @@ |
|||
#!/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 |
|||
from pubsublogger import publisher |
|||
sys.path.append(os.environ['AIL_BIN']) |
|||
from Helper import Process |
|||
|
|||
sys.path.append(os.path.join(os.environ['AIL_BIN'], 'lib')) |
|||
import ConfigLoader |
|||
import d4 |
|||
|
|||
# # TODO: lauch me in core screen |
|||
# # TODO: check if already launched in core screen |
|||
|
|||
if __name__ == '__main__': |
|||
publisher.port = 6380 |
|||
publisher.channel = "Script" |
|||
|
|||
config_section = 'D4_client' |
|||
p = Process(config_section) |
|||
publisher.info("""D4_client is Running""") |
|||
|
|||
last_refresh = time.time() |
|||
d4_client = d4.create_d4_client() |
|||
|
|||
while True: |
|||
if last_refresh < d4.get_config_last_update_time(): |
|||
d4_client = d4.create_d4_client() |
|||
last_refresh = time.time() |
|||
print('D4 Client: config updated') |
|||
|
|||
dns_record = p.get_from_set() |
|||
if dns_record is None: |
|||
publisher.debug("Script D4_client is idling 1s") |
|||
time.sleep(1) |
|||
continue |
|||
|
|||
if d4_client: |
|||
# Send DNS Record to D4Server |
|||
d4_client.send_manual_data(dns_record) |
|||
@ -0,0 +1,74 @@ |
|||
#!/usr/bin/env python3 |
|||
# -*-coding:UTF-8 -* |
|||
|
|||
import os |
|||
import sys |
|||
import time |
|||
import redis |
|||
import d4_pyclient |
|||
|
|||
sys.path.append(os.path.join(os.environ['AIL_BIN'], 'lib')) |
|||
import ConfigLoader |
|||
|
|||
config_loader = ConfigLoader.ConfigLoader() |
|||
r_serv_db = config_loader.get_redis_conn("ARDB_DB") |
|||
r_cache = config_loader.get_redis_conn("Redis_Cache") |
|||
config_loader = None |
|||
|
|||
def get_ail_uuid(): |
|||
return r_serv_db.get('ail:uuid') |
|||
|
|||
def get_d4_client_config_dir(): |
|||
return os.path.join(os.environ['AIL_HOME'], 'configs', 'd4client_passiveDNS_conf') |
|||
|
|||
def create_d4_config_file(filename, content): |
|||
if not os.path.isfile(filename): |
|||
with open(filename, 'a') as f: |
|||
f.write(content) |
|||
|
|||
def get_d4_client_config(): |
|||
d4_client_config = get_d4_client_config_dir() |
|||
filename = os.path.join(d4_client_config, 'uuid') |
|||
if not os.path.isfile(filename): |
|||
create_d4_config_file(filename, get_ail_uuid()) |
|||
return d4_client_config |
|||
|
|||
def is_passive_dns_enabled(cache=True): |
|||
if cache: |
|||
res = r_cache.get('d4:passivedns:enabled') |
|||
if res is None: |
|||
res = r_serv_db.hget('d4:passivedns', 'enabled') == 'True' |
|||
r_cache.set('d4:passivedns:enabled', res) |
|||
return res |
|||
else: |
|||
return res == 'True' |
|||
else: |
|||
return r_serv_db.hget('d4:passivedns', 'enabled') == 'True' |
|||
|
|||
def change_passive_dns_state(new_state): |
|||
old_state = is_passive_dns_enabled(cache=False) |
|||
if old_state != new_state: |
|||
r_serv_db.hset('d4:passivedns', 'enabled', bool(new_state)) |
|||
r_cache.set('d4:passivedns:enabled', bool(new_state)) |
|||
update_time = time.time() |
|||
r_serv_db.hset('d4:passivedns', 'update_time', update_time) |
|||
r_cache.set('d4:passivedns:last_update_time', update_time) |
|||
return True |
|||
return False |
|||
|
|||
def get_config_last_update_time(): |
|||
last_update_time = r_cache.get('d4:passivedns:last_update_time') |
|||
if not last_update_time: |
|||
last_update_time = r_serv_db.hget('d4:passivedns', 'update_time') |
|||
if not last_update_time: |
|||
last_update_time = 0 |
|||
last_update_time = float(last_update_time) |
|||
r_cache.set('d4:passivedns:last_update_time', last_update_time) |
|||
return float(last_update_time) |
|||
|
|||
def create_d4_client(): |
|||
if is_passive_dns_enabled(): |
|||
d4_client = d4_pyclient.D4Client(get_d4_client_config(), False) |
|||
return d4_client |
|||
else: |
|||
return None |
|||
@ -0,0 +1 @@ |
|||
d4pdns.circl.lu:4443 |
|||
@ -0,0 +1 @@ |
|||
ail passivedns sensor key |
|||
@ -0,0 +1 @@ |
|||
4096 |
|||
@ -0,0 +1 @@ |
|||
stdin |
|||
@ -0,0 +1 @@ |
|||
8 |
|||
@ -0,0 +1 @@ |
|||
1 |
|||
@ -0,0 +1,98 @@ |
|||
<!DOCTYPE html> |
|||
<html> |
|||
|
|||
<head> |
|||
<title>Passive DNS - AIL</title> |
|||
<link rel="icon" href="{{ url_for('static', filename='image/ail-icon.png') }}"> |
|||
|
|||
<!-- Core CSS --> |
|||
<link href="{{ url_for('static', filename='css/bootstrap4.min.css') }}" rel="stylesheet"> |
|||
<link href="{{ url_for('static', filename='css/font-awesome.min.css') }}" rel="stylesheet"> |
|||
<link href="{{ url_for('static', filename='css/dataTables.bootstrap4.min.css') }}" rel="stylesheet"> |
|||
|
|||
<!-- JS --> |
|||
<script src="{{ url_for('static', filename='js/jquery.js')}}"></script> |
|||
<script src="{{ url_for('static', filename='js/popper.min.js')}}"></script> |
|||
<script src="{{ url_for('static', filename='js/bootstrap4.min.js')}}"></script> |
|||
<script src="{{ url_for('static', filename='js/jquery.dataTables.min.js')}}"></script> |
|||
<script src="{{ url_for('static', filename='js/dataTables.bootstrap.min.js')}}"></script> |
|||
|
|||
</head> |
|||
<body> |
|||
|
|||
{% include 'nav_bar.html' %} |
|||
|
|||
<div class="container-fluid"> |
|||
<div class="row"> |
|||
|
|||
{% include 'settings/menu_sidebar.html' %} |
|||
|
|||
<div class="col-12 col-lg-10" id="core_content"> |
|||
|
|||
<div class="d-flex justify-content-center my-4"> |
|||
<a href="https://d4-project.org/"> |
|||
<img src="{{ url_for('static', filename='image/d4-logo.png')}}" alt="D4 project"> |
|||
</a> |
|||
</div> |
|||
|
|||
<p class="lead px-4"> |
|||
Passive DNS or pDNS is a service which records domain name system server (DNS) answers to DNS client requests.<br> |
|||
In order to see the evolution of records over time, a history is recorded.<br> |
|||
Various sources can be used to build a large sensor network.<br> |
|||
<br> |
|||
Enabling the D4 passive DNS sensor in AIL will contribute resolved domains and host to the global Passive DNS community operated by |
|||
<a href="https://www.circl.lu/"> |
|||
CIRCL.lu |
|||
</a> |
|||
<br> |
|||
<br> |
|||
(if you want to have access to the global Passive DNS community |
|||
<a href="https://www.circl.lu/services/passive-dns/"> |
|||
https://www.circl.lu/services/passive-dns |
|||
</a> |
|||
) |
|||
</p> |
|||
|
|||
|
|||
{% if passivedns_enabled %} |
|||
<a href="{{ url_for('settings.passive_dns_change_state') }}?state=disable"> |
|||
<button class="btn btn-danger mx-4 my-2"> |
|||
Disable D4 Client |
|||
</button> |
|||
</a> |
|||
{% else %} |
|||
<a href="{{ url_for('settings.passive_dns_change_state') }}?state=enable"> |
|||
<button class="btn btn-primary mx-4 my-2"> |
|||
Enable D4 Client |
|||
</button> |
|||
</a> |
|||
{% endif %} |
|||
</div> |
|||
</div> |
|||
</div> |
|||
|
|||
</body> |
|||
|
|||
<script> |
|||
$(document).ready(function(){ |
|||
$("#nav_settings").addClass("active"); |
|||
$("#passive_dns").removeClass("text-muted"); |
|||
} ); |
|||
|
|||
function toggle_sidebar(){ |
|||
if($('#nav_menu').is(':visible')){ |
|||
$('#nav_menu').hide(); |
|||
$('#side_menu').removeClass('border-right') |
|||
$('#side_menu').removeClass('col-lg-2') |
|||
$('#core_content').removeClass('col-lg-10') |
|||
}else{ |
|||
$('#nav_menu').show(); |
|||
$('#side_menu').addClass('border-right') |
|||
$('#side_menu').addClass('col-lg-2') |
|||
$('#core_content').addClass('col-lg-10') |
|||
} |
|||
} |
|||
|
|||
</script> |
|||
|
|||
</html> |
|||
|
After Width: 226 | Height: 210 | Size: 17 KiB |
쓰기
미리보기
불러오는 중...
취소
저장
Reference in new issue