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"
}

相关文章
|
21天前
|
JSON 监控 API
掌握使用 requests 库发送各种 HTTP 请求和处理 API 响应
本课程全面讲解了使用 Python 的 requests 库进行 API 请求与响应处理,内容涵盖环境搭建、GET 与 POST 请求、参数传递、错误处理、请求头设置及实战项目开发。通过实例教学,学员可掌握基础到高级技巧,并完成天气查询应用等实际项目,适合初学者快速上手网络编程与 API 调用。
305 130
|
2月前
|
XML JSON API
识别这些API接口定义(http,https,api,RPC,webservice,Restful api ,OpenAPI)
本内容介绍了API相关的术语分类,包括传输协议(HTTP/HTTPS)、接口风格(RESTful、WebService、RPC)及开放程度(API、OpenAPI),帮助理解各类API的特点与应用场景。
|
9月前
|
缓存 监控 负载均衡
提升HTTP动态代理IP性能的最佳实践
在现代网络环境中,HTTP动态代理IP的优化配置至关重要。通过选择合适的代理类型(正向/反向代理)、配置缓存、使用负载均衡、加强安全配置(SSL/TLS加密、身份验证)、管理日志、性能监控、限制带宽、定期更新软件和优化用户体验(减少延迟、内容压缩),可以显著提升网络性能、安全性及用户满意度。根据具体需求灵活调整配置,实现最佳效果。
339 64
提升HTTP动态代理IP性能的最佳实践
|
3月前
|
SQL 缓存 监控
SqlRest让SQL秒变Http API,还支持20+数据库(含国产数据库)
杭州奥零数据科技有限公司成立于2023年,专注于数据中台业务,维护开源项目AllData并提供商业版解决方案。AllData提供数据集成、存储、开发、治理及BI展示等一站式服务,支持AI大模型应用,助力企业高效利用数据价值。
|
4月前
|
JSON 编解码 API
Go语言网络编程:使用 net/http 构建 RESTful API
本章介绍如何使用 Go 语言的 `net/http` 标准库构建 RESTful API。内容涵盖 RESTful API 的基本概念及规范,包括 GET、POST、PUT 和 DELETE 方法的实现。通过定义用户数据结构和模拟数据库,逐步实现获取用户列表、创建用户、更新用户、删除用户的 HTTP 路由处理函数。同时提供辅助函数用于路径参数解析,并展示如何设置路由器启动服务。最后通过 curl 或 Postman 测试接口功能。章节总结了路由分发、JSON 编解码、方法区分、并发安全管理和路径参数解析等关键点,为更复杂需求推荐第三方框架如 Gin、Echo 和 Chi。
|
5月前
|
数据采集
Haskell编程中,利用HTTP爬虫实现IP抓取
以上就是利用Haskell编写IP抓取爬虫的详细步骤。希望这篇文章的演示对于理解在Haskell这种函数式编程语言中如何实现网络爬虫有所帮助,而其中的网络访问、标签解析和列表处理等技术在许多其他的问题中都有广泛的应用。
93 26
|
5月前
|
数据采集 监控 安全
HTTP代理和IP代理的不同点及代理IP能带来的好处分析
总的来说,无论是HTTP代理还是IP代理,选择哪一种主要还是要看你的需求和使用场景,同时也要为可能的风险做好准备。
126 9
|
7月前
|
负载均衡 监控 安全
优化HTTP代理IP安全稳定性的关键要点
随着科技发展,越来越多企业依赖HTTP代理IP。为确保其安全稳定,建议采取以下措施:选择可靠服务商、使用HTTPS加密、定期更换IP、监控可用性、设置访问控制、使用负载均衡、配置防火墙、定期更新维护及用户教育。这些方法能有效提升代理IP的安全性和稳定性。
287 59
|
9月前
|
编解码 安全 网络安全
指纹浏览器中HTTP代理IP的重要性及使用原因
随着数字化发展,网络安全和隐私保护成为核心需求,指纹浏览器应运而生。它通过客户端信息唯一标识用户身份。搭配HTTP代理IP可增强安全性,具体表现为:1. 保护用户地址;2. 提高信息安全;3. 防止指纹检测;4. 增强网络安全。HTTP代理以其稳定性、安全性,在网络营销等领域发挥重要作用,二者结合为用户提供更强的隐私和安全保护。
286 34
|
8月前
|
数据采集 搜索推荐 API
短效HTTP代理IP的优点表现在哪些方面?
短效HTTP代理IP凭借其独特优势,在数字化时代备受青睐。它能满足多种业务场景,如广告推广、数据采集等,支持多个API参数,提供高效稳定的个性化定制服务。短效代理IP用量大、更换频繁,确保正常访问行为,提升业务执行效率。选择高质量的HTTP代理服务商,能保证更好的稳定性和请求速度,满足用户的核心需求。
137 4

热门文章

最新文章