使用 Python 中的 taxii2-client 库连接到 Pulse Dive TAXII 2.1 服务器时出现问题

问题描述 投票:0回答:1

我正在尝试利用Python中的taxii2-client库连接到Pulse Dive TAXII 2.1服务器以进行威胁情报交换。然而,我在连接脉冲潜水 CTi 馈送时遇到了困难。有人可以提供有关如何使用 Taxii2-client 库正确实现此连接的指导吗?

当前设置:我正在 Python 环境中工作,并使用 Taxii2-client 库来实现 TAXII 客户端。 目标:我的目标是与 Pulse Dive TAXII 2.1 服务器建立连接以检索威胁情报数据。 问题:我面临以下问题:无法通过 api 密钥进行身份验证,库也没有提供包含身份验证标头的选项。它仅提供使用用户名和密码的身份验证方法

在下面的代码片段中

from taxii2client.v21 import Collection

collection = Collection("https://pulsedive.com/taxii2/api/collections?accept=application%2Ftaxii%2Bjson%3Bversion%3D2.1&pretty=1&key=bbcff74cf8442edcc8d52a4b61ec9a58912e0b018bbb473c0f08136595676723")

print(collection.get_objects())

提供的 url 包含 api 密钥,但我收到 401 错误(未经过身份验证) 有什么办法可以解决这个问题吗?

我尝试了脉冲潜水文档中提到的所有内容
链接 还探索了其他库,如 cabby,但它缺乏 Taxii2.1 支持

python security pulse advanced-threat-protection
1个回答
0
投票

所以我想出了如何连接到 Pulsedive Taxii 2.1 客户端,经过大量研究,尽管互联网上的资源很少,但从 Pulsedive Taxii 服务器提取数据的代码如下:

import sys
import json

 url = "https://pulsedive.com/taxii2"
 username = "taxii2"
 password = <your Api key> #Api key can be found out once you create an account and go to https://pulsedive.com/api/taxii

server = Server(url=url, user=username, password=password)

col = {}
num_collections = 0

for api_root in server.api_roots:
    # Count the number of collections
    num_collections += len(api_root.collections)
    
print('total number of collections',num_collections)
for collection in api_root.collections:
    col[collection.id] = collection
    response = collection.get_objects()
    print('response objects',response)

in the above code, we are pulling data from all the objects from all the collections
make sure the access rights of each collection are protected, as not every collection would have read-only access

© www.soinside.com 2019 - 2024. All rights reserved.