Quick Python Scripts for Security Professionals
Posted on May 10, 2025 • 1 minutes • 129 words
During a recent triage, I had to brush up on my Python skills to try to automate some tasks that I had to do. Here are a few helpful Python scripts could be helpful for security professionals. This page will continue to be updated as I often times use the same scripts to manipulate data in similiar ways.
This first script reads a file with IPs and gets the unique IPs and stores them into a set and prints them out. In the example below, the strip method is invoked twice, the first to remove spaces, and the second time to remove the [].
cleaned_ips = set()
with open("ips.txt", "r") as f:
for line in f:
ip = line.strip().strip("[]")
cleaned_ips.add(ip)
# Print distinct IPs
for ip in cleaned_ips:
print(ip)