@electerm/ssh2 1.14.0 → 1.16.1
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/lib/client.js +6 -18
- package/lib/protocol/Protocol.js +9 -2
- package/lib/protocol/SFTP.js +1 -1
- package/lib/protocol/crypto/build/Makefile +347 -0
- package/lib/protocol/crypto/build/Release/.deps/Release/obj.target/sshcrypto/src/binding.o.d +247 -0
- package/lib/protocol/crypto/build/Release/.deps/Release/sshcrypto.node.d +1 -0
- package/lib/protocol/crypto/build/Release/obj.target/sshcrypto/src/binding.o +0 -0
- package/lib/protocol/crypto/build/Release/sshcrypto.node +0 -0
- package/lib/protocol/crypto/build/binding.Makefile +6 -0
- package/lib/protocol/crypto/build/gyp-mac-tool +772 -0
- package/lib/protocol/crypto/build/sshcrypto.target.mk +194 -0
- package/lib/protocol/kex.js +45 -6
- package/lib/protocol/keyParser.js +1 -1
- package/lib/protocol/zlib.js +6 -2
- package/lib/server.js +5 -1
- package/package.json +6 -3
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
# This file is generated by gyp; do not edit.
|
|
2
|
+
|
|
3
|
+
TOOLSET := target
|
|
4
|
+
TARGET := sshcrypto
|
|
5
|
+
DEFS_Debug := \
|
|
6
|
+
'-DNODE_GYP_MODULE_NAME=sshcrypto' \
|
|
7
|
+
'-DUSING_UV_SHARED=1' \
|
|
8
|
+
'-DUSING_V8_SHARED=1' \
|
|
9
|
+
'-DV8_DEPRECATION_WARNINGS=1' \
|
|
10
|
+
'-DV8_DEPRECATION_WARNINGS' \
|
|
11
|
+
'-DV8_IMMINENT_DEPRECATION_WARNINGS' \
|
|
12
|
+
'-D_GLIBCXX_USE_CXX11_ABI=1' \
|
|
13
|
+
'-D_DARWIN_USE_64_BIT_INODE=1' \
|
|
14
|
+
'-D_LARGEFILE_SOURCE' \
|
|
15
|
+
'-D_FILE_OFFSET_BITS=64' \
|
|
16
|
+
'-DOPENSSL_NO_PINSHARED' \
|
|
17
|
+
'-DOPENSSL_THREADS' \
|
|
18
|
+
'-DOPENSSL_API_COMPAT=0x10100000L' \
|
|
19
|
+
'-DREAL_OPENSSL_MAJOR=3' \
|
|
20
|
+
'-DBUILDING_NODE_EXTENSION' \
|
|
21
|
+
'-DDEBUG' \
|
|
22
|
+
'-D_DEBUG' \
|
|
23
|
+
'-DV8_ENABLE_CHECKS'
|
|
24
|
+
|
|
25
|
+
# Flags passed to all source files.
|
|
26
|
+
CFLAGS_Debug := \
|
|
27
|
+
-O0 \
|
|
28
|
+
-gdwarf-2 \
|
|
29
|
+
-mmacosx-version-min=10.15 \
|
|
30
|
+
-arch x86_64 \
|
|
31
|
+
-Wall \
|
|
32
|
+
-Wendif-labels \
|
|
33
|
+
-W \
|
|
34
|
+
-Wno-unused-parameter
|
|
35
|
+
|
|
36
|
+
# Flags passed to only C files.
|
|
37
|
+
CFLAGS_C_Debug := \
|
|
38
|
+
-fno-strict-aliasing
|
|
39
|
+
|
|
40
|
+
# Flags passed to only C++ files.
|
|
41
|
+
CFLAGS_CC_Debug := \
|
|
42
|
+
-std=gnu++17 \
|
|
43
|
+
-stdlib=libc++ \
|
|
44
|
+
-fno-rtti \
|
|
45
|
+
-fno-exceptions \
|
|
46
|
+
-fno-strict-aliasing
|
|
47
|
+
|
|
48
|
+
# Flags passed to only ObjC files.
|
|
49
|
+
CFLAGS_OBJC_Debug :=
|
|
50
|
+
|
|
51
|
+
# Flags passed to only ObjC++ files.
|
|
52
|
+
CFLAGS_OBJCC_Debug :=
|
|
53
|
+
|
|
54
|
+
INCS_Debug := \
|
|
55
|
+
-I/Users/home/Library/Caches/node-gyp/18.17.1/include/node \
|
|
56
|
+
-I/Users/home/Library/Caches/node-gyp/18.17.1/src \
|
|
57
|
+
-I/Users/home/Library/Caches/node-gyp/18.17.1/deps/openssl/config \
|
|
58
|
+
-I/Users/home/Library/Caches/node-gyp/18.17.1/deps/openssl/openssl/include \
|
|
59
|
+
-I/Users/home/Library/Caches/node-gyp/18.17.1/deps/uv/include \
|
|
60
|
+
-I/Users/home/Library/Caches/node-gyp/18.17.1/deps/zlib \
|
|
61
|
+
-I/Users/home/Library/Caches/node-gyp/18.17.1/deps/v8/include \
|
|
62
|
+
-I$(srcdir)/../../../node_modules/nan
|
|
63
|
+
|
|
64
|
+
DEFS_Release := \
|
|
65
|
+
'-DNODE_GYP_MODULE_NAME=sshcrypto' \
|
|
66
|
+
'-DUSING_UV_SHARED=1' \
|
|
67
|
+
'-DUSING_V8_SHARED=1' \
|
|
68
|
+
'-DV8_DEPRECATION_WARNINGS=1' \
|
|
69
|
+
'-DV8_DEPRECATION_WARNINGS' \
|
|
70
|
+
'-DV8_IMMINENT_DEPRECATION_WARNINGS' \
|
|
71
|
+
'-D_GLIBCXX_USE_CXX11_ABI=1' \
|
|
72
|
+
'-D_DARWIN_USE_64_BIT_INODE=1' \
|
|
73
|
+
'-D_LARGEFILE_SOURCE' \
|
|
74
|
+
'-D_FILE_OFFSET_BITS=64' \
|
|
75
|
+
'-DOPENSSL_NO_PINSHARED' \
|
|
76
|
+
'-DOPENSSL_THREADS' \
|
|
77
|
+
'-DOPENSSL_API_COMPAT=0x10100000L' \
|
|
78
|
+
'-DREAL_OPENSSL_MAJOR=3' \
|
|
79
|
+
'-DBUILDING_NODE_EXTENSION'
|
|
80
|
+
|
|
81
|
+
# Flags passed to all source files.
|
|
82
|
+
CFLAGS_Release := \
|
|
83
|
+
-O3 \
|
|
84
|
+
-gdwarf-2 \
|
|
85
|
+
-mmacosx-version-min=10.15 \
|
|
86
|
+
-arch x86_64 \
|
|
87
|
+
-Wall \
|
|
88
|
+
-Wendif-labels \
|
|
89
|
+
-W \
|
|
90
|
+
-Wno-unused-parameter
|
|
91
|
+
|
|
92
|
+
# Flags passed to only C files.
|
|
93
|
+
CFLAGS_C_Release := \
|
|
94
|
+
-fno-strict-aliasing
|
|
95
|
+
|
|
96
|
+
# Flags passed to only C++ files.
|
|
97
|
+
CFLAGS_CC_Release := \
|
|
98
|
+
-std=gnu++17 \
|
|
99
|
+
-stdlib=libc++ \
|
|
100
|
+
-fno-rtti \
|
|
101
|
+
-fno-exceptions \
|
|
102
|
+
-fno-strict-aliasing
|
|
103
|
+
|
|
104
|
+
# Flags passed to only ObjC files.
|
|
105
|
+
CFLAGS_OBJC_Release :=
|
|
106
|
+
|
|
107
|
+
# Flags passed to only ObjC++ files.
|
|
108
|
+
CFLAGS_OBJCC_Release :=
|
|
109
|
+
|
|
110
|
+
INCS_Release := \
|
|
111
|
+
-I/Users/home/Library/Caches/node-gyp/18.17.1/include/node \
|
|
112
|
+
-I/Users/home/Library/Caches/node-gyp/18.17.1/src \
|
|
113
|
+
-I/Users/home/Library/Caches/node-gyp/18.17.1/deps/openssl/config \
|
|
114
|
+
-I/Users/home/Library/Caches/node-gyp/18.17.1/deps/openssl/openssl/include \
|
|
115
|
+
-I/Users/home/Library/Caches/node-gyp/18.17.1/deps/uv/include \
|
|
116
|
+
-I/Users/home/Library/Caches/node-gyp/18.17.1/deps/zlib \
|
|
117
|
+
-I/Users/home/Library/Caches/node-gyp/18.17.1/deps/v8/include \
|
|
118
|
+
-I$(srcdir)/../../../node_modules/nan
|
|
119
|
+
|
|
120
|
+
OBJS := \
|
|
121
|
+
$(obj).target/$(TARGET)/src/binding.o
|
|
122
|
+
|
|
123
|
+
# Add to the list of files we specially track dependencies for.
|
|
124
|
+
all_deps += $(OBJS)
|
|
125
|
+
|
|
126
|
+
# CFLAGS et al overrides must be target-local.
|
|
127
|
+
# See "Target-specific Variable Values" in the GNU Make manual.
|
|
128
|
+
$(OBJS): TOOLSET := $(TOOLSET)
|
|
129
|
+
$(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE))
|
|
130
|
+
$(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE))
|
|
131
|
+
$(OBJS): GYP_OBJCFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) $(CFLAGS_OBJC_$(BUILDTYPE))
|
|
132
|
+
$(OBJS): GYP_OBJCXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) $(CFLAGS_OBJCC_$(BUILDTYPE))
|
|
133
|
+
|
|
134
|
+
# Suffix rules, putting all outputs into $(obj).
|
|
135
|
+
|
|
136
|
+
$(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD
|
|
137
|
+
@$(call do_cmd,cxx,1)
|
|
138
|
+
|
|
139
|
+
# Try building from generated source, too.
|
|
140
|
+
|
|
141
|
+
$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD
|
|
142
|
+
@$(call do_cmd,cxx,1)
|
|
143
|
+
|
|
144
|
+
$(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.cc FORCE_DO_CMD
|
|
145
|
+
@$(call do_cmd,cxx,1)
|
|
146
|
+
|
|
147
|
+
# End of this set of suffix rules
|
|
148
|
+
### Rules for final target.
|
|
149
|
+
LDFLAGS_Debug := \
|
|
150
|
+
-undefined dynamic_lookup \
|
|
151
|
+
-Wl,-search_paths_first \
|
|
152
|
+
-mmacosx-version-min=10.15 \
|
|
153
|
+
-arch x86_64 \
|
|
154
|
+
-L$(builddir) \
|
|
155
|
+
-stdlib=libc++
|
|
156
|
+
|
|
157
|
+
LIBTOOLFLAGS_Debug := \
|
|
158
|
+
-undefined dynamic_lookup \
|
|
159
|
+
-Wl,-search_paths_first
|
|
160
|
+
|
|
161
|
+
LDFLAGS_Release := \
|
|
162
|
+
-undefined dynamic_lookup \
|
|
163
|
+
-Wl,-search_paths_first \
|
|
164
|
+
-mmacosx-version-min=10.15 \
|
|
165
|
+
-arch x86_64 \
|
|
166
|
+
-L$(builddir) \
|
|
167
|
+
-stdlib=libc++
|
|
168
|
+
|
|
169
|
+
LIBTOOLFLAGS_Release := \
|
|
170
|
+
-undefined dynamic_lookup \
|
|
171
|
+
-Wl,-search_paths_first
|
|
172
|
+
|
|
173
|
+
LIBS :=
|
|
174
|
+
|
|
175
|
+
$(builddir)/sshcrypto.node: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE))
|
|
176
|
+
$(builddir)/sshcrypto.node: LIBS := $(LIBS)
|
|
177
|
+
$(builddir)/sshcrypto.node: GYP_LIBTOOLFLAGS := $(LIBTOOLFLAGS_$(BUILDTYPE))
|
|
178
|
+
$(builddir)/sshcrypto.node: TOOLSET := $(TOOLSET)
|
|
179
|
+
$(builddir)/sshcrypto.node: $(OBJS) FORCE_DO_CMD
|
|
180
|
+
$(call do_cmd,solink_module)
|
|
181
|
+
|
|
182
|
+
all_deps += $(builddir)/sshcrypto.node
|
|
183
|
+
# Add target alias
|
|
184
|
+
.PHONY: sshcrypto
|
|
185
|
+
sshcrypto: $(builddir)/sshcrypto.node
|
|
186
|
+
|
|
187
|
+
# Short alias for building this executable.
|
|
188
|
+
.PHONY: sshcrypto.node
|
|
189
|
+
sshcrypto.node: $(builddir)/sshcrypto.node
|
|
190
|
+
|
|
191
|
+
# Add executable to "all" target.
|
|
192
|
+
.PHONY: all
|
|
193
|
+
all: $(builddir)/sshcrypto.node
|
|
194
|
+
|
package/lib/protocol/kex.js
CHANGED
|
@@ -232,13 +232,37 @@ function handleKexInit(self, payload) {
|
|
|
232
232
|
clientList = localKex;
|
|
233
233
|
remoteExtInfoEnabled = (serverList.indexOf('ext-info-s') !== -1);
|
|
234
234
|
}
|
|
235
|
+
if (self._strictMode === undefined) {
|
|
236
|
+
if (self._server) {
|
|
237
|
+
self._strictMode =
|
|
238
|
+
(clientList.indexOf('kex-strict-c-v00@openssh.com') !== -1);
|
|
239
|
+
} else {
|
|
240
|
+
self._strictMode =
|
|
241
|
+
(serverList.indexOf('kex-strict-s-v00@openssh.com') !== -1);
|
|
242
|
+
}
|
|
243
|
+
// Note: We check for seqno of 1 instead of 0 since we increment before
|
|
244
|
+
// calling the packet handler
|
|
245
|
+
if (self._strictMode) {
|
|
246
|
+
debug && debug('Handshake: strict KEX mode enabled');
|
|
247
|
+
if (self._decipher.inSeqno !== 1) {
|
|
248
|
+
if (debug)
|
|
249
|
+
debug('Handshake: KEXINIT not first packet in strict KEX mode');
|
|
250
|
+
return doFatalError(
|
|
251
|
+
self,
|
|
252
|
+
'Handshake failed: KEXINIT not first packet in strict KEX mode',
|
|
253
|
+
'handshake',
|
|
254
|
+
DISCONNECT_REASON.KEY_EXCHANGE_FAILED
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
235
259
|
// Check for agreeable key exchange algorithm
|
|
236
260
|
for (i = 0;
|
|
237
261
|
i < clientList.length && serverList.indexOf(clientList[i]) === -1;
|
|
238
262
|
++i);
|
|
239
263
|
if (i === clientList.length) {
|
|
240
264
|
// No suitable match found!
|
|
241
|
-
debug && debug('Handshake:
|
|
265
|
+
debug && debug('Handshake: no matching key exchange algorithm');
|
|
242
266
|
return doFatalError(
|
|
243
267
|
self,
|
|
244
268
|
'Handshake failed: no matching key exchange algorithm',
|
|
@@ -1236,6 +1260,8 @@ const createKeyExchange = (() => {
|
|
|
1236
1260
|
'Inbound: NEWKEYS'
|
|
1237
1261
|
);
|
|
1238
1262
|
this._receivedNEWKEYS = true;
|
|
1263
|
+
if (this._protocol._strictMode)
|
|
1264
|
+
this._protocol._decipher.inSeqno = 0;
|
|
1239
1265
|
++this._step;
|
|
1240
1266
|
|
|
1241
1267
|
return this.finish(!this._protocol._server && !this._hostVerified);
|
|
@@ -1756,11 +1782,20 @@ function onKEXPayload(state, payload) {
|
|
|
1756
1782
|
payload = this._packetRW.read.read(payload);
|
|
1757
1783
|
|
|
1758
1784
|
const type = payload[0];
|
|
1785
|
+
|
|
1786
|
+
if (!this._strictMode) {
|
|
1787
|
+
switch (type) {
|
|
1788
|
+
case MESSAGE.IGNORE:
|
|
1789
|
+
case MESSAGE.UNIMPLEMENTED:
|
|
1790
|
+
case MESSAGE.DEBUG:
|
|
1791
|
+
if (!MESSAGE_HANDLERS)
|
|
1792
|
+
MESSAGE_HANDLERS = require('./handlers.js');
|
|
1793
|
+
return MESSAGE_HANDLERS[type](this, payload);
|
|
1794
|
+
}
|
|
1795
|
+
}
|
|
1796
|
+
|
|
1759
1797
|
switch (type) {
|
|
1760
1798
|
case MESSAGE.DISCONNECT:
|
|
1761
|
-
case MESSAGE.IGNORE:
|
|
1762
|
-
case MESSAGE.UNIMPLEMENTED:
|
|
1763
|
-
case MESSAGE.DEBUG:
|
|
1764
1799
|
if (!MESSAGE_HANDLERS)
|
|
1765
1800
|
MESSAGE_HANDLERS = require('./handlers.js');
|
|
1766
1801
|
return MESSAGE_HANDLERS[type](this, payload);
|
|
@@ -1776,6 +1811,8 @@ function onKEXPayload(state, payload) {
|
|
|
1776
1811
|
state.firstPacket = false;
|
|
1777
1812
|
return handleKexInit(this, payload);
|
|
1778
1813
|
default:
|
|
1814
|
+
// Ensure packet is either an algorithm negotiation or KEX
|
|
1815
|
+
// algorithm-specific packet
|
|
1779
1816
|
if (type < 20 || type > 49) {
|
|
1780
1817
|
return doFatalError(
|
|
1781
1818
|
this,
|
|
@@ -1824,6 +1861,8 @@ function trySendNEWKEYS(kex) {
|
|
|
1824
1861
|
kex._protocol._packetRW.write.finalize(packet, true)
|
|
1825
1862
|
);
|
|
1826
1863
|
kex._sentNEWKEYS = true;
|
|
1864
|
+
if (kex._protocol._strictMode)
|
|
1865
|
+
kex._protocol._cipher.outSeqno = 0;
|
|
1827
1866
|
}
|
|
1828
1867
|
}
|
|
1829
1868
|
|
|
@@ -1832,7 +1871,7 @@ module.exports = {
|
|
|
1832
1871
|
kexinit,
|
|
1833
1872
|
onKEXPayload,
|
|
1834
1873
|
DEFAULT_KEXINIT_CLIENT: new KexInit({
|
|
1835
|
-
kex: DEFAULT_KEX.concat(['ext-info-c']),
|
|
1874
|
+
kex: DEFAULT_KEX.concat(['ext-info-c', 'kex-strict-c-v00@openssh.com']),
|
|
1836
1875
|
serverHostKey: DEFAULT_SERVER_HOST_KEY,
|
|
1837
1876
|
cs: {
|
|
1838
1877
|
cipher: DEFAULT_CIPHER,
|
|
@@ -1848,7 +1887,7 @@ module.exports = {
|
|
|
1848
1887
|
},
|
|
1849
1888
|
}),
|
|
1850
1889
|
DEFAULT_KEXINIT_SERVER: new KexInit({
|
|
1851
|
-
kex: DEFAULT_KEX,
|
|
1890
|
+
kex: DEFAULT_KEX.concat(['kex-strict-s-v00@openssh.com']),
|
|
1852
1891
|
serverHostKey: DEFAULT_SERVER_HOST_KEY,
|
|
1853
1892
|
cs: {
|
|
1854
1893
|
cipher: DEFAULT_CIPHER,
|
|
@@ -446,7 +446,7 @@ const BaseKey = {
|
|
|
446
446
|
this.type === parsed.type
|
|
447
447
|
&& this[SYM_PRIV_PEM] === parsed[SYM_PRIV_PEM]
|
|
448
448
|
&& this[SYM_PUB_PEM] === parsed[SYM_PUB_PEM]
|
|
449
|
-
&& this[SYM_PUB_SSH]
|
|
449
|
+
&& this[SYM_PUB_SSH].equals(parsed[SYM_PUB_SSH])
|
|
450
450
|
);
|
|
451
451
|
},
|
|
452
452
|
};
|
package/lib/protocol/zlib.js
CHANGED
|
@@ -69,8 +69,9 @@ class Zlib {
|
|
|
69
69
|
|
|
70
70
|
writeSync(chunk, retChunks) {
|
|
71
71
|
const handle = this._handle;
|
|
72
|
-
if (!handle)
|
|
73
|
-
|
|
72
|
+
if (!handle) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
74
75
|
|
|
75
76
|
let availInBefore = chunk.length;
|
|
76
77
|
let availOutBefore = this._chunkSize - this._outOffset;
|
|
@@ -188,6 +189,9 @@ class ZlibPacketWriter {
|
|
|
188
189
|
finalize(payload, force) {
|
|
189
190
|
if (this._protocol._kexinit === undefined || force) {
|
|
190
191
|
const output = this._zlib.writeSync(payload, true);
|
|
192
|
+
if (!output) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
191
195
|
const packet = this._protocol._cipher.allocPacket(output.totalLen);
|
|
192
196
|
if (output.push === undefined) {
|
|
193
197
|
packet.set(output, 5);
|
package/lib/server.js
CHANGED
|
@@ -294,7 +294,11 @@ class Server extends EventEmitter {
|
|
|
294
294
|
}
|
|
295
295
|
|
|
296
296
|
const algorithms = {
|
|
297
|
-
kex: generateAlgorithmList(
|
|
297
|
+
kex: generateAlgorithmList(
|
|
298
|
+
cfgAlgos.kex,
|
|
299
|
+
DEFAULT_KEX,
|
|
300
|
+
SUPPORTED_KEX
|
|
301
|
+
).concat(['kex-strict-s-v00@openssh.com']),
|
|
298
302
|
serverHostKey: hostKeyAlgoOrder,
|
|
299
303
|
cs: {
|
|
300
304
|
cipher: generateAlgorithmList(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@electerm/ssh2",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.16.1",
|
|
4
4
|
"author": "Brian White <mscdex@mscdex.net>",
|
|
5
5
|
"description": "SSH2 client and server modules written in pure JavaScript for node.js",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -13,8 +13,11 @@
|
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@mscdex/eslint-config": "^1.1.0",
|
|
16
|
-
"eslint": "^7.32.0"
|
|
17
|
-
|
|
16
|
+
"eslint": "^7.32.0"
|
|
17
|
+
},
|
|
18
|
+
"optionalDependencies": {
|
|
19
|
+
"cpu-features": "~0.0.10",
|
|
20
|
+
"nan": "^2.20.0"
|
|
18
21
|
},
|
|
19
22
|
"scripts": {
|
|
20
23
|
"install": "node install.js",
|