一个用于在IP地址上证明intel并启用检测和响应的工具。
ip-inspector的Python项目详细描述
IP检查员
IP Inspector是一个命令行工具和库,用于证明IP地址上的intel,以便启用intel检测和响应。在
它的构建是模块化的,因此它可以为任何提供IP地址或计算机网络信息的API增加价值。但是,目前它只使用MaxMind提供的免费GeoLite2 databases,并且该工具/库可以方便地与MaxMind API接口使用。也就是说,我写这篇文章是为了给我们的intel,detect,and response程序增加价值。这个值是通过跟踪和响应IP地址来获得的,这些地址在我们的检测设备中以不同的方式显示在它们的元数据上。对于通过简单的黑名单和/或白名单实现的ip检查器,您可以手动或以编程方式维护对您的情况有价值的不同ip地址元数据字段,例如ASN、组织名称、国家/地区等
安装和设置
python3 -m pip install ip-inspector
MaxMind GeoLite2
命令行工具和MaxMind客户端将首先查找本地MaxMind GeoLite2数据库文件,然后在以下默认位置(debian)查找系统文件:
/usr/share/GeoIP/GeoLite2-ASN.mmdb
/usr/share/GeoIP/GeoLite2-City.mmdb
/usr/share/GeoIP/GeoLite2-Country.mmdb
您可以在此处注册免费许可证密钥:https://www.maxmind.com/en/geolite2/signup。然后可以使用MaxMindgeoipupdate命令来更新系统数据库。在
但是,如果要使用ip检查器下载和维护GeoLite2数据库,则需要提供许可证密钥。有几种方法可以提供该许可证密钥,具体取决于您希望如何使用ip检查器。在
在命令行上提供将保存许可证密钥以备将来使用:
^{pr2}$接下来,可以使用update命令下载最新的数据库文件。在
$ ip-inspector -u
如果要下载GeoLite2数据库的本地副本,则可以使用库完成相同的操作:
fromip_inspectorimportmaxmind# I'm pretending we have already loaded a config and PROXIES, for the sake of the example and to show# that update_databases accepts **args to pass to requests.proxies=PROXIESif'use_proxy'inconfigandconfig.getboolean('use_proxy')elseNonemaxmind.update_databases(license_key='your_license_key',proxies=proxies):
使用它
获得免费的MaxMindlicense key。在
像图书馆一样:
fromip_inspectorimportmaxmindfromip_inspectorimportInspector# If you just want the maxmind client:mmc=maxmind.Client(license_key='your_license_key')# The Inspector with blacklist/whitelist functionalitymmi=Inspector(maxmind.Client(license_key='your_license_key'))
命令行工具:
$ ip-inspector -h
usage: ip-inspector [-h] [-d] [-u] [-r] [-pp] [-i IP]
[-f {IP,ASN,ORG,Continent,Country,Region,City,Time Zone,Latitude,Longitude,Accuracy Radius}]
[-csv] [--from-stdin] [-lk LICENSE_KEY] [-c CONFIG_PATH]
[--customize]
{whitelist,blacklist} ...
Inspect IP address metadata for IDR purposes
positional arguments:
{whitelist,blacklist}
whitelist For interacting with the IP Network Organization
whitelist
blacklist For interacting with the IP Network Organization
blacklist.
optional arguments:
-h, --help show this help message and exit
-d, --debug Turn on debug logging.
-u, --update-databases
Update the MaxMind GeoLite2 Databases
-r, --raw-results return results in their raw json format
-pp, --pretty-print Pretty print the raw json results
-i IP, --ip IP A single IP address to inspect.
-f {IP,ASN,ORG,Continent,Country,Region,City,Time Zone,Latitude,Longitude,Accuracy Radius}, --field {IP,ASN,ORG,Continent,Country,Region,City,Time Zone,Latitude,Longitude,Accuracy Radius}
specific fields to return
-csv print fields as comma seperated with --from-stdin and
fields
--from-stdin Inspect each IP in a list of IP addresses passed to
STDIN
-lk LICENSE_KEY, --license-key LICENSE_KEY
MaxMind Liscense Key (saves to config for future use)
-c CONFIG_PATH, --config-path CONFIG_PATH
A JSON config to override the default configuration.
The path is saved for future use.
--customize Write a copy of the existing configuration to the
local config path for easily making configuration
overrideschanges, or updates. Edit the local config to
meet your needs.
不完整
我已经实现了我所需要的最低限度的东西来解决眼前的需要,但我建立了这个长期使用。我计划的一些功能还没有实现。如果有人读到这篇文章,你真是太酷了。在
- 项目
标签: