alexandregz / twofactor_gauthenticator
此RoundCube插件将Google两步验证添加到登录过程(OTP)中
Requires
- php: >=5.3.0
This package is auto-updated.
Last update: 2024-09-19 10:43:06 UTC
README
此RoundCube插件将两步验证(OTP)添加到登录过程中。
它与所有TOTP应用程序兼容 RFC 6238
部分代码来自: Ricardo Signes Justin Buchanan Ricardo Iván Vieitez Parra
GoogleAuthenticator类 由Michael Kliewe编写(用于查看秘密)
qrcode.js 由ShimSangmin编写
还要感谢 Victor R. Rodriguez Dominguez 提供的一些想法和支持
安装
- 从github克隆:HOME_RC/plugins$ git clone https://github.com/alexandregz/twofactor_gauthenticator.git
(或使用composer HOME_RC$ composer require alexandregz/twofactor_gauthenticator:dev-master
注意:当composer询问插件激活时,回答N)
- 在HOME_RC/config/config.inc.php中激活插件:$config['plugins'] = array('twofactor_gauthenticator');
配置
转到设置任务,在“2步骤Google验证”菜单中,点击“设置所有字段(需要保存)”。
插件会自动为您创建密钥。
注意:插件必须基于32个有效字符([A-Z][2-7]),请参阅https://github.com/alexandregz/twofactor_gauthenticator/blob/master/PHPGangsta/GoogleAuthenticator.php#L18
来自#139
要将帐户添加到应用程序中,您可以使用二维码(简单方法)或输入密钥。检查第一个代码后点击“保存”。
此外,您还可以添加一次性的“恢复代码”以供使用(使用后将被删除)。恢复代码是可选的,因此可以留空。
注册用户
如果config值force_enrollment_users为true,则所有用户都需要使用两步方法登录。他们会收到关于此的警告消息,并且不能跳过而未保存配置
同一字段
如果config值2step_codes_on_login_form为true,则两步代码(和恢复)必须与密码值一起发送,附加到此处,从登录屏幕:“正常”代码仅跟在密码后面(passwordCODE),恢复代码在两个竖线之后(password||RECOVERYCODE)
实际上仅在samefield分支中
代码
代码有2*30秒的时钟容差,就像默认的Google应用程序一样(可能在未来的版本中可编辑)
许可协议
MIT,请参阅许可协议
注意
与RoundCube 0.9.5和Google应用程序进行了测试。还与Roundcube 1.0.4进行了测试。
请记住,同步时间对于TOTP至关重要:“为了使其工作,用户设备的时钟和服务器需要大致同步(服务器通常接受从客户端时间戳生成的时间戳差±1的一次性密码)”(来自http://en.wikipedia.org/wiki/Time-based_One-time_Password_Algorithm)
作者
Alexandre Espinosa Menor aemenor@gmail.com
问题
使用github处理开放问题,请不要给我发关于那个问题的邮件,谢谢——通常Gmail会将此类消息标记为垃圾邮件
测试
- Vagrant: https://github.com/alexandregz/vagrant-twofactor_gauthenticator
- Docker: https://hub.docker.com/r/alexandregz/twofactor_gauthenticator/
与Kolab一起使用
在public_html/assets目录中添加一个符号链接
查看解释#29(评论),由https://github.com/d7415提供
客户端实现
您可以使用各种OTP客户端——链接由https://github.com/helmo提供
日志
建议由simon@magrin.com提供
要记录错误代码,请将$_enable_logs变量更改为true。
日志存储在文件HOME_RC/logs/log_errors_2FA.txt中——必须创建目录
白名单
您可以在配置文件中定义白名单IP(请参阅config.inc.php.dist),以实现自动登录——插件不会要求您输入代码
卸载
要禁用插件,您可以使用两种方法
-
仅针对一个用户:从数据库恢复用户首选项为null(rouncubeDB.users.preferences)——用户插件选项存储在这里。
-
对所有用户:从config.inc.php中删除插件/删除插件本身
仅针对特定用户激活
-
使用config.inc.php文件(请参阅config.inc.php.dist示例文件)
-
修改数组users_allowed_2FA,包含您想要使用插件的用户。注意:您可以使用正则表达式
与1.3.x版本一起使用
使用1.3.9版本分支
$ git checkout 1.3.9-version
如果您下载了1.4.x RC版本(带有弹性皮肤),则通常使用master版本(感谢tborgans)
2022-04-02安全事件
由kototilt@haiiro.dev报告(感谢报告和PoC脚本)
我对脚本进行了小小的修改,不允许在不生成从渲染页面生成的参数会话的情况下保存配置,以强制用户输入先前2FA代码并浏览网站。
注意:我还检查了用户是否启用了2FA,因为只有第一个条件——检查会话——应用在激活2FA之前就把我踢了出来。
twofactor_gauthenticator_save()
在函数twofactor_gauthenticator_save()
中,我添加了以下代码
// save config function twofactor_gauthenticator_save() { $rcmail = rcmail::get_instance(); // 2022-04-03: Corrected security incidente reported by kototilt@haiiro.dev // "2FA in twofactor_gauthenticator can be bypassed allowing an attacker to disable 2FA or change the TOTP secret." // // Solution: if user don't have session created by any rendered page, we kick out $config_2FA = self::__get2FAconfig(); if(!$_SESSION['twofactor_gauthenticator_2FA_login'] && $config_2FA['activate']) { $this->__exitSession(); }
想法是从渲染页面创建会话变量,从__goingRoundcubeTask
函数(重定向到roundcube任务
)重定向
使用PoC python脚本进行测试
在安全漏洞的情况下之前
alex@vosjod:~/Desktop/report$ ./poc.py Password:xxxxxxxx 1. Fetching login page (https://:8888/roundcubemail-1.4.8) 2. Logging in POST https://:8888/roundcubemail-1.4.8/?_task=login 3. Disabling 2FA POST https://:8888/roundcubemail-1.4.8/?_task=settings&_action=plugin.twofactor_gauthenticator-save POST returned task "settings" 2FA disabled!
修改了代码并再次测试,不允许在不访问RC任务(带有2FA身份验证)的情况下停用/修改
alex@vosjod:~/Desktop/report$ ./poc.py Password:xxxxxxxxx 1. Fetching login page (https://:8888/roundcubemail-1.4.8) 2. Logging in POST https://:8888/roundcubemail-1.4.8/?_task=login 3. Disabling 2FA POST https://:8888/roundcubemail-1.4.8/?_task=settings&_action=plugin.twofactor_gauthenticator-save POST returned task "login" Expected "settings" task, something went wrong
docker-compose
您可以使用docker-compose
文件来修改和测试插件
- 将
mail.EXAMPLE.com
替换为您的IMAP和SMTP服务器。 docker-compose up
- 您可以使用
adminer
检查数据库并重置秘密,例如。