在Cowrie(蜜罐)中,我们可以使用Python编写自定义的插件来实现阻止特定用户名条目密码存储的功能。以下是一个示例解决方法:
prevent_password_storage.py
。from cowrie.core.plugins import BasePlugin
from cowrie.core import ttylog
class PreventPasswordStoragePlugin(BasePlugin):
def start(self):
"""
此方法在插件启动时调用
"""
# 覆盖Cowrie的ttylog.Passwords类,阻止密码存储
ttylog.Passwords = PreventPasswordStoragePasswords
class PreventPasswordStoragePasswords(ttylog.Passwords):
def to_log(self, username, password):
"""
覆盖to_log方法,阻止特定用户名条目的密码存储
"""
# 在这里添加你想要阻止存储密码的用户名
blocked_usernames = ["admin", "root"]
if username not in blocked_usernames:
# 如果用户名不在阻止列表中,则继续存储密码
super().to_log(username, password)
将该文件放置在Cowrie蜜罐的插件目录中。默认情况下,插件目录位于/opt/cowrie/cowrie-git/twisted/plugins/
。
打开Cowrie的配置文件/opt/cowrie/cowrie-git/cowrie.cfg
,找到并修改以下行:
[honeypot]
...
services.ttylog.factory = cowrie.core.ttylog.CowrieTTYLogFactory
...
将其修改为:
[honeypot]
...
services.ttylog.factory = prevent_password_storage.PreventPasswordStoragePlugin
...
保存并关闭配置文件。
重新启动Cowrie蜜罐,使修改生效。
现在,特定用户名条目的密码将不会存储在Cowrie蜜罐中。