ARTICLE DETAIL

资讯详情

深耕网站建设、视觉设计与SEO优化的一线实战洞察。

routersploit 实战:Ubiquiti 路由器 SSH 默认凭据检测模块 ssh_default_creds 全解析

routersploit 实战:Ubiquiti 路由器 SSH 默认凭据检测模块 ssh_default_creds 全解析 routersploit 实战Ubiquiti 路由器 SSH 默认凭据检测模块 ssh_default_creds 全解析【免费下载链接】routersploitExploitation Framework for Embedded Devices项目地址: https://gitcode.com/gh_mirrors/ro/routersploit本指南聚焦 routersploit 框架中的creds/routers/ubiquiti/ssh_default_creds模块——一个针对 Ubiquiti优倍快路由器 SSH 服务执行默认凭据字典攻击的专用模块。文章将从模块定位、参数体系、交互式操作、底层实现到测试验证逐层展开读完即可在授权环境下独立完成对 Ubiquiti 路由器 SSH 默认口令的检测并理解 routersploit 凭据类模块的通用架构。模块定位面向 Ubiquiti 路由器的 SSH 默认口令攻击ssh_default_creds模块的官方描述为对 Ubiquiti 路由器 SSH 服务执行默认凭据字典攻击dictionary attack一旦命中有效凭据立即以表格形式展示给用户见 ssh_default_creds.md。从源码结构看该模块采用专用子类 通用基类的设计routersploit/modules/creds/routers/ubiquiti/ssh_default_creds.py中的Exploit类直接继承自通用模块routersploit/modules/creds/generic/ssh_default.py的Exploit只通过__info__元数据和一组默认参数来定制厂商行为class Exploit(SSHDefault): __info__ { name: Ubiquiti Router Default SSH Creds, description: Module performs dictionary attack against Ubiquiti Router SSH service. If valid credentials are found, they are displayed to the user., authors: (Marcin Bury marcin[at]threat9.com,), devices: (Ubiquiti Router,), } target OptIP(, Target IPv4, IPv6 address or file with ip:port (file://)) port OptPort(22, Target SSH port) threads OptInteger(1, Number of threads) defaults OptWordlist(admin:admin,root:ubnt,ubnt:ubnt, User:Pass or file with default credentials (file://))同一目录下还存在 ftp_default_creds.py继承通用 FTP 模块与telnet_default_creds.py三者构成 Ubiquiti 路由器的多协议默认凭据检测组合。SSH 变体默认针对端口 22内置三组业界广为流传的 Ubiquiti 默认口令组合。核心参数解析字段类型、默认值与取值范围模块可配置参数全部继承自基类通过show options查看。各参数的类型约束由 option.py 中的 Option 子类实现下面逐项说明。参数类型默认值说明targetOptIP空目标 IPv4/IPv6 地址或file://开头的多目标文件路径portOptPort22目标 SSH 端口合法范围 165535threadsOptInteger1并发线程数defaultsOptWordlistadmin:admin,root:ubnt,ubnt:ubnt以逗号分隔的User:Pass列表或file://词表文件stop_on_successOptBooltrue首次认证成功后是否立即停止verbosityOptBooltrue是否逐条打印认证尝试日志参数类型的行为细节OptIP__set__通过is_ipv4/is_ipv6校验非法地址会抛出OptionValidationError拒绝接受非 IP 格式的目标。OptPort强制int(value)转换并要求0 value 65535越界或无法转换均报错见 option.py 中OptPort.__set__。OptWordlist__get__在读取时完成解析——若值以file://开头则打开对应文件、逐行strip()后返回行列表否则按逗号切分为列表。__set__会校验file://指向的文件必须真实存在否则报File ... does not exist.。OptBool仅接受字符串true/false赋值显示值会规范化为小写。默认凭据词表defaults的默认值为admin:admin,root:ubnt,ubnt:ubnt测试文件 test_ssh_default_creds.py 明确断言了该词表assert exploit.defaults [admin:admin, root:ubnt, ubnt:ubnt]值得注意的是Ubiquiti 官方固件历史上广泛使用ubnt:ubnt作为默认管理凭据root:ubnt则常见于部分型号的底层账户因此这三组组合是检测该品牌设备 SSH 弱口令的高性价比起点。交互式实战从启动到命中凭据的完整操作模块的完整操作流程记录在 ssh_default_creds.md 中共五步启动框架./rsf.py加载模块use creds/routers/ubiquiti/ssh_default_creds设置目标set target [TargetIP]执行攻击run若命中有效凭据结果将展示给用户完整运行场景示例以下为该文档提供的真实场景输出目标为192.168.1.1SSH 端口 22rsf use creds/routers/ubiquiti/ssh_default_creds rsf (Ubiquiti Router Default SSH Creds) set target 192.168.1.1 [] target 192.168.1.1 rsf (Ubiquiti Router Default SSH Creds) run [*] Running module... [*] Target exposes SSH service [*] Starting default credentials attack against SSH service [*] thread-0 thread is starting... [-] SSH Authentication Failed - Username: admin Password: 12345 [-] SSH Authentication Failed - Username: admin Password: 123456 [-] SSH Authentication Failed - Username: Admin Password: 12345 [-] SSH Authentication Failed - Username: Admin Password: 123456 [] SSH Authentication Successful - Username: admin Password: admin [*] thread-0 thread is terminated. [*] Elapsed time: 2.3932292461395264 seconds [] Credentials found! Target Port Service Username Password ------ ---- ------- -------- -------- 192.168.1.1 22 ssh admin admin输出语义说明[-]前缀表示认证失败SSH Authentication Failed[]表示认证成功日志中的12345/123456/Admin等条目说明defaults已被用户自定义扩充示例演示了run前通过set defaults扩展词表的场景。命中后框架以对齐表格输出Target / Port / Service / Username / Password五列结果并打印Elapsed time统计耗时。自定义词表与批量目标扩展词表set defaults admin:admin,root:ubnt,ubnt:ubnt,admin:password或set defaults file:///path/to/creds.txt每行一个User:Pass。批量目标target支持file://协议文件每行一个ip:port。该能力由exploit.py中的multi装饰器实现解析时按partition(:)拆分带端口则覆盖模块默认端口不带则回退到port选项值逐行执行攻击见 exploit.py。底层实现原理攻击链路与并发机制攻击主流程run()方法初始化空凭据列表后调用attack()攻击链路如下见 generic/ssh_default.py服务探测check()先通过ssh_client.test_connect()验证目标是否暴露 SSH 服务。test_connect()见 ssh_client.py以随机 12 位密码尝试连接若收到paramiko.AuthenticationException说明 SSH 服务存在且已进入认证阶段返回True并打印Target exposes SSH service否则打印Target does not expose SSH并终止攻击。词表迭代LockedIterator包装defaults列表通过threading.Lock保证多线程下每组凭据只被消费一次。线程调度run_threads(threads, target_function, data)创建指定数量线程每个线程命名thread-0、thread-1……由threading.Event控制停止信号结束后打印Elapsed time见 exploit.py。凭据尝试target_function内对每条User:Pass调用ssh_client.login(username, password)成功后若stop_on_success为真则清除 Event 令其余线程退出并把(target, port, ssh, username, password)追加到凭据列表。结果汇总若列表非空打印Credentials found!并输出表格否则打印Credentials not found。SSH 客户端实现细节SSHCli.login()见 ssh_client.py基于 paramiko 实现timeoutSSH_TIMEOUT8 秒、banner_timeoutSSH_TIMEOUT避免无响应目标长时间阻塞look_for_keysFalse、allow_agentFalse禁用本机私钥与 ssh-agent确保仅使用字典密码认证set_missing_host_key_policy(paramiko.AutoAddPolicy())自动接受未知主机密钥成功返回TrueAuthenticationException则打印失败日志并关闭连接。供其他模块复用的静默检查接口基类还提供mute修饰的check_default()抑制所有 stdout 输出执行完整攻击命中则返回凭据列表否则返回None。该接口供扫描器如scanners/autopwn.py内部调用用于在不打扰用户的情况下批量确认默认凭据。测试验证模块行为的自动化保障tests/creds/routers/ubiquiti/test_ssh_default_creds.py针对该模块断言了关键行为exploit Exploit() assert exploit.target assert exploit.port 22 assert exploit.threads 1 assert exploit.defaults [admin:admin, root:ubnt, ubnt:ubnt] assert exploit.stop_on_success is True assert exploit.verbosity is True exploit.target generic_target.host exploit.port generic_target.port assert exploit.check() is False assert exploit.check_default() is None assert exploit.run() is None测试通过generic_targetfixture 指向测试专用 SSH 服务器验证了默认参数值端口 22、单线程、内置词表、命中即停、详细日志以及目标不可达/无 SSH 服务时check()、check_default()、run()均安全返回的容错路径——即在未暴露 SSH 的目标上模块不会抛异常只会静默结束。使用边界与注意事项授权前提默认凭据检测属于安全评估行为仅应在拥有明确授权的自有设备或测试靶场上执行routersploit 定位为嵌入式设备渗透测试框架见 README.md滥用造成的后果由使用者自行承担。版本差异不同 Ubiquiti 固件版本的默认口令策略不同ubnt:ubnt等在较新固件上可能已强制修改未命中不代表设备安全仅代表默认口令集失效。适用协议族如需同时检测 FTP端口 21与 Telnet可切换到同目录下的 ftp_default_creds.py 与telnet_default_creds.py对应模块其内置词表与 SSH 版本一致。【免费下载链接】routersploitExploitation Framework for Embedded Devices项目地址: https://gitcode.com/gh_mirrors/ro/routersploit创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
返回列表