-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiplsch.py
27 lines (24 loc) · 979 Bytes
/
iplsch.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Import regular expressions.
import re
# Create an empty array object (LIST).
ipList = []
# File to use as baseline. e.g. List from Marius.
with open('base.txt', "r") as file1:
# Simple for each line in file
for line in file1:
# Sanitise line/string and push it to array.
ipList.append(line.strip())
# File to use query against baseline. e.g. List from UFW.
# https://github.com/poddmo/ufw-blocklist
with open('test.txt', "r") as file2:
# Simple for each line in file
for line in file2:
# Assign variable to regex filter of line/string (IP).
ipAddr = re.findall( r'[0-9]+(?:\.[0-9]+){3}', line )[0]
# Evaluate if the string (IP) exists within the array (LIST).
if ipAddr not in ipList:
# If the above condition is true,
# split the string (IP) off to a variable.
d = line.split()
# Finally, print out the result on the screen.
print('Missing:', d[0])