RDtoS5 2018 版逆向解决端口限制 4 位问题

RDtoS5

RDtoS5​工具全称 Remote Desktop to Socks5​,支持将 Windows​远程桌面通过 Socks5​代理进行访问。

最新版本需要付费,免费版限制 10 分钟会断一次连接。

2018 版本可以免费使用,但是端口限制了 4 位。

本文将对工具进行逆向分析,并修改端口限制。

  • 工具界面

IDA 逆向分析

打开 IDA​,将 exe​文件拖入分析

其中 WinMain​是入口函数,双击打开函数,按 F5​将汇编转换成伪代码

​​​​

程序启动后调用 sub_401F60​函数,从注册表读取配置信息,注册表路径为 HKEY_CURRENT_USERSoftware\Thegrideon Software\RDtoS5

接下来调用 DialogFunc​函数初始化界面

点击 Start​按钮时,会从控件中读取值,其中端口号读取的长度为 5

查看 GetDlgItemTextA​函数的描述,第三位为字符长度,包含结束字符,超出则截断,所以此处最多只能读取 4 个字符

1
2
3
4
5
6
7
8
9
//[in] cchMax
//Type: int
//The maximum length, in characters, of the string to be copied to the buffer pointed to by lpString. If the length of the string, including the null character, exceeds the limit, the string is truncated.
UINT GetDlgItemTextA(
  [in]  HWND  hDlg,
  [in]  int   nIDDlgItem,
  [out] LPSTR lpString,
  [in]  int   cchMax
);

修改端口长度

接下来我们将端口长度修改为 6

Tab​键切换到汇编模式,在 push 5​这一行右键,选择 Keypathch​ -> Patcher

push 5​修改为 push 6​,点击 Patch​,一共三个地方需要修改,同理将另外两个 push 5​修改为​push 6

修改完成后,F5​返回伪代码界面,可以看到 5 已经变成了 6

最后点击 Edit -> Patgch program -> Apply patches to input file...​,将修改保存到原始文件

运行修改后的 exe,发现可以将端口设置为 5 位了

到此已经完成端口的修改

注册表脚本

从刚才分析可以看到,这些参数是存放在注册表的,所以我们可以通过写入注册表参数初始化这些信息

创建一个 rdtos5.reg​文件,将下列的参数修改后执行,即可完成参数设置

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\SOFTWARE\Thegrideon Software\RDtoS5]
"cLocPort"="7777"
"cSockServ"="127.0.0.1"
"cSockPort"="10808"
"cSockName"=""
"cSockPass"=""
"cTargServ"="example.com"
"cTargPort"="48707"

0%