-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathidbf_u2i_scrubber.py
executable file
·63 lines (56 loc) · 1.85 KB
/
idbf_u2i_scrubber.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env python3
###########################################################################
#
# Identity Database Framework (idbf)
#
# FILENAME: idbf_u2i_scrubber.py
# DESCRIPTION: Time based scrubber script for iDbF
#
# AUTHOR: Patrick K. Ryon (slashdoom)
# LICENSE: 3 clause BSD (see LICENSE file)
#
###########################################################################
from lib.idbf_user_to_ip_db import *
import configparser
import logging
import os
#setup logging
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
# setup console logging handler
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
ch_format = logging.Formatter('%(asctime)s - %(name)s - %(levelname)-8s - %(message)s')
ch.setFormatter(ch_format)
logger.addHandler(ch)
# setup file logging handler
fh = logging.FileHandler("{0}.log".format(__name__))
fh.setLevel(logging.WARNING)
fh_format = logging.Formatter('%(asctime)s - %(name)s - %(levelname)-8s - %(message)s')
fh.setFormatter(fh_format)
logger.addHandler(fh)
# open config file
config = configparser.ConfigParser()
# read db info
config.read(os.path.join(os.path.dirname(__file__), "etc", "idbf_conf"))
try:
# attempt DATABASE config read
db_host = config["DATABASE"]["db_host"]
db_user = config["DATABASE"]["db_user"]
db_pass = config["DATABASE"]["db_pass"]
db_name = config["DATABASE"]["db_name"]
except:
# send error to logger
logger.error("DATABASE connection settings not found in config")
exit(0)
u2i_db = idbf_user_to_ip_db(db_host,db_user,db_pass,db_name)
try:
# attempt SCRUBBER config read
scrub_day = config["SCRUBBER"]["u2i_DAY"]
scrub_hour = config["SCRUBBER"]["u2i_HOUR"]
scrub_minute = config["SCRUBBER"]["u2i_MINUTE"]
except:
# send warning to logger
logger.error("SCRUBBER settings not found in config")
exit(0)
u2i_db.u2i_user_scrub(scrub_day, scrub_hour, scrub_minute)