
A Python script that gathers all valid IP addresses from all text files from a directory, and checks them against Whois database, TOR relays and location
This script scans every file from a given folder recursively, extracts every IPv4 and IPv6 address, filters out the public IP addresses and then queries these IPs against TOR relays, WhoIs service and Location service. It outputs 4 files: a CSV file and a JSON file with all details of the IP addresses, a CSV file containing an index of every found IP address and a KML file with all the locations gathered.
Python 3.9.x
To install dependencies, run:
pip install -r requirements.txt
pip install pyinstaller
pyinstaller --onefile osips.py
python osips.py [-h] [-F INPUTFOLDER] [-f INPUTFILE] [-p INPUTFILESPATTERN] [-o OUTPUTFILESNAME] [-t {y,n,Y,N}] [-w {y,n,Y,N}] [-l {y,n,Y,N}] [-locationEndpoint LOCATIONENDPOINT]
python osips.py
python osips.py --checkTor Y --checkWhoIs Y --checkLocations Y --inputFolder testFolder/ --inputFilesPattern * --outputFilesName test
python osips.py -h
-h, --help
Show the help message and exit-F INPUTFOLDER, --inputFolder INPUTFOLDER
A folder containing files with IPs (log files, email files, text files etc). The IPs can be IPv4 and/or IPv6 and can be placed anywhere in the files. The script will parse every file in the folder and will scan for every IP-f INPUTFILE, --inputFile INPUTFILE
Use this option to scan only one file instead of a folder with files. The file can be any text file that contains IP addresses (log files, email files, text files etc.)-p INPUTFILESPATTERN, --inputFilesPattern INPUTFILESPATTERN
Enter the pattern to use for the files in the input folder. Example: * for all files, *.txt for text files.-o OUTPUTFILESNAME, --outputFilesName OUTPUTFILESNAME
The name for the output files, WITHOUT EXTENSION. 4 different files will be created with this name: a CSV file storing the IP details, an index file storing the IP indexes, a JSON file storing the details and a KML file storing the locations.-t {y,n,Y,N}, --checkTor {y,n,Y,N}
Specify if you want to check every public IP address against the TOR relays IP addresses-w {y,n,Y,N}, --checkWhoIs {y,n,Y,N}
Specify if you want to extract WhoIs information for every public IP address-l {y,n,Y,N}, --checkLocations {y,n,Y,N}
Specify if you want to geocode every public IP address and extract location info using -locationEndpoint LOCATIONENDPOINT
Default REST endpoint for location is "https://reallyfreegeoip.org/json/". You can specify a diffrent end point, includding placeholder. The result must be in JSON and must include the following fields: country_name, region_code, region_name, city, zip_code, time_zone, latitude, longitude, metro_code