Example #1
0
def main() -> None:
    args = parse_args()
    filename_a = args.filename_a
    filename_b = args.filename_b
    set_a = hosts_tools.load_domains_from_list(filename_a)
    set_b = hosts_tools.load_domains_from_list(filename_b)

    list_a = HostList(filename_a, set_a)
    list_b = HostList(filename_b, set_b)

    print()
    print_list_size(list_a, list_b)
    print()
    print_list_difference(list_a, list_b)
Example #2
0
def main():
    args = parse_args()
    main_domains = hosts_tools.load_domains_from_list(args.list + '.txt')
    expanded_domains = hosts_tools.load_domains_from_list(args.list +
                                                          '-extended.txt')
    whitelist = hosts_tools.load_domains_from_whitelist(args.list +
                                                        '-whitelist.txt')
    main_domains_len_start = len(main_domains)
    expanded_domains_len_start = len(expanded_domains)
    with open('secrets.json') as f:
        data = json.load(f)
        api_key = data['virustotal_api_key']

    if args.update:
        found = crt_update(main_domains, args.verbose)
        expanded_domains.update(found)

    if args.virustotal:
        found = virustotal_update(main_domains, api_key, args.verbose)
        expanded_domains.update(found)

    main_domains.update(args.domains)
    found = crt_update(args.domains, args.verbose)
    expanded_domains.update(found)

    found = virustotal_update(args.domains, api_key, args.verbose)
    expanded_domains.update(found)

    expanded_domains = hosts_tools.filter_whitelist(expanded_domains,
                                                    whitelist)

    main_domains_len_end = len(main_domains)
    main_domains_len_diff = main_domains_len_end - main_domains_len_start
    expanded_domains_len_end = len(expanded_domains)
    expanded_domains_len_diff = expanded_domains_len_end - expanded_domains_len_start

    print('Base list: %s, expanded by: %s' %
          (main_domains_len_end, main_domains_len_diff))
    print('Extended List: %s, expanded by %s' %
          (expanded_domains_len_end, expanded_domains_len_diff))
    print('List Difference: %s' %
          (expanded_domains_len_end - main_domains_len_end))

    if not args.dryrun:
        hosts_tools.write_domain_list(args.list + '.txt', main_domains)
        hosts_tools.write_domain_list(args.list + '-extended.txt',
                                      expanded_domains)
Example #3
0
 def test_read_domains_list(self):
     domains = hosts_tools.load_domains_from_list(self.TEST_FILE_NAME)
     assert domains
     assert not self.TEST_DOMAINS.difference(domains)