First of all, I searched the Internet and stackoverflow for about 3 days and did not find anything I was looking for.
I do a weekly security audit where I return a CSV file with IP addresses and open ports. They look like this:
20160929.csv
10.4.0.23;22
10.12.7.8;23
10.18.3.192;23
20161006.csv
10.4.0.23;22
10.18.3.192;23
10.24.0.2;22
10.75.1.0;23
The difference is as follows:
10.12.7.8:23 is closed.
10.24.0.2:22 and 10.75.1.0:23 .
I want the script to print me:
[-] 10.12.7.8:23
[+] 10.24.0.2:22
[+] 10.75.1.0:23
How can I make a script as follows? I tried my difflib, but that is not what I need. I need to also write this later or send this output as mail, for which I already have a script.
Unix, Windows . diff .
:
old = set((line.strip() for line in open('1.txt', 'r+')))
new = open('2.txt', 'r+')
diff = open('diff.txt', 'w')
for line in new:
if line.strip() not in old:
diff.write(line)
new.close()
diff.close()
old = set((line.strip() for line in open('1.txt', 'r+')))
new = open('2.txt', 'r+')
diff = open('diff.txt', 'w')
for line in new:
if line.strip() not in old:
diff.write(line)
new.close()
diff.close()