mirror of
https://github.com/DoubleLabyrinth/navicat-keygen.git
synced 2019-12-02 05:10:56 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6b29f20c46 | ||
|
|
0586ceefb6 | ||
|
|
bf2fb47a3a | ||
|
|
e81e0f0813 | ||
|
|
793d1e583c | ||
|
|
acd61f1822 | ||
|
|
d14695a524 | ||
|
|
7f84cf3294 |
@@ -18,26 +18,29 @@ If you still meet a failure, you can submit a failure report and please fill in
|
||||
- [ ] Navicat Report Viewer
|
||||
- [ ] Other, please write here: ______
|
||||
|
||||
2. What is your Navicat language version? Check one of the following:
|
||||
2. What's your Navicat version number?
|
||||
Please write here: ______
|
||||
|
||||
3. What is your Navicat language version? Check one of the following:
|
||||
- [ ] English
|
||||
- [ ] Simplified Chinese
|
||||
- [ ] Traditional Chinese
|
||||
- [ ] Other, please write here: ______
|
||||
|
||||
3. What is your OS? Check one of the following:
|
||||
4. What is your OS? Check one of the following:
|
||||
- [ ] Windows
|
||||
- [ ] macOS
|
||||
- [ ] Linux
|
||||
|
||||
4. Can you post console output here? If don't have, leave it empty.
|
||||
5. Can you post console output here? If don't have, leave it empty.
|
||||
```
|
||||
Please post here
|
||||
```
|
||||
|
||||
5. If __Request Code__ or __Activation Code__ is shown, please post the content of `RegPrivateKey.pem` here:
|
||||
6. If __Request Code__ or __Activation Code__ is shown, please post the content of `RegPrivateKey.pem` here:
|
||||
```
|
||||
Please post here
|
||||
```
|
||||
|
||||
6. If you have other information to provide, please write here.
|
||||
7. If you have other information to provide, please write here.
|
||||
(If you don't have, leave it empty.)
|
||||
|
||||
@@ -18,26 +18,29 @@ assignees: ''
|
||||
- [ ] Navicat Report Viewer
|
||||
- [ ] 其他,请写在这里:______
|
||||
|
||||
2. 你的Navicat产品语言版本是什么?选择下面一个:
|
||||
2. 你的Navicat版本号是多少?
|
||||
请写在这里:______
|
||||
|
||||
3. 你的Navicat产品语言版本是什么?选择下面一个:
|
||||
- [ ] English
|
||||
- [ ] Simplified Chinese
|
||||
- [ ] Traditional Chinese
|
||||
- [ ] 其他,请写在这里:______
|
||||
|
||||
3. 你的操作系统是什么?选择下面一个:
|
||||
4. 你的操作系统是什么?选择下面一个:
|
||||
- [ ] Windows
|
||||
- [ ] macOS
|
||||
- [ ] Linux
|
||||
|
||||
4. 你可以把命令行输出贴出来吗?如果你没有,请留空:
|
||||
5. 你可以把命令行输出贴出来吗?如果你没有,请留空:
|
||||
```
|
||||
贴在这里
|
||||
```
|
||||
|
||||
5. 如果 __请求码__ 或者 __激活码__ 出现了,请把 `RegPrivateKey.pem` 的内容贴在这里:
|
||||
6. 如果 __请求码__ 或者 __激活码__ 出现了,请把 `RegPrivateKey.pem` 的内容贴在这里:
|
||||
```
|
||||
贴在这里
|
||||
```
|
||||
|
||||
6. 如果你有其他信息要提供的,请写在这里:
|
||||
7. 如果你有其他信息要提供的,请写在这里:
|
||||
(如果你没有,请留空。)
|
||||
|
||||
@@ -40,60 +40,80 @@ This repository will tell you how Navicat offline activation works.
|
||||
|
||||
Press Enter to continue or Ctrl + C to abort.
|
||||
|
||||
MESSAGE: [PatchSolution3] Keywords[0] has been found:
|
||||
MESSAGE: PatchSolution0 will be omitted.
|
||||
|
||||
MESSAGE: PatchSolution3: Keywords[0] has been found:
|
||||
Relative Machine Code Offset = +0x0000000001644a08
|
||||
Relative Machine Code RVA = +0x0000000001645608
|
||||
Patch Offset = +0x00000000023d56e4
|
||||
Patch Size = 3 byte(s)
|
||||
MESSAGE: [PatchSolution3] Keywords[1] has been found:
|
||||
Relative Machine Code Offset = +0x0000000001644a5f
|
||||
Relative Machine Code RVA = +0x000000000164565f
|
||||
Patch Offset = +0x0000000001644a63
|
||||
Patch Size = 2 byte(s)
|
||||
...
|
||||
...
|
||||
...
|
||||
MESSAGE: [PatchSolution3] Keywords[109] has been found:
|
||||
Relative Machine Code Offset = +0x0000000001651558
|
||||
Relative Machine Code RVA = +0x0000000001652158
|
||||
Patch Offset = +0x000000000165155c
|
||||
Patch Size = 2 byte(s)
|
||||
MESSAGE: [PatchSolution3] Keywords[110] has been found:
|
||||
MESSAGE: PatchSolution3: Keywords[110] has been found:
|
||||
Relative Machine Code Offset = +0x000000000165155e
|
||||
Relative Machine Code RVA = +0x000000000165215e
|
||||
Patch Offset = +0x0000000001651561
|
||||
Patch Size = 1 byte(s)
|
||||
|
||||
MESSAGE: PatchSolution2 will be omitted.
|
||||
|
||||
MESSAGE: PatchSolution1: Keywords[0] has been found: offset = +0x021f7390.
|
||||
MESSAGE: PatchSolution1: Keywords[1] has been found: offset = +0x0074bd39.
|
||||
MESSAGE: PatchSolution1: Keywords[2] has been found: offset = +0x021f70a0.
|
||||
MESSAGE: PatchSolution1: Keywords[3] has been found: offset = +0x0074bd1f.
|
||||
MESSAGE: PatchSolution1: Keywords[4] has been found: offset = +0x021f708c.
|
||||
|
||||
MESSAGE: Generating new RSA private key, it may take a long time.
|
||||
MESSAGE: New RSA private key has been saved to RegPrivateKey.pem.
|
||||
|
||||
Your RSA public key:
|
||||
-----BEGIN PUBLIC KEY-----
|
||||
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxnosIMaINNalTS93BgGF
|
||||
dcbodlk3X2PVuPl+HZuYLLfrGPfzgtfXKzM7RzEuJOX9ozs4lyiB298ImnS/fa4g
|
||||
xHKJBvdk11PgD3mSTU6+PwIR45ud5RcbsuwnjVUEpXkth+9tjaxiNNtaDH5af4+z
|
||||
/ExWeRLH/8lnNMhC5wndvPhw2gbrypAD1VvBPj0LG7Ktmt1Sqx25aBdikp/uEPvn
|
||||
eXQgOgH7H+L8id8RtKItI+ZSwojaDWu9ROpvVejlA7W4ceZlNVeGCSqIieL7MUpm
|
||||
DpRmLgBBoXrZgQTyG1Z9RjXD3+Q361z2RvfZZcsnMxfMA04NRscoqlG7eC2JW5JN
|
||||
swIDAQAB
|
||||
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsWnV5hQxlXvDA3Ad4k5N
|
||||
ZLz4cO+iGEPegSovIDcwTo097I+0pXYKPTVl+0iKC5JtJRObb4Xx9yK9gGwqkcxo
|
||||
o6WzKq0xY1jz7X6obxwlQCNse3Os1wr0rIY0UzP1dCpkW/5MwGbFxiB6PEVqkzmJ
|
||||
CmHBzZDRu/jAuL1nyoiGnUStqwENNYhyl4k7r8AiJkBZGMOCrj6v0JfgNna25Ce6
|
||||
QCFojlY4dkYQ5/7njQ3qpLwMeLEXEysMW3aUScSB68/vsHnB4C0fIkwfEPYZ/AC5
|
||||
AqbWHVbNmveB3rjV+tZZxXcLE8ArgKh1Gs+2VtnL09gwHm6WcpyPZ42G6tMDjWyw
|
||||
1wIDAQAB
|
||||
-----END PUBLIC KEY-----
|
||||
|
||||
******************************************
|
||||
* PatchSulution3 *
|
||||
******************************************
|
||||
@ +023d56e4: 4D 49 49 ---> 4D 49 49
|
||||
@ +01644a63: 42 49 ---> 42 49
|
||||
@ +01644a68: 6A ---> 6A
|
||||
@ +01644ace: 41 ---> 41
|
||||
@ +01644b28: 4E 42 67 6B ---> 4E 42 67 6B
|
||||
@ +01644b32: 71 ---> 71
|
||||
@ +023d56e8: 68 6B 69 47 39 77 ---> 68 6B 69 47 39 77
|
||||
...
|
||||
...
|
||||
...
|
||||
@ +023d58d0: 37 73 57 ---> 71 6C 47
|
||||
@ +023d58d4: 36 63 6A ---> 37 65 43
|
||||
@ +023d58d8: 78 6C 6A 75 75 51 61 ---> 32 4A 57 35 4A 4E 73
|
||||
@ +023d58d4: 36 63 6A ---> 47 36 74
|
||||
@ +023d58d8: 78 6C 6A 75 75 51 61 ---> 4D 44 6A 57 79 77 31
|
||||
@ +023d58e8: 77 49 44 41 ---> 77 49 44 41
|
||||
@ +0165155c: 51 41 ---> 51 41
|
||||
@ +01651561: 42 ---> 42
|
||||
|
||||
******************************************
|
||||
* PatchSulution1 *
|
||||
******************************************
|
||||
@ +0x021f7390
|
||||
Previous:
|
||||
+0x00000000021F7390 44 37 35 31 32 35 42 37 30 37 36 37 42 39 34 31 D75125B70767B941
|
||||
+0x00000000021F73A0 34 35 42 34 37 43 31 43 42 33 43 30 37 35 35 45 45B47C1CB3C0755E
|
||||
+0x00000000021F73B0 37 43 43 42 38 38 32 35 43 35 44 43 45 30 43 35 7CCB8825C5DCE0C5
|
||||
...
|
||||
...
|
||||
...
|
||||
|
||||
@ +0x021f708c
|
||||
Previous:
|
||||
+0x00000000021F7080 31 32 32 35 4f 45 29 2e 00 00 00 00 39 32 39 33 1225OE).....9293
|
||||
+0x00000000021F7090 33 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3...............
|
||||
After:
|
||||
+0x00000000021F7080 31 32 32 35 4f 45 29 2e 00 00 00 00 32 37 45 38 1225OE).....27E8
|
||||
+0x00000000021F7090 45 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 E...............
|
||||
|
||||
MESSAGE: Patch has been done successfully.
|
||||
```
|
||||
|
||||
@@ -129,31 +149,31 @@ This repository will tell you how Navicat offline activation works.
|
||||
|
||||
```
|
||||
Select Navicat product:
|
||||
1. DataModeler
|
||||
2. Premium
|
||||
3. MySQL
|
||||
4. PostgreSQL
|
||||
5. Oracle
|
||||
6. SQLServer
|
||||
7. SQLite
|
||||
8. MariaDB
|
||||
9. MongoDB
|
||||
10. ReportViewer
|
||||
0. DataModeler
|
||||
1. Premium
|
||||
2. MySQL
|
||||
3. PostgreSQL
|
||||
4. Oracle
|
||||
5. SQLServer
|
||||
6. SQLite
|
||||
7. MariaDB
|
||||
8. MongoDB
|
||||
9. ReportViewer
|
||||
|
||||
(Input index)> 1
|
||||
|
||||
Select product language:
|
||||
1. English
|
||||
2. Simplified Chinese
|
||||
3. Traditional Chinese
|
||||
4. Japanese
|
||||
5. Polish
|
||||
6. Spanish
|
||||
7. French
|
||||
8. German
|
||||
9. Korean
|
||||
10. Russian
|
||||
11. Portuguese
|
||||
0. English
|
||||
1. Simplified Chinese
|
||||
2. Traditional Chinese
|
||||
3. Japanese
|
||||
4. Polish
|
||||
5. Spanish
|
||||
6. French
|
||||
7. German
|
||||
8. Korean
|
||||
9. Russian
|
||||
10. Portuguese
|
||||
|
||||
(Input index)> 1
|
||||
|
||||
|
||||
+66
-46
@@ -38,60 +38,80 @@
|
||||
|
||||
Press Enter to continue or Ctrl + C to abort.
|
||||
|
||||
MESSAGE: [PatchSolution3] Keywords[0] has been found:
|
||||
MESSAGE: PatchSolution0 will be omitted.
|
||||
|
||||
MESSAGE: PatchSolution3: Keywords[0] has been found:
|
||||
Relative Machine Code Offset = +0x0000000001644a08
|
||||
Relative Machine Code RVA = +0x0000000001645608
|
||||
Patch Offset = +0x00000000023d56e4
|
||||
Patch Size = 3 byte(s)
|
||||
MESSAGE: [PatchSolution3] Keywords[1] has been found:
|
||||
Relative Machine Code Offset = +0x0000000001644a5f
|
||||
Relative Machine Code RVA = +0x000000000164565f
|
||||
Patch Offset = +0x0000000001644a63
|
||||
Patch Size = 2 byte(s)
|
||||
...
|
||||
...
|
||||
...
|
||||
MESSAGE: [PatchSolution3] Keywords[109] has been found:
|
||||
Relative Machine Code Offset = +0x0000000001651558
|
||||
Relative Machine Code RVA = +0x0000000001652158
|
||||
Patch Offset = +0x000000000165155c
|
||||
Patch Size = 2 byte(s)
|
||||
MESSAGE: [PatchSolution3] Keywords[110] has been found:
|
||||
MESSAGE: PatchSolution3: Keywords[110] has been found:
|
||||
Relative Machine Code Offset = +0x000000000165155e
|
||||
Relative Machine Code RVA = +0x000000000165215e
|
||||
Patch Offset = +0x0000000001651561
|
||||
Patch Size = 1 byte(s)
|
||||
|
||||
MESSAGE: PatchSolution2 will be omitted.
|
||||
|
||||
MESSAGE: PatchSolution1: Keywords[0] has been found: offset = +0x021f7390.
|
||||
MESSAGE: PatchSolution1: Keywords[1] has been found: offset = +0x0074bd39.
|
||||
MESSAGE: PatchSolution1: Keywords[2] has been found: offset = +0x021f70a0.
|
||||
MESSAGE: PatchSolution1: Keywords[3] has been found: offset = +0x0074bd1f.
|
||||
MESSAGE: PatchSolution1: Keywords[4] has been found: offset = +0x021f708c.
|
||||
|
||||
MESSAGE: Generating new RSA private key, it may take a long time.
|
||||
MESSAGE: New RSA private key has been saved to RegPrivateKey.pem.
|
||||
|
||||
Your RSA public key:
|
||||
-----BEGIN PUBLIC KEY-----
|
||||
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxnosIMaINNalTS93BgGF
|
||||
dcbodlk3X2PVuPl+HZuYLLfrGPfzgtfXKzM7RzEuJOX9ozs4lyiB298ImnS/fa4g
|
||||
xHKJBvdk11PgD3mSTU6+PwIR45ud5RcbsuwnjVUEpXkth+9tjaxiNNtaDH5af4+z
|
||||
/ExWeRLH/8lnNMhC5wndvPhw2gbrypAD1VvBPj0LG7Ktmt1Sqx25aBdikp/uEPvn
|
||||
eXQgOgH7H+L8id8RtKItI+ZSwojaDWu9ROpvVejlA7W4ceZlNVeGCSqIieL7MUpm
|
||||
DpRmLgBBoXrZgQTyG1Z9RjXD3+Q361z2RvfZZcsnMxfMA04NRscoqlG7eC2JW5JN
|
||||
swIDAQAB
|
||||
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsWnV5hQxlXvDA3Ad4k5N
|
||||
ZLz4cO+iGEPegSovIDcwTo097I+0pXYKPTVl+0iKC5JtJRObb4Xx9yK9gGwqkcxo
|
||||
o6WzKq0xY1jz7X6obxwlQCNse3Os1wr0rIY0UzP1dCpkW/5MwGbFxiB6PEVqkzmJ
|
||||
CmHBzZDRu/jAuL1nyoiGnUStqwENNYhyl4k7r8AiJkBZGMOCrj6v0JfgNna25Ce6
|
||||
QCFojlY4dkYQ5/7njQ3qpLwMeLEXEysMW3aUScSB68/vsHnB4C0fIkwfEPYZ/AC5
|
||||
AqbWHVbNmveB3rjV+tZZxXcLE8ArgKh1Gs+2VtnL09gwHm6WcpyPZ42G6tMDjWyw
|
||||
1wIDAQAB
|
||||
-----END PUBLIC KEY-----
|
||||
|
||||
******************************************
|
||||
* PatchSulution3 *
|
||||
******************************************
|
||||
@ +023d56e4: 4D 49 49 ---> 4D 49 49
|
||||
@ +01644a63: 42 49 ---> 42 49
|
||||
@ +01644a68: 6A ---> 6A
|
||||
@ +01644ace: 41 ---> 41
|
||||
@ +01644b28: 4E 42 67 6B ---> 4E 42 67 6B
|
||||
@ +01644b32: 71 ---> 71
|
||||
@ +023d56e8: 68 6B 69 47 39 77 ---> 68 6B 69 47 39 77
|
||||
...
|
||||
...
|
||||
...
|
||||
@ +023d58d0: 37 73 57 ---> 71 6C 47
|
||||
@ +023d58d4: 36 63 6A ---> 37 65 43
|
||||
@ +023d58d8: 78 6C 6A 75 75 51 61 ---> 32 4A 57 35 4A 4E 73
|
||||
@ +023d58d4: 36 63 6A ---> 47 36 74
|
||||
@ +023d58d8: 78 6C 6A 75 75 51 61 ---> 4D 44 6A 57 79 77 31
|
||||
@ +023d58e8: 77 49 44 41 ---> 77 49 44 41
|
||||
@ +0165155c: 51 41 ---> 51 41
|
||||
@ +01651561: 42 ---> 42
|
||||
|
||||
******************************************
|
||||
* PatchSulution1 *
|
||||
******************************************
|
||||
@ +0x021f7390
|
||||
Previous:
|
||||
+0x00000000021F7390 44 37 35 31 32 35 42 37 30 37 36 37 42 39 34 31 D75125B70767B941
|
||||
+0x00000000021F73A0 34 35 42 34 37 43 31 43 42 33 43 30 37 35 35 45 45B47C1CB3C0755E
|
||||
+0x00000000021F73B0 37 43 43 42 38 38 32 35 43 35 44 43 45 30 43 35 7CCB8825C5DCE0C5
|
||||
...
|
||||
...
|
||||
...
|
||||
|
||||
@ +0x021f708c
|
||||
Previous:
|
||||
+0x00000000021F7080 31 32 32 35 4f 45 29 2e 00 00 00 00 39 32 39 33 1225OE).....9293
|
||||
+0x00000000021F7090 33 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3...............
|
||||
After:
|
||||
+0x00000000021F7080 31 32 32 35 4f 45 29 2e 00 00 00 00 32 37 45 38 1225OE).....27E8
|
||||
+0x00000000021F7090 45 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 E...............
|
||||
|
||||
MESSAGE: Patch has been done successfully.
|
||||
```
|
||||
|
||||
@@ -127,31 +147,31 @@
|
||||
|
||||
```
|
||||
Select Navicat product:
|
||||
1. DataModeler
|
||||
2. Premium
|
||||
3. MySQL
|
||||
4. PostgreSQL
|
||||
5. Oracle
|
||||
6. SQLServer
|
||||
7. SQLite
|
||||
8. MariaDB
|
||||
9. MongoDB
|
||||
10. ReportViewer
|
||||
0. DataModeler
|
||||
1. Premium
|
||||
2. MySQL
|
||||
3. PostgreSQL
|
||||
4. Oracle
|
||||
5. SQLServer
|
||||
6. SQLite
|
||||
7. MariaDB
|
||||
8. MongoDB
|
||||
9. ReportViewer
|
||||
|
||||
(Input index)> 1
|
||||
|
||||
Select product language:
|
||||
1. English
|
||||
2. Simplified Chinese
|
||||
3. Traditional Chinese
|
||||
4. Japanese
|
||||
5. Polish
|
||||
6. Spanish
|
||||
7. French
|
||||
8. German
|
||||
9. Korean
|
||||
10. Russian
|
||||
11. Portuguese
|
||||
0. English
|
||||
1. Simplified Chinese
|
||||
2. Traditional Chinese
|
||||
3. Japanese
|
||||
4. Polish
|
||||
5. Spanish
|
||||
6. French
|
||||
7. German
|
||||
8. Korean
|
||||
9. Russian
|
||||
10. Portuguese
|
||||
|
||||
(Input index)> 1
|
||||
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
class PatchSolution{
|
||||
public:
|
||||
virtual void SetFile(FileMapper* pLibccFile) = 0;
|
||||
virtual bool CheckKey(RSACipher* pCipher) const = 0;
|
||||
virtual bool FindPatchOffset() noexcept = 0;
|
||||
virtual bool CheckKey(RSACipher* pCipher) const = 0;
|
||||
virtual void MakePatch(RSACipher* pCipher) const = 0;
|
||||
virtual ~PatchSolution() {}
|
||||
};
|
||||
@@ -58,17 +58,35 @@ public:
|
||||
virtual void MakePatch(RSACipher* cipher) const override;
|
||||
};
|
||||
|
||||
// PatchSolution1 will replace the RSA public key stored in libcc.dll
|
||||
// PatchSolution1, 2, 3 will replace the RSA public key stored in libcc.dll
|
||||
|
||||
class PatchSolution1 : public PatchSolution {
|
||||
private:
|
||||
static const char* Keywords[5];
|
||||
static const size_t KeywordsLength[5];
|
||||
|
||||
enum KeywordDataType {
|
||||
IMM_DATA,
|
||||
STRING_DATA
|
||||
};
|
||||
|
||||
struct KeywordInfo {
|
||||
const char* PtrToData;
|
||||
size_t Length;
|
||||
KeywordDataType Type;
|
||||
};
|
||||
|
||||
struct PatchPointInfo {
|
||||
uint8_t* PtrToPatch;
|
||||
size_t PatchSize;
|
||||
size_t MaxPatchSize;
|
||||
};
|
||||
|
||||
static constexpr size_t KeywordsCount = 5;
|
||||
static const KeywordInfo Keywords[KeywordsCount];
|
||||
|
||||
ImageInterpreter _TargetFile;
|
||||
off_t PatchOffsets[5];
|
||||
mutable PatchPointInfo _Patches[KeywordsCount];
|
||||
public:
|
||||
PatchSolution1() :
|
||||
PatchOffsets{ -1, -1, -1, -1, -1 } {}
|
||||
PatchSolution1() : _Patches{ } {}
|
||||
|
||||
virtual void SetFile(FileMapper* pLibccFile) override {
|
||||
if (!_TargetFile.ParseImage(pLibccFile->GetView<PVOID>(), true)) {
|
||||
@@ -77,11 +95,11 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
virtual bool CheckKey(RSACipher* cipher) const override;
|
||||
virtual bool CheckKey(RSACipher* pCipher) const override;
|
||||
|
||||
virtual bool FindPatchOffset() noexcept override;
|
||||
|
||||
virtual void MakePatch(RSACipher* cipher) const override;
|
||||
virtual void MakePatch(RSACipher* pCipher) const override;
|
||||
};
|
||||
|
||||
class PatchSolution2 : public PatchSolution {
|
||||
|
||||
@@ -31,7 +31,7 @@ bool PatchSolution0::FindPatchOffset() noexcept {
|
||||
for (DWORD i = 0; i < PtrToResourceSectionHeader->SizeOfRawData; ++i) {
|
||||
if (memcmp(PtrToResourceSection + i, Keyword, KeywordLength) == 0) {
|
||||
PatchOffset = PtrToResourceSectionHeader->PointerToRawData + i;
|
||||
_tprintf_s(TEXT("MESSAGE: [Solution0] Keyword has been found: offset = +0x%08lx.\n"), PatchOffset);
|
||||
_tprintf_s(TEXT("MESSAGE: PatchSolution0: Keyword has been found: offset = +0x%08lx.\n"), PatchOffset);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -54,6 +54,9 @@ void PatchSolution0::MakePatch(RSACipher* cipher) const {
|
||||
cipher->ExportKeyString<RSACipher::KeyType::PublicKey, RSACipher::KeyFormat::PEM>();
|
||||
Helper::ReplaceSubString(PublicKeyPEM, "\n", "\r\n");
|
||||
|
||||
_putts(TEXT("******************************************"));
|
||||
_putts(TEXT("* PatchSulution0 *"));
|
||||
_putts(TEXT("******************************************"));
|
||||
_tprintf_s(TEXT("@ +0x%08x\nPrevious:\n"), PatchOffset);
|
||||
Helper::PrintMemory(pFileView + PatchOffset,
|
||||
pFileView + PatchOffset + KeywordLength,
|
||||
|
||||
@@ -5,15 +5,24 @@
|
||||
#undef __BASE_FILE__
|
||||
#define __BASE_FILE__ "PatchSolution1.cpp"
|
||||
|
||||
const char* PatchSolution1::Keywords[5] = {
|
||||
const PatchSolution1::KeywordInfo PatchSolution1::Keywords[5] = {
|
||||
{
|
||||
"D75125B70767B94145B47C1CB3C0755E"
|
||||
"7CCB8825C5DCE0C58ACF944E08280140"
|
||||
"9A02472FAFFD1CD77864BB821AE36766"
|
||||
"FEEDE6A24F12662954168BFA314BD950"
|
||||
"32B9D82445355ED7BC0B880887D650F5",
|
||||
160,
|
||||
STRING_DATA
|
||||
},
|
||||
|
||||
{
|
||||
"\xfe\xea\xbc\x01",
|
||||
4,
|
||||
IMM_DATA
|
||||
},
|
||||
|
||||
{
|
||||
"E1CED09B9C2186BF71A70C0FE2F1E0AE"
|
||||
"F3BD6B75277AAB20DFAF3D110F75912B"
|
||||
"FB63AC50EC4C48689D1502715243A79F"
|
||||
@@ -38,23 +47,24 @@ const char* PatchSolution1::Keywords[5] = {
|
||||
"460F41ACF997C30E7C3AF025FA171B5F"
|
||||
"5AD4D6B15E95C27F6B35AD61875E5505"
|
||||
"449B4E",
|
||||
|
||||
742,
|
||||
STRING_DATA
|
||||
},
|
||||
|
||||
{
|
||||
"\x59\x08\x01\x00",
|
||||
|
||||
"92933"
|
||||
};
|
||||
|
||||
const size_t PatchSolution1::KeywordsLength[5] = {
|
||||
160,
|
||||
4,
|
||||
742,
|
||||
4,
|
||||
5
|
||||
4,
|
||||
IMM_DATA
|
||||
},
|
||||
|
||||
{
|
||||
"92933",
|
||||
5,
|
||||
STRING_DATA
|
||||
}
|
||||
};
|
||||
|
||||
bool PatchSolution1::CheckKey(RSACipher* cipher) const {
|
||||
BOOL bOk = FALSE;
|
||||
|
||||
std::string RSAPublicKeyPEM =
|
||||
cipher->ExportKeyString<RSACipher::KeyType::PublicKey, RSACipher::KeyFormat::PEM>();
|
||||
Helper::ReplaceSubString(RSAPublicKeyPEM, "\n", "\r\n");
|
||||
@@ -64,203 +74,247 @@ bool PatchSolution1::CheckKey(RSACipher* cipher) const {
|
||||
if (EncryptedPem.length() != 920)
|
||||
return false;
|
||||
|
||||
if (EncryptedPem[160] > '9' || EncryptedPem[160] < '1')
|
||||
// we require the chars in [p1, p2) of EncryptedPem must be number chars
|
||||
size_t p1, p2;
|
||||
|
||||
p1 = _Patches[0].MaxPatchSize;
|
||||
p2 = Keywords[0].Length + 8; // 8 = strlen("29158142")
|
||||
if (p1 >= p2)
|
||||
p1 = p2 - 1;
|
||||
|
||||
if (('1' <= EncryptedPem[p1] && EncryptedPem[p1] <= '9') == false)
|
||||
return false;
|
||||
|
||||
for (int i = 1; i < 8; ++i)
|
||||
if (EncryptedPem[160 + i] > '9' || EncryptedPem[160 + i] < '0')
|
||||
for (size_t i = p1 + 1; i < p2; ++i)
|
||||
if (('0' <= EncryptedPem[i] && EncryptedPem[i] <= '9') == false)
|
||||
return false;
|
||||
|
||||
if (EncryptedPem[910] > '9' || EncryptedPem[910] < '1')
|
||||
_Patches[0].PatchSize = p1;
|
||||
|
||||
p1 = Keywords[0].Length + 8 + _Patches[2].MaxPatchSize;
|
||||
p2 = Keywords[0].Length + 8 + Keywords[2].Length + 5;
|
||||
if (p1 >= p2)
|
||||
p1 = p2 - 1;
|
||||
|
||||
if (('1' <= EncryptedPem[p1] && EncryptedPem[p1] <= '9') == false)
|
||||
return false;
|
||||
|
||||
for (int i = 1; i < 5; ++i)
|
||||
if (EncryptedPem[910 + i] > '9' || EncryptedPem[910 + i] < '0')
|
||||
for (size_t i = p1 + 1; i < p2; ++i)
|
||||
if (('0' <= EncryptedPem[i] && EncryptedPem[i] <= '9') == false)
|
||||
return false;
|
||||
|
||||
_Patches[2].PatchSize = p1 - Keywords[0].Length - 8;
|
||||
|
||||
_Patches[4].PatchSize = Keywords[4].Length;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PatchSolution1::FindPatchOffset() noexcept {
|
||||
PIMAGE_SECTION_HEADER textSectionHeader = _TargetFile.GetSectionHeader(".text");
|
||||
PIMAGE_SECTION_HEADER rdataSectionHeader = _TargetFile.GetSectionHeader(".rdata");
|
||||
uint8_t* PtrToSectiontext = _TargetFile.GetSectionView<uint8_t>(".text");
|
||||
uint8_t* PtrToSectionrdata = _TargetFile.GetSectionView<uint8_t>(".rdata");
|
||||
off_t Offsets[5] = { -1, -1, -1, -1, -1 };
|
||||
PIMAGE_SECTION_HEADER SectionHeader_text = _TargetFile.GetSectionHeader(".text");
|
||||
PIMAGE_SECTION_HEADER SectionHeader_rdata = _TargetFile.GetSectionHeader(".rdata");
|
||||
uint8_t* PtrToSection_text = _TargetFile.GetSectionView<uint8_t>(".text");
|
||||
uint8_t* PtrToSection_rdata = _TargetFile.GetSectionView<uint8_t>(".rdata");
|
||||
PatchPointInfo TempPatches[KeywordsCount] = {};
|
||||
|
||||
if (textSectionHeader == nullptr)
|
||||
if (SectionHeader_text == nullptr)
|
||||
return false;
|
||||
if (rdataSectionHeader == nullptr)
|
||||
if (SectionHeader_rdata == nullptr)
|
||||
return false;
|
||||
|
||||
// -------------------------
|
||||
// try to search Keywords[0]
|
||||
// -------------------------
|
||||
for (DWORD i = 0; i < rdataSectionHeader->SizeOfRawData; ++i) {
|
||||
if (memcmp(PtrToSectionrdata + i, Keywords[0], KeywordsLength[0]) == 0) {
|
||||
Offsets[0] = rdataSectionHeader->PointerToRawData + i;
|
||||
for (DWORD i = 0; i < SectionHeader_rdata->SizeOfRawData; ++i) {
|
||||
if (memcmp(PtrToSection_rdata + i, Keywords[0].PtrToData, Keywords[0].Length) == 0) {
|
||||
TempPatches[0].PtrToPatch = PtrToSection_rdata + i;
|
||||
|
||||
size_t j = Keywords[0].Length;
|
||||
while (TempPatches[0].PtrToPatch[j] == 0)
|
||||
++j;
|
||||
|
||||
TempPatches[0].MaxPatchSize = j - 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (Offsets[0] == -1)
|
||||
if (TempPatches[0].PtrToPatch == nullptr)
|
||||
return false;
|
||||
|
||||
// -------------------------
|
||||
// try to search Keywords[2]
|
||||
// -------------------------
|
||||
for (DWORD i = 0; i < rdataSectionHeader->SizeOfRawData; ++i) {
|
||||
if (memcmp(PtrToSectionrdata + i, Keywords[2], KeywordsLength[2]) == 0) {
|
||||
Offsets[2] = rdataSectionHeader->PointerToRawData + i;
|
||||
for (DWORD i = 0; i < SectionHeader_rdata->SizeOfRawData; ++i) {
|
||||
if (memcmp(PtrToSection_rdata + i, Keywords[2].PtrToData, Keywords[2].Length) == 0) {
|
||||
TempPatches[2].PtrToPatch = PtrToSection_rdata + i;
|
||||
|
||||
size_t j = Keywords[2].Length;
|
||||
while (TempPatches[2].PtrToPatch[j] == 0)
|
||||
++j;
|
||||
|
||||
TempPatches[2].MaxPatchSize = j - 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (Offsets[2] == -1)
|
||||
if (TempPatches[2].PtrToPatch == nullptr)
|
||||
return false;
|
||||
|
||||
// -------------------------
|
||||
// try to search Keywords[4]
|
||||
// -------------------------
|
||||
for (DWORD i = 0; i < rdataSectionHeader->SizeOfRawData; ++i) {
|
||||
if (memcmp(PtrToSectionrdata + i, Keywords[4], KeywordsLength[4]) == 0) {
|
||||
Offsets[4] = rdataSectionHeader->PointerToRawData + i;
|
||||
for (DWORD i = 0; i < SectionHeader_rdata->SizeOfRawData; ++i) {
|
||||
if (memcmp(PtrToSection_rdata + i, Keywords[4].PtrToData, Keywords[4].Length) == 0) {
|
||||
TempPatches[4].PtrToPatch = PtrToSection_rdata + i;
|
||||
|
||||
size_t j = Keywords[4].Length;
|
||||
while (TempPatches[4].PtrToPatch[j] == 0)
|
||||
++j;
|
||||
|
||||
TempPatches[4].MaxPatchSize = j - 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (Offsets[4] == -1)
|
||||
if (TempPatches[4].PtrToPatch == nullptr)
|
||||
return false;
|
||||
|
||||
// -------------------------
|
||||
// try to search Keywords[1] and Keywords[3]
|
||||
// -------------------------
|
||||
for (DWORD i = 0; i < textSectionHeader->SizeOfRawData; ++i) {
|
||||
if (memcmp(PtrToSectiontext + i, Keywords[1], KeywordsLength[1]) == 0) {
|
||||
for (DWORD i = 0; i < SectionHeader_text->SizeOfRawData; ++i) {
|
||||
if (memcmp(PtrToSection_text + i, Keywords[1].PtrToData, Keywords[1].Length) == 0) {
|
||||
|
||||
// Keywords[3] must be close to Keywords[1]
|
||||
for (DWORD j = i - 64; j < i + 64; ++j) {
|
||||
if (memcmp(PtrToSectiontext + j, Keywords[3], KeywordsLength[3]) == 0) {
|
||||
Offsets[1] = textSectionHeader->PointerToRawData + i;
|
||||
Offsets[3] = textSectionHeader->PointerToRawData + j;
|
||||
if (memcmp(PtrToSection_text + j, Keywords[3].PtrToData, Keywords[3].Length) == 0) {
|
||||
TempPatches[1].PtrToPatch = PtrToSection_text + i;
|
||||
TempPatches[1].PatchSize = Keywords[1].Length;
|
||||
TempPatches[1].MaxPatchSize = Keywords[1].Length;
|
||||
|
||||
TempPatches[3].PtrToPatch = PtrToSection_text + j;
|
||||
TempPatches[3].PatchSize = Keywords[3].Length;
|
||||
TempPatches[3].MaxPatchSize = Keywords[3].Length;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Offsets[1] and Offsets[3] are set synchronously
|
||||
// so check Offsets[1] is enough
|
||||
if (Offsets[1] != -1)
|
||||
|
||||
if (TempPatches[3].PtrToPatch)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (Offsets[1] == -1)
|
||||
if (TempPatches[1].PtrToPatch == nullptr || TempPatches[3].PtrToPatch == nullptr)
|
||||
return false;
|
||||
|
||||
PatchOffsets[0] = Offsets[0];
|
||||
PatchOffsets[1] = Offsets[1];
|
||||
PatchOffsets[2] = Offsets[2];
|
||||
PatchOffsets[3] = Offsets[3];
|
||||
PatchOffsets[4] = Offsets[4];
|
||||
_tprintf_s(TEXT("MESSAGE: [PatchSolution1] Keywords[0] has been found: offset = +0x%08lx.\n"), PatchOffsets[0]);
|
||||
_tprintf_s(TEXT("MESSAGE: [PatchSolution1] Keywords[1] has been found: offset = +0x%08lx.\n"), PatchOffsets[1]);
|
||||
_tprintf_s(TEXT("MESSAGE: [PatchSolution1] Keywords[2] has been found: offset = +0x%08lx.\n"), PatchOffsets[2]);
|
||||
_tprintf_s(TEXT("MESSAGE: [PatchSolution1] Keywords[3] has been found: offset = +0x%08lx.\n"), PatchOffsets[3]);
|
||||
_tprintf_s(TEXT("MESSAGE: [PatchSolution1] Keywords[4] has been found: offset = +0x%08lx.\n"), PatchOffsets[4]);
|
||||
for (size_t i = 0; i < KeywordsCount; ++i) {
|
||||
_Patches[i] = TempPatches[i];
|
||||
_tprintf_s(TEXT("MESSAGE: PatchSolution1: Keywords[%zu] has been found: offset = +0x%08zx.\n"),
|
||||
i,
|
||||
_Patches[i].PtrToPatch - _TargetFile.GetImageBaseView<uint8_t>());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void PatchSolution1::MakePatch(RSACipher* pCipher) const {
|
||||
std::string PublicKeyPEM;
|
||||
std::string EncryptedPEM;
|
||||
uint8_t* pFileView = _TargetFile.GetImageBaseView<uint8_t>();
|
||||
|
||||
PublicKeyPEM =
|
||||
std::string PublicKeyPEM =
|
||||
pCipher->ExportKeyString<RSACipher::KeyType::PublicKey, RSACipher::KeyFormat::PEM>();
|
||||
Helper::ReplaceSubString(PublicKeyPEM, "\n", "\r\n");
|
||||
|
||||
EncryptedPEM = Helper::NavicatCipher.EncryptString(PublicKeyPEM);
|
||||
std::string EncryptedPEM = Helper::NavicatCipher.EncryptString(PublicKeyPEM);
|
||||
|
||||
// split encrypted_pem_pubkey to 5 part: |160 chars|8 chars|742 chars|5 chars|5 chars|
|
||||
// | |
|
||||
// \ / \ /
|
||||
// ImmValue1 ImmValue3
|
||||
std::string EncryptedPEM0(EncryptedPEM.begin(), EncryptedPEM.begin() + 160);
|
||||
std::string EncryptedPEM1(EncryptedPEM.begin() + 160, EncryptedPEM.begin() + 160 + 8);
|
||||
std::string EncryptedPEM2(EncryptedPEM.begin() + 160 + 8, EncryptedPEM.begin() + 160 + 8 + 742);
|
||||
std::string EncryptedPEM3(EncryptedPEM.begin() + 160 + 8 + 742, EncryptedPEM.begin() + 160 + 8 + 742 + 5);
|
||||
std::string EncryptedPEM4(EncryptedPEM.begin() + 160 + 8 + 742 + 5, EncryptedPEM.end());
|
||||
size_t p0, p1, p2, p3, p4, p5;
|
||||
p0 = 0;
|
||||
p1 = p0 + _Patches[0].PatchSize;
|
||||
p2 = Keywords[0].Length + 8;
|
||||
p3 = p2 + _Patches[2].PatchSize;
|
||||
p4 = Keywords[0].Length + 8 + Keywords[2].Length + 5;
|
||||
p5 = 920;
|
||||
|
||||
std::string EncryptedPEM0(EncryptedPEM.begin() + p0, EncryptedPEM.begin() + p1);
|
||||
std::string EncryptedPEM1(EncryptedPEM.begin() + p1, EncryptedPEM.begin() + p2);
|
||||
std::string EncryptedPEM2(EncryptedPEM.begin() + p2, EncryptedPEM.begin() + p3);
|
||||
std::string EncryptedPEM3(EncryptedPEM.begin() + p3, EncryptedPEM.begin() + p4);
|
||||
std::string EncryptedPEM4(EncryptedPEM.begin() + p4, EncryptedPEM.begin() + p5);
|
||||
uint32_t ImmValue1 = std::stoul(EncryptedPEM1.c_str());
|
||||
uint32_t ImmValue3 = std::stoul(EncryptedPEM3.c_str());
|
||||
|
||||
_putts(TEXT("******************************************"));
|
||||
_putts(TEXT("* PatchSulution1 *"));
|
||||
_putts(TEXT("******************************************"));
|
||||
|
||||
// ----------------------------------
|
||||
// process PatchOffsets[0]
|
||||
// ----------------------------------
|
||||
_tprintf_s(TEXT("@ +0x%08lx\nPrevious:\n"), PatchOffsets[0]);
|
||||
Helper::PrintMemory(pFileView + PatchOffsets[0],
|
||||
pFileView + PatchOffsets[0] + KeywordsLength[0],
|
||||
_tprintf_s(TEXT("@ +0x%08zx\nPrevious:\n"), _Patches[0].PtrToPatch - pFileView);
|
||||
Helper::PrintMemory(_Patches[0].PtrToPatch,
|
||||
_Patches[0].PtrToPatch + _Patches[0].PatchSize,
|
||||
pFileView);
|
||||
memcpy(pFileView + PatchOffsets[0], EncryptedPEM0.c_str(), KeywordsLength[0]);
|
||||
memcpy(_Patches[0].PtrToPatch, EncryptedPEM0.c_str(), _Patches[0].PatchSize);
|
||||
_putts(TEXT("After:"));
|
||||
Helper::PrintMemory(pFileView + PatchOffsets[0],
|
||||
pFileView + PatchOffsets[0] + KeywordsLength[0],
|
||||
Helper::PrintMemory(_Patches[0].PtrToPatch,
|
||||
_Patches[0].PtrToPatch + _Patches[0].PatchSize,
|
||||
pFileView);
|
||||
_putts(TEXT(""));
|
||||
|
||||
// ----------------------------------
|
||||
// process PatchOffsets[1]
|
||||
// ----------------------------------
|
||||
_tprintf_s(TEXT("@ +0x%08lx\nPrevious:\n"), PatchOffsets[1]);
|
||||
Helper::PrintMemory(pFileView + PatchOffsets[1],
|
||||
pFileView + PatchOffsets[1] + KeywordsLength[1],
|
||||
_tprintf_s(TEXT("@ +0x%08zx\nPrevious:\n"), _Patches[1].PtrToPatch - pFileView);
|
||||
Helper::PrintMemory(_Patches[1].PtrToPatch,
|
||||
_Patches[1].PtrToPatch + _Patches[1].PatchSize,
|
||||
pFileView);
|
||||
memcpy(pFileView + PatchOffsets[1], &ImmValue1, KeywordsLength[1]);
|
||||
memcpy(_Patches[1].PtrToPatch, &ImmValue1, sizeof(uint32_t));
|
||||
_putts(TEXT("After:"));
|
||||
Helper::PrintMemory(pFileView + PatchOffsets[1],
|
||||
pFileView + PatchOffsets[1] + KeywordsLength[1],
|
||||
Helper::PrintMemory(_Patches[1].PtrToPatch,
|
||||
_Patches[1].PtrToPatch + _Patches[1].PatchSize,
|
||||
pFileView);
|
||||
_putts(TEXT(""));
|
||||
|
||||
// ----------------------------------
|
||||
// process PatchOffsets[2]
|
||||
// ----------------------------------
|
||||
_tprintf_s(TEXT("@ +0x%08lx\nPrevious:\n"), PatchOffsets[2]);
|
||||
Helper::PrintMemory(pFileView + PatchOffsets[2],
|
||||
pFileView + PatchOffsets[2] + KeywordsLength[2],
|
||||
_tprintf_s(TEXT("@ +0x%08zx\nPrevious:\n"), _Patches[2].PtrToPatch - pFileView);
|
||||
Helper::PrintMemory(_Patches[2].PtrToPatch,
|
||||
_Patches[2].PtrToPatch + _Patches[2].PatchSize,
|
||||
pFileView);
|
||||
memcpy(pFileView + PatchOffsets[2], EncryptedPEM2.c_str(), KeywordsLength[2]);
|
||||
memcpy(_Patches[2].PtrToPatch, EncryptedPEM2.c_str(), _Patches[2].PatchSize);
|
||||
_putts(TEXT("After:"));
|
||||
Helper::PrintMemory(pFileView + PatchOffsets[2],
|
||||
pFileView + PatchOffsets[2] + KeywordsLength[2],
|
||||
Helper::PrintMemory(_Patches[2].PtrToPatch,
|
||||
_Patches[2].PtrToPatch + _Patches[2].PatchSize,
|
||||
pFileView);
|
||||
_putts(TEXT(""));
|
||||
|
||||
// ----------------------------------
|
||||
// process PatchOffsets[3]
|
||||
// ----------------------------------
|
||||
_tprintf_s(TEXT("@ +0x%08lx\nPrevious:\n"), PatchOffsets[3]);
|
||||
Helper::PrintMemory(pFileView + PatchOffsets[3],
|
||||
pFileView + PatchOffsets[3] + KeywordsLength[3],
|
||||
_tprintf_s(TEXT("@ +0x%08zx\nPrevious:\n"), _Patches[3].PtrToPatch - pFileView);
|
||||
Helper::PrintMemory(_Patches[3].PtrToPatch,
|
||||
_Patches[3].PtrToPatch + _Patches[3].PatchSize,
|
||||
pFileView);
|
||||
memcpy(pFileView + PatchOffsets[3], &ImmValue3, KeywordsLength[3]);
|
||||
memcpy(_Patches[3].PtrToPatch, &ImmValue3, sizeof(uint32_t));
|
||||
_putts(TEXT("After:"));
|
||||
Helper::PrintMemory(pFileView + PatchOffsets[3],
|
||||
pFileView + PatchOffsets[3] + KeywordsLength[3],
|
||||
Helper::PrintMemory(_Patches[3].PtrToPatch,
|
||||
_Patches[3].PtrToPatch + _Patches[3].PatchSize,
|
||||
pFileView);
|
||||
_putts(TEXT(""));
|
||||
|
||||
// ----------------------------------
|
||||
// process PatchOffsets[4]
|
||||
// ----------------------------------
|
||||
_tprintf_s(TEXT("@ +0x%08lx\nPrevious:\n"), PatchOffsets[4]);
|
||||
Helper::PrintMemory(pFileView + PatchOffsets[4],
|
||||
pFileView + PatchOffsets[4] + KeywordsLength[4],
|
||||
_tprintf_s(TEXT("@ +0x%08zx\nPrevious:\n"), _Patches[4].PtrToPatch - pFileView);
|
||||
Helper::PrintMemory(_Patches[4].PtrToPatch,
|
||||
_Patches[4].PtrToPatch + _Patches[4].PatchSize,
|
||||
pFileView);
|
||||
memcpy(pFileView + PatchOffsets[4], EncryptedPEM4.c_str(), KeywordsLength[4]);
|
||||
memcpy(_Patches[4].PtrToPatch, EncryptedPEM4.c_str(), _Patches[4].PatchSize);
|
||||
_putts(TEXT("After:"));
|
||||
Helper::PrintMemory(pFileView + PatchOffsets[4],
|
||||
pFileView + PatchOffsets[4] + KeywordsLength[4],
|
||||
Helper::PrintMemory(_Patches[4].PtrToPatch,
|
||||
_Patches[4].PtrToPatch + _Patches[4].PatchSize,
|
||||
pFileView);
|
||||
_putts(TEXT(""));
|
||||
}
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ bool PatchSolution2::FindPatchOffset() noexcept {
|
||||
memcpy(PatchOffsets, Offsets, sizeof(PatchOffsets));
|
||||
|
||||
for (size_t i = 0; i < KeywordsCount; ++i)
|
||||
_tprintf_s(TEXT("MESSAGE: [PatchSolution2] Keywords[%zu] has been found: offset = +0x%08lx.\n"),
|
||||
_tprintf_s(TEXT("MESSAGE: PatchSolution2: Keywords[%zu] has been found: offset = +0x%08lx.\n"),
|
||||
i,
|
||||
PatchOffsets[i]);
|
||||
|
||||
@@ -214,7 +214,7 @@ bool PatchSolution2::FindPatchOffset() noexcept {
|
||||
memcpy(PatchOffsets, Offsets, sizeof(PatchOffsets));
|
||||
|
||||
for (size_t i = 0; i < KeywordsCount; ++i)
|
||||
_tprintf_s(TEXT("MESSAGE: [PatchSolution2] Keywords[%zu] has been found: offset = +0x%08lx.\n"),
|
||||
_tprintf_s(TEXT("MESSAGE: PatchSolution2: Keywords[%zu] has been found: offset = +0x%08lx.\n"),
|
||||
i,
|
||||
PatchOffsets[i]);
|
||||
|
||||
@@ -237,6 +237,10 @@ void PatchSolution2::MakePatch(RSACipher* pCipher) const {
|
||||
}
|
||||
}
|
||||
|
||||
_putts(TEXT("******************************************"));
|
||||
_putts(TEXT("* PatchSulution2 *"));
|
||||
_putts(TEXT("******************************************"));
|
||||
|
||||
for (size_t i = 0; i < KeywordsCount; ++i) {
|
||||
_tprintf_s(TEXT("@ +0x%08lx: %02X %02X %02X ---> "),
|
||||
PatchOffsets[i],
|
||||
|
||||
@@ -631,7 +631,7 @@ bool PatchSolution3::FindPatchOffset() noexcept {
|
||||
return false;
|
||||
|
||||
for (size_t i = 0; i < KeywordsCount; ++i) {
|
||||
_tprintf_s(TEXT("MESSAGE: [PatchSolution3] Keywords[%zu] has been found:\n"), i);
|
||||
_tprintf_s(TEXT("MESSAGE: PatchSolution3: Keywords[%zu] has been found:\n"), i);
|
||||
_tprintf_s(TEXT(" Relative Machine Code Offset = +0x%016zx\n"), _Patches[i].PtrToRelativeCode - pFileView);
|
||||
_tprintf_s(TEXT(" Relative Machine Code RVA = +0x%016llx\n"), _Patches[i].RelativeCodeRVA);
|
||||
_tprintf_s(TEXT(" Patch Offset = +0x%016zx\n"), _Patches[i].PtrToPatch - pFileView);
|
||||
@@ -732,6 +732,10 @@ void PatchSolution3::MakePatch(RSACipher* pCipher) const {
|
||||
|
||||
uint8_t* pFileView = _TargetFile.GetImageBaseView<uint8_t>();
|
||||
|
||||
_putts(TEXT("******************************************"));
|
||||
_putts(TEXT("* PatchSulution3 *"));
|
||||
_putts(TEXT("******************************************"));
|
||||
|
||||
size_t ptr = 0;
|
||||
for (size_t i = 0; i < KeywordsCount; ++i) {
|
||||
_tprintf_s(TEXT("@ +%08zx: "), _Patches[i].PtrToPatch - pFileView);
|
||||
|
||||
+185
-120
@@ -119,8 +119,6 @@ int _tmain(int argc, PTSTR argv[]) {
|
||||
ResourceGuard<CppObjectTraits<PatchSolution>> pSolution2;
|
||||
ResourceGuard<CppObjectTraits<PatchSolution>> pSolution3;
|
||||
|
||||
pCipher.TakeHoldOf(new RSACipher());
|
||||
|
||||
try {
|
||||
SetPath(argv[1]);
|
||||
} catch (Exception& e) {
|
||||
@@ -131,50 +129,33 @@ int _tmain(int argc, PTSTR argv[]) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// -----------
|
||||
// decide which PatchSolution
|
||||
// -----------
|
||||
pCipher.TakeHoldOf(new RSACipher());
|
||||
|
||||
// -----------------
|
||||
// Map files
|
||||
// -----------------
|
||||
do {
|
||||
pLibccDLL.TakeHoldOf(new FileMapper());
|
||||
try {
|
||||
pLibccDLL.GetHandle()->MapFile(InstallationPath + TEXT("libcc.dll"));
|
||||
|
||||
pSolution3.TakeHoldOf(new PatchSolution3());
|
||||
pSolution3.GetHandle()->SetFile(pLibccDLL);
|
||||
if (pSolution3.GetHandle()->FindPatchOffset() == false) {
|
||||
PRINT_MESSAGE_LITERAL("MESSAGE: PatchSolution3 will be omitted.");
|
||||
pSolution3.Release();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
||||
pSolution2.TakeHoldOf(new PatchSolution2());
|
||||
pSolution2.GetHandle()->SetFile(pLibccDLL);
|
||||
if (pSolution2.GetHandle()->FindPatchOffset() == false) {
|
||||
PRINT_MESSAGE_LITERAL("MESSAGE: PatchSolution2 will be omitted.");
|
||||
pSolution2.Release();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
||||
pSolution1.TakeHoldOf(new PatchSolution1());
|
||||
pSolution1.GetHandle()->SetFile(pLibccDLL);
|
||||
if (pSolution1.GetHandle()->FindPatchOffset() == false) {
|
||||
PRINT_MESSAGE_LITERAL("MESSAGE: PatchSolution1 will be omitted.");
|
||||
pSolution2.Release();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
||||
pLibccDLL.Release();
|
||||
break;
|
||||
} catch (Exception& e) {
|
||||
if (e.HasErrorCode() && e.ErrorCode() == ERROR_FILE_NOT_FOUND) {
|
||||
PRINT_MESSAGE_LITERAL("MESSAGE: libcc.dll is not found.");
|
||||
PRINT_MESSAGE_LITERAL(" PatchSolution1 will be omitted.");
|
||||
PRINT_MESSAGE_LITERAL(" PatchSolution2 will be omitted.");
|
||||
PRINT_MESSAGE_LITERAL(" PatchSolution3 will be omitted.");
|
||||
pLibccDLL.Release();
|
||||
} else {
|
||||
if (!e.HasErrorCode() || e.ErrorCode() != ERROR_FILE_NOT_FOUND) {
|
||||
ExceptionReport(e);
|
||||
if (e.HasErrorCode() && e.ErrorCode() == ERROR_ACCESS_DENIED)
|
||||
PRINT_MESSAGE_LITERAL("Please re-run with Administrator privilege.");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
pLibccDLL.Release();
|
||||
|
||||
pMainExe.TakeHoldOf(new FileMapper());
|
||||
try {
|
||||
pMainExe.GetHandle()->MapFile(InstallationPath + TEXT("Navicat.exe"));
|
||||
MainAppName = TEXT("Navicat.exe");
|
||||
break;
|
||||
} catch (Exception& e) {
|
||||
if (!e.HasErrorCode() || e.ErrorCode() != ERROR_FILE_NOT_FOUND) {
|
||||
ExceptionReport(e);
|
||||
if (e.HasErrorCode() && e.ErrorCode() == ERROR_ACCESS_DENIED)
|
||||
PRINT_MESSAGE_LITERAL("Please re-run with Administrator privilege.");
|
||||
@@ -182,104 +163,188 @@ int _tmain(int argc, PTSTR argv[]) {
|
||||
}
|
||||
}
|
||||
|
||||
pMainExe.TakeHoldOf(new FileMapper());
|
||||
do {
|
||||
try {
|
||||
pMainExe.GetHandle()->MapFile(InstallationPath + TEXT("Navicat.exe"));
|
||||
MainAppName = TEXT("Navicat.exe");
|
||||
break;
|
||||
} catch (Exception& e) {
|
||||
if (!e.HasErrorCode() || e.ErrorCode() != ERROR_FILE_NOT_FOUND) {
|
||||
ExceptionReport(e);
|
||||
if (e.HasErrorCode() && e.ErrorCode() == ERROR_ACCESS_DENIED)
|
||||
PRINT_MESSAGE_LITERAL("Please re-run with Administrator privilege.");
|
||||
return 0;
|
||||
}
|
||||
try {
|
||||
pMainExe.GetHandle()->MapFile(InstallationPath + TEXT("Modeler.exe"));
|
||||
MainAppName = TEXT("Modeler.exe");
|
||||
break;
|
||||
} catch (Exception& e) {
|
||||
if (!e.HasErrorCode() || e.ErrorCode() != ERROR_FILE_NOT_FOUND) {
|
||||
ExceptionReport(e);
|
||||
if (e.HasErrorCode() && e.ErrorCode() == ERROR_ACCESS_DENIED)
|
||||
PRINT_MESSAGE_LITERAL("Please re-run with Administrator privilege.");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
pMainExe.GetHandle()->MapFile(InstallationPath + TEXT("Modeler.exe"));
|
||||
MainAppName = TEXT("Modeler.exe");
|
||||
break;
|
||||
} catch (Exception& e) {
|
||||
if (!e.HasErrorCode() || e.ErrorCode() != ERROR_FILE_NOT_FOUND) {
|
||||
ExceptionReport(e);
|
||||
if (e.HasErrorCode() && e.ErrorCode() == ERROR_ACCESS_DENIED)
|
||||
PRINT_MESSAGE_LITERAL("Please re-run with Administrator privilege.");
|
||||
return 0;
|
||||
}
|
||||
try {
|
||||
pMainExe.GetHandle()->MapFile(InstallationPath + TEXT("Rviewer.exe"));
|
||||
MainAppName = TEXT("Rviewer.exe");
|
||||
break;
|
||||
} catch (Exception& e) {
|
||||
if (!e.HasErrorCode() || e.ErrorCode() != ERROR_FILE_NOT_FOUND) {
|
||||
ExceptionReport(e);
|
||||
if (e.HasErrorCode() && e.ErrorCode() == ERROR_ACCESS_DENIED)
|
||||
PRINT_MESSAGE_LITERAL("Please re-run with Administrator privilege.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
try {
|
||||
pMainExe.GetHandle()->MapFile(InstallationPath + TEXT("Rviewer.exe"));
|
||||
MainAppName = TEXT("Rviewer.exe");
|
||||
break;
|
||||
} catch (Exception& e) {
|
||||
if (!e.HasErrorCode() || e.ErrorCode() != ERROR_FILE_NOT_FOUND) {
|
||||
ExceptionReport(e);
|
||||
if (e.HasErrorCode() && e.ErrorCode() == ERROR_ACCESS_DENIED)
|
||||
PRINT_MESSAGE_LITERAL("Please re-run with Administrator privilege.");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
pMainExe.Release();
|
||||
} while (false);
|
||||
}
|
||||
pMainExe.Release();
|
||||
} while (false);
|
||||
|
||||
// -----------
|
||||
// decide PatchSolutions
|
||||
// -----------
|
||||
|
||||
if (pMainExe.IsValid()) {
|
||||
try {
|
||||
pSolution0.TakeHoldOf(new PatchSolution0());
|
||||
pSolution0.GetHandle()->SetFile(pMainExe);
|
||||
if (pSolution0.GetHandle()->FindPatchOffset() == false) {
|
||||
PRINT_MESSAGE_LITERAL("MESSAGE: PatchSolution0 will be omitted.");
|
||||
pSolution0.Release();
|
||||
}
|
||||
PRINT_MESSAGE_LITERAL("");
|
||||
} catch (Exception& e) {
|
||||
ExceptionReport(e);
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
PRINT_MESSAGE_LITERAL("MESSAGE: PatchSolution0 will be omitted.");
|
||||
PRINT_MESSAGE_LITERAL("");
|
||||
}
|
||||
|
||||
if (pLibccDLL.IsValid()) {
|
||||
try {
|
||||
pSolution3.TakeHoldOf(new PatchSolution3());
|
||||
pSolution3.GetHandle()->SetFile(pLibccDLL);
|
||||
if (pSolution3.GetHandle()->FindPatchOffset() == false) {
|
||||
PRINT_MESSAGE_LITERAL("MESSAGE: PatchSolution3 will be omitted.");
|
||||
pSolution3.Release();
|
||||
}
|
||||
PRINT_MESSAGE_LITERAL("");
|
||||
|
||||
pSolution2.TakeHoldOf(new PatchSolution2());
|
||||
pSolution2.GetHandle()->SetFile(pLibccDLL);
|
||||
if (pSolution2.GetHandle()->FindPatchOffset() == false) {
|
||||
PRINT_MESSAGE_LITERAL("MESSAGE: PatchSolution2 will be omitted.");
|
||||
pSolution2.Release();
|
||||
}
|
||||
PRINT_MESSAGE_LITERAL("");
|
||||
|
||||
pSolution1.TakeHoldOf(new PatchSolution1());
|
||||
pSolution1.GetHandle()->SetFile(pLibccDLL);
|
||||
if (pSolution1.GetHandle()->FindPatchOffset() == false) {
|
||||
PRINT_MESSAGE_LITERAL("MESSAGE: PatchSolution1 will be omitted.");
|
||||
pSolution2.Release();
|
||||
}
|
||||
PRINT_MESSAGE_LITERAL("");
|
||||
} catch (Exception& e) {
|
||||
ExceptionReport(e);
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
PRINT_MESSAGE_LITERAL("MESSAGE: PatchSolution3 will be omitted.");
|
||||
PRINT_MESSAGE_LITERAL("MESSAGE: PatchSolution2 will be omitted.");
|
||||
PRINT_MESSAGE_LITERAL("MESSAGE: PatchSolution1 will be omitted.");
|
||||
PRINT_MESSAGE_LITERAL("");
|
||||
}
|
||||
|
||||
if (pSolution0.IsValid() == false)
|
||||
pMainExe.Release();
|
||||
|
||||
if (pSolution1.IsValid() == false && pSolution2.IsValid() == false && pSolution3.IsValid() == false)
|
||||
pLibccDLL.Release();
|
||||
|
||||
if (pSolution0.IsValid() == false &&
|
||||
pSolution1.IsValid() == false &&
|
||||
pSolution2.IsValid() == false &&
|
||||
pSolution3.IsValid() == false)
|
||||
{
|
||||
PRINT_MESSAGE_LITERAL("");
|
||||
PRINT_MESSAGE_LITERAL("ERROR: Cannot find RSA public key.");
|
||||
PRINT_MESSAGE_LITERAL("Are you sure your Navicat has not been patched before?");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// -------------
|
||||
// LoadKey
|
||||
// BackupFile
|
||||
// MakePatch
|
||||
// -------------
|
||||
try {
|
||||
LoadKey(pCipher, argc == 3 ? argv[2] : nullptr,
|
||||
pSolution0,
|
||||
pSolution1,
|
||||
pSolution2,
|
||||
LoadKey(pCipher,
|
||||
argc == 3 ? argv[2] : nullptr,
|
||||
pSolution0,
|
||||
pSolution1,
|
||||
pSolution2,
|
||||
pSolution3);
|
||||
} catch (Exception& e) {
|
||||
ExceptionReport(e);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (pLibccDLL) {
|
||||
BackupFile(InstallationPath + LibccName, InstallationPath + LibccName + TEXT(".backup"));
|
||||
} else {
|
||||
// -------------
|
||||
// BackupFile
|
||||
// -------------
|
||||
try {
|
||||
if (pMainExe.IsValid())
|
||||
BackupFile(InstallationPath + MainAppName, InstallationPath + MainAppName + TEXT(".backup"));
|
||||
}
|
||||
|
||||
if (pSolution3.IsValid())
|
||||
pSolution3.GetHandle()->MakePatch(pCipher);
|
||||
if (pSolution2.IsValid())
|
||||
pSolution2.GetHandle()->MakePatch(pCipher);
|
||||
if (pSolution1.IsValid())
|
||||
pSolution1.GetHandle()->MakePatch(pCipher);
|
||||
if (pSolution0.IsValid())
|
||||
pSolution0.GetHandle()->MakePatch(pCipher);
|
||||
} catch (Exception& e) {
|
||||
ExceptionReport(e);
|
||||
if (e.HasErrorCode() && e.ErrorCode() == ERROR_FILE_EXISTS) {
|
||||
if (pLibccDLL.IsValid()) {
|
||||
_tprintf_s(TEXT("The backup of %s has been found.\n"), LibccName.c_str());
|
||||
_tprintf_s(TEXT("Please remove %s.backup in Navicat installation path if you're sure %s has not been patched.\n"),
|
||||
LibccName.c_str(),
|
||||
LibccName.c_str());
|
||||
_tprintf_s(TEXT("Otherwise please restore %s by %s.backup and remove %s.backup then try again.\n"),
|
||||
LibccName.c_str(),
|
||||
LibccName.c_str(),
|
||||
LibccName.c_str());
|
||||
} else {
|
||||
_tprintf_s(TEXT("The backup of %s has been found.\n"), MainAppName.c_str());
|
||||
_tprintf_s(TEXT("Please remove %s.backup in Navicat installation path if you're sure %s has not been patched.\n"),
|
||||
MainAppName.c_str(),
|
||||
MainAppName.c_str());
|
||||
_tprintf_s(TEXT("Otherwise please restore %s by %s.backup and remove %s.backup then try again.\n"),
|
||||
MainAppName.c_str(),
|
||||
MainAppName.c_str(),
|
||||
MainAppName.c_str());
|
||||
}
|
||||
_tprintf_s(TEXT("The backup of %s has been found.\n"), MainAppName.c_str());
|
||||
_tprintf_s(TEXT("Please remove %s.backup in Navicat installation path if you're sure %s has not been patched.\n"),
|
||||
MainAppName.c_str(),
|
||||
MainAppName.c_str());
|
||||
_tprintf_s(TEXT("Otherwise please restore %s by %s.backup and remove %s.backup then try again.\n"),
|
||||
MainAppName.c_str(),
|
||||
MainAppName.c_str(),
|
||||
MainAppName.c_str());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
PRINT_MESSAGE_LITERAL("");
|
||||
try {
|
||||
if (pLibccDLL.IsValid())
|
||||
BackupFile(InstallationPath + LibccName, InstallationPath + LibccName + TEXT(".backup"));
|
||||
} catch (Exception& e) {
|
||||
ExceptionReport(e);
|
||||
if (e.HasErrorCode() && e.ErrorCode() == ERROR_FILE_EXISTS) {
|
||||
_tprintf_s(TEXT("The backup of %s has been found.\n"), LibccName.c_str());
|
||||
_tprintf_s(TEXT("Please remove %s.backup in Navicat installation path if you're sure %s has not been patched.\n"),
|
||||
LibccName.c_str(),
|
||||
LibccName.c_str());
|
||||
_tprintf_s(TEXT("Otherwise please restore %s by %s.backup and remove %s.backup then try again.\n"),
|
||||
LibccName.c_str(),
|
||||
LibccName.c_str(),
|
||||
LibccName.c_str());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// -------------
|
||||
// MakePatch
|
||||
// -------------
|
||||
try {
|
||||
if (pSolution3.IsValid()) {
|
||||
pSolution3.GetHandle()->MakePatch(pCipher);
|
||||
PRINT_MESSAGE_LITERAL("");
|
||||
}
|
||||
if (pSolution2.IsValid()) {
|
||||
pSolution2.GetHandle()->MakePatch(pCipher);
|
||||
PRINT_MESSAGE_LITERAL("");
|
||||
}
|
||||
if (pSolution1.IsValid()) {
|
||||
pSolution1.GetHandle()->MakePatch(pCipher);
|
||||
PRINT_MESSAGE_LITERAL("");
|
||||
}
|
||||
if (pSolution0.IsValid()) {
|
||||
pSolution0.GetHandle()->MakePatch(pCipher);
|
||||
PRINT_MESSAGE_LITERAL("");
|
||||
}
|
||||
} catch (Exception& e) {
|
||||
ExceptionReport(e);
|
||||
return 0;
|
||||
}
|
||||
|
||||
PRINT_MESSAGE_LITERAL("MESSAGE: Patch has been done successfully.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user