diff --git a/README.md b/README.md index 681e1dc..0432f4b 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,11 @@ Within Python Virtual Environment: 1. Run `pip install -r requirements.txt` to install needed Python libraries. -2. Run `python db-setup.py` to setup and create new Postgresql database and needed tables in it. +2. Run `python db-setup.py` to setup and create new Postgresql database and needed tables in it. + +3. Run `python torips.py` to write Tor exit nodes IPs to database. You need to get the torbulkexitlist from [here](https://check.torproject.org/torbulkexitlist) + +4. Use your favourite scheduling method to set `python spamcheck.py` to run regularly. + -3. Use your favourite scheduling method to set `python spamcheck.py` to run regularly. diff --git a/checktornodes.py b/checktornodes.py new file mode 100644 index 0000000..ce076ae --- /dev/null +++ b/checktornodes.py @@ -0,0 +1,148 @@ +import os +import sys +import psycopg2 +import pdb + +def check_ip(ip): + + is_tor_exit_node = 'f' + + conn = None + + try: + + conn = psycopg2.connect(database = spamcheck_db, user = spamcheck_db_user, password = "", host = "/var/run/postgresql", port = "5432") + + cur = conn.cursor() + + cur.execute('select ip from torexit_ips where ip=(%s)', (ip,)) + + row = cur.fetchone() + + if row != None: + + print(f'{ip} is a Tor exit node') + + is_tor_exit_node = 't' + + cur.close() + + except (Exception, psycopg2.DatabaseError) as error: + + print(error) + + finally: + + if conn is not None: + + conn.close() + + return is_tor_exit_node + +def get_spam_ips(): + + spam_ip_lst = [] + + conn = None + + try: + + conn = psycopg2.connect(database = spamcheck_db, user = spamcheck_db_user, password = "", host = "/var/run/postgresql", port = "5432") + + cur = conn.cursor() + + cur.execute('select ip from spamcheck') + + rows = cur.fetchall() + + for row in rows: + + spam_ip_lst.append(row[0]) + + cur.close() + + except (Exception, psycopg2.DatabaseError) as error: + + print(error) + + finally: + + if conn is not None: + + conn.close() + + return spam_ip_lst + +def db_config(): + + # Load db configuration from config file + config_filepath = "config/db_config.txt" + spamcheck_db = get_parameter("spamcheck_db", config_filepath) + spamcheck_db_user = get_parameter("spamcheck_db_user", config_filepath) + + return (spamcheck_db, spamcheck_db_user) + +# Returns the parameter from the specified file +def get_parameter( parameter, file_path ): + # Check if secrets file exists + if not os.path.isfile(file_path): + print("File %s not found, exiting."%file_path) + sys.exit(0) + + # Find parameter in file + with open( file_path ) as f: + for line in f: + if line.startswith( parameter ): + return line.replace(parameter + ":", "").strip() + + # Cannot find parameter, exit + print(file_path + " Missing parameter %s "%parameter) + sys.exit(0) + +############################################################################### +# main + +if __name__ == '__main__': + + spamcheck_db, spamcheck_db_user = db_config() + + spam_ip_lst = get_spam_ips() + + print(f'{len(spam_ip_lst)} IPs found.') + + i = 0 + + while i < len(spam_ip_lst): + + is_tor_exit_node = check_ip(spam_ip_lst[i]) + + tor_exit_node = 't' if is_tor_exit_node == 't' else 'f' + + update_sql = 'UPDATE spamcheck set tor_exit_node=(%s) where ip=(%s)' + + conn = None + + try: + + conn = psycopg2.connect(database = spamcheck_db, user = spamcheck_db_user, password = "", host = "/var/run/postgresql", port = "5432") + + cur = conn.cursor() + + cur.execute(update_sql, (tor_exit_node, spam_ip_lst[i])) + + conn.commit() + + cur.close() + + except (Exception, psycopg2.DatabaseError) as error: + + print(error) + + finally: + + if conn is not None: + + conn.close() + + i += 1 + diff --git a/db-setup.py b/db-setup.py index f96ca6e..fdbfae3 100644 --- a/db-setup.py +++ b/db-setup.py @@ -150,9 +150,14 @@ if __name__ == '__main__': db_user = spamcheck_db_user table = "spamcheck" - sql = "create table "+table+" (created_at timestamptz, id bigint PRIMARY KEY, email varchar(200), ip inet, text varchar(200))" + sql = "create table "+table+" (created_at timestamptz, id bigint PRIMARY KEY, email varchar(200), ip inet, text varchar(200), tor_exit_node boolean)" create_table(db, db_user, table, sql) + table = "torexit_ips" + sql = "create table "+table+" (created_at timestamptz, ip inet PRIMARY KEY)" + create_table(db, db_user, table, sql) + + ############################################################ print("Done!") diff --git a/spamcheck.py b/spamcheck.py index 60c8bda..b055b65 100644 --- a/spamcheck.py +++ b/spamcheck.py @@ -7,8 +7,103 @@ import sys import os.path import operator import psycopg2 +from langdetect import detect +import requests import pdb +def check_ip(ip): + + is_tor_exit_node = 'f' + + conn = None + + try: + + conn = psycopg2.connect(database = spamcheck_db, user = spamcheck_db_user, password = "", host = "/var/run/postgresql", port = "5432") + + cur = conn.cursor() + + cur.execute('select ip from torexit_ips where ip=(%s)', (ip,)) + + row = cur.fetchone() + + if row != None: + + is_tor_exit_node = 't' + + cur.close() + + except (Exception, psycopg2.DatabaseError) as error: + + print(error) + + finally: + + if conn is not None: + + conn.close() + + return is_tor_exit_node + +def check_approval(user_id): + + approved = False + + try: + + conn = None + + conn = psycopg2.connect(database = mastodon_db, user = mastodon_db_user, password = "", host = "/var/run/postgresql", port = "5432") + + cur = conn.cursor() + + cur.execute("select approved from users where id = (%s)", (user_id,)) + + row = cur.fetchone() + + if row != None: + + approved = row[0] + + cur.close() + + return approved + + except (Exception, psycopg2.DatabaseError) as error: + + print (error) + + finally: + + if conn is not None: + + conn.close() + +def mastodon(): + + # Load secrets from secrets file + secrets_filepath = "secrets/secrets.txt" + uc_client_id = get_parameter("uc_client_id", secrets_filepath) + uc_client_secret = get_parameter("uc_client_secret", secrets_filepath) + uc_access_token = get_parameter("uc_access_token", secrets_filepath) + + # Load configuration from config file + config_filepath = "config/config.txt" + mastodon_hostname = get_parameter("mastodon_hostname", config_filepath) + + # Initialise Mastodon API + mastodon = Mastodon( + client_id=uc_client_id, + client_secret=uc_client_secret, + access_token=uc_access_token, + api_base_url='https://' + mastodon_hostname, + ) + + # Initialise access headers + headers = {'Authorization': 'Bearer %s'%uc_access_token} + + return (mastodon, mastodon_hostname) + def db_config(): # Load db configuration from config file @@ -44,6 +139,8 @@ if __name__ == '__main__': mastodon_db, mastodon_db_user, spamcheck_db, spamcheck_db_user = db_config() + mastodon, mastodon_hostname = mastodon() + ############################################################################### # check new registering ############################################################################### @@ -98,12 +195,50 @@ if __name__ == '__main__': ############################################################################### - insert_sql = 'INSERT INTO spamcheck(created_at, id, email, ip, text) VALUES(%s,%s,%s,%s,%s) ON CONFLICT DO NOTHING' + insert_sql = 'INSERT INTO spamcheck(created_at, id, email, ip, text: tor_exit_node) VALUES(%s,%s,%s,%s,%s,%s) ON CONFLICT DO NOTHING' i = 0 while i < len(id_lst): + if detect(text_lst[i]) != 'ca': + + is_tor_exit_node = check_ip(ip_lst[i]) + + tor_exit_node = 't' if is_tor_exit_node else 'f' + + conn = None + + try: + + conn = psycopg2.connect(database = spamcheck_db, user = spamcheck_db_user, password = "", host = "/var/run/postgresql", port = "5432") + + cur = conn.cursor() + + cur.execute(insert_sql, (created_at_lst[i], id_lst[i], email_lst[i], ip_lst[i], text_lst[i]), tor_exit_node) + + conn.commit() + + cur.close() + + except (Exception, psycopg2.DatabaseError) as error: + + print(error) + + finally: + + if conn is not None: + + conn.close() + + print(created_at_lst[i], id_lst[i], email_lst[i], ip_lst[i], text_lst[i]) + + i = i + 1 + + ########################################################################## + + approved_users_id_lst = [] + conn = None try: @@ -112,9 +247,13 @@ if __name__ == '__main__': cur = conn.cursor() - cur.execute(insert_sql, (created_at_lst[i], id_lst[i], email_lst[i], ip_lst[i], text_lst[i])) + cur.execute('select id from spamcheck') - conn.commit() + rows = cur.fetchall() + + for row in rows: + + approved_users_id_lst.append(row) cur.close() @@ -128,7 +267,32 @@ if __name__ == '__main__': conn.close() - print(created_at_lst[i], id_lst[i], email_lst[i], ip_lst[i], text_lst[i]) + for user_id in approved_users_id_lst: - i = i + 1 + approved = check_approval(user_id) + if approved: + + conn = None + + try: + + conn = psycopg2.connect(database = spamcheck_db, user = spamcheck_db_user, password = "", host = "/var/run/postgresql", port = "5432") + + cur = conn.cursor() + + cur.execute('delete from spamcheck where id=(%s)', (user_id,)) + + conn.commit() + + cur.close() + + except (Exception, psycopg2.DatabaseError) as error: + + print(error) + + finally: + + if conn is not None: + + conn.close() diff --git a/torbulkexitlist b/torbulkexitlist new file mode 100644 index 0000000..ba73de7 --- /dev/null +++ b/torbulkexitlist @@ -0,0 +1,1759 @@ +176.10.99.200 +109.70.100.28 +51.75.64.23 +82.221.128.191 +109.70.100.31 +185.220.100.254 +185.220.103.9 +195.176.3.23 +185.220.100.243 +185.220.100.245 +198.58.107.53 +199.249.230.83 +199.249.230.75 +104.244.76.13 +23.129.64.132 +71.19.144.106 +95.143.193.125 +185.220.100.241 +109.70.100.22 +178.20.55.18 +195.176.3.20 +199.249.230.121 +109.70.100.23 +91.250.242.12 +185.82.219.109 +185.220.103.4 +199.249.230.89 +45.15.16.98 +45.15.16.82 +45.15.16.70 +207.244.70.35 +217.79.178.53 +185.220.100.242 +204.11.50.131 +171.25.193.77 +91.92.109.43 +199.249.230.84 +109.70.100.21 +185.220.100.246 +213.95.149.22 +162.247.74.7 +109.169.33.163 +81.16.33.31 +82.221.131.5 +23.129.64.142 +23.129.64.133 +46.232.251.191 +176.58.100.98 +199.249.230.65 +94.16.121.91 +199.249.230.118 +51.254.48.93 +109.70.100.25 +162.247.72.199 +80.67.172.162 +109.70.100.26 +185.220.100.255 +27.122.59.100 +178.17.171.102 +43.251.159.144 +178.17.171.197 +23.129.64.147 +178.17.174.10 +199.249.230.85 +5.2.77.146 +109.70.100.30 +185.220.100.247 +162.247.74.27 +162.247.74.204 +202.165.228.225 +23.129.64.144 +83.96.213.63 +178.175.131.194 +176.10.104.240 +179.48.251.188 +185.10.16.41 +80.241.60.207 +178.17.174.232 +94.230.208.147 +109.69.67.17 +46.29.248.238 +185.220.100.253 +185.220.100.248 +199.249.230.115 +199.249.230.71 +66.146.193.33 +185.220.103.6 +103.253.41.98 +109.70.100.34 +185.220.100.251 +45.129.56.200 +45.128.133.242 +178.17.170.164 +185.220.100.244 +185.165.171.84 +185.100.85.21 +202.165.228.161 +45.66.35.35 +185.220.103.8 +162.247.74.202 +46.166.139.111 +193.218.118.182 +176.53.90.26 +199.249.230.114 +162.247.74.201 +109.70.100.29 +138.59.18.110 +199.249.230.74 +199.249.230.76 +82.223.14.245 +109.70.100.27 +178.17.171.39 +103.236.201.88 +176.10.107.180 +195.176.3.19 +199.249.230.68 +199.249.230.81 +87.118.116.90 +89.163.143.8 +91.244.181.85 +87.118.122.30 +199.249.230.79 +89.234.157.254 +195.206.105.217 +87.118.116.103 +162.247.74.213 +144.217.80.80 +45.114.130.4 +62.171.144.155 +109.70.100.20 +204.85.191.8 +87.118.96.154 +162.247.74.74 +199.249.230.82 +23.239.22.248 +139.99.172.11 +162.247.74.217 +23.129.64.139 +23.129.64.138 +185.65.205.10 +95.154.24.73 +87.118.122.51 +95.142.161.63 +94.142.244.16 +23.129.64.143 +198.96.155.3 +185.130.44.108 +18.27.197.252 +82.221.131.71 +178.17.170.135 +159.89.174.9 +185.220.100.250 +45.76.115.159 +94.230.208.148 +77.81.247.72 +199.249.230.70 +109.70.100.24 +162.247.74.216 +185.216.32.130 +104.244.74.57 +185.100.87.41 +188.214.104.146 +162.247.74.200 +162.247.73.192 +185.220.100.240 +109.70.100.32 +185.220.100.249 +23.129.64.137 +185.56.171.94 +164.132.9.199 +23.129.64.134 +37.228.129.2 +185.42.170.203 +185.100.86.154 +163.172.41.228 +130.149.80.199 +185.100.86.128 +199.249.230.123 +199.249.230.106 +199.249.230.108 +198.50.128.237 +162.247.74.206 +209.141.50.178 +199.249.230.104 +123.30.128.138 +185.220.103.7 +23.129.64.149 +185.220.100.252 +104.244.74.97 +199.249.230.102 +178.17.174.198 +199.249.230.64 +51.161.43.235 +180.150.226.99 +95.128.43.164 +189.84.21.44 +109.70.100.19 +199.249.230.100 +45.140.170.187 +109.70.100.33 +198.98.51.189 +23.129.64.148 +192.42.116.16 +181.119.30.26 +195.176.3.24 +178.17.174.14 +94.32.66.15 +87.118.116.12 +178.17.174.196 +199.249.230.80 +51.38.233.93 +171.25.193.20 +209.141.54.195 +23.129.64.140 +185.220.103.5 +23.129.64.135 +178.20.55.16 +151.237.185.110 +166.70.207.2 +23.129.64.141 +180.149.125.139 +217.12.221.131 +178.17.174.211 +185.65.206.154 +125.212.241.131 +178.17.170.23 +103.28.52.93 +95.216.145.1 +204.85.191.9 +23.129.64.146 +46.194.42.94 +46.194.149.79 +46.194.57.149 +46.194.130.137 +46.194.138.182 +185.35.202.222 +71.174.105.126 +104.244.72.115 +109.70.100.35 +109.70.100.36 +199.195.250.77 +195.80.151.30 +45.79.177.190 +104.244.73.193 +178.17.170.13 +185.170.114.25 +208.68.7.129 +103.228.53.155 +212.109.197.1 +131.255.4.96 +91.132.147.168 +107.189.10.237 +82.146.55.139 +23.129.64.130 +23.129.64.131 +23.129.64.136 +217.79.179.7 +134.249.106.21 +185.38.175.130 +195.144.21.219 +94.140.114.190 +199.249.230.140 +199.249.230.142 +199.249.230.141 +199.249.230.144 +199.249.230.143 +199.249.230.148 +199.249.230.146 +199.249.230.149 +199.249.230.145 +199.249.230.147 +199.249.230.152 +199.249.230.151 +199.249.230.166 +199.249.230.168 +199.249.230.160 +199.249.230.183 +199.249.230.187 +199.249.230.162 +199.249.230.164 +199.249.230.181 +199.249.230.174 +199.249.230.185 +199.249.230.170 +199.249.230.159 +199.249.230.156 +199.249.230.153 +199.249.230.158 +199.249.230.157 +199.249.230.154 +199.249.230.172 +199.249.230.163 +199.249.230.189 +204.194.29.4 +209.141.45.189 +185.185.170.27 +104.244.73.43 +193.218.118.155 +193.218.118.156 +209.141.53.20 +185.4.132.183 +185.4.132.135 +184.105.220.24 +94.142.241.194 +171.25.193.78 +171.25.193.25 +71.19.144.89 +193.218.118.125 +193.218.118.145 +185.235.146.29 +185.220.102.250 +185.220.102.252 +185.220.102.251 +185.220.102.253 +185.220.102.254 +185.220.102.249 +185.220.102.248 +185.38.175.131 +74.82.47.194 +185.107.47.215 +84.53.225.118 +193.189.100.202 +193.189.100.194 +193.189.100.199 +193.189.100.195 +193.189.100.198 +193.189.100.196 +193.189.100.197 +219.91.10.8 +219.91.12.146 +219.91.14.213 +104.244.76.170 +88.80.20.86 +199.249.230.67 +199.249.230.178 +199.249.230.66 +199.249.230.73 +199.249.230.177 +199.249.230.116 +199.249.230.88 +199.249.230.150 +199.249.230.72 +199.249.230.161 +199.249.230.86 +199.249.230.69 +199.249.230.155 +199.249.230.175 +199.249.230.112 +199.249.230.110 +199.249.230.78 +147.135.105.62 +101.100.146.147 +185.220.102.241 +185.220.102.245 +185.220.102.246 +185.220.102.244 +185.220.102.247 +185.220.102.243 +185.220.102.242 +185.220.102.240 +193.239.232.101 +71.19.154.84 +64.113.32.29 +163.172.29.30 +45.79.144.222 +204.17.56.42 +5.2.78.69 +107.189.30.86 +45.151.167.10 +51.15.59.15 +92.246.84.133 +205.185.124.200 +104.244.74.28 +192.34.80.176 +199.195.254.254 +200.122.181.2 +193.218.118.90 +193.218.118.100 +92.223.93.145 +198.98.60.90 +209.141.46.203 +178.17.174.164 +45.154.255.147 +104.244.73.13 +107.189.11.153 +104.244.73.93 +45.153.160.129 +45.153.160.130 +81.6.43.9 +81.6.43.167 +5.2.77.22 +199.195.254.81 +104.244.73.205 +51.83.131.42 +51.195.42.226 +51.178.86.137 +198.98.51.151 +141.239.152.254 +45.153.160.138 +45.153.160.132 +45.153.160.131 +45.153.160.140 +45.153.160.139 +45.153.160.133 +45.153.160.135 +45.153.160.136 +45.153.160.134 +45.153.160.137 +104.244.77.53 +104.244.73.46 +104.244.75.33 +107.189.10.143 +104.244.74.211 +104.244.72.168 +213.164.204.89 +104.244.73.85 +213.164.204.90 +104.244.77.101 +79.136.1.46 +185.56.80.65 +198.98.61.131 +198.98.48.175 +51.195.103.74 +213.164.204.38 +178.17.174.68 +87.118.110.27 +205.185.127.35 +185.112.144.119 +185.196.2.251 +209.141.56.96 +205.185.120.173 +37.187.96.183 +209.141.41.225 +104.244.72.152 +204.8.156.142 +104.244.77.122 +104.244.79.187 +107.189.10.154 +104.244.72.36 +104.244.72.248 +107.189.11.207 +104.244.75.80 +104.244.79.196 +213.164.204.94 +213.164.204.160 +208.68.4.129 +37.187.196.70 +45.153.160.2 +192.42.116.27 +192.42.116.19 +192.42.116.22 +192.42.116.20 +192.42.116.15 +192.42.116.25 +192.42.116.28 +192.42.116.26 +192.42.116.13 +192.42.116.23 +192.42.116.17 +192.42.116.24 +192.42.116.14 +192.42.116.18 +104.244.74.55 +213.164.204.152 +213.164.204.116 +213.164.204.165 +107.189.31.181 +216.218.134.12 +199.184.215.11 +213.164.204.171 +104.244.77.95 +193.218.118.167 +193.218.118.62 +107.174.244.102 +185.112.146.85 +209.141.59.180 +193.218.118.183 +91.149.225.120 +157.90.38.9 +176.152.45.213 +107.189.30.230 +107.189.31.102 +205.185.120.206 +51.15.235.211 +185.100.87.202 +199.249.230.101 +199.249.230.119 +199.249.230.169 +199.249.230.186 +199.249.230.77 +199.249.230.182 +199.249.230.173 +199.249.230.165 +199.249.230.176 +199.249.230.117 +199.249.230.122 +199.249.230.171 +199.249.230.179 +199.249.230.111 +199.249.230.103 +199.249.230.113 +199.249.230.188 +199.249.230.180 +199.249.230.167 +199.249.230.107 +199.249.230.184 +199.249.230.105 +199.249.230.120 +193.189.100.203 +193.189.100.204 +193.189.100.206 +199.249.230.109 +193.189.100.205 +172.81.131.110 +185.233.100.23 +172.81.131.111 +193.31.24.154 +198.98.57.207 +51.15.197.24 +209.141.55.26 +185.193.127.153 +37.187.2.76 +185.100.87.250 +82.221.139.190 +194.182.73.224 +185.67.82.114 +45.79.177.21 +213.164.205.168 +104.244.72.123 +213.164.205.169 +82.68.49.227 +213.164.205.167 +104.244.72.91 +107.189.10.63 +107.189.30.22 +193.218.118.101 +45.95.235.86 +193.218.118.147 +66.175.208.248 +185.100.87.129 +45.151.167.11 +185.10.68.65 +190.10.8.166 +139.99.239.135 +51.79.204.46 +167.71.224.186 +143.198.208.126 +192.46.212.198 +172.104.179.146 +185.104.120.10 +62.171.142.3 +176.126.253.190 +45.121.147.218 +198.54.128.94 +192.195.80.10 +198.167.206.246 +198.167.206.232 +198.167.206.156 +198.167.206.194 +198.167.206.131 +198.167.206.222 +198.167.206.149 +198.167.206.182 +198.167.206.129 +198.167.206.183 +198.167.206.242 +198.167.206.197 +198.167.206.244 +198.167.206.237 +198.167.206.166 +198.167.206.152 +198.167.206.167 +198.167.206.185 +198.167.206.180 +198.167.206.162 +198.167.206.170 +198.167.206.225 +198.167.206.174 +198.167.206.238 +198.167.206.253 +198.167.206.220 +198.167.206.154 +198.167.206.228 +198.167.206.233 +198.167.206.230 +198.167.206.200 +198.167.206.241 +198.167.206.192 +198.167.206.186 +198.167.206.153 +198.167.206.248 +198.167.206.227 +198.167.206.160 +198.167.206.213 +198.167.206.184 +198.167.206.205 +51.158.183.63 +45.192.176.44 +51.161.43.237 +209.141.49.232 +72.167.47.69 +91.219.237.21 +114.199.75.111 +213.164.206.124 +213.164.206.123 +176.123.7.102 +51.77.39.255 +51.255.106.85 +91.219.236.197 +173.249.57.253 +104.244.73.126 +209.141.34.232 +94.140.115.133 +50.254.218.37 +185.117.118.15 +95.211.118.194 +23.160.193.176 +212.102.50.33 +5.2.69.50 +185.83.214.69 +203.159.80.73 +45.144.225.119 +156.146.34.193 +89.163.243.88 +89.163.252.30 +89.163.154.91 +89.163.252.230 +5.199.143.202 +89.163.249.192 +213.202.216.189 +89.163.249.244 +89.163.150.213 +31.210.20.110 +51.81.160.187 +185.100.87.192 +173.212.219.49 +135.125.46.180 +185.142.239.49 +46.226.105.119 +159.65.50.174 +68.183.184.174 +96.66.15.152 +107.189.6.166 +209.141.51.252 +216.186.250.53 +185.107.47.171 +138.68.69.37 +5.2.67.226 +178.17.171.109 +185.104.120.20 +185.104.120.30 +185.104.120.40 +45.137.184.31 +185.100.87.72 +31.42.185.24 +199.195.253.53 +91.219.236.228 +199.195.253.184 +107.189.5.248 +141.136.0.129 +185.82.127.25 +94.140.115.76 +141.136.0.117 +51.195.107.236 +205.185.126.167 +94.140.114.213 +213.164.204.177 +198.98.48.203 +205.185.123.97 +199.195.253.149 +205.185.115.45 +205.185.113.225 +5.2.76.221 +66.220.242.222 +5.2.72.226 +107.152.43.154 +45.142.214.89 +194.156.98.85 +198.98.59.35 +185.191.127.212 +185.191.127.214 +5.183.209.134 +185.191.127.231 +185.191.127.213 +5.183.209.136 +5.183.209.135 +185.191.127.215 +198.98.51.222 +193.239.232.102 +51.15.227.109 +51.15.127.227 +135.148.43.32 +107.189.8.65 +107.189.30.23 +107.189.29.41 +85.202.80.35 +104.244.77.235 +107.189.31.241 +205.185.117.149 +185.82.126.13 +104.244.72.239 +217.160.174.204 +107.189.30.75 +107.189.31.87 +129.159.35.205 +139.162.43.196 +107.189.7.243 +185.129.62.62 +104.244.73.169 +107.189.30.58 +107.189.2.222 +104.244.77.73 +45.61.186.108 +45.61.186.166 +209.141.57.164 +45.61.185.114 +45.61.185.90 +107.189.1.160 +104.244.72.65 +213.61.215.54 +107.189.10.218 +45.61.186.113 +163.172.213.212 +45.61.186.169 +185.212.149.103 +41.77.136.114 +185.242.180.182 +5.183.209.217 +208.68.5.17 +77.68.20.217 +45.61.185.125 +185.10.68.195 +41.215.241.146 +93.95.227.69 +93.95.227.55 +93.95.227.202 +107.189.7.156 +185.112.144.49 +209.141.46.81 +45.61.184.239 +104.244.76.44 +198.98.57.24 +62.212.95.196 +93.95.227.227 +192.160.102.169 +192.160.102.170 +192.160.102.164 +46.232.249.138 +198.144.121.43 +192.160.102.166 +185.165.168.77 +199.195.251.182 +176.58.121.177 +59.115.123.139 +61.230.160.44 +61.230.162.191 +61.230.161.95 +59.115.116.5 +59.115.120.248 +59.115.118.231 +36.227.169.17 +36.227.174.70 +36.227.165.170 +59.115.116.103 +36.227.164.189 +36.227.162.217 +59.115.124.192 +192.160.102.165 +192.160.102.168 +107.189.31.195 +107.189.7.175 +107.189.5.68 +198.98.62.120 +31.42.184.34 +172.107.201.134 +185.220.102.4 +185.165.169.18 +135.125.137.236 +107.189.4.203 +107.189.28.100 +144.172.118.4 +46.182.21.248 +107.189.31.227 +23.106.122.112 +185.100.87.139 +45.61.185.53 +45.61.184.244 +49.50.107.221 +195.37.209.9 +95.211.100.149 +5.182.210.216 +5.182.210.155 +82.118.253.153 +185.100.87.253 +5.255.97.149 +107.189.5.5 +5.2.188.23 +104.244.79.6 +104.244.79.234 +104.244.72.120 +107.189.13.254 +185.112.146.73 +107.189.14.165 +184.105.146.50 +104.244.72.132 +51.68.190.9 +109.201.133.100 +102.130.113.37 +102.130.113.9 +198.98.62.79 +198.98.50.112 +199.195.252.18 +198.98.60.19 +185.31.175.243 +185.31.175.226 +185.31.175.240 +185.31.175.220 +185.31.175.228 +185.31.175.231 +185.31.175.213 +185.31.175.235 +185.31.175.247 +185.31.175.207 +185.31.175.252 +185.31.175.215 +107.189.13.143 +111.90.145.190 +107.189.12.240 +107.189.12.238 +185.112.144.191 +185.130.47.58 +107.189.29.207 +201.22.99.17 +177.205.183.0 +51.81.143.174 +51.68.214.45 +107.189.30.151 +95.216.107.148 +81.17.18.62 +103.171.85.126 +107.189.14.47 +107.189.14.182 +107.189.28.253 +104.244.77.80 +107.189.8.33 +209.127.17.234 +45.61.187.205 +104.244.78.168 +213.164.204.146 +45.12.134.108 +198.98.57.191 +31.42.186.101 +141.95.18.225 +185.82.126.222 +94.140.114.174 +107.189.12.148 +209.141.60.19 +104.244.76.127 +141.95.18.207 +213.164.206.127 +185.220.101.1 +185.220.101.3 +185.220.101.2 +185.220.101.6 +185.220.101.4 +185.220.101.7 +185.220.101.5 +185.220.101.8 +193.189.100.200 +193.189.100.201 +107.189.28.102 +185.220.101.14 +185.220.101.11 +185.220.101.15 +185.220.101.13 +185.220.101.12 +185.220.101.16 +185.220.101.10 +185.220.101.9 +185.220.101.41 +185.220.101.33 +185.220.101.42 +185.220.101.39 +185.220.101.36 +185.220.101.38 +185.220.101.40 +185.220.101.32 +185.220.101.34 +185.220.101.37 +185.220.101.35 +46.167.244.6 +185.220.101.45 +185.220.101.48 +185.220.101.44 +185.220.101.51 +185.220.101.50 +185.220.101.49 +185.220.101.52 +185.220.101.47 +185.220.101.46 +185.220.101.43 +81.17.18.61 +54.36.108.162 +185.220.101.61 +185.220.101.60 +185.220.101.55 +185.220.101.53 +185.220.101.54 +185.220.101.57 +185.220.101.63 +185.220.101.62 +185.220.101.56 +185.220.101.59 +185.220.101.58 +81.17.18.60 +107.189.29.16 +107.189.28.84 +107.189.13.94 +107.189.28.241 +89.236.112.100 +51.75.161.78 +51.38.127.41 +146.59.18.159 +151.115.60.113 +93.115.84.143 +185.82.126.31 +198.98.59.49 +185.14.97.147 +23.129.64.250 +81.17.18.59 +209.141.41.103 +107.189.13.172 +107.189.2.91 +199.195.253.119 +37.123.163.58 +23.129.64.145 +5.255.97.176 +176.58.89.182 +185.112.144.68 +193.32.127.153 +193.32.127.152 +193.32.127.156 +193.32.127.155 +185.113.128.30 +193.32.127.157 +193.32.127.158 +91.221.57.179 +209.141.51.30 +104.244.78.160 +104.244.72.7 +198.98.48.231 +45.61.187.222 +104.244.75.225 +199.195.249.16 +185.100.86.74 +51.159.70.42 +205.185.124.231 +205.185.114.229 +104.244.73.8 +107.189.14.119 +205.185.116.157 +178.17.174.162 +5.2.75.253 +185.165.168.229 +5.2.70.223 +5.2.70.192 +5.2.70.198 +210.114.1.172 +107.189.12.135 +128.31.0.13 +185.107.195.109 +51.15.250.93 +107.189.7.88 +185.100.87.136 +5.2.73.66 +23.184.48.9 +107.189.1.90 +185.38.175.132 +54.37.16.241 +104.244.76.167 +185.129.61.6 +185.129.61.5 +185.129.61.2 +185.129.61.3 +185.129.61.1 +185.129.61.4 +185.220.102.6 +185.220.102.7 +185.220.102.8 +93.95.228.205 +107.189.4.253 +185.100.85.61 +107.189.10.120 +122.117.91.144 +212.192.246.95 +194.135.33.152 +5.2.79.187 +5.2.79.184 +198.144.121.93 +185.191.124.143 +37.228.129.5 +54.36.101.21 +45.9.150.112 +107.189.3.60 +212.193.30.142 +83.97.20.206 +212.193.30.143 +23.129.64.213 +173.237.206.68 +23.129.64.210 +23.129.64.212 +23.129.64.211 +104.244.78.213 +107.189.1.178 +93.95.228.129 +195.254.135.76 +185.100.85.132 +199.195.248.29 +5.255.96.245 +204.85.191.7 +193.32.127.227 +107.189.3.244 +185.243.218.50 +152.67.229.162 +5.79.109.48 +107.189.12.47 +193.218.118.231 +45.61.185.54 +107.189.12.97 +104.244.75.74 +83.97.20.189 +185.10.68.22 +193.32.126.151 +107.189.14.27 +152.70.59.26 +185.100.86.182 +51.195.45.190 +193.110.95.34 +23.129.64.216 +23.129.64.215 +23.129.64.219 +23.129.64.217 +185.130.45.170 +23.129.64.218 +23.129.64.214 +5.2.72.113 +5.2.79.179 +5.2.72.110 +5.2.72.101 +198.98.61.102 +41.215.242.42 +178.17.171.150 +31.13.195.124 +185.107.70.56 +5.2.77.64 +85.93.218.204 +62.102.148.68 +62.102.148.69 +198.46.166.157 +185.220.101.17 +185.220.101.18 +144.172.118.74 +45.61.185.88 +5.2.77.74 +68.99.156.190 +23.120.182.121 +5.255.97.170 +185.165.171.175 +41.77.137.114 +107.189.14.77 +198.98.54.184 +107.189.10.150 +104.244.74.121 +104.244.76.173 +199.195.248.80 +107.189.5.206 +104.244.78.183 +198.98.56.248 +104.244.75.88 +107.189.6.61 +107.189.3.110 +198.98.62.74 +198.98.60.97 +107.189.8.201 +185.220.103.113 +185.220.103.116 +185.220.103.115 +185.220.103.114 +185.220.103.120 +185.220.103.117 +185.220.103.118 +185.220.103.119 +91.90.120.138 +91.90.120.131 +86.107.104.249 +86.107.104.232 +156.146.50.153 +156.146.50.130 +156.146.34.78 +185.112.147.12 +185.31.175.191 +185.31.175.188 +185.31.175.196 +51.15.76.60 +220.135.161.136 +142.4.205.238 +45.13.104.179 +31.13.195.94 +185.51.76.187 +107.189.13.251 +160.119.249.240 +5.188.108.126 +107.189.12.169 +51.15.244.188 +107.189.12.7 +87.120.8.57 +209.127.17.242 +23.236.146.162 +23.154.177.2 +23.154.177.6 +23.154.177.3 +23.154.177.5 +23.154.177.7 +23.154.177.4 +49.36.228.202 +219.100.37.243 +5.2.72.124 +5.2.72.73 +5.2.72.168 +5.2.73.169 +5.2.73.229 +92.35.79.252 +92.35.70.172 +219.100.36.177 +198.98.57.230 +5.2.75.218 +5.8.95.201 +38.34.184.213 +204.27.60.147 +85.208.110.228 +154.94.7.88 +154.92.22.125 +107.189.1.175 +81.17.18.58 +199.195.253.156 +45.61.186.251 +45.61.186.103 +209.141.36.206 +209.141.44.158 +107.189.14.76 +104.244.72.136 +198.98.62.6 +198.98.56.60 +107.189.10.137 +45.61.184.34 +198.98.49.20 +185.220.101.146 +185.220.101.178 +185.220.101.143 +185.220.101.150 +185.220.101.149 +185.220.101.148 +185.220.101.142 +185.220.101.138 +185.220.101.151 +185.220.101.139 +185.220.101.156 +185.220.101.141 +185.220.101.134 +185.220.101.152 +185.220.101.147 +185.220.101.177 +185.220.101.144 +185.220.101.136 +185.220.101.158 +185.220.101.137 +185.220.101.175 +185.220.101.157 +185.220.101.133 +185.220.101.159 +185.220.101.135 +185.220.101.155 +185.220.101.145 +185.220.101.140 +185.220.101.166 +185.220.101.171 +185.220.101.160 +185.220.101.168 +185.220.101.170 +185.220.101.172 +185.220.101.161 +185.220.101.167 +185.220.101.173 +185.220.101.162 +185.220.101.169 +185.220.101.163 +185.220.101.153 +185.220.101.165 +185.220.101.164 +185.220.101.174 +185.220.101.176 +185.220.101.184 +185.220.101.187 +185.220.101.188 +185.220.101.128 +185.220.101.181 +185.220.101.154 +185.220.101.191 +185.220.101.183 +185.220.101.186 +185.220.101.180 +185.220.101.132 +185.220.101.179 +185.220.101.182 +185.220.101.185 +185.220.101.190 +185.220.101.189 +185.220.101.129 +151.80.148.159 +209.141.41.127 +5.2.79.111 +86.52.209.68 +178.170.37.11 +104.244.74.23 +209.141.37.94 +107.189.29.103 +205.185.119.35 +192.81.223.177 +5.2.72.75 +194.60.87.46 +185.117.215.9 +135.125.188.22 +89.212.183.135 +93.103.244.79 +185.220.101.131 +185.220.101.130 +37.120.183.100 +209.141.51.187 +37.120.183.97 +209.141.38.146 +209.141.39.187 +209.141.39.99 +37.120.183.91 +209.141.38.209 +205.185.122.149 +158.69.63.54 +185.165.169.200 +104.149.136.246 +172.106.16.74 +54.39.209.228 +209.141.59.243 +205.185.116.159 +37.120.183.99 +205.185.125.147 +209.141.38.232 +37.120.183.98 +209.141.43.51 +209.141.39.49 +37.120.183.101 +209.141.41.62 +209.141.38.46 +104.244.77.139 +51.15.180.36 +209.141.58.146 +46.173.218.146 +104.244.72.129 +209.141.53.99 +209.141.36.177 +46.161.27.142 +107.189.31.26 +107.189.3.246 +107.189.30.111 +89.34.27.203 +5.180.107.20 +149.28.93.88 +45.136.5.245 +107.189.14.55 +103.214.5.13 +85.254.72.56 +104.149.133.54 +172.106.17.218 +158.101.219.32 +185.17.121.254 +185.17.121.250 +185.17.121.251 +185.100.87.174 +194.32.107.51 +194.85.248.174 +95.214.54.97 +156.146.63.138 +156.146.63.16 +191.101.217.16 +156.146.63.137 +156.146.63.21 +176.125.230.28 +185.157.162.201 +5.2.70.140 +5.255.102.127 +213.203.177.219 +213.203.177.217 +5.255.100.243 +185.181.60.16 +194.32.107.72 +194.32.107.59 +194.32.107.55 +194.32.107.56 +194.32.107.71 +194.32.107.58 +194.32.107.69 +185.181.60.99 +185.243.218.60 +194.32.107.57 +194.32.107.54 +185.243.218.40 +194.32.107.68 +194.32.107.70 +83.97.20.151 +198.98.49.184 +185.29.10.251 +149.129.250.26 +149.129.254.15 +47.90.252.161 +74.208.87.158 +205.185.115.207 +205.185.113.35 +209.141.45.168 +141.95.159.52 +206.188.197.120 +82.165.183.88 +185.157.80.70 +142.44.133.80 +20.123.18.209 +52.138.168.233 +209.141.44.112 +23.183.81.25 +23.183.82.222 +209.141.56.243 +23.183.83.71 +45.61.188.145 +45.61.185.65 +45.61.185.98 +45.61.184.103 +45.61.187.34 +23.183.82.153 +45.61.186.15 +185.142.236.193 +185.247.226.89 +45.61.188.168 +37.228.129.109 +195.144.21.228 +185.165.171.46 +45.61.185.19 +185.142.236.236 +91.234.19.55 +198.98.62.150 +95.111.255.193 +82.165.223.202 +45.61.186.171 +194.32.107.187 +71.19.150.73 +45.61.186.233 +45.61.186.7 +45.61.184.114 +45.61.188.230 +45.61.184.247 +45.61.186.61 +45.61.186.21 +209.141.48.150 +45.61.185.169 +185.10.68.168 +209.141.54.234 +209.141.55.199 +107.189.31.223 +209.141.55.38 +138.68.155.147 +104.244.72.247 +107.189.11.228 +89.44.197.136 +31.42.176.162 +104.192.3.118 +205.185.124.66 +185.82.217.178 +185.220.101.19 +185.220.101.24 +185.220.101.30 +185.220.101.25 +185.220.101.27 +185.220.101.22 +185.220.101.26 +185.220.101.28 +179.43.187.138 +185.220.101.21 +185.220.101.20 +185.220.101.29 +199.19.224.239 +185.220.101.31 +107.189.29.105 +107.189.29.107 +185.220.101.23 +147.135.62.203 +107.189.31.112 +107.189.12.227 +54.146.233.218 +107.189.13.100 +104.244.76.180 +104.244.75.199 +104.244.77.102 +107.189.13.238 +34.126.213.76 +107.189.14.98 +185.220.101.0 +24.151.1.50 +45.151.167.12 +45.151.167.13 +45.79.58.157 +185.217.1.6 +173.82.68.78 +94.186.197.21 +212.47.229.4 +107.174.138.172 +193.32.126.161 +89.238.178.75 +181.174.164.37 +65.21.80.142 +65.21.80.138 +135.181.122.185 +89.44.197.33 +185.100.87.133 +51.15.43.205 +65.21.80.140 +65.21.80.137 +5.230.72.176 +206.166.251.86 +45.61.136.89 +195.90.200.211 +51.81.147.81 +185.232.71.81 +195.123.247.209 +92.205.29.217 +96.22.31.6 +193.46.254.26 +31.207.47.47 +51.195.166.171 +195.123.246.144 +23.128.248.11 +198.98.59.65 +45.61.188.164 +199.195.253.162 +23.128.248.13 +198.98.56.81 +205.185.113.72 +45.61.185.168 +23.128.248.12 +209.141.45.227 +209.141.46.47 +91.219.236.176 +104.244.79.203 +104.244.75.155 +107.189.1.187 +107.189.29.249 +107.189.13.219 +107.189.8.46 +185.163.204.160 +185.163.204.111 +104.244.73.66 +107.189.10.131 +104.244.74.112 +185.163.204.197 +185.163.204.125 +91.219.237.18 +107.189.3.89 +107.189.6.173 +185.163.204.237 +107.189.31.141 +104.244.73.158 +107.189.1.211 +185.163.204.128 +107.189.12.87 +107.189.13.43 +107.189.30.72 +104.244.77.167 +107.189.11.96 +107.189.8.126 +107.189.12.120 +104.244.76.82 +107.189.14.46 +107.189.2.236 +91.219.237.229 +107.189.12.105 +107.189.30.88 +107.189.13.230 +107.189.14.123 +107.189.14.96 +107.189.14.163 +107.189.14.180 +107.189.14.78 +107.189.28.197 +45.61.185.74 +107.189.4.201 +107.189.1.219 +107.189.10.68 +107.189.4.135 +107.189.5.13 +104.244.76.190 +104.244.76.102 +107.189.8.233 +107.189.11.250 +91.219.238.96 +107.189.12.70 +185.163.204.136 +107.189.11.120 +107.189.29.252 +107.189.13.113 +107.189.3.83 +107.189.28.214 +213.159.244.99 +107.189.6.50 +107.189.5.39 +104.244.75.60 +104.244.75.6 +104.244.73.55 +107.189.14.140 +107.189.31.16 +107.189.8.135 +91.219.236.200 +107.189.14.10 +104.244.79.192 +107.189.1.203 +107.189.6.37 +101.127.180.196 +45.61.186.225 +188.68.62.150 +188.68.62.139 +94.45.137.158 +178.158.233.93 +188.68.62.149 +84.249.59.60 +65.108.154.115 +51.159.67.223 +185.113.140.90 +144.217.86.109 +198.98.59.195 +82.165.111.147 +24.214.252.110 +179.43.175.65 +83.149.110.185 +23.184.48.209 +194.195.242.65 +146.59.45.142 +45.61.187.26 +5.255.97.211 +84.140.163.31 +37.221.66.128 +103.73.64.111 +209.141.45.215 +185.17.123.84 +185.143.220.236 +185.17.123.82 +194.147.84.41 +185.17.123.85 +45.95.11.159 +185.157.160.115 +45.141.56.79 +213.232.235.228 +93.95.231.13 +163.172.60.213 +83.97.20.80 +199.195.248.20 +192.53.162.179 +45.61.187.94 +107.189.30.70 +45.61.139.90 +45.154.168.39 +152.70.161.130 +94.140.114.193 +117.53.155.129 +185.36.81.95 +52.26.52.123 +78.24.219.51 +37.120.182.1 +188.68.62.252 +188.68.62.244 +23.254.142.207 +79.141.167.2 +185.41.69.47 +150.95.214.190 +18.190.114.245 +203.206.117.28 +93.95.230.253 +89.58.19.2 +194.233.166.189 +185.191.124.150 +185.191.124.151 +147.135.62.201 +103.214.5.127 +152.70.208.182 +172.107.241.110 +93.95.231.58 +5.255.97.237 +70.34.203.203 +51.15.67.157 +185.170.114.243 +104.244.75.164 +89.221.219.185 +104.244.76.233 +51.195.166.177 +140.238.156.114 +185.209.196.164 +146.59.10.127 +147.182.213.236 +34.131.223.10 +34.124.209.100 +202.61.205.29 +93.95.231.27 +194.32.107.159 +5.45.100.222 +107.189.1.34 +194.32.107.161 +150.230.29.26 +198.98.60.54 +152.89.107.127 +5.255.100.26 +150.230.26.151 +172.245.190.118 +72.14.189.179 +194.233.160.145 +139.177.199.216 +109.74.203.74 +159.223.56.232 +31.222.238.75 +86.127.133.22 +188.27.79.140 +5.12.198.40 +146.59.10.130 +135.125.147.170 +89.137.155.17 +51.81.33.224 +207.188.139.168 +185.186.142.34 +188.130.139.178 +109.248.201.48 +194.32.107.171 +27.32.12.118 +164.90.168.77 +142.44.156.144 +106.68.165.195 +193.119.46.71 +104.219.236.100 +185.193.125.42 +5.255.98.156 +45.77.4.154 +87.229.6.65 +192.144.39.121 +45.61.188.32 +104.168.44.51 +79.112.133.210 +79.112.158.237 +79.112.143.23 +108.61.229.72 +185.247.226.69 +202.61.224.72 +54.38.185.176 +27.33.157.178 +58.104.185.68 +23.128.248.17 +23.128.248.16 +23.128.248.15 +23.128.248.14 +107.189.13.42 +198.98.60.43 +23.128.248.18 +185.191.124.152 +185.191.124.153 +167.172.43.61 +2.84.8.172 +198.251.88.26 +217.133.35.146 +194.32.107.157 +82.118.18.244 +185.146.232.20 +124.156.9.65 +34.131.111.117 +51.15.7.157 +185.105.116.219 +107.189.14.3 +144.172.118.37 +40.71.125.29 +138.124.183.65 +80.92.205.188 +213.66.116.248 +23.175.32.11 +209.127.78.218 +23.184.48.238 +51.158.147.221 +212.192.216.105 +71.19.148.87 +185.243.218.46 +185.243.218.41 +67.249.107.195 +162.219.176.3 +184.75.223.195 +184.75.221.171 +93.95.230.245 +31.13.195.141 +37.48.117.204 +45.9.148.215 +138.197.162.69 +185.112.144.158 +45.61.173.71 +45.61.173.73 +23.236.146.166 +78.60.180.159 +46.226.105.168 +37.187.49.191 +198.144.120.177 +198.144.120.234 +209.141.50.247 +209.141.55.96 +185.130.47.82 +23.154.177.19 +23.154.177.21 +23.154.177.18 +23.154.177.20 +89.58.17.76 +188.68.58.0 +37.221.211.54 +185.193.127.45 +31.220.2.100 +161.97.116.228 +185.225.68.13 +31.42.186.114 +62.182.84.30 +31.42.186.113 +62.182.84.155 +199.195.250.229 +199.195.251.151 +198.98.49.221 +45.61.187.111 +69.61.38.236 +193.119.39.173 +110.175.240.206 +103.234.220.205 +198.98.51.65 +199.195.251.68 +104.219.236.119 +193.218.118.55 +31.42.184.136 +195.2.74.173 +164.92.250.62 +172.107.94.154 +185.150.119.132 +193.218.118.158 +81.16.33.42 +72.11.137.182 +46.38.247.22 +185.243.216.93 +185.243.216.92 +185.243.216.17 +185.243.216.91 diff --git a/torips.py b/torips.py new file mode 100644 index 0000000..de60259 --- /dev/null +++ b/torips.py @@ -0,0 +1,78 @@ +import os +import datetime +import psycopg2 +import pdb + +def insert_tor_ip(tor_ip): + + insert_sql = 'INSERT INTO torexit_ips(created_at, ip) VALUES(%s,%s) ON CONFLICT DO NOTHING' + + conn = None + + try: + + conn = psycopg2.connect(database = spamcheck_db, user = spamcheck_db_user, password = "", host = "/var/run/postgresql", port = "5432") + + cur = conn.cursor() + + cur.execute(insert_sql, (now, tor_ip)) + + conn.commit() + + print(f'Tor IP {tor_ip} saved to database') + + cur.close() + + except (Exception, psycopg2.DatabaseError) as error: + + print(error) + + finally: + + if conn is not None: + + conn.close() + +def db_config(): + + # Load db configuration from config file + config_filepath = "config/db_config.txt" + spamcheck_db = get_parameter("spamcheck_db", config_filepath) + spamcheck_db_user = get_parameter("spamcheck_db_user", config_filepath) + + return (spamcheck_db, spamcheck_db_user) + +def get_parameter( parameter, file_path ): + # Check if secrets file exists + if not os.path.isfile(file_path): + print("File %s not found, exiting."%file_path) + sys.exit(0) + + # Find parameter in file + with open( file_path ) as f: + for line in f: + if line.startswith( parameter ): + return line.replace(parameter + ":", "").strip() + + # Cannot find parameter, exit + print(file_path + " Missing parameter %s "%parameter) + sys.exit(0) + +if __name__ == '__main__': + + spamcheck_db, spamcheck_db_user = db_config() + + now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") + + filepath = 'torbulkexitlist' + with open(filepath) as fp: + line = fp.readline() + cnt = 1 + while line: + #print("Line {}: {}".format(cnt, line.strip())) + line = fp.readline().rstrip('\n') + if line != '': + insert_tor_ip(line) + cnt += 1 + +