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

Test Authentication from Linux Console using python3 pexpect

Working with the IT420 lab, you will discover that we need to discover a vulnerable user account.  The following python3 script uses the pex...