mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-12-25 22:55:52 -05:00
Fixed Web Power Switch nonce counter
This commit is contained in:
parent
c10964d892
commit
606c8d2d7b
@ -756,6 +756,7 @@ function CreateWebPowerSwitch(parent, hostname, port, username, password) {
|
|||||||
var retryTimer = null;
|
var retryTimer = null;
|
||||||
var challenge = null;
|
var challenge = null;
|
||||||
var challengeRetry = 0;
|
var challengeRetry = 0;
|
||||||
|
var nonceCounter = 1;
|
||||||
|
|
||||||
obj.state = 0; // 0 = Disconnected, 1 = Connecting, 2 = Connected
|
obj.state = 0; // 0 = Disconnected, 1 = Connecting, 2 = Connected
|
||||||
obj.ports = [];
|
obj.ports = [];
|
||||||
@ -872,7 +873,7 @@ function CreateWebPowerSwitch(parent, hostname, port, username, password) {
|
|||||||
if (challenge != null) {
|
if (challenge != null) {
|
||||||
const buf = Buffer.alloc(10);
|
const buf = Buffer.alloc(10);
|
||||||
challenge.cnonce = crypto.randomFillSync(buf).toString('hex');
|
challenge.cnonce = crypto.randomFillSync(buf).toString('hex');
|
||||||
challenge.nc = '00000001';
|
challenge.nc = nonceCounter++;
|
||||||
const ha1 = crypto.createHash('md5');
|
const ha1 = crypto.createHash('md5');
|
||||||
ha1.update([username, challenge.realm, password].join(':'));
|
ha1.update([username, challenge.realm, password].join(':'));
|
||||||
var xha1 = ha1.digest('hex')
|
var xha1 = ha1.digest('hex')
|
||||||
@ -886,7 +887,7 @@ function CreateWebPowerSwitch(parent, hostname, port, username, password) {
|
|||||||
"realm": challenge.realm,
|
"realm": challenge.realm,
|
||||||
"nonce": challenge.nonce,
|
"nonce": challenge.nonce,
|
||||||
"uri": options.path,
|
"uri": options.path,
|
||||||
"response": response.digest("hex"),
|
"response": response.digest('hex'),
|
||||||
"cnonce": challenge.cnonce,
|
"cnonce": challenge.cnonce,
|
||||||
"opaque": challenge.opaque
|
"opaque": challenge.opaque
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user