Wednesday, December 24, 2014

Extract IP Address from File Reading Line by Line (Python)

I needed to extract an IP Address from each line inside of a file and kicked out the following script:

#!/usr/bin/python
# Extract IP Addresses

import re
file = open("temp.log")

for line in file:
        ip = re.findall( r'[0-9]+(?:\.[0-9]+){3}', line )
        print ip

No comments:

Post a Comment

Docker with Juiceshop - Focus on SQL Injection

In preparation for an ethical hacking class that I will be teaching, I wanted to work through a few of the Vulnhub or docker images to refr...