From d0135c248d9c91e6978e96aa2ea2e3c888f3079a Mon Sep 17 00:00:00 2001 From: Terrtia Date: Wed, 1 Aug 2018 15:26:29 +0200 Subject: [PATCH] add iban country statistic --- bin/BankAccount.py | 11 +++++++++++ doc/api/create_lu_graph.py | 8 ++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/bin/BankAccount.py b/bin/BankAccount.py index 58fa3e64..42baf535 100755 --- a/bin/BankAccount.py +++ b/bin/BankAccount.py @@ -11,6 +11,8 @@ It apply IBAN regexes on paste content and warn if above a threshold. import redis import time +import redis +import datetime import re import string from itertools import chain @@ -54,11 +56,13 @@ def check_all_iban(l_iban, paste, filename): iban = ''.join(e for e in iban if e.isalnum()) #iban = iban.upper() res = iban_regex_verify.findall(iban) + date = datetime.datetime.now().strftime("%Y%m") if res: print('checking '+iban) if is_valid_iban(iban): print('------') nb_valid_iban = nb_valid_iban + 1 + server_statistics.hincrby('iban_by_tld:'+date, iban[0:2], 1) if(nb_valid_iban > 0): to_print = 'Iban;{};{};{};'.format(paste.p_source, paste.p_date, paste.p_name) @@ -79,6 +83,13 @@ if __name__ == "__main__": p = Process(config_section) max_execution_time = p.config.getint("BankAccount", "max_execution_time") + # ARDB # + server_statistics = redis.StrictRedis( + host=p.config.get("ARDB_Statistics", "host"), + port=p.config.getint("ARDB_Statistics", "port"), + db=p.config.getint("ARDB_Statistics", "db"), + decode_responses=True) + publisher.info("BankAccount started") message = p.get_from_set() diff --git a/doc/api/create_lu_graph.py b/doc/api/create_lu_graph.py index 1c9440ef..c2a66769 100755 --- a/doc/api/create_lu_graph.py +++ b/doc/api/create_lu_graph.py @@ -135,8 +135,9 @@ if __name__ == '__main__': 1: credential_pie, 2: mail_pie 3: sqlinjection_pie, - 4: domain_pie,''', - choices=[0, 1, 2, 3, 4], action='store') + 4: domain_pie, + 5: iban_pie,''', + choices=[0, 1, 2, 3, 4, 5], action='store') parser.add_argument('country', type=str, default="de", help='''The country code, de:default''', @@ -170,6 +171,7 @@ if __name__ == '__main__': create_pie_chart(args.country, 'mail_by_tld:', date, "AIL: mail leak by tld", path, 'AIL_mail_by_tld.png') create_pie_chart(args.country, 'SQLInjection_by_tld:', date, "AIL: SQLInjection by tld", path, 'AIL_SQLInjection_by_tld.png') create_pie_chart(args.country.upper(), 'domain_by_tld:', date, "AIL: Domain by tld", path, 'AIL_domain_by_tld.png') + create_pie_chart(args.country.upper(), 'iban_by_tld:', date, "AIL: Iban by tld", path, 'AIL_iban_by_tld.png') elif args.type == 1: create_pie_chart(args.country, 'credential_by_tld:', date, "AIL: Credential leak by tld", path, 'AIL_credential_by_tld.png') elif args.type == 2: @@ -178,3 +180,5 @@ if __name__ == '__main__': create_pie_chart(args.country, 'SQLInjection_by_tld:', date, "AIL: sqlInjection by tld", path, 'AIL_sqlInjectionl_by_tld.png') elif args.type == 4: create_pie_chart(args.country.upper(), 'domain_by_tld:', date, "AIL: Domain by tld", path, 'AIL_domain_by_tld.png') + elif args.type == 5: + create_pie_chart(args.country.upper(), 'iban_by_tld:', date, "AIL: Iban by tld", path, 'AIL_iban_by_tld.png')