Mythologyli / zju-connect

ZJU RVPN 客户端的 Go 语言实现
GNU Affero General Public License v3.0
313 stars 21 forks source link

[Enhancement] 支持输入登录验证码 #8

Closed Mythologyli closed 1 year ago

Mythologyli commented 1 year ago

论坛有用户反映无法正常登录,登录时返回提示 The characters are incorrect or has expired!。很可能需要输入验证码。

该用户之前频繁错误密码登录被判定为 IP 暴力登录,可能已触发风控。

curl https://rvpn.zju.edu.cn/por/login_auth.csp?apiversion=1 发现存在 <RndImg>0</RndImg> <!-- image check --> 字段。需要输入验证码的用户此段应该为验证码图片链接。

目前主要问题是没有合适账户进行测试。

Mythologyli commented 1 year ago

尝试暴力登录后此段变为 <RndImg>1</RndImg> <!-- image check -->

完整内容为:

<?xml version="1.0" encoding="utf-8"?>
<Auth>
<StartAuth>1</StartAuth> <!-- return next auth type -->
<TwfID>9f2f762dbf555580</TwfID> <!-- twfid from server -->
<RndImg>1</RndImg> <!-- image check -->
<Anonymous>0</Anonymous> <!-- anonymous login allowed or not -->
<Deny_normal_user>0</Deny_normal_user> <!-- normal user login allowed or not -->
<Autoinstall>1</Autoinstall> <!-- auto install components enabled or not -->
<Softkey>0</Softkey> <!-- soft key enable or not -->
<enablesavepwd>1</enablesavepwd> <!-- save password enable or not -->
<enableautologin>1</enableautologin> <!-- auto login enable or not -->
<enableautoRelogin>1</enableautoRelogin> <!-- auto relogin enable or not -->
<enablethirdpartycert>0</enablethirdpartycert>
<certcodetype>UCS-2</certcodetype>
<Is_enable_mult_client>0</Is_enable_mult_client>   <!--enable mulit client -->
<Mult_client_guid>NULL</Mult_client_guid>                  <!--mulit client guid-->
<Is_multclient_version>1</Is_multclient_version>  <!--is mulit client version-->

<Multiline></Multiline>
<DomainSSOEnable>0</DomainSSOEnable>
<DomainSSOUrl></DomainSSOUrl>
<DenyAccessWithoutCom>0</DenyAccessWithoutCom>
<DeviceType>ssl</DeviceType> <!-- ssl or vsp -->
<SSLCipherSuite>
        <EC>AES128-SHA</EC>
</SSLCipherSuite>
<RSA_ENCRYPT_KEY>A42BF0C3E207A340CB8CFD9907451E45CCCBBA25089CD148E9D180A5CAB870E36B5328D2255300EF23473158EEACE0EF8EB1F3950B8D9FC0EBB206E2CA6261AC0F7F861DA89EE90738AF76AE36B55BB5F59285BD6650FD1A0BE31F9A7F400DDE0BF0DC5D9611ED8D7837A83C1E2F37652D73A07865D410EDC4D3B583283E19736846F9927BBDD5814EF66F305CAA5273A77A97EE8AB2D9666EF92B6D8AE73C848F0D4BF2B613A96754D689B1781C747688BFDF7D545B99A0386FDFF065A325CDDEC48C86E2B2A99EA2EA3C99EDFA3737B873BDD90338763357F41E8583AAD2B96C2956243FCA81256DE2DAC0AF05822AF9B9197197B74328154813D490ACA481</RSA_ENCRYPT_KEY>
<RSA_ENCRYPT_EXP>65537</RSA_ENCRYPT_EXP>
<RESET_PASSWORD>1</RESET_PASSWORD>
<USB_KEY_DLL></USB_KEY_DLL>
<AllowBindSms>0</AllowBindSms>
<GMVERSION>1.1</GMVERSION>
<VPNVERSION>M7.6.6R1</VPNVERSION>
<SSLALGOR>1</SSLALGOR>
<EFlag>close</EFlag>
<Extra>5988ce377bb98347eb46d779d1459712</Extra>
Mythologyli commented 1 year ago

验证码图片 URL 为:https://rvpn.zju.edu.cn/por/rand_code.csp

将验证码添加到:

form := url.Values{
    "svpn_rand_code":    {""},
    "mitm":              {""},
    "svpn_req_randcode": {csrfCode},
    "svpn_name":         {username},
    "svpn_password":     {encryptedPasswordHex},
}

svpn_rand_code 中无效,仍提示 The characters are incorrect or has expired!,可能需要某种编码。

另外,需要验证码的情况下多次输错将暂时封锁账户,时长未知。虽说是封锁账户,但更换 IP 后可以正常登录。

Mythologyli commented 1 year ago

支持输入验证码似乎没用,刚才试了用网页登录,输入验证码还是会提示这个用户被暴力破解,ip被封锁

从 zju-connect 返回的结果看,有三个阶段:正常登录 -> 输错次数多导致需要验证码 -> 输错次数更多导致封禁

你是在第二个还是第三个阶段进行的测试?

Mythologyli commented 1 year ago

从 zju-connect 返回的结果看,有三个阶段:正常登录 -> 输错次数多导致需要验证码 -> 输错次数更多导致封禁

你是在第二个还是第三个阶段进行的测试?

似乎是第三个阶段了,那我再试试,顺手抓个包看看

如果 IP 被封,可以尝试手机热点或宽带重新拨号

Mythologyli commented 1 year ago

从抓包来看,验证码是明文 图片

通过输入验证码可以正常登录吗

Mythologyli commented 1 year ago

基于以下原因,决定不实现此功能:

  1. 通过研究找到了验证码的请求接口,但验证码有失效时间,不便于命令行登录
  2. 此功能有被滥用的可能

通过提交 e8416ec 在需要验证码时阻止登录,防止失败次数过多导致 IP 被封禁