Created
November 4, 2021 23:57
-
-
Save leodr/e14a1b7aaa9438f3b4e19ad6793b672f to your computer and use it in GitHub Desktop.
Changes the networking MAC address on macOS.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { exec } = require("child_process"); | |
let macAddress; | |
do { | |
macAddress = "XX:XX:XX:XX:XX:XX".replace(/X/g, () => | |
"0123456789abcdef".charAt(Math.floor(Math.random() * 16)) | |
); | |
} while (parseInt(macAddress[1], 16) % 2 !== 0); | |
console.log(macAddress); | |
const cmd = "sudo ifconfig en0 ether " + macAddress; | |
console.log(cmd); | |
exec(cmd, (err, stdout, stderr) => { | |
console.log(stdout); | |
if (err || stderr) console.error("error: " + stderr); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment