spoof-d 0.5.1 → 0.5.3

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/README.md CHANGED
@@ -62,6 +62,12 @@ This repository ([TT5H/spoof-d](https://github.com/TT5H/spoof-d)) is a fork of [
62
62
  - **DUID (DHCPv6) spoofing** for complete IPv6 network identity management
63
63
  - **Automatic verification** of DUID changes with retry logic
64
64
 
65
+ ## Requirements
66
+
67
+ - **Node.js**: Version 12.0.0 or higher
68
+ - **Operating System**: macOS, Windows 10/11, or Linux
69
+ - **Privileges**: Administrator/root access required for MAC and DUID changes
70
+
65
71
  ## Installation
66
72
 
67
73
  ### From npm (recommended)
@@ -368,7 +374,6 @@ sudo spoofy duid reset en0
368
374
  | 3 | DUID-LL | Link-layer address only (default) |
369
375
  | 4 | DUID-UUID | UUID-based identifier |
370
376
 
371
- <<<<<<< HEAD
372
377
  ### Show detailed interface information
373
378
 
374
379
  ```bash
package/index.js CHANGED
@@ -127,12 +127,31 @@ function execWithTimeout(command, options = {}, timeout = 30000) {
127
127
  }
128
128
  }
129
129
 
130
+ /**
131
+ * Synchronous sleep using Atomics.wait (non-blocking alternative to busy-wait)
132
+ * Falls back to busy-wait only if SharedArrayBuffer is not available
133
+ * @param {number} ms - Milliseconds to sleep
134
+ */
135
+ function sleepSync(ms) {
136
+ if (typeof SharedArrayBuffer !== 'undefined') {
137
+ const sab = new SharedArrayBuffer(4);
138
+ const int32 = new Int32Array(sab);
139
+ Atomics.wait(int32, 0, 0, ms);
140
+ } else {
141
+ // Fallback for environments without SharedArrayBuffer
142
+ const end = Date.now() + ms;
143
+ while (Date.now() < end) {
144
+ // Busy wait fallback
145
+ }
146
+ }
147
+ }
148
+
130
149
  /**
131
150
  * Retries a function with exponential backoff
132
151
  * @param {Function} fn
133
152
  * @param {number} maxRetries
134
153
  * @param {number} delay
135
- * @return {Promise}
154
+ * @return {any}
136
155
  */
137
156
  function retry(fn, maxRetries = 3, delay = 500) {
138
157
  let lastError;
@@ -143,11 +162,7 @@ function retry(fn, maxRetries = 3, delay = 500) {
143
162
  lastError = err;
144
163
  if (i < maxRetries - 1) {
145
164
  const waitTime = delay * Math.pow(2, i);
146
- // Simple sleep for sync operations
147
- const start = Date.now();
148
- while (Date.now() - start < waitTime) {
149
- // Busy wait
150
- }
165
+ sleepSync(waitTime);
151
166
  }
152
167
  }
153
168
  }
package/lib/duid.js CHANGED
@@ -939,6 +939,25 @@ function getCurrentDUID () {
939
939
  return getPlatformImpl().getCurrentDUID()
940
940
  }
941
941
 
942
+ /**
943
+ * Synchronous sleep using Atomics.wait (non-blocking alternative to busy-wait)
944
+ * Falls back to busy-wait only if SharedArrayBuffer is not available
945
+ * @param {number} ms - Milliseconds to sleep
946
+ */
947
+ function sleepSync (ms) {
948
+ if (typeof SharedArrayBuffer !== 'undefined') {
949
+ const sab = new SharedArrayBuffer(4)
950
+ const int32 = new Int32Array(sab)
951
+ Atomics.wait(int32, 0, 0, ms)
952
+ } else {
953
+ // Fallback for environments without SharedArrayBuffer
954
+ const end = Date.now() + ms
955
+ while (Date.now() < end) {
956
+ // Busy wait fallback
957
+ }
958
+ }
959
+ }
960
+
942
961
  /**
943
962
  * Retries a function with exponential backoff (sync version)
944
963
  * @param {Function} fn
@@ -955,11 +974,7 @@ function retry (fn, maxRetries = 3, delay = 500) {
955
974
  lastError = err
956
975
  if (i < maxRetries - 1) {
957
976
  const waitTime = delay * Math.pow(2, i)
958
- // Simple sleep for sync operations
959
- const start = Date.now()
960
- while (Date.now() - start < waitTime) {
961
- // Busy wait
962
- }
977
+ sleepSync(waitTime)
963
978
  }
964
979
  }
965
980
  }
@@ -997,10 +1012,7 @@ function setDUID (duid, iface = null, verify = true) {
997
1012
  const { execSync } = require('child_process')
998
1013
  try {
999
1014
  // Wait a bit longer for DHCP client to pick up the change
1000
- const start = Date.now()
1001
- while (Date.now() - start < 2000) {
1002
- // Wait 2 seconds
1003
- }
1015
+ sleepSync(2000)
1004
1016
  newDuid = getCurrentDUID()
1005
1017
  } catch (e) {
1006
1018
  // If still can't verify, throw error
@@ -1070,10 +1082,7 @@ function restoreDUID (iface = null, verify = true) {
1070
1082
  }, 3, 1000)
1071
1083
  } catch (err) {
1072
1084
  // Wait a bit longer and try once more
1073
- const start = Date.now()
1074
- while (Date.now() - start < 2000) {
1075
- // Wait 2 seconds
1076
- }
1085
+ sleepSync(2000)
1077
1086
  newDuid = getCurrentDUID()
1078
1087
  if (!newDuid) {
1079
1088
  throw new Error(
package/lib/history.js CHANGED
@@ -19,8 +19,13 @@ function getHistory() {
19
19
  function saveHistory(history) {
20
20
  try {
21
21
  fs.writeFileSync(HISTORY_FILE, JSON.stringify(history, null, 2), "utf8");
22
+ return true;
22
23
  } catch (err) {
23
- // Silently fail if we can't write history
24
+ // Log warning if we can't write history (only in verbose mode or if DEBUG is set)
25
+ if (process.env.DEBUG || process.env.SPOOFY_VERBOSE) {
26
+ console.warn(`Warning: Could not save history to ${HISTORY_FILE}: ${err.message}`);
27
+ }
28
+ return false;
24
29
  }
25
30
  }
26
31
 
package/lib/oui.js CHANGED
@@ -3,6 +3,7 @@
3
3
  // This is a subset - can be expanded with full IEEE OUI database
4
4
 
5
5
  const OUI_DB = {
6
+ // Virtual Machine vendors
6
7
  "00:05:69": "VMware",
7
8
  "00:0C:29": "VMware",
8
9
  "00:50:56": "VMware",
@@ -11,58 +12,24 @@ const OUI_DB = {
11
12
  "00:1C:42": "Parallels",
12
13
  "00:0F:4B": "Virtual Iron",
13
14
  "08:00:27": "VirtualBox",
14
- "00:1B:21": "Intel",
15
- "00:1E:67": "Intel",
16
- "00:21:70": "Intel",
17
- "00:25:00": "Intel",
18
- "00:26:B9": "Intel",
19
- "00:1A:79": "Intel",
20
- "00:15:17": "Intel",
21
- "00:13:CE": "Intel",
15
+ // Intel
22
16
  "00:0D:3A": "Intel",
23
17
  "00:0E:0C": "Intel",
24
18
  "00:11:11": "Intel",
25
- "00:14:4F": "Intel",
26
- "00:16:76": "Intel",
27
- "00:18:DE": "Intel",
28
- "00:1B:77": "Intel",
29
- "00:1C:C0": "Intel",
30
- "00:1D:7E": "Intel",
31
- "00:1E:67": "Intel",
32
- "00:21:5C": "Intel",
33
- "00:23:14": "Intel",
34
- "00:23:DF": "Intel",
35
- "00:24:D6": "Intel",
36
- "00:25:00": "Intel",
37
- "00:26:18": "Intel",
38
- "00:26:4A": "Intel",
39
- "00:26:B9": "Intel",
40
- "00:26:C7": "Intel",
41
- "00:27:13": "Intel",
42
- "00:50:56": "VMware",
43
- "00:0C:29": "VMware",
44
- "00:05:69": "VMware",
45
- "00:1B:21": "Intel",
46
- "00:1E:67": "Intel",
47
- "00:21:70": "Intel",
48
- "00:25:00": "Intel",
49
- "00:26:B9": "Intel",
50
- "00:1A:79": "Intel",
51
- "00:15:17": "Intel",
52
19
  "00:13:CE": "Intel",
53
- "00:0D:3A": "Intel",
54
- "00:0E:0C": "Intel",
55
- "00:11:11": "Intel",
56
20
  "00:14:4F": "Intel",
21
+ "00:15:17": "Intel",
57
22
  "00:16:76": "Intel",
58
23
  "00:18:DE": "Intel",
24
+ "00:1A:79": "Intel",
25
+ "00:1B:21": "Intel",
59
26
  "00:1B:77": "Intel",
60
27
  "00:1C:C0": "Intel",
61
28
  "00:1D:7E": "Intel",
62
29
  "00:1E:67": "Intel",
63
30
  "00:21:5C": "Intel",
31
+ "00:21:70": "Intel",
64
32
  "00:23:14": "Intel",
65
- "00:23:DF": "Intel",
66
33
  "00:24:D6": "Intel",
67
34
  "00:25:00": "Intel",
68
35
  "00:26:18": "Intel",
@@ -70,18 +37,17 @@ const OUI_DB = {
70
37
  "00:26:B9": "Intel",
71
38
  "00:26:C7": "Intel",
72
39
  "00:27:13": "Intel",
73
- "00:50:F2": "Apple",
40
+ // Apple
74
41
  "00:1E:C2": "Apple",
75
42
  "00:23:12": "Apple",
76
43
  "00:23:6C": "Apple",
77
44
  "00:23:DF": "Apple",
78
- "00:25:00": "Apple",
79
45
  "00:25:4B": "Apple",
80
46
  "00:26:08": "Apple",
81
- "00:26:4A": "Apple",
82
47
  "00:26:BB": "Apple",
83
48
  "00:26:CA": "Apple",
84
49
  "00:50:E4": "Apple",
50
+ "00:50:F2": "Apple",
85
51
  "00:56:CD": "Apple",
86
52
  "00:61:71": "Apple",
87
53
  "00:6D:52": "Apple",
@@ -106,7 +72,6 @@ const OUI_DB = {
106
72
  "04:E5:36": "Apple",
107
73
  "04:F1:3E": "Apple",
108
74
  "04:F7:E4": "Apple",
109
- "08:00:27": "VirtualBox",
110
75
  "08:66:98": "Apple",
111
76
  "08:70:45": "Apple",
112
77
  "08:74:02": "Apple",
@@ -174,7 +139,6 @@ const OUI_DB = {
174
139
  "6C:40:08": "Apple",
175
140
  "6C:72:20": "Apple",
176
141
  "70:48:0F": "Apple",
177
- "70:56:51": "Realtek",
178
142
  "74:E2:F5": "Apple",
179
143
  "78:31:C1": "Apple",
180
144
  "78:4F:43": "Apple",
@@ -218,42 +182,8 @@ const OUI_DB = {
218
182
  "F4:F1:5A": "Apple",
219
183
  "F8:1E:DF": "Apple",
220
184
  "FC:25:3F": "Apple",
221
- "00:1B:21": "Intel",
222
- "00:1E:67": "Intel",
223
- "00:21:70": "Intel",
224
- "00:25:00": "Intel",
225
- "00:26:B9": "Intel",
226
- "00:1A:79": "Intel",
227
- "00:15:17": "Intel",
228
- "00:13:CE": "Intel",
229
- "00:0D:3A": "Intel",
230
- "00:0E:0C": "Intel",
231
- "00:11:11": "Intel",
232
- "00:14:4F": "Intel",
233
- "00:16:76": "Intel",
234
- "00:18:DE": "Intel",
235
- "00:1B:77": "Intel",
236
- "00:1C:C0": "Intel",
237
- "00:1D:7E": "Intel",
238
- "00:1E:67": "Intel",
239
- "00:21:5C": "Intel",
240
- "00:23:14": "Intel",
241
- "00:23:DF": "Intel",
242
- "00:24:D6": "Intel",
243
- "00:25:00": "Intel",
244
- "00:26:18": "Intel",
245
- "00:26:4A": "Intel",
246
- "00:26:B9": "Intel",
247
- "00:26:C7": "Intel",
248
- "00:27:13": "Intel",
249
- "00:50:56": "VMware",
250
- "00:0C:29": "VMware",
251
- "00:05:69": "VMware",
252
- "00:16:3E": "Xen",
253
- "00:03:FF": "Microsoft Hyper-V",
254
- "00:1C:42": "Parallels",
255
- "00:0F:4B": "Virtual Iron",
256
- "08:00:27": "VirtualBox",
185
+ // Other vendors
186
+ "70:56:51": "Realtek",
257
187
  };
258
188
 
259
189
  function lookupVendor(mac) {
package/package.json CHANGED
@@ -1,7 +1,11 @@
1
1
  {
2
2
  "name": "spoof-d",
3
3
  "description": "Cross-platform MAC address and DUID spoofing utility for macOS, Windows, and Linux",
4
- "version": "0.5.1",
4
+ "version": "0.5.3",
5
+ "author": "TT5H",
6
+ "engines": {
7
+ "node": ">=12.0.0"
8
+ },
5
9
  "bin": {
6
10
  "spoofy": "bin/cmd.js"
7
11
  },
@@ -27,7 +31,7 @@
27
31
  "zero-fill": "^2.2.4"
28
32
  },
29
33
  "devDependencies": {
30
- "standard": "*"
34
+ "standard": "^17.0.0"
31
35
  },
32
36
  "homepage": "https://github.com/TT5H/spoof-d",
33
37
  "keywords": [
@@ -51,7 +55,6 @@
51
55
  "windows",
52
56
  "linux",
53
57
  "cross-platform",
54
- "network",
55
58
  "adapter"
56
59
  ],
57
60
  "license": "MIT",