spoof-d 0.4.0 → 0.5.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/README.md CHANGED
@@ -7,9 +7,9 @@
7
7
 
8
8
  > **✅ Cross-Platform Support**: This is a modernized fork of the original `spoof` project, updated for compatibility with modern macOS (Sequoia 15.4+, Tahoe 26+), Windows 10/11, and Linux. All platforms are now fully supported!
9
9
 
10
- ### Easily spoof your MAC address on macOS, Windows, and Linux!
10
+ ### Easily spoof your MAC address and DUID on macOS, Windows, and Linux!
11
11
 
12
- A Node.js utility for changing MAC addresses across all major platforms. Features reliable macOS support, modern Windows PowerShell integration, and Linux `ip link` commands. This fork includes enhanced error handling, automatic verification, retry logic, and improved cross-platform compatibility.
12
+ A Node.js utility for changing MAC addresses and DHCPv6 DUIDs across all major platforms. Features reliable macOS support, modern Windows PowerShell integration, and Linux `ip link` commands. This fork includes enhanced error handling, automatic verification, retry logic, and improved cross-platform compatibility.
13
13
 
14
14
  ## About This Fork
15
15
 
@@ -85,6 +85,110 @@ npm install -g .
85
85
 
86
86
  This gives you the latest development version with all the latest features.
87
87
 
88
+ ## Shell Completions
89
+
90
+ `spoof-d` includes shell completion support for bash, zsh, fish, and PowerShell, making it easier to use the CLI with tab completion.
91
+
92
+ ### Automatic Installation
93
+
94
+ The easiest way to install completions is using the built-in command:
95
+
96
+ ```bash
97
+ spoofy completion
98
+ ```
99
+
100
+ This will automatically detect your shell and install the appropriate completion file. You can also specify a shell explicitly:
101
+
102
+ ```bash
103
+ spoofy completion --shell=bash
104
+ spoofy completion --shell=zsh
105
+ spoofy completion --shell=fish
106
+ spoofy completion --shell=powershell
107
+ ```
108
+
109
+ ### Manual Installation
110
+
111
+ #### Bash
112
+
113
+ ```bash
114
+ # Copy completion file
115
+ mkdir -p ~/.bash_completion.d
116
+ cp completions/spoofy.bash ~/.bash_completion.d/spoofy
117
+
118
+ # Add to ~/.bashrc
119
+ echo "source ~/.bash_completion.d/spoofy" >> ~/.bashrc
120
+ source ~/.bashrc
121
+ ```
122
+
123
+ Or install globally (requires root):
124
+
125
+ ```bash
126
+ sudo cp completions/spoofy.bash /etc/bash_completion.d/spoofy
127
+ ```
128
+
129
+ #### Zsh
130
+
131
+ ```bash
132
+ # Copy completion file
133
+ mkdir -p ~/.zshrc.d
134
+ cp completions/spoofy.zsh ~/.zshrc.d/_spoofy
135
+
136
+ # Add to ~/.zshrc
137
+ echo "fpath=(~/.zshrc.d \$fpath)" >> ~/.zshrc
138
+ echo "autoload -U compinit && compinit" >> ~/.zshrc
139
+ source ~/.zshrc
140
+ ```
141
+
142
+ Or install globally (requires root):
143
+
144
+ ```bash
145
+ sudo cp completions/spoofy.zsh /usr/local/share/zsh/site-functions/_spoofy
146
+ ```
147
+
148
+ #### Fish
149
+
150
+ ```bash
151
+ # Copy completion file
152
+ mkdir -p ~/.config/fish/completions
153
+ cp completions/spoofy.fish ~/.config/fish/completions/spoofy.fish
154
+ ```
155
+
156
+ Fish will automatically load completions from `~/.config/fish/completions/`. Just restart your fish shell.
157
+
158
+ Or install globally (requires root):
159
+
160
+ ```bash
161
+ sudo cp completions/spoofy.fish /usr/share/fish/completions/spoofy.fish
162
+ ```
163
+
164
+ #### PowerShell
165
+
166
+ ```powershell
167
+ # Copy completion file
168
+ New-Item -ItemType Directory -Force -Path (Split-Path $PROFILE)
169
+ Copy-Item completions/spoofy.ps1 $PROFILE
170
+
171
+ # Add to PowerShell profile
172
+ Add-Content $PROFILE ". $PROFILE"
173
+
174
+ # Reload profile
175
+ . $PROFILE
176
+ ```
177
+
178
+ Or add manually to your profile:
179
+
180
+ ```powershell
181
+ . C:\path\to\completions\spoofy.ps1
182
+ ```
183
+
184
+ ### Features
185
+
186
+ - **Command completion**: Tab-complete all available commands (`list`, `set`, `randomize`, `duid`, etc.)
187
+ - **Interface name completion**: Automatically suggests available network interfaces
188
+ - **Option completion**: Tab-complete all flags and options (`--wifi`, `--verbose`, etc.)
189
+ - **DUID subcommand completion**: Full completion support for DUID commands
190
+ - **Context-aware**: Completions adapt based on the current command and position
191
+
88
192
  ## Quick Start
89
193
 
90
194
  ### List network interfaces
@@ -264,6 +368,7 @@ sudo spoofy duid reset en0
264
368
  | 3 | DUID-LL | Link-layer address only (default) |
265
369
  | 4 | DUID-UUID | UUID-based identifier |
266
370
 
371
+ <<<<<<< HEAD
267
372
  ### Show detailed interface information
268
373
 
269
374
  ```bash
@@ -416,6 +521,79 @@ Long-running operations show progress indicators:
416
521
  ⏳ Changing MAC address... ✓ Successfully set MAC address
417
522
  ```
418
523
 
524
+ ### Programmatic Usage
525
+
526
+ ```javascript
527
+ const spoofy = require('spoofy');
528
+
529
+ // Get current DUID
530
+ const current = spoofy.duid.getCurrentDUID();
531
+ console.log('Current DUID:', spoofy.duid.formatDUID(current));
532
+
533
+ // Parse DUID info
534
+ const info = spoofy.duid.parseDUID(current);
535
+ console.log('Type:', info.typeName);
536
+ console.log('MAC:', info.lladdr);
537
+
538
+ // Check if original is stored
539
+ if (spoofy.duid.hasOriginalDUID()) {
540
+ const original = spoofy.duid.getOriginalDUID();
541
+ console.log('Original DUID:', spoofy.duid.formatDUID(original));
542
+ }
543
+
544
+ // Generate a random DUID
545
+ const newDuid = spoofy.duid.generateDUID(spoofy.duid.DUID_TYPES.DUID_LL);
546
+ console.log('Generated:', spoofy.duid.formatDUID(newDuid));
547
+
548
+ // Set DUID (requires root) - automatically saves original on first call
549
+ spoofy.duid.setDUID(newDuid, 'en0');
550
+
551
+ // Randomize DUID
552
+ spoofy.duid.randomizeDUID(spoofy.duid.DUID_TYPES.DUID_LLT, 'en0');
553
+
554
+ // Sync DUID to current MAC address
555
+ spoofy.duid.syncDUID('en0', spoofy.duid.DUID_TYPES.DUID_LL);
556
+
557
+ // Restore to original DUID
558
+ spoofy.duid.restoreDUID('en0');
559
+ ```
560
+
561
+ ### Combined MAC + DUID Spoofing
562
+
563
+ For complete identity change on IPv6 networks, you should change both MAC and DUID.
564
+
565
+ **Recommended workflow using sync:**
566
+
567
+ ```bash
568
+ sudo spoofy randomize en0 # Spoof MAC first
569
+ sudo spoofy duid sync en0 # Sync DUID to match spoofed MAC
570
+ ```
571
+
572
+ The `sync` command automatically matches the DUID to your current (spoofed) MAC address.
573
+
574
+ **Alternative - randomize both separately:**
575
+
576
+ ```bash
577
+ sudo spoofy randomize en0
578
+ sudo spoofy duid randomize en0
579
+ ```
580
+
581
+ **Manual sync for advanced use:**
582
+
583
+ When using DUID-LL or DUID-LLT types, the DUID includes the MAC address. For consistent spoofing, ensure the MAC in your DUID matches your spoofed MAC:
584
+
585
+ ```javascript
586
+ const spoofy = require('spoofy');
587
+
588
+ // Spoof MAC
589
+ const newMac = '00:11:22:33:44:55';
590
+ spoofy.setInterfaceMAC('en0', newMac, 'Wi-Fi');
591
+
592
+ // Create matching DUID
593
+ const duid = spoofy.duid.generateDUID(spoofy.duid.DUID_TYPES.DUID_LL, newMac);
594
+ spoofy.duid.setDUID(duid, 'en0');
595
+ ```
596
+
419
597
  ## Platform Support
420
598
 
421
599
  ### macOS ✅
@@ -460,7 +638,125 @@ sudo spoofy set 00:11:22:33:44:55 wlan0
460
638
 
461
639
  - WiFi will briefly disconnect when changing MAC address
462
640
  - Some network restrictions or hardware may prevent MAC spoofing
463
- - Requires sudo/root privileges for all MAC address changes
641
+ - Requires sudo/root privileges for all MAC address and DUID changes
642
+ - DUID changes may require DHCPv6 lease renewal to take effect
643
+
644
+ ## NetworkManager Integration (Linux)
645
+
646
+ On Linux systems using NetworkManager, MAC address changes may be immediately overwritten by NetworkManager if the interface is managed. `spoof-d` includes NetworkManager detection and integration to help prevent this issue.
647
+
648
+ ### Automatic Detection
649
+
650
+ When changing MAC addresses on Linux, `spoof-d` automatically:
651
+ - Detects if NetworkManager is present and running
652
+ - Checks if the target interface is managed by NetworkManager
653
+ - Warns you if the interface is managed (MAC changes may be overwritten)
654
+
655
+ ### Using `--nm-reconnect`
656
+
657
+ To automatically reconnect the NetworkManager device after a MAC change:
658
+
659
+ ```bash
660
+ sudo spoofy randomize eth0 --nm-reconnect
661
+ ```
662
+
663
+ This will:
664
+ 1. Change the MAC address
665
+ 2. Disconnect the device from NetworkManager
666
+ 3. Reconnect the device to apply the new MAC address
667
+
668
+ ### Force NetworkManager Restart
669
+
670
+ If normal reconnection doesn't work, you can force NetworkManager to restart networking (use with caution):
671
+
672
+ ```bash
673
+ sudo spoofy randomize eth0 --nm-reconnect --force
674
+ ```
675
+
676
+ **Warning:** The `--force` flag will temporarily disable all NetworkManager networking, which may disconnect all network interfaces briefly.
677
+
678
+ ### Manual NetworkManager Management
679
+
680
+ If you prefer to manage NetworkManager manually:
681
+
682
+ 1. **Temporarily disconnect the device:**
683
+ ```bash
684
+ nmcli dev disconnect eth0
685
+ sudo spoofy randomize eth0
686
+ nmcli dev connect eth0
687
+ ```
688
+
689
+ 2. **Mark device as unmanaged** (persistent):
690
+ Edit `/etc/NetworkManager/NetworkManager.conf`:
691
+ ```ini
692
+ [keyfile]
693
+ unmanaged-devices=interface-name:eth0
694
+ ```
695
+ Then restart NetworkManager:
696
+ ```bash
697
+ sudo systemctl restart NetworkManager
698
+ ```
699
+
700
+ 3. **Disable NetworkManager for specific interface** (temporary):
701
+ ```bash
702
+ nmcli device set eth0 managed no
703
+ sudo spoofy randomize eth0
704
+ nmcli device set eth0 managed yes
705
+ ```
706
+
707
+ ### Verbose Output
708
+
709
+ Use `--verbose` to see detailed NetworkManager status:
710
+
711
+ ```bash
712
+ sudo spoofy randomize eth0 --verbose
713
+ ```
714
+
715
+ This will show:
716
+ - NetworkManager detection method (nmcli, systemctl, etc.)
717
+ - Device management status
718
+ - Raw nmcli output for debugging
719
+
720
+ ## Testing
721
+
722
+ The project includes test suites for core functionality:
723
+
724
+ ### DUID Tests
725
+
726
+ Test DUID generation, parsing, and conversion:
727
+
728
+ ```bash
729
+ # Run all DUID tests
730
+ npm run test:duid
731
+ # or
732
+ node test/test-duid.js
733
+
734
+ # Run specific test
735
+ node test/test-duid.js --test=generation
736
+ node test/test-duid.js --test=parsing
737
+ ```
738
+
739
+ ### NetworkManager Tests (Linux only)
740
+
741
+ Test NetworkManager detection and device status parsing:
742
+
743
+ ```bash
744
+ # Run all NetworkManager tests
745
+ npm run test:nm
746
+ # or
747
+ node test/test-networkmanager.js
748
+
749
+ # Run specific test (parsing tests work on any platform)
750
+ node test/test-networkmanager.js --test=parsing
751
+ ```
752
+
753
+ ### Run All Tests
754
+
755
+ ```bash
756
+ npm run test:all
757
+ ```
758
+
759
+ **Note:** NetworkManager tests require a Linux system with NetworkManager installed. Parsing tests work on any platform.
464
760
 
465
761
  ## Troubleshooting
466
762
 
@@ -469,6 +765,7 @@ sudo spoofy set 00:11:22:33:44:55 wlan0
469
765
  2. Ensure WiFi is turned on before attempting to change MAC
470
766
  3. On modern macOS, you may need to reconnect to WiFi after the change
471
767
  4. Try running `networksetup -detectnewhardware` if changes don't take effect
768
+ 5. For DUID changes, you may need to disable/re-enable IPv6 or renew DHCPv6 lease
472
769
 
473
770
  ### Windows
474
771
  1. **Run as Administrator**: Right-click PowerShell or Command Prompt and select "Run as Administrator"
@@ -480,8 +777,12 @@ sudo spoofy set 00:11:22:33:44:55 wlan0
480
777
  ### Linux
481
778
  1. Make sure you're running with `sudo` (required for network changes)
482
779
  2. Ensure the `ip` command is available (usually in `iproute2` package)
483
- 3. Some network interfaces may be managed by NetworkManager - you may need to disable it temporarily
780
+ 3. **NetworkManager conflicts**: If NetworkManager is managing your interface, MAC changes may be overwritten
781
+ - Use `--nm-reconnect` to automatically reconnect after MAC change
782
+ - Or manually disconnect/reconnect: `nmcli dev disconnect <iface>` then `nmcli dev connect <iface>`
783
+ - Or mark interface as unmanaged in NetworkManager config (see NetworkManager Integration section)
484
784
  4. Virtual interfaces and certain hardware may not support MAC address changes
785
+ 5. If MAC changes don't persist, check NetworkManager status: `nmcli device status`
485
786
 
486
787
  ## Contributing
487
788