whatsapp-nodejs 0.0.1-security → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of whatsapp-nodejs might be problematic. Click here for more details.
- package/.eslintignore +2 -0
- package/.eslintrc.js +59 -0
- package/.prettierrc +11 -0
- package/README.md +51 -3
- package/package.json +97 -3
- package/proto/ClientHello.proto +167 -0
- package/proto/HandshakeMessage.proto +26 -0
- package/proto/Message.proto +795 -0
- package/proto/SessionStructure.proto +113 -0
- package/proto/WhisperTextProtocol.proto +29 -0
- package/src/SocketClient.js +241 -0
- package/src/SocketManager.js +130 -0
- package/src/WASocketClient.js +170 -0
- package/src/Whatsapp.js +169 -0
- package/src/WhatsappServer.js +17 -0
- package/src/bin/decoder.js +1 -0
- package/src/bin/dict.js +1 -0
- package/src/bin/dict1.js +1 -0
- package/src/bin/dict2.js +1 -0
- package/src/bin/encoder.js +1 -0
- package/src/config.js +71 -0
- package/src/db.js +44 -0
- package/src/index.js +7 -0
- package/src/lib/SocketProxy.js +225 -0
- package/src/lib/libsignal-protocol.js +14 -0
- package/src/lib/utils.js +123 -0
- package/src/logger.js +79 -0
- package/src/packet/ProtocolEntity.js +39 -0
- package/src/packet/ProtocolTreeNode.js +202 -0
- package/src/protobuf/pb.js +32415 -0
- package/src/protocol/CipherState.js +48 -0
- package/src/protocol/FallbackPatternModifier.js +48 -0
- package/src/protocol/ForwarderHandshakeState.js +56 -0
- package/src/protocol/HandShake.js +273 -0
- package/src/protocol/HandshakePattern.js +62 -0
- package/src/protocol/HandshakeState.js +223 -0
- package/src/protocol/PKCS7.js +89 -0
- package/src/protocol/SwitchableHandshakeState.js +64 -0
- package/src/protocol/WASymmetricState.js +116 -0
- package/src/protocol/crypto.js +112 -0
- package/src/protocol/handshakepatterns/HandshakePattern.js +62 -0
- package/src/protocol/handshakepatterns/IKHandshakePattern.js +17 -0
- package/src/protocol/handshakepatterns/XXHandshakePattern.js +9 -0
- package/src/schema/account.js +65 -0
- package/src/schema/axolotl.js +8 -0
- package/src/schema/business.js +15 -0
- package/src/schema/common.js +26 -0
- package/src/schema/dayreport.js +21 -0
- package/src/schema/identify.js +49 -0
- package/src/schema/message.js +44 -0
- package/src/schema/prekey.js +51 -0
- package/src/schema/recvmessage.js +33 -0
- package/src/schema/senderkey.js +20 -0
- package/src/schema/session.js +22 -0
- package/src/schema/signedprekeys.js +56 -0
- package/test/WASocketClient.test.js +23 -0
- package/test/handshake.test.js +38 -0
- package/test/logger.test.js +17 -0
- package/test/whatsapp.test.js +17 -0
package/.eslintignore
ADDED
package/.eslintrc.js
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
module.exports = {
|
2
|
+
parser: 'babel-eslint',
|
3
|
+
extends: ['airbnb', 'prettier', 'plugin:prettier/recommended'],
|
4
|
+
env: {
|
5
|
+
browser: true,
|
6
|
+
node: true,
|
7
|
+
es6: true,
|
8
|
+
mocha: true,
|
9
|
+
jest: true,
|
10
|
+
jasmine: true,
|
11
|
+
},
|
12
|
+
globals: {
|
13
|
+
APP_TYPE: true,
|
14
|
+
page: true,
|
15
|
+
},
|
16
|
+
rules: {
|
17
|
+
'import/no-absolute-path': 0,
|
18
|
+
'jsx-a11y/anchor-is-valid': 0,
|
19
|
+
'react/jsx-filename-extension': [1, { extensions: ['.js'] }],
|
20
|
+
'react/jsx-wrap-multilines': 0,
|
21
|
+
'react/prop-types': 0,
|
22
|
+
'react/forbid-prop-types': 0,
|
23
|
+
'react/jsx-one-expression-per-line': 0,
|
24
|
+
'import/no-unresolved': [2, { ignore: ['^@/', '^umi/'] }],
|
25
|
+
'import/no-extraneous-dependencies': [
|
26
|
+
2,
|
27
|
+
{
|
28
|
+
optionalDependencies: true,
|
29
|
+
devDependencies: ['**/tests/**.js', '/mock/**.js', '**/**.test.js'],
|
30
|
+
},
|
31
|
+
],
|
32
|
+
'jsx-a11y/no-noninteractive-element-interactions': 0,
|
33
|
+
'jsx-a11y/click-events-have-key-events': 0,
|
34
|
+
'jsx-a11y/no-static-element-interactions': 0,
|
35
|
+
'jsx-a11y/anchor-is-valid': 0,
|
36
|
+
'no-underscore-dangle': 0,
|
37
|
+
'no-plusplus': 0,
|
38
|
+
'consistent-return': 0,
|
39
|
+
'no-await-in-loop': 0,
|
40
|
+
'no-return-await': 0,
|
41
|
+
'no-param-reassign': 0,
|
42
|
+
'class-methods-use-this': 0,
|
43
|
+
'react-hooks/exhaustive-deps': 0,
|
44
|
+
'react/destructuring-assignment': 0,
|
45
|
+
'jsx-a11y/label-has-associated-control': 0,
|
46
|
+
'jsx-a11y/label-has-for': 0,
|
47
|
+
'react/no-danger': 0,
|
48
|
+
'no-console': 0,
|
49
|
+
'no-continue': 0,
|
50
|
+
camelcase: 0,
|
51
|
+
'no-unused-vars': 0,
|
52
|
+
'prefer-destructuring': 0,
|
53
|
+
'no-bitwise': 0,
|
54
|
+
'operator-assignment': 0,
|
55
|
+
},
|
56
|
+
settings: {
|
57
|
+
polyfills: ['fetch', 'promises', 'url'],
|
58
|
+
},
|
59
|
+
};
|
package/.prettierrc
ADDED
package/README.md
CHANGED
@@ -1,5 +1,53 @@
|
|
1
|
-
|
1
|
+
商业合作或定制化需求可以联系:yisbug@gmail.com
|
2
2
|
|
3
|
-
|
3
|
+
### 关于
|
4
4
|
|
5
|
-
|
5
|
+
|
6
|
+
这是一个基于 WhatsApp Android 客户端的 WhatsApp 通信协议 SDK,意味着您可以基于这套 SDK 打造任意 WhatsApp 客户端,或者完成一些特定的需求.
|
7
|
+
|
8
|
+
官方最新版本:https://www.whatsapp.com/android/
|
9
|
+
|
10
|
+
目前 SDK 所支持的最新版本:2.22.21.71
|
11
|
+
|
12
|
+
|
13
|
+
TODO:
|
14
|
+
|
15
|
+
- [x] 完成登陆 2022.10.15
|
16
|
+
- [ ] 完成注册 2022.10.31
|
17
|
+
- [ ] 完成收发消息 2022.11.15
|
18
|
+
|
19
|
+
此 SDK 基于 nodejs 开发,同时提供了标准的 socket 接口供其他语言调用。理论上正常的语言都可以调用使用本 SDK。
|
20
|
+
|
21
|
+
环境要求:
|
22
|
+
|
23
|
+
* nodejs: 16.17.1 LTS 版本
|
24
|
+
* mongodb: -
|
25
|
+
* redis: -
|
26
|
+
|
27
|
+
### 使用
|
28
|
+
|
29
|
+
更多示例请参考 `test/whatsapp.test.js`
|
30
|
+
|
31
|
+
``` javascript
|
32
|
+
const Whatsapp = require('./src/whatsapp');
|
33
|
+
|
34
|
+
const main = async()=>{
|
35
|
+
const whatsapp = new Whatsapp();
|
36
|
+
await whatsapp.init({
|
37
|
+
mobile: '',
|
38
|
+
cc:'',
|
39
|
+
mnc:'',
|
40
|
+
mcc:'',
|
41
|
+
proxy:{
|
42
|
+
host: '127.0.0.1',
|
43
|
+
port: 1080
|
44
|
+
}
|
45
|
+
});
|
46
|
+
|
47
|
+
await whatsapp.login();
|
48
|
+
};
|
49
|
+
|
50
|
+
main();
|
51
|
+
|
52
|
+
|
53
|
+
```
|
package/package.json
CHANGED
@@ -1,6 +1,100 @@
|
|
1
1
|
{
|
2
2
|
"name": "whatsapp-nodejs",
|
3
|
-
"version": "0.0.1
|
4
|
-
"description": "
|
5
|
-
"
|
3
|
+
"version": "0.0.1",
|
4
|
+
"description": "This is a library based on whatsapp androd latest version, you can use it build your own app.",
|
5
|
+
"main": "src/index.js",
|
6
|
+
"directories": {
|
7
|
+
"doc": "docs"
|
8
|
+
},
|
9
|
+
"scripts": {
|
10
|
+
"start": "NODE_ENV=production npm run startHttp && npm run startSocket",
|
11
|
+
"startHttp": "NODE_ENV=production egg-scripts start --daemon --title=egg-server-whatsapp",
|
12
|
+
"startSocket": "NODE_ENV=production pm2 start ecosystem.config.js",
|
13
|
+
"dev": "NODE_ENV=development npm run startHttpDev && npm run startSocketDev",
|
14
|
+
"startHttpDev": "NODE_ENV=development egg-scripts start --daemon --title=egg-server-whatsapp",
|
15
|
+
"startSocketDev": "NODE_ENV=development pm2 start socket.js -i max",
|
16
|
+
"stop": "npm run stopHttp && npm run stopSocket",
|
17
|
+
"stopHttp": "egg-scripts stop --title=egg-server-whatsapp",
|
18
|
+
"stopSocket": "pm2 delete all",
|
19
|
+
"reset": "npm run stop && npm run start",
|
20
|
+
"resetHttp": "npm run stopHttp && npm run startHttp",
|
21
|
+
"resetSocket": "pm2 reload all",
|
22
|
+
"npm run log": "tail -f /root/logs/whatsapp/whatsapp-web.log -n 500",
|
23
|
+
"npm run errorlog": "tail -f /root/logs/whatsapp/common-error.log -n 500",
|
24
|
+
"pbjs": "pbjs -t static-module -w commonjs -o src/protobuf/pb.js proto/*.proto",
|
25
|
+
"pub": "sh ./scripts/shell/pubserver.sh",
|
26
|
+
"f": "frida -U --no-pause -f com.whatsapp -l scripts/frida/main.js",
|
27
|
+
"socket": "frida -U --no-pause -f com.whatsapp -l frida/socket.js",
|
28
|
+
"debug": "egg-bin debug",
|
29
|
+
"test1": "npm run lint -- --fix && npm run test-local",
|
30
|
+
"test": "mocha -t 6000000000 -b -w test/*",
|
31
|
+
"test-local": "egg-bin test --watchAll -t 6000000",
|
32
|
+
"cov": "egg-bin cov",
|
33
|
+
"lint": "eslint .",
|
34
|
+
"ci": "npm run lint && npm run cov",
|
35
|
+
"rpc": "egg-rpc-generator",
|
36
|
+
"init": "npm run rpc"
|
37
|
+
},
|
38
|
+
"engines": {
|
39
|
+
"node": ">=16.11.0"
|
40
|
+
},
|
41
|
+
"keywords": [
|
42
|
+
"whatsapp"
|
43
|
+
],
|
44
|
+
"author": "yisbug@gmail.com",
|
45
|
+
"dependencies": {
|
46
|
+
"@privacyresearch/libsignal-protocol-typescript": "0.0.9",
|
47
|
+
"bunyan": "^1.8.15",
|
48
|
+
"bunyan-debug-stream": "^2.0.0",
|
49
|
+
"curve25519-n": "^1.5.0",
|
50
|
+
"egg": "^2.21.1",
|
51
|
+
"egg-bcrypt": "^1.1.0",
|
52
|
+
"egg-cloud": "^0.2.0",
|
53
|
+
"egg-cors": "^2.2.0",
|
54
|
+
"egg-jwt": "^3.1.6",
|
55
|
+
"egg-redis": "^2.4.0",
|
56
|
+
"egg-validate": "^2.0.2",
|
57
|
+
"eggooo": "^1.0.1",
|
58
|
+
"exceljs": "^4.1.1",
|
59
|
+
"fast-xml-parser": "^3.19.0",
|
60
|
+
"fs-extra": "^7.0.1",
|
61
|
+
"got": "^11.8.5",
|
62
|
+
"heapdump": "^0.3.15",
|
63
|
+
"ioredis": "^4.17.3",
|
64
|
+
"mime": "^2.5.2",
|
65
|
+
"moment": "^2.24.0",
|
66
|
+
"mongoose": "^5.10.7",
|
67
|
+
"nodemailer": "^6.1.1",
|
68
|
+
"protobufjs": "^6.11.3",
|
69
|
+
"shelljs": "^0.8.3",
|
70
|
+
"socks-proxy-agent": "^5.0.0",
|
71
|
+
"swig": "^1.4.2",
|
72
|
+
"tunnel": "0.0.6",
|
73
|
+
"uuid": "^7.0.3"
|
74
|
+
},
|
75
|
+
"devDependencies": {
|
76
|
+
"@types/frida-gum": "^16.2.0",
|
77
|
+
"@types/node": "^14.18.23",
|
78
|
+
"babel-eslint": "^10.1.0",
|
79
|
+
"egg-bin": "^4.15.0",
|
80
|
+
"egg-mock": "^4.0.1",
|
81
|
+
"egg-scripts": "^2.13.0",
|
82
|
+
"eslint": "^6.0.1",
|
83
|
+
"eslint-config-airbnb": "^18.2.1",
|
84
|
+
"eslint-config-egg": "^7.3.1",
|
85
|
+
"eslint-config-prettier": "^4.2.0",
|
86
|
+
"eslint-plugin-babel": "^5.3.0",
|
87
|
+
"eslint-plugin-compat": "^3.1.1",
|
88
|
+
"eslint-plugin-import": "^2.22.1",
|
89
|
+
"eslint-plugin-jsx-a11y": "^6.2.1",
|
90
|
+
"eslint-plugin-markdown": "^1.0.0",
|
91
|
+
"eslint-plugin-prettier": "^3.0.1",
|
92
|
+
"eslint-plugin-react": "^7.13.0",
|
93
|
+
"eslint-plugin-react-hooks": "^4.2.0",
|
94
|
+
"frida-compile": "^10.0.0",
|
95
|
+
"mocha": "^8.3.0",
|
96
|
+
"pm2": "^4.5.4",
|
97
|
+
"prettier": "^1.18.2"
|
98
|
+
},
|
99
|
+
"license": "ISC"
|
6
100
|
}
|
@@ -0,0 +1,167 @@
|
|
1
|
+
syntax = "proto2";
|
2
|
+
package ClientHello;
|
3
|
+
|
4
|
+
|
5
|
+
enum UserAgentPlatform
|
6
|
+
{
|
7
|
+
ANDROID = 0;
|
8
|
+
IOS = 1;
|
9
|
+
WINDOWS_PHONE = 2;
|
10
|
+
BLACKBERRY = 3;
|
11
|
+
BLACKBERRYX = 4;
|
12
|
+
S40 = 5;
|
13
|
+
S60 = 6;
|
14
|
+
PYTHON_CLIENT = 7;
|
15
|
+
TIZEN = 8;
|
16
|
+
ENTERPRISE = 9;
|
17
|
+
SMB_ANDROID = 10;
|
18
|
+
KAIOS = 11;
|
19
|
+
SMB_IOS = 12;
|
20
|
+
WINDOWS = 13;
|
21
|
+
WEB = 14;
|
22
|
+
}
|
23
|
+
|
24
|
+
enum ConnectType
|
25
|
+
{
|
26
|
+
CELLULAR_UNKNOWN = 0;
|
27
|
+
WIFI_UNKNOWN = 1;
|
28
|
+
CELLULAR_EDGE = 100;
|
29
|
+
CELLULAR_IDEN = 101;
|
30
|
+
CELLULAR_UMTS = 102;
|
31
|
+
CELLULAR_EVDO = 103;
|
32
|
+
CELLULAR_GPRS = 104;
|
33
|
+
CELLULAR_HSDPA = 105;
|
34
|
+
CELLULAR_HSUPA = 106;
|
35
|
+
CELLULAR_HSPA = 107;
|
36
|
+
CELLULAR_CDMA = 108;
|
37
|
+
CELLULAR_1XRTT = 109;
|
38
|
+
CELLULAR_EHRPD = 110;
|
39
|
+
CELLULAR_LTE = 111;
|
40
|
+
CELLULAR_HSPAP = 112;
|
41
|
+
}
|
42
|
+
|
43
|
+
enum ReleaseChannel{
|
44
|
+
RELEASE = 0;
|
45
|
+
BETA = 1;
|
46
|
+
ALPHA = 2;
|
47
|
+
DEBUG = 3;
|
48
|
+
}
|
49
|
+
|
50
|
+
message AppVersion
|
51
|
+
{
|
52
|
+
required uint32 primary = 1;
|
53
|
+
required uint32 secondary = 2;
|
54
|
+
required uint32 tertiary = 3;
|
55
|
+
optional uint32 quaternary = 4;
|
56
|
+
}
|
57
|
+
|
58
|
+
message UserAgent
|
59
|
+
{
|
60
|
+
optional UserAgentPlatform platform = 1;
|
61
|
+
optional AppVersion app_version = 2;
|
62
|
+
optional string mcc = 3;
|
63
|
+
optional string mnc = 4;
|
64
|
+
optional string os_version = 5;
|
65
|
+
optional string manufacturer = 6;
|
66
|
+
optional string device = 7;
|
67
|
+
optional string os_build_number = 8;
|
68
|
+
optional string phone_id = 9;
|
69
|
+
optional ReleaseChannel release_channel = 10;
|
70
|
+
optional string locale_language_iso_639_1 = 11;
|
71
|
+
optional string locale_country_iso_3166_1_alpha_2 = 12;
|
72
|
+
optional string device2 = 13;
|
73
|
+
}
|
74
|
+
|
75
|
+
message C2S
|
76
|
+
{
|
77
|
+
enum ClientFeature { NONE = 0; }
|
78
|
+
enum ConnectType {
|
79
|
+
UNKNOWN = 0;
|
80
|
+
WIFI = 1;
|
81
|
+
EDGE = 100;
|
82
|
+
IDEN = 101;
|
83
|
+
UMTS = 102;
|
84
|
+
EVDO = 103;
|
85
|
+
GPRS = 104;
|
86
|
+
HSDPA = 105;
|
87
|
+
HSUPA = 106;
|
88
|
+
HSPA = 107;
|
89
|
+
CDMA = 108;
|
90
|
+
ONExRTT = 109;
|
91
|
+
EHRPD = 110;
|
92
|
+
LTE = 111;
|
93
|
+
HSPAP = 112;
|
94
|
+
}
|
95
|
+
enum ConnectReason {
|
96
|
+
PUSH = 0;
|
97
|
+
USER_ACTIVATED = 1;
|
98
|
+
SCHEDULED = 2;
|
99
|
+
ERROR_RECONNECT = 3;
|
100
|
+
NETWORK_SWITCH = 4;
|
101
|
+
PING_RECONNECT = 5;
|
102
|
+
}
|
103
|
+
message DnsSource {
|
104
|
+
enum DnsMethod {
|
105
|
+
METHOD_0 = 0;
|
106
|
+
METHOD_1 = 1;
|
107
|
+
METHOD_2 = 2;
|
108
|
+
METHOD_3 = 3;
|
109
|
+
}
|
110
|
+
|
111
|
+
optional DnsMethod dnsMethod = 15;
|
112
|
+
optional bool appCached = 16;
|
113
|
+
}
|
114
|
+
enum IosAppExtension {
|
115
|
+
EXT_0 = 0;
|
116
|
+
EXT_1 = 1;
|
117
|
+
EXT_2 = 2;
|
118
|
+
}
|
119
|
+
|
120
|
+
message WebInfo {
|
121
|
+
message WebdPayload {
|
122
|
+
optional bool uses_participant_in_key = 1;
|
123
|
+
optional bool supports_starred_messages = 2;
|
124
|
+
optional bool supports_document_messages = 3;
|
125
|
+
optional bool supports_url_messages = 4;
|
126
|
+
optional bool supports_media_retry = 5;
|
127
|
+
optional bool supports_e2e_image = 6;
|
128
|
+
optional bool supports_e2e_video = 7;
|
129
|
+
optional bool supports_e2e_audio = 8;
|
130
|
+
optional bool supports_e2e_document = 9;
|
131
|
+
optional string document_types = 10;
|
132
|
+
}
|
133
|
+
|
134
|
+
optional string ref_token = 1;
|
135
|
+
optional string version = 2;
|
136
|
+
optional WebdPayload webd_payload = 3;
|
137
|
+
}
|
138
|
+
|
139
|
+
message CompanionRegData{
|
140
|
+
optional bytes e_regid = 1;
|
141
|
+
optional bytes e_keytype = 2;
|
142
|
+
optional bytes e_ident = 3;
|
143
|
+
optional bytes e_skey_id = 4;
|
144
|
+
optional bytes e_skey_val = 5;
|
145
|
+
optional bytes e_skey_sig = 6;
|
146
|
+
optional bytes build_hash = 7;
|
147
|
+
optional bytes companion_props = 8;
|
148
|
+
}
|
149
|
+
|
150
|
+
optional uint64 username = 1;
|
151
|
+
optional bool passive = 3;
|
152
|
+
repeated ClientFeature client_features = 4;
|
153
|
+
optional UserAgent useragent = 5;
|
154
|
+
optional WebInfo web_info = 6;
|
155
|
+
optional string push_name = 7;
|
156
|
+
optional sfixed32 session_id = 9;
|
157
|
+
optional bool short_connect = 10;
|
158
|
+
optional ConnectType connect_type = 12;
|
159
|
+
optional ConnectReason connect_reason = 13;
|
160
|
+
repeated sfixed32 shards = 14;
|
161
|
+
optional DnsSource dns_source = 15;
|
162
|
+
optional uint32 connect_attempt_count = 16;
|
163
|
+
optional CompanionRegData reg_data = 19;
|
164
|
+
optional uint32 tag23 = 23;
|
165
|
+
optional uint32 tag24 = 24;
|
166
|
+
optional IosAppExtension ios_app_extension = 30;
|
167
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
syntax = "proto2";
|
2
|
+
package HandshakeMessage;
|
3
|
+
|
4
|
+
|
5
|
+
message ClientHello {
|
6
|
+
optional bytes ephemeral = 1;
|
7
|
+
optional bytes static = 2;
|
8
|
+
optional bytes payload = 3;
|
9
|
+
}
|
10
|
+
|
11
|
+
message ServerHello {
|
12
|
+
optional bytes ephemeral = 1;
|
13
|
+
optional bytes static = 2;
|
14
|
+
optional bytes payload = 3;
|
15
|
+
}
|
16
|
+
|
17
|
+
message ClientFinish{
|
18
|
+
optional bytes static = 1;
|
19
|
+
optional bytes payload = 2;
|
20
|
+
}
|
21
|
+
|
22
|
+
message HandshakeMessage{
|
23
|
+
optional ClientHello client_hello = 2;
|
24
|
+
optional ServerHello server_hello = 3;
|
25
|
+
optional ClientFinish client_finish = 4;
|
26
|
+
}
|