Advertisement
Guest User

Untitled

a guest
Apr 14th, 2022
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. import ast
  2.  
  3. with open("example.txt", "r") as f:
  4. data = f.read()
  5. new_list = ast.literal_eval(data)
  6.  
  7. ips=[]
  8. for item in new_list:
  9. ip=item[0]
  10. ips.append(ip)
  11.  
  12. counter={}
  13. for item in ips:
  14. try:
  15. counter[item]=counter[item] + 1
  16. except:
  17. counter[item]=1
  18. print("IP {} => {}".format(item,counter[item]))
  19.  
  20. print("The following IPs triggered the DDoS protection\n",counter)
  21.  
  22. for item in counter:
  23. x=counter[item]
  24. if x > 200:
  25. print("The IP {} has been banned ({} packets)".format(item,x))
  26. ### CURRENTLY NOT DOING ANYTHING. USE THE LIBRARY SYS TO EXECUTE YOUR OWN BAN-COMMAND/SCRIPT!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement