This repository was archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
41 lines (40 loc) · 1.55 KB
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import csv
import requests
import json
def check(ip):
result = requests.get("https://api.abuseipdb.com/api/v2/check", headers = {"Accept": "application/json","Key": apikey}, params = {"ipAddress": ip}).json()
try:
if result["data"]["totalReports"] > 1:
print(f'{result["data"]["ipAddress"]}','=',f'[{result["data"]["countryCode"]}]','-',f'Times Reported: {result["data"]["totalReports"]}','-',f'Confidace: {result["data"]["abuseConfidenceScore"]}%','-',f'Last Report: {result["data"]["lastReportedAt"]}',f'(https://www.abuseipdb.com/check/{ip})')
else:
print(ip, "=",f'[{result["data"]["countryCode"]}]'," Ip is clear!")
except:
pass
try:
if result["errors"][0]["detail"] == "The ip address must be a valid IPv4 or IPv6 address (e.g. 8.8.8.8 or 2001:4860:4860::8888).":
print(ip,"=","Invalid IP!")
except:
pass
apikey = input("Please enter an API key\n")
if apikey == "":
print(f"API key invalid")
exit()
mode = input("Enable Bulk Check? (.csv file) [true,false]\n").lower()
if mode == "true":
print("Bulk Mode")
filepath = str(input("Please enter an filepath to .csv file\n"))
rows = []
with open(filepath, 'r') as file:
csvreader = csv.reader(file)
header = next(csvreader)
for row in csvreader:
rows.append(row)
ip = str(row[0])
check(ip)
else:
print("Single Mode")
ip = input("Enter an IP Adress\n")
print("Checking an IP...\n-------------\n")
check(ip)
exit()
#python3 run.py