Stix,Taxii,Python3,Cabby API把数据转换成一种格式我可以

2024-06-06 00:22:53 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用cabbyapi:https://github.com/EclecticIQ/cabby

希望通过taxii客户端获取stix信息。在

我的python代码从www.hailataxii.com网站在

数据在容器中。。我可以把它翻过来。。它看起来像xml,但是没有xml解析器读取或操作数据。我想把每一条记录放到字典里,然后把数据放到某种数据库里。。但在我找到从下载中获取数据的方法之前,我很茫然。很少有数据或例子。在

如有任何建议,将不胜感激。在

以下是我测试的基本代码:

import pprint

from cabby import create_client

HailATaxiiFeedList=[
    'guest.Abuse_ch',
    'guest.CyberCrime_Tracker',
    'guest.EmergingThreats_rules',
    'guest.Lehigh_edu',
    'guest.MalwareDomainList_Hostlist',
    'guest.blutmagie_de_torExits',
    'guest.dataForLast_7daysOnly',
    'guest.dshield_BlockList',
    'guest.phishtank_com'
]

client = create_client(
    'hailataxii.com',
    use_https=False,
    discovery_path='/taxii-discovery-service')

print (": Discover_Collections:")
services = client.discover_services()
for service in services:
    print('Service type= {s.type} , address= {s.address}' .format(s=service))

print (": Get_Collections:")
collections = client.get_collections(
    uri='http://hailataxii.com/taxii-data')

for collection_name in HailATaxiiFeedList:
    print ("Polling :", collection_name, ".. could take a while, please be patient..")
    file = open(("./iocs/"+ collection_name + ".xml"), "w")
    content_blocks = client.poll(collection_name=collection_name)

    count =1
    for block in content_blocks:
        taxii_message=block.content.decode('utf-8')
        file.write(taxii_message)
        count+=1
        if count > 20: # just getting the 20 top objects because the lists are huge
            break
    file.close()

输出看起来像xml,但是没有xml解析器会接触它。在

^{pr2}$

如有任何建议,将不胜感激。在


Tags: 数据nameincomclientforservicexml
1条回答
网友
1楼 · 发布于 2024-06-06 00:22:53

您所看到的XML是STIX。退房:https://www.eclecticiq.com/stix-taxii。然后点击STIX网站的链接,找到(右下角)“工具”部分。您应该找到库和解析工具,使其有用。在

或者,有商业平台可以做数据处理魔术。谷歌“威胁情报平台”。在

干杯, 约普

创始人 折衷

相关问题 更多 >