访问StopBadware数据源的PythonAPI实现
pysbw的Python项目详细描述
python 3的实现 StopBadware<;https://www.stopBadware.org/>;私有api<;https://stopbadware.atlassian.net/wiki/display/apidocs/stopbadware+api+documentation+home>;。 在其当前形式中,它只实现从特定时间戳、IP地址和基于搜索的事件下载 在时间戳上。
如何使用
import pysbw import time api = pysbw.API('~/.stopbadware.key') # Retrieve event reports for past 24 hours using UNIX style timestamp json_response = api.retrieve(int(time.time()) - 24 * 3600) # Retrieve event report with report UID json_response = api.retrieve("564f2c78e4b0a131f050f844") # Retrieve event reports for past 24 hours using search functionality end = int(time.time()) json_response = self.api.search_between(end - 24 * 3600, end)
安装
pip3 install pysbw --pre
密钥文件示例
[sbw] apikey=<String of private key> publickey=<String of public key>
实例化
api = pysbw.API('~/.virustotal.key') # The default way of using the api = pysbw.API('', private_api_key=<PRIVATE API KEY>, public_api_key=<PUBLIC API KEY>) # Providing other parameters api = pysbw.API( ... , max_retires=<N: Number>) # If specified the API will only retry <N> times to get the response api = pysbw.API( ... , rate_limit={"requests": 40, "seconds": 300}) # The rate limits for the number of queries to the API
API
使用方法*retrieve()*获取报告。这种方法是第一次 参数可以是:
- 从那以后检索报表的UTC格式的Unix时间戳 时间戳
- 用点表示法的IP地址,如“8.8.8.8”,以检索所有 有关IP地址的报告
- 事件报告uid,它是一个24位十六进制数。
retrieve()将尝试自动检测您提供的内容。如果你 要显式,可以将thing\u类型参数与 值:
- IP
- 时间戳
- uid
这些值作为常量提供,您可以在 “api_constans”类,可以按如下方式导入
from pysbw import API_Constansts
使用方法*search_between()*搜索两个之间的事件 时间戳值。
参考文献
SBW API文档<;https://stopbadware.atlassian.net/wiki/display/apidocs/stopbadware+api+documentation+home>;。