wilcocrypt 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +77 -0
- package/encryption.js +103 -0
- package/main.js +55 -0
- package/nokey.js +2 -0
- package/package.json +18 -0
- package/test/config.json +3 -0
- package/test/decrypt.js +6 -0
- package/test/decryptLog.js +6 -0
- package/test/encrypt.js +4 -0
- package/test/encrypted/main +1 -0
- package/test/test.js +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# wilcocrypt
|
|
2
|
+
|
|
3
|
+
wilcocrypt is een prachtige tool voor het vergrendelen, oftewel encrypten, van JavaScript code.
|
|
4
|
+
|
|
5
|
+
## Voorbeeld
|
|
6
|
+
|
|
7
|
+
### config.json
|
|
8
|
+
In config.json moet de even het begin van JSON code toevoegen, de rest word automatisch gedaan.
|
|
9
|
+
```json
|
|
10
|
+
{}
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### main.js
|
|
14
|
+
Hierin moet de originele JavaScript code.
|
|
15
|
+
```js
|
|
16
|
+
console.log("Voorbeeld");
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### encrypt.js
|
|
20
|
+
Hierin staat de code voor het encrypten.
|
|
21
|
+
```js
|
|
22
|
+
const wilcocrypt = require("wilcocrypt");
|
|
23
|
+
const path = require("path");
|
|
24
|
+
|
|
25
|
+
wilcocrypt.encryptFile(path.join(__dirname, "config.json"), path.join(__dirname, "main.js"), path.join(__dirname, "encrypted"));
|
|
26
|
+
```
|
|
27
|
+
Dit zorgt ervoor dat het bestand config.json word genomen als keyFile, main.js als JavaScript bestand, en encrypted als de map waar het bestand inkomt.
|
|
28
|
+
|
|
29
|
+
### decrypt.js
|
|
30
|
+
Hierin staat de code voor het decrypten.
|
|
31
|
+
```js
|
|
32
|
+
const wilcocrypt = require("wilcocrypt");
|
|
33
|
+
const path = require("path");
|
|
34
|
+
|
|
35
|
+
const main = wilcocrypt.decryptFile(path.join(__dirname, "config.json"), path.join(__dirname, "encrypted"));
|
|
36
|
+
|
|
37
|
+
main(require, __dirname);
|
|
38
|
+
```
|
|
39
|
+
Hierin staat weer dat config.json word genomen als keyFile en encrypted als de map waar het bestand instaat.
|
|
40
|
+
|
|
41
|
+
Als je nu uitvoert:
|
|
42
|
+
```shell
|
|
43
|
+
node encrypt.js
|
|
44
|
+
```
|
|
45
|
+
Dan komt er een mapje encrypted met daarin iets zoals dit:
|
|
46
|
+
```
|
|
47
|
+
ec3d347f42dcb45872dbe11384511403442d24fe0c502e2070db8ca2fea0c3f9c2d1bb15c0f27a83ed128c545ee668f176d4c4c3ce78fe3c69f0979c80e9ee2e97533b2701b90cff18af9643441ccfde6b428c7746fd722ccf6b9290be12254b9a5d0bbbc121442d8a6077b8857c87788acfd00c0448e5e8edd28c093f1f24b016743aa13bbff1ecf0a6e7424307973d440f57cf3bc6b4770018c9e2effeaeb94b762975c526f44299d8734e1407ae994b27dabf6fed930ee0201e90812aa547b57cd75e718d96bb7915e2c1d37026b7bcec4c5c331a17b4f882f43f427ccf9b99a4ed51921bfdede2b40a493034e3016144bc1db0f93616e9bafcaf2e04623699d768ed6b099fc2a29820c39329de6e58e392c6ff43722b57f9bb3e006fbd0e4a5ba83ae7844b780dffd347115a070587def1a552ffbb3fa248a50d55a3e20b0632de552a83f995bf0697e963809d51d08c2cc3675d2d1e1427ac74279b40ebb5298576dec079b726e3ca1590c67119943ca3b265f3afe64df6acb1ddd5a285d8812bc1964c68a2c4fb69c9f0b4e4828ac7bd6778e5bac26da778aac5f5db727eb8da208cabad5f19f020125a71c6f1611f5e3e3add92e7b994c253eaf4becbb092309294952afae4e7bd2e16761b8d5f2ec1cafc5782ceaa0ee7cd1acd9cf7417a3a38f2ffc19f47c5c48dcecb240d83ad82fb16ea82633ac15a4c0af8aa614de5eaadbf550861c90aa2f1004957d96c3bf12c6ba3b766319a065bbf44b08e24576819249fa84b8583b4828d983338efa35f744fc75d9b3f96a23a552d655290cd0d3826cc24d883a39212c28addfcba95a0efcd5a8e14a56f08b17e5db749c063459a3e45d6c1ca89f86bc7d5fb5b6a0c745a27a918fc2169fdd9f6974d41f778a3078557d785d1b9bd0f40b890b1c21a7011f5ce8198b57603b219036400016c936a1b0e91a63037c7397d5d1a463a2ebf293c3217694c854a28d42cd3a08588470b2390a8df1d21f489cf68f279e8b45edf8f45d299ac6d50dc2f37139d17cba18ecb264783e1484b8e9bfa916820788371484f821a0a5464df34cbf95a6faab3bd4cfd128cc9acb57ef4f2893f96b324ee06968b199836797601d64c0670602cec99c561387399459114cf5c5a8556f7878538cbfddf95e2bfec6e3199120e8e8cde931a9816b86e3562185ab023e0fe2cd10f75685b03734f05380d9803c50bbe9bfc112ccfdb45e537e9b5e645536a0b6a5bf071722de3ef2522e0912b51c2cf5a1e268cd2207d242ce5797001d44482d0cc5931e84c7039674576f9d44b67739d1eaab7fd94e50cd191cc460f805cc27143834a37f76ccd65271ce2342f23c50806e509a2567982d008c5256bace9cb81b9f46e2b1c2d41bdb94b357227c3bc0e3f49eabd390d596cd1349a28d5a3c60e6e7ac65fdffabe797a6a4352f4ab67228f52c17dedd83a14f2faf2479757aac21818741c13323b27c12f18858ef2c3362ed730651ffdd64c166ffb53b8a2703d191b2160aaaf36aee571adc522cf148be4a7cb07eb58f3d702959c857e1b4fb9f80d8d616fbd98f1acb92a983bb480a43635b1ef6a47e471098974eb00babaee1127c0f3a4911b7d1f52d1
|
|
48
|
+
```
|
|
49
|
+
Als je uitvoert:
|
|
50
|
+
```shell
|
|
51
|
+
node decrypt.js
|
|
52
|
+
```
|
|
53
|
+
dan komt er:
|
|
54
|
+
```
|
|
55
|
+
Voorbeeld
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Extra functie
|
|
59
|
+
|
|
60
|
+
Voor de mensen die het leuk vinden is er ook nog de `decryptLog` functie. Die is als volgt te gebruiken:
|
|
61
|
+
```js
|
|
62
|
+
const wilcocrypt = require("wilcocrypt");
|
|
63
|
+
const path = require("path");
|
|
64
|
+
|
|
65
|
+
const decrypted = wilcocrypt.decryptLog(path.join(__dirname, "config.json"), path.join(__dirname, "encrypted"));
|
|
66
|
+
|
|
67
|
+
console.log(decrypted);
|
|
68
|
+
```
|
|
69
|
+
Dan komt de letterlijke decrypte code eruit:
|
|
70
|
+
```js
|
|
71
|
+
(function(_0xbf65d7,_0x15daa7){var _0x3afcd9=_0x1c81,_0x162bea=_0xbf65d7();while(!![]){try{var _0x72f333=-parseInt(_0x3afcd9(0x1cd))/0x1*(parseInt(_0x3afcd9(0x1c5))/0x2)+-parseInt(_0x3afcd9(0x1c7))/0x3*(-parseInt(_0x3afcd9(0x1cf))/0x4)+parseInt(_0x3afcd9(0x1c6))/0x5*(-parseInt(_0x3afcd9(0x1c8))/0x6)+-parseInt(_0x3afcd9(0x1cc))/0x7*(parseInt(_0x3afcd9(0x1c9))/0x8)+parseInt(_0x3afcd9(0x1cb))/0x9+parseInt(_0x3afcd9(0x1ce))/0xa+parseInt(_0x3afcd9(0x1ca))/0xb;if(_0x72f333===_0x15daa7)break;else _0x162bea['push'](_0x162bea['shift']());}catch(_0x40b1fe){_0x162bea['push'](_0x162bea['shift']());}}}(_0x28c4,0x64e14),console['log']('Test'));function _0x1c81(_0x3d5a59,_0x380b95){var _0x28c429=_0x28c4();return _0x1c81=function(_0x1c8195,_0x52ce1d){_0x1c8195=_0x1c8195-0x1c5;var _0x1c95c4=_0x28c429[_0x1c8195];return _0x1c95c4;},_0x1c81(_0x3d5a59,_0x380b95);}function _0x28c4(){var _0x1e89dd=['1008jGxdEe','7819449tGJxNe','1651914cFJLIy','4907qNvfVo','125821GAjXcS','2295720dsiUxg','989348uvKaZU','2oNaZQT','79145gxkvGD','3anJDXL','282HSwsBf'];_0x28c4=function(){return _0x1e89dd;};return _0x28c4();}
|
|
72
|
+
```
|
|
73
|
+
Dit is in princiepe zelfs in de webbrowser uit te voeren, dan krijg je in de console: `Voorbeeld`
|
|
74
|
+
|
|
75
|
+
#### Credits
|
|
76
|
+
|
|
77
|
+
Dit project is gebaseerd op het github repository [SweatyCircle439/439cription](https://github.com/sweatycircle439/439cription) wat is gelicenseerd onder appache 2.0
|
package/encryption.js
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
const crypto = require("crypto");
|
|
2
|
+
const fs = require("fs-extra");
|
|
3
|
+
const path = require("path");
|
|
4
|
+
const JavaScriptObfuscator = require('javascript-obfuscator');
|
|
5
|
+
|
|
6
|
+
const encryptHeader = "Wilco's Encryption Script V1.0.0\n";
|
|
7
|
+
|
|
8
|
+
function deriveKey(keyNumber) {
|
|
9
|
+
const keyBuffer = Buffer.from(String(keyNumber));
|
|
10
|
+
return crypto.createHash('sha256').update(keyBuffer).digest();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
* @param {any} value
|
|
16
|
+
* @param {String} encryptionKey
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
function encrypt(value, encryptionKey) {
|
|
20
|
+
const encryptableValue = encryptHeader + JSON.stringify(value);
|
|
21
|
+
const encryptionNum = encryptionKey.split("").map(char => char.charCodeAt(0)).join("");
|
|
22
|
+
const key = deriveKey(encryptionNum);
|
|
23
|
+
const iv = crypto.randomBytes(16);
|
|
24
|
+
const cipher = crypto.createCipheriv('aes-256-cbc', key, iv);
|
|
25
|
+
let encrypted = cipher.update(encryptableValue, 'utf8', 'hex');
|
|
26
|
+
encrypted += cipher.final('hex');
|
|
27
|
+
return iv.toString('hex') + encrypted;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
*
|
|
32
|
+
* @param {String} encryptedValue
|
|
33
|
+
* @param {String} encryptionKey
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
function decrypt(encryptedValue, encryptionKey) {
|
|
37
|
+
const keyNumber = encryptionKey.split("").map(char => char.charCodeAt(0)).join("");
|
|
38
|
+
const key = deriveKey(keyNumber);
|
|
39
|
+
const iv = Buffer.from(encryptedValue.slice(0, 32), 'hex');
|
|
40
|
+
const encryptedText = encryptedValue.slice(32);
|
|
41
|
+
const decipher = crypto.createDecipheriv('aes-256-cbc', key, iv);
|
|
42
|
+
let decrypted = decipher.update(encryptedText, 'hex', 'utf8');
|
|
43
|
+
decrypted += decipher.final('utf8');
|
|
44
|
+
if (!decrypted.startsWith(encryptHeader)) {
|
|
45
|
+
throw new Error("decryption key is invalid");
|
|
46
|
+
}
|
|
47
|
+
const lst = decrypted.split(encryptHeader);
|
|
48
|
+
lst.shift();
|
|
49
|
+
return JSON.parse(lst.join(encryptHeader));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function encryptFileSync(file, encryptionKey, shouldObfiscate = false) {
|
|
53
|
+
let res = fs.readFileSync(file).toString();
|
|
54
|
+
if (shouldObfiscate) {
|
|
55
|
+
res = JavaScriptObfuscator.obfuscate(res).getObfuscatedCode();
|
|
56
|
+
}
|
|
57
|
+
// console.log(res);
|
|
58
|
+
return encrypt(res, encryptionKey);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function decryptFileSync(file, encryptionKey) {
|
|
62
|
+
return decrypt(fs.readFileSync(file).toString(), encryptionKey);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function encryptDirSync(dir, encryptionKey) {
|
|
66
|
+
/**
|
|
67
|
+
*
|
|
68
|
+
* @param {String} dir
|
|
69
|
+
* @returns {{type: String, name: String, contents?: String|tree.returns}}
|
|
70
|
+
*/
|
|
71
|
+
function tree(dir) {
|
|
72
|
+
const objects = [];
|
|
73
|
+
// console.log(dir);
|
|
74
|
+
const files = fs.readdirSync(dir);
|
|
75
|
+
for (const file of files) {
|
|
76
|
+
if (fs.lstatSync(path.join(dir, file)).isDirectory()) {
|
|
77
|
+
if (file !== "node_modules") {
|
|
78
|
+
objects.push({
|
|
79
|
+
type: "directory",
|
|
80
|
+
name: file,
|
|
81
|
+
contents: tree(path.join(dir, file))
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
} else {
|
|
85
|
+
objects.push({
|
|
86
|
+
type: "file",
|
|
87
|
+
name: file,
|
|
88
|
+
contents: fs.readFileSync(path.join(dir, file))
|
|
89
|
+
})
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return objects;
|
|
93
|
+
}
|
|
94
|
+
return encrypt(tree(dir), encryptionKey);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
module.exports = {
|
|
98
|
+
encrypt,
|
|
99
|
+
decrypt,
|
|
100
|
+
encryptFileSync,
|
|
101
|
+
decryptFileSync,
|
|
102
|
+
encryptDirSync
|
|
103
|
+
}
|
package/main.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
const { randomUUID } = require("crypto");
|
|
2
|
+
const fs = require("fs-extra");
|
|
3
|
+
const path = require("path");
|
|
4
|
+
const logginglog = require("logginglog");
|
|
5
|
+
const encryption = require("./encryption");
|
|
6
|
+
|
|
7
|
+
const color = logginglog.colors();
|
|
8
|
+
const serverlog = logginglog.makeLogger('WCrypt', color.rainbow);
|
|
9
|
+
|
|
10
|
+
function encryptFile(keyFile, inputFile, outputDir) {
|
|
11
|
+
keyFile = path.join(keyFile);
|
|
12
|
+
|
|
13
|
+
fs.ensureFileSync(keyFile);
|
|
14
|
+
|
|
15
|
+
const json = fs.readJSONSync(keyFile);
|
|
16
|
+
|
|
17
|
+
const key = `WPKey ${randomUUID().replaceAll("-", " ")} ${randomUUID().replaceAll("-", " ")} ${randomUUID().replaceAll("-", " ")} ${randomUUID().replaceAll("-", " ")} ${randomUUID().replaceAll("-", " ")}`;
|
|
18
|
+
|
|
19
|
+
json.key = key;
|
|
20
|
+
|
|
21
|
+
fs.ensureDirSync(path.join(outputDir));
|
|
22
|
+
fs.writeFileSync(path.join(outputDir, "main"), encryption.encryptFileSync(path.join(inputFile), key, true));
|
|
23
|
+
|
|
24
|
+
fs.writeJsonSync(keyFile, json, {
|
|
25
|
+
spaces: 4, EOL: '\r\n'
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
serverlog(`Uw code is succesvol gemaakt in ${path.join(__dirname, "encrypted", "main")}`);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function decryptLog(keyFile, outputDir) {
|
|
32
|
+
let decrypted = fs.readFileSync(path.join(__dirname, "nokey.js")).toString();
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
decrypted = encryption.decryptFileSync(path.join(outputDir, "main"), fs.readJSONSync(path.join(keyFile)).key);
|
|
36
|
+
} catch (error) {
|
|
37
|
+
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return decrypted;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function decryptFile(keyFile, outputDir) {
|
|
44
|
+
const decrypted = decryptLog(keyFile, outputDir);
|
|
45
|
+
|
|
46
|
+
const main = new Function('require', '__dirname', decrypted);
|
|
47
|
+
|
|
48
|
+
return main;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
module.exports = {
|
|
52
|
+
encryptFile,
|
|
53
|
+
decryptFile,
|
|
54
|
+
decryptLog
|
|
55
|
+
}
|
package/nokey.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "wilcocrypt",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A encrypt tool for JS",
|
|
5
|
+
"license": "ISC",
|
|
6
|
+
"author": "Wilco Joosen",
|
|
7
|
+
"type": "commonjs",
|
|
8
|
+
"main": "main.js",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "node test/test.js",
|
|
11
|
+
"update": "npx -y Jelmerro/nus"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"fs-extra": "11.3.0",
|
|
15
|
+
"javascript-obfuscator": "4.1.1",
|
|
16
|
+
"logginglog": "^1.0.0"
|
|
17
|
+
}
|
|
18
|
+
}
|
package/test/config.json
ADDED
package/test/decrypt.js
ADDED
package/test/encrypt.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ec3d347f42dcb45872dbe11384511403442d24fe0c502e2070db8ca2fea0c3f9c2d1bb15c0f27a83ed128c545ee668f176d4c4c3ce78fe3c69f0979c80e9ee2e97533b2701b90cff18af9643441ccfde6b428c7746fd722ccf6b9290be12254b9a5d0bbbc121442d8a6077b8857c87788acfd00c0448e5e8edd28c093f1f24b016743aa13bbff1ecf0a6e7424307973d440f57cf3bc6b4770018c9e2effeaeb94b762975c526f44299d8734e1407ae994b27dabf6fed930ee0201e90812aa547b57cd75e718d96bb7915e2c1d37026b7bcec4c5c331a17b4f882f43f427ccf9b99a4ed51921bfdede2b40a493034e3016144bc1db0f93616e9bafcaf2e04623699d768ed6b099fc2a29820c39329de6e58e392c6ff43722b57f9bb3e006fbd0e4a5ba83ae7844b780dffd347115a070587def1a552ffbb3fa248a50d55a3e20b0632de552a83f995bf0697e963809d51d08c2cc3675d2d1e1427ac74279b40ebb5298576dec079b726e3ca1590c67119943ca3b265f3afe64df6acb1ddd5a285d8812bc1964c68a2c4fb69c9f0b4e4828ac7bd6778e5bac26da778aac5f5db727eb8da208cabad5f19f020125a71c6f1611f5e3e3add92e7b994c253eaf4becbb092309294952afae4e7bd2e16761b8d5f2ec1cafc5782ceaa0ee7cd1acd9cf7417a3a38f2ffc19f47c5c48dcecb240d83ad82fb16ea82633ac15a4c0af8aa614de5eaadbf550861c90aa2f1004957d96c3bf12c6ba3b766319a065bbf44b08e24576819249fa84b8583b4828d983338efa35f744fc75d9b3f96a23a552d655290cd0d3826cc24d883a39212c28addfcba95a0efcd5a8e14a56f08b17e5db749c063459a3e45d6c1ca89f86bc7d5fb5b6a0c745a27a918fc2169fdd9f6974d41f778a3078557d785d1b9bd0f40b890b1c21a7011f5ce8198b57603b219036400016c936a1b0e91a63037c7397d5d1a463a2ebf293c3217694c854a28d42cd3a08588470b2390a8df1d21f489cf68f279e8b45edf8f45d299ac6d50dc2f37139d17cba18ecb264783e1484b8e9bfa916820788371484f821a0a5464df34cbf95a6faab3bd4cfd128cc9acb57ef4f2893f96b324ee06968b199836797601d64c0670602cec99c561387399459114cf5c5a8556f7878538cbfddf95e2bfec6e3199120e8e8cde931a9816b86e3562185ab023e0fe2cd10f75685b03734f05380d9803c50bbe9bfc112ccfdb45e537e9b5e645536a0b6a5bf071722de3ef2522e0912b51c2cf5a1e268cd2207d242ce5797001d44482d0cc5931e84c7039674576f9d44b67739d1eaab7fd94e50cd191cc460f805cc27143834a37f76ccd65271ce2342f23c50806e509a2567982d008c5256bace9cb81b9f46e2b1c2d41bdb94b357227c3bc0e3f49eabd390d596cd1349a28d5a3c60e6e7ac65fdffabe797a6a4352f4ab67228f52c17dedd83a14f2faf2479757aac21818741c13323b27c12f18858ef2c3362ed730651ffdd64c166ffb53b8a2703d191b2160aaaf36aee571adc522cf148be4a7cb07eb58f3d702959c857e1b4fb9f80d8d616fbd98f1acb92a983bb480a43635b1ef6a47e471098974eb00babaee1127c0f3a4911b7d1f52d1
|
package/test/test.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
console.log("Test");
|