pidms-cli 1.0.1 → 1.0.2
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/index.js +5 -3
- package/machine-id.js +31 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* pidms - Microsoft Product Key Inspector SDK
|
|
3
3
|
*
|
|
4
|
-
* Maintained by ActvKey (https://actvkey.com)
|
|
5
4
|
* Powered by CID Portal (https://cidportal.win)
|
|
6
5
|
* License: MIT
|
|
7
6
|
*/
|
|
8
7
|
|
|
9
8
|
const https = require('https');
|
|
9
|
+
const { getMachineId } = require('./machine-id');
|
|
10
10
|
|
|
11
11
|
function sanitizeKey(rawKey) {
|
|
12
12
|
if (!rawKey || typeof rawKey !== 'string') return '';
|
|
@@ -33,7 +33,8 @@ function checkKeys(keysArray) {
|
|
|
33
33
|
headers: {
|
|
34
34
|
'Content-Type': 'application/json',
|
|
35
35
|
'Content-Length': Buffer.byteLength(payload),
|
|
36
|
-
'
|
|
36
|
+
'X-Device-ID': getMachineId(), // Auto-creates CLI#001 in Key Vault!
|
|
37
|
+
'User-Agent': 'pidms-cli/1.0.2 (Node.js)'
|
|
37
38
|
},
|
|
38
39
|
timeout: 15000
|
|
39
40
|
}, (res) => {
|
|
@@ -72,5 +73,6 @@ async function checkKey(singleKey) {
|
|
|
72
73
|
module.exports = {
|
|
73
74
|
sanitizeKey,
|
|
74
75
|
checkKey,
|
|
75
|
-
checkKeys
|
|
76
|
+
checkKeys,
|
|
77
|
+
getMachineId
|
|
76
78
|
};
|
package/machine-id.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const { execSync } = require('child_process');
|
|
2
|
+
const crypto = require('crypto');
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const os = require('os');
|
|
5
|
+
|
|
6
|
+
function getMachineId() {
|
|
7
|
+
try {
|
|
8
|
+
if (process.platform === 'win32') {
|
|
9
|
+
const out = execSync('reg query "HKLM\\SOFTWARE\\Microsoft\\Cryptography" /v MachineGuid', { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] });
|
|
10
|
+
const match = out.match(/MachineGuid\s+REG_SZ\s+([a-zA-Z0-9-]+)/i);
|
|
11
|
+
if (match && match[1]) {
|
|
12
|
+
return crypto.createHash('sha256').update(match[1].trim()).digest('hex');
|
|
13
|
+
}
|
|
14
|
+
} else if (process.platform === 'linux') {
|
|
15
|
+
const id = fs.existsSync('/etc/machine-id')
|
|
16
|
+
? fs.readFileSync('/etc/machine-id', 'utf8')
|
|
17
|
+
: fs.readFileSync('/var/lib/dbus/machine-id', 'utf8');
|
|
18
|
+
return crypto.createHash('sha256').update(id.trim()).digest('hex');
|
|
19
|
+
} else if (process.platform === 'darwin') {
|
|
20
|
+
const out = execSync('ioreg -rd1 -c IOPlatformExpertDevice', { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] });
|
|
21
|
+
const match = out.match(/"IOPlatformUUID"\s*=\s*"([^"]+)"/i);
|
|
22
|
+
if (match && match[1]) {
|
|
23
|
+
return crypto.createHash('sha256').update(match[1].trim()).digest('hex');
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
} catch (e) {}
|
|
27
|
+
const fallbackStr = os.hostname() + os.homedir() + (os.cpus()[0]?.model || 'cpu');
|
|
28
|
+
return crypto.createHash('sha256').update(fallbackStr).digest('hex');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
module.exports = { getMachineId };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pidms-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Fast, lightweight CLI & SDK to inspect Microsoft Windows & Office product keys, detect license channels (Retail, OEM, Volume:MAK), and verify activation status.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|