Last active
April 3, 2022 16:59
-
-
Save hakluke/97d429b44af922f4f8f1ed2257ac9c9d to your computer and use it in GitHub Desktop.
Little Python script to dump IP addresses from a file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import sys, re | |
f = open(sys.argv[1],'r') | |
text = f.read() | |
ips = [] | |
regex = re.findall(r'\b(?:\d{1,3}\.){3}\d{1,3}\b',text) | |
if regex is not None: | |
for match in regex: | |
if match not in ips: | |
ips.append(match) | |
print(match) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment