다음은 다양한 스팸 데이터베이스에 IP 주소가 있는지 확인하는 Python 스크립트입니다. ipaddress
IP 주소를 검증하는 모듈 requests
HTTP 요청을 수행하는 모듈:
import requests
import ipaddress
def check_spam(ip_address):
# Validate the IP address
try:
ipaddress.ip_address(ip_address)
except ValueError:
print("Invalid IP address format")
return
# List of spam databases to check
spam_databases = [
"b.barracudacentral.org",
"bl.spamcop.net",
"dnsbl.sorbs.net",
"zen.spamhaus.org"
]
# Check each database for the IP address
for db in spam_databases:
query = ip_address + '.' + db
try:
response = requests.get("http://"+query)
if response.text.startswith("127.0.0"):
print(f"{ip_address} found in {db}")
else:
print(f"{ip_address} not found in {db}")
except requests.RequestException as e:
print(f"Error checking {ip_address} in {db}: {e}")
# Example usage
ip_to_check = "123.456.789.10" # Replace this with the IP address you want to check
check_spam(ip_to_check)
이 스크립트는 IP 주소를 입력으로 사용하고 해당 형식의 유효성을 검사한 다음 DNSBL(DNS 블랙리스트) 조회를 사용하여 여러 스팸 데이터베이스에 대해 IP 주소를 확인합니다. IP 주소가 데이터베이스 중 하나에서 발견되면 발견된 위치를 나타내는 메시지가 인쇄됩니다. 그렇지 않으면 특정 데이터베이스에서 IP 주소를 찾을 수 없다는 메시지를 인쇄합니다.
댓글 (0)
여기에는 아직 댓글이 없습니다. 첫 번째 댓글이 되실 수 있습니다!