Last active
May 21, 2021 19:08
-
-
Save sbassett29/8bb366d507b636de4258c161d96137b0 to your computer and use it in GitHub Desktop.
Some python to validate SFS file md5 digests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
""" Validate SFS download files and md5 sigs en masse | |
Author: sbassett29 | |
License: CC0 | |
""" | |
import hashlib | |
import re | |
import requests | |
sfs_base_url = 'https://www.stopforumspam.com' | |
sfs_download_url = ''.join([sfs_base_url, '/downloads']) | |
href_pat = 'href="(\/downloads\/listed_ip_(30|90|180).+\.gz)"' | |
resp = requests.get(sfs_download_url) | |
for (url_part, extra) in re.findall(href_pat, resp.text): | |
file_url = ''.join([sfs_base_url, url_part]) | |
file_url_md5 = ''.join([file_url, '.md5']) | |
resp_file_url = requests.get(file_url).content | |
resp_file_url_md5 = requests.get(file_url_md5).text | |
print('TESTING: ', file_url) | |
py_md5 = hashlib.md5(resp_file_url).hexdigest() | |
if (py_md5 == resp_file_url_md5): | |
print('...md5s match!...') | |
else: | |
print('...md5s DO NOT match!...') | |
print('[ ', py_md5, ' | ', resp_file_url_md5, ' ]') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment