1 min read

Simple Way to Compare Lists of IP Addresses in Python

The “lazy” in me tried to make this vulnerability analysis the other day easier on my poor spreadsheet-weary eyes.

Objective: Compare 2 Lists of IP addresses using Python

Here’s a simple way to compare lists of IP addresses in python

You might for example want to compare a baseline inventory list to a routine Nessus scan to ensure all machines are logged in the inventory

Github: https://github.com/ethanolivertroy/compare-lists

The Code

How to Use

Create your 2 text files with the IP Addresses in a list

- One IP address per line

- Store files in ‘input’ directory

Edit the file paths to the IP Address List Files
ips1 = "/Users/your_user/Github/sub_folder/compare-lists/input/file1.txt"
ips2 = "/Users/your_user/Github/sub_folder/compare-lists/input/file2.txt"

Note: The ip addresses used in this repo were created with https://www.ipvoid.com/random-ip/

Run the code
python3 compare-lists.py
Sample Output