we modified it a little to fit the purpose of generating a valid random MAC Address.
View Code-- Program to spoof MAC Address
set macUser to do shell script "whoami"
set osVersion to do shell script "sw_vers | grep 'ProductVersion:' | grep -Eo '[0-9]+[0-9]*\\.[0-9]*' | sed -e \"s/\\.//g\""
if osVersion < 105 then
set osVersion to true
else
set osVersion to false
end if
set myProg to getSHsource()
-- change 2 to a bigger number if needed
repeat with interface from 0 to 2
try
--
set currMac to word 2 of (do shell script "ifconfig en" & interface & " | grep 'ether '")
set currMac to (do shell script "ifconfig en" & interface & " | grep 'ether '")
on error
exit repeat
end try
if currMac contains "ether" then
set newMac to do shell script "sh " & myProg
display dialog "en" & interface & " New Mac: " & newMac
set isActive to word 2 of (do shell script "ifconfig en" & interface & " | grep 'status: '")
if isActive does not contain "inactive" then
delay 2
end if
if macUser does not contain "root" then
if osVersion is true then
do shell script "ifconfig en" & interface & " ether " & newMac with administrator privileges
else
do shell script "ifconfig en" & interface & " lladdr " & newMac with administrator privileges
end if
else
if osVersion is true then
do shell script "ifconfig en" & interface & " ether " & newMac
else
do shell script "ifconfig en" & interface & " lladdr " & newMac
end if
end if
else
display dialog "Interface en" & interface & " not present"
end if
end repeat
on getSHsource()
set shProg to "#!/bin/sh
EMVersion=1.r3
ReleaseYear=2009
ReleaseDate=2009-04-08
WHICH=-g
SHOW=-m
vmrandom() {
vmrandmac=$(dd if=/dev/urandom bs=1 count=3 2>/dev/null | od -tx1 | head -1 | cut -d' ' -f2- | awk '{ print \"00:0c:29:\"$1\":\"$2\":\"$3 }')
echo $vmrandmac
}
vmstatic() {
max3f=$(printf \"%02X\" $(expr $(dd if=/dev/urandom bs=1 count=1 2>/dev/null | od -tu1 | head -1 | cut -d' ' -f2-) / 4) | tr A-Z a-z)
vmstatmac=$(echo -n \"00:50:56:$max3f:\" $(dd if=/dev/urandom bs=1 count=2 2>/dev/null | od -tx1 | head -1 | cut -d' ' -f2- | awk '{ print $1\":\"$2 }') | sed 's/\\ //')
echo $vmstatmac
}
global() {
globalmac=$(dd if=/dev/urandom bs=1 count=6 2>/dev/null | od -tx1 | head -1 | cut -d' ' -f2- | awk '{ print $1\":\"$2\":\"$3\":\"$4\":\"$5\":\"$6 }')
echo $globalmac
}
xensource() {
max3f=$(printf \"%02X\" $(expr $(dd if=/dev/urandom bs=1 count=1 2>/dev/null | od -tu1 | head -1 | cut -d' ' -f2-) / 4) | tr A-Z a-z)
xensource=$(echo -n \"00:50:56:$max3f:\" $(dd if=/dev/urandom bs=1 count=2 2>/dev/null | od -tx1 | head -1 | cut -d' ' -f2- | awk '{ print $1\":\"$2 }') | sed 's/\\ //')
echo $xensource
}
case \"$WHICH\" in
r|-r|random|-random)
if [ \"$SHOW\" != \"-m\" ]; then
echo -n \"Random VMware MAC Address: \"
fi
vmrandom
echo \"\"
;;
R|-R|RANDOM|-RANDOM|Random|-Random)
if [ \"$SHOW\" != \"-m\" ]; then
echo -n \"Random VMware MAC Address: \"
fi
vmrandom | tr a-z A-Z
echo \"\"
;;
s|-s|static|-static)
if [ \"$SHOW\" != \"-m\" ]; then
echo -n \"Static VMware MAC Address: \"
fi
vmstatic
echo \"\"
;;
S|-S|STATIC|-STATIC|Static|-Static)
if [ \"$SHOW\" != \"-m\" ]; then
echo -n \"Static VMware MAC Address: \"
fi
vmstatic | tr a-z A-Z
echo \"\"
;;
g|-g|global|-global)
if [ \"$SHOW\" != \"-m\" ]; then
echo -n \"Global MAC Address: \"
fi
global
echo \"\"
;;
G|-G|GLOBAL|-GLOBAL|Global|-Global)
if [ \"$SHOW\" != \"-m\" ]; then
echo -n \"Global MAC Address: \"
fi
global | tr a-z A-Z
echo \"\"
;;
x|-x|xen|-xen)
if [ \"$SHOW\" != \"-m\" ]; then
echo -n \"XenSource MAC Address: \"
fi
xensource
echo \"\"
;;
X|-X|XEN|-XEN|Xen|-Xen)
if [ \"$SHOW\" != \"-m\" ]; then
echo -n \"XenSource MAC Address: \"
fi
xensource | tr a-z A-Z
echo \"\"
;;
*)
exit 1
esac
exit $?
"
return shProg
end getSHsource
Copy this code to your AppleScript Editor and save it as an Application with "Run only" option.
Drop it to your Dock and with one click your MAC Addresses for every enX interfaces will be changed.