GrayLog使用HTTP JSONPath方式调用微步在线云API识别威胁IP

简介: GrayLog使用HTTP JSONPath方式调用微步在线云API识别威胁IP

640.png

需求:


针对GrayLog的安全告警日志中的一些攻击IP,经常需要手工去微步在线情报社区去查恶意IP,为了提高效率,探索是否可以对IP进行自动化关联查询

640.png

思路:


1、GrayLog的LookupTable有HTTP JSONPATH这种方式,可以研究一下怎么使用2、翻阅微步在线API接口文档以及一些常用的IP地址库接口API 3、结合GrayLog强大的可定制化的功能,探索是否可以实现想要的效果


解决过程与步骤:


1、微步在线API接口文档

640.png



640.png

640.png


2、curl命令测试

curl -v -X GET 'https://api.threatbook.cn/v3/scene/ip_reputation?apikey=API_KEY&resource=37.59.54.205'

640.png

yum install jq -y
curl  -X GET 'https://api.threatbook.cn/v3/scene/ip_reputation?apikey=API_KEY&resource=37.59.54.205'| jq 

640.png


3、GrayLog配置Lookup Tables

https://api.threatbook.cn/v3/scene/ip_reputation?apikey=API_KEY&resource=${key}


640.png

640.png

640.png


{
  "data": {
    "37.59.54.205": {
      "severity": "low",
      "judgments": [
        "Scanner",
        "IDC"
      ],
      "tags_classes": [],
      "basic": {
        "carrier": "OVH SAS",
        "location": {
          "country": "France",
          "province": "Ile-de-France",
          "city": "Paris",
          "lng": "2.345101",
          "lat": "48.848483",
          "country_code": "FR"
        }
      },
      "asn": {
        "rank": 2,
        "info": "OVH, FR",
        "number": 16276
      },
      "scene": "",
      "confidence_level": "low",
      "is_malicious": true,
      "update_time": "2020-11-25 09:11:44"
    }
  },
  "response_code": 0,
  "verbose_msg": "OK"
}

640.png


640.png


IPv4 归属地,经纬度查询可以使用如下API接口

接口地址:https://api.ipplus360.com/ip/geo/v1/city/
请求方式:HTTPS GET/POST
请求示例:https://api.ipplus360.com/ip/geo/v1/city/?key=您申请的key&ip=您需要查询的ip&coordsys=WGS84


640.png


640.png

最后针对以上API接口配置的LookupTable如下


640.png


4、可以针对有公网IP字段调用以上接口并将查询结果保存为日志


例如对Linux服务器暴力破解攻击IP为例例如将Linux服务器接入到GrayLog后,使用正则表达式提取器提取出暴力破解IP的ssh_login_failed_ip字段

Failed password for .* from(.+?)\s.?

640.png


然后使用LookupTable提取器,将IP经纬度结果转成字段

ip_geo_latitude Lookup Table
Trying to extract data from ssh_login_failed_ip into ssh_login_failed_ip_geo_latitude
ip_geo_longitude Lookup Table
Trying to extract data from ssh_login_failed_ip into ssh_login_failed_ip_geo_longitude

当然也可以调用IP威胁情报的LookupTable

ip_geo_longitude Lookup Table
Trying to extract data from ssh_login_failed_ip into ssh_login_failed_ip_geo_longitude

640.png



5、Pipeline配置


使用Pipeline拼接出经纬度地址位置字段


rule "GeoIP lookup: ssh_login_failed_ip"
when
  has_field("ssh_login_failed_ip_geo_latitude") and has_field("ssh_login_failed_ip_geo_longitude")
then
    let ip_geo_latitude = to_string($message.ssh_login_failed_ip_geo_latitude);
    let ip_geo_longitude = to_string($message.ssh_login_failed_ip_geo_longitude);
    let ip_location_temp1 =  concat(to_string(ip_geo_latitude),",");
    let ip_location_temp2 =  concat(ip_location_temp1, ip_geo_longitude);
    set_field("ssh_login_failed_ip_location", ip_location_temp2);
end

image.png


使用Pipeline配置生成IP威胁情报查询结果字段ssh_login_failed_ip_threatcheck_result640.png

ip_threatcheck_result
rule "IPThreatChecklookup: ssh_login_failed_ip"
when
  has_field("ssh_login_failed_ip")
then
    let ip_threatcheck_result = lookup("ipthreatcheck",to_string($message.ssh_login_failed_ip));
    debug (ip_threatcheck_result) ;
    set_field("ssh_login_failed_ip_threatcheck_result", ip_threatcheck_result);
end

8ce251d30be6810c61ddef75d5ba9b85.png

5a1f3b5698aabe96fdfca939ee099b82.png


6、配置DashBoard显示攻击IP的经纬度


最终的效果

38546c67f3619fb13518323ef8036a5f.png

9de5133dc4f7294e2ba4a7d6e51a5035.png

c799491cac3393f257f4bfd3314b7aa9.png


如上图所示:Zombie关键字搜索可以判定该攻击IP为僵尸傀儡机

地理位置为荷兰


Tips:


附上提取器的相关语法配置文件

{
  "extractors": [
    {
      "title": "ip_geo_latitude",
      "extractor_type": "lookup_table",
      "converters": [],
      "order": 1,
      "cursor_strategy": "copy",
      "source_field": "ssh_login_failed_ip",
      "target_field": "ssh_login_failed_ip_geo_latitude",
      "extractor_config": {
        "lookup_table_name": "ipplus360_lat"
      },
      "condition_type": "none",
      "condition_value": ""
    },
    {
      "title": "ip_geo_longitude",
      "extractor_type": "lookup_table",
      "converters": [],
      "order": 2,
      "cursor_strategy": "copy",
      "source_field": "ssh_login_failed_ip",
      "target_field": "ssh_login_failed_ip_geo_longitude",
      "extractor_config": {
        "lookup_table_name": "ipplus360_lng"
      },
      "condition_type": "none",
      "condition_value": ""
    },
    {
      "title": "ip_threatcheck",
      "extractor_type": "lookup_table",
      "converters": [],
      "order": 3,
      "cursor_strategy": "copy",
      "source_field": "ssh_login_failed_ip",
      "target_field": "ssh_login_failed_ip_threatcheck",
      "extractor_config": {
        "lookup_table_name": "ipthreatcheck"
      },
      "condition_type": "none",
      "condition_value": ""
    },
    {
      "title": "json_extractor",
      "extractor_type": "json",
      "converters": [],
      "order": 4,
      "cursor_strategy": "copy",
      "source_field": "ssh_login_failed_ip_threatcheck_result",
      "target_field": "",
      "extractor_config": {
        "flatten": false,
        "list_separator": ", ",
        "kv_separator": "=",
        "key_prefix": "ip_threatcheck_result_",
        "key_separator": "_",
        "replace_key_whitespace": false,
        "key_whitespace_replacement": "_"
      },
      "condition_type": "none",
      "condition_value": ""
    },
    {
      "title": "ssh_login_failed_ip_extractor",
      "extractor_type": "regex",
      "converters": [],
      "order": 0,
      "cursor_strategy": "copy",
      "source_field": "message",
      "target_field": "ssh_login_failed_ip",
      "extractor_config": {
        "regex_value": "Failed password for .* from(.+?)\\s.?"
      },
      "condition_type": "string",
      "condition_value": "Failed password "
    }
  ],
  "version": "4.2.10"
}

相关文章
|
3天前
|
安全 网络协议 网络安全
干货|代理IP协议有何区别?深入了解 SOCKS5、HTTP 代理
HTTP和HTTPS是互联网主要的两大协议,HTTP是基础的简单请求-响应协议,常用于TCP上,但数据传输不安全。HTTPS是HTTP的安全版本,添加了SSL层进行加密和身份验证,提供更高的安全性,用于保护数据和验证网站真实性。HTTPS需CA证书,可能产生费用,并使用443端口而非HTTP的80端口。
|
3天前
|
网络协议 安全 数据安全/隐私保护
干货|代理IP协议有何区别?深入了解 SOCKS5、HTTP 代理
SOCKS5和HTTP是两种代理协议,前者是通用型,支持多种网络流量,提供身份验证、IPv6支持及UDP兼容性,更适合实时数据传输。HTTP代理专用于HTTP协议,适用于Web资源请求。SOCKS5在传输方式、功能、兼容性和安全性上更胜一筹,而HTTP代理则在处理HTTP请求时更专业。选择代理协议应根据需求和应用场景,考虑服务的稳定性和安全性。付费代理如kookeey全球代理,支持双协议,速度快且可扩展性强,是可靠的选择。
|
4天前
|
API
http代理ip请求并发数是什么?有什么用?
HTTP代理IP请求并发数指单个客户端对API或代理IP同时发起的请求数量,分为API链接请求并发和IP最大连接数。并发是瞬时同时请求,不同提供商限制不同。高并发请求的代理IP服务商能更好地应对程序压力。选择时应考虑这一因素。
|
14天前
|
数据采集 缓存 网络协议
静态代理IP是否支持HTTP和HTTPS?
静态代理IP支持HTTP、HTTPS、FTP、Socks5等协议,HTTP协议因其简单、灵活而常用,通常比HTTPS速度快,因无需加密处理。HTTP代理比SOCKS5代理通常更快,因为HTTP专注于HTTP请求,而SOCKS5处理多种网络流量。静态HTTP代理适合浏览器和爬虫,SOCKS5代理支持更多协议,如TCP、UDP。选择取决于应用场景和需求。
|
17天前
|
数据采集
如何选择高质量http/Socks5代理ip?
选择高质量HTTP、Socks5代理IP对爬虫和数据采集至关重要。了解代理IP类型,根据需求选择HTTP或Socks5代理。选择稳定、快速、分布广泛、数量充足且不易被封的代理IP供应商。关注代理IP速度、质量、稳定性、区域和使用频率。测试代理IP的连接速度、可用性、匿名性和使用频率。定期更换代理IP以保持效率和可靠性。
|
18天前
|
监控 安全 API
在使用HTTP代理IP的需要注意什么?
在使用HTTP代理IP时,关键点包括选择可靠服务商、确保匿名性、合法合规使用、遵循服务商规定、定期更换IP、检测IP可用性、处理封禁、设置超时时间、监控服务商通知、使用加密协议、定期评估服务质量和遵守法规。这些措施能保证代理的有效性、安全性和合规性。
|
18天前
|
JSON 测试技术 API
Python的Api自动化测试使用HTTP客户端库发送请求
【4月更文挑战第18天】在Python中进行HTTP请求和API自动化测试有多个库可选:1) `requests`是最流行的选择,支持多种请求方法和内置JSON解析;2) `http.client`是标准库的一部分,适合需要低级别控制的用户;3) `urllib`提供URL操作,适用于复杂请求;4) `httpx`拥有类似`requests`的API,提供现代特性和异步支持。根据具体需求选择,如多数情况`requests`已足够。
15 3
|
24天前
|
Ubuntu 应用服务中间件 Linux
nginx 配置代理ip访问https的域名配置
nginx 配置代理ip访问https的域名配置
|
24天前
|
网络协议 Linux Windows
TCP/IP、Http、Socket之间的区别
TCP/IP、Http、Socket之间的区别
|
24天前
|
数据采集 Python
数据采集时使用HTTP代理IP效率不高怎么办?
数据采集时使用HTTP代理IP效率不高怎么办?