一个用于在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.

不完整

我已经实现了我所需要的最低限度的东西来解决眼前的需要,但我建立了这个长期使用。我计划的一些功能还没有实现。如果有人读到这篇文章,你真是太酷了。在

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何从tester类访问/更改ArrayList?   java如何在Android中以编程方式更改菜单标题   spring boot在Kafka Java中为同一主题创建多个消费者组   java JVM字节码表示法,注释语法。调用动力学   java活动在旋转后泄漏了窗口PopupWindow   java允许Nashorn运行用户代码   Java Joda Time实现一个日期范围迭代器   当字符串长度为奇数时使用递归打印字符串的java基本情况   java无法从JSONArray获取JSONObject   java有没有一种方法可以使用单个示例文件进行所有测试?   java My bufferedReader读取整个文件,而不仅仅是一行。为什么?   当已有用户输入时,java变量为null   java如何将正则表达式与阿拉伯语文本一起使用   java Selenium WebDriver“单击”和JavascriptExecutor单击之间有什么区别   java在运行代码时,排序方法会在第二个数组应该按升序或降序排序时打印相同的精确数组号   java如何在HashMap中添加多个具有相同键的相同类型的对象   java有人知道为什么菜单栏在使用系统gtk主题时会显示白色文本吗?   在tomcat中用java方法访问JavaScript文件