用于从 DroneBL 添加、查找和删除条目的库
项目描述
吡虫啉
安装
$ pip3 install dronebl
用法
下面的 RPC 密钥、IP 和 ID 是假的。
查找IP
>>> from dronebl import DroneBL
>>> d = DroneBL("04efa460cf244b6e88d9d2b8c31eb953")
>>> # by IP
>>> d.lookup("198.51.100.123")
[Lookup(198.51.100.123, id=3174874, type=19, datetime=2020-08-21T10:18:44, comment='abused VPN (connect verified)')]
>>> # by ID
>>> d.lookup(3174874)
[Lookup(198.51.100.123, id=3174874, type=19, datetime=2020-08-21T10:18:44, comment='abused VPN (connect verified)')]
>>> # non-existent
>>> d.lookup(3174875)
[]
添加 IP
>>> d.add("198.51.100.123", 19, "abused VPN (connect verified)")
(3174874, 'Added 198.51.100.123')
>>> d.add("198.51.100.123", 19, "abused VPN (connect verified)")
(None, 'You already reported 198.51.100.123 as type 19')
使用端口添加
>>> d.add("198.51.100.123", 19, "abused VPN (connect verified)", 1337)
(3174874, 'Added 198.51.100.123')
更新评论
>>> d.update(3174874, "abused VPN")
(True, 'Updated 3174874')
>>> d.update(3174875, "abused VPN")
(False, 'The id 3174875 does not exist')
删除 IP
>>> d.remove(3174874)
(True, 'Removed 3174874')
>>> d.remove(3174874)
(False, '3174874 already delisted')
批次
>>> b = d.batch()
>>> b.remove(3174872)
>>> b.update(3174873, "abused VPN")
>>> b.add("198.51.100.123", 19, "abused VPN (connect verified)")
>>> b.add("198.51.100.124", 13, "ssh bruteforce")
>>> r = d.commit(b)
>>> for res in r:
... print(res)
...
('remove', True, 'Removed 3174872')
('update', True, 'Updated 3174873')
('add', 3174874, 'Added 198.51.100.123')
('add', 3174875, 'Added 198.51.100.124')
>>> b = d.type_batch(19)
>>> b.add("198.51.100.125", "abused VPN (connect verified)")
>>> d.commit(b)
[('add', 3174876, 'Added 198.51.100.125')]
异步!
的异步版本上提供了相同的方法DroneBL,AsyncDroneBL
>>> from dronebl import AsyncDroneBL
>>> d = AsyncDroneBL("04efa460cf244b6e88d9d2b8c31eb953")
>>> await d.lookup("198.51.100.123")
Lookup(198.51.100.123, id=3174874, type=19, datetime=2020-08-21T10:18:44, comment='abused VPN (connect verified)')
接触
项目详情
下载文件
下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。
源分布
dronebl-0.4.8.tar.gz
(6.3 kB
查看哈希)
内置分布
dronebl-0.4.8-py3-none-any.whl
(8.4 kB
查看哈希)