我一直在制作一个 BASh 脚本,将您的 MAC 地址更改为您从列表中选择的任何制造商的地址。在脚本运行的最后一部分,它会在完成之前停止。这是该部分的代码:
function spoofUseMAC() {
echo
read -p "[*] $($stopAllFX; $bgBlack; $white)Enter the number code for manufacturer: >>> " num
echo "[-] Generating MAC Address"
num=$( expr $num - 1 )
declare -a array
while read -r; do
array+=( "$REPLY" )
done < addr.txt
end=$( for i in {1..6} ; do echo -n ${hexchars:$(( $RANDOM % 16 )):1} ; done | sed -e 's/\(..\)/:\1/g' )
macAddress=${array[$num]}$end
echo "[-] MAC Address generated !"
echo "[-] Using address: $macAddress"
$skyBlue; $bold; echo
ifconfig
$white
read -p "[*] $($stopAllFX; $bgBlack; $white)Select an interface: >>> " iface
$yellow; echo "[-] $iface selected !"
$white; echo "[-] Disabling $iface ..."
ifconfig $iface down
ifconfig '$iface' hw ether '$macAddress'
echo "[-] MAC Address spoofed !"
sleep 1
echo "[-] Enabling $iface ..."
ifconfig '$iface' up
echo "[-] $iface enabled !"
echo "[-] Using address: $macAddress"
exit
}
function spoofSearchAgainOrNot() {
$bold; $white; echo
echo "[*] $($stopAllFX; $bgBlack; $white)Please select an option from the list below:"
$yellow; $bold; echo " [$($white)0$($yellow)] $($stopAllFX; $bgBlack; $white)Search again"
$yellow; $bold; echo " [$($white)1$($yellow)] $($stopAllFX; $bgBlack; $white)Use one of these"
read -p ">>> " searchAgainOrNot
if [[ "$searchAgainOrNot" == "0" ]]; then
spoofSearch
elif [[ "$searchAgainOrNot" == "1" ]]; then
spoofUseMAC
else
spoofSearchAgainOrNot
fi
}
# Spoof, search option selected
function spoofSearch() {
$bold; echo
read -p "[*] $($stopAllFX; $bgBlack; $white)Search for a manufacturer: >>> " search
$blue; awk -F '#' '{printf("%10d %s\n", NR, ":" $1 )}' /usr/bin/oui.txt | grep -i $search
spoofSearchAgainOrNot
}
# Spoof
function spoof() {
echo; $white
echo "[*] $($stopAllFX; $bgBlack; $white)Please select an option from the list below:"
$yellow; $bold; echo " [$($white)0$($yellow)] $($stopAllFX; $bgBlack; $white)Search for a manufacturer"
$yellow; $bold; echo " [$($white)1$($yellow)] $($stopAllFX; $bgBlack; $white)Browse for a manufacturer through $($bold)long $($stopAllFX; $bgBlack; $white)list"
read -p ">>> " searchOrBrowse
if [[ $searchOrBrowse == "0" ]]; then
spoofSearch
elif [[ $searchOrBrowse == "1" ]]; then
spoofBrowse
else
spoof
fi
}
为什么运行此脚本后我无法使用互联网(git clone
说)?could not resolve hostname: github.com
为什么还没有完成?
编辑:这应该适用于 MacOS 和 Linux。在 MacOS 上,没有ip route
命令,但在 Linux 上,ip route
结果是:
192.168.0.0/24 dev wlp1s0 proto kernel scope link src 192.168.0.18
192.168.0.0/24 dev wlp1s0 proto kernel scope link src 192.168.0.18 metric 600
答案1
有些卡对于更改/欺骗 MAC 地址有点挑剔。
在 OSX 中,接口 MAC 地址更改,特别是 wifi 接口,必须执行多次才能正确,例如经常循环,因为我怀疑它必须在特定时间内完成;对于最新版本的 OSX/MacOS,第一次时通常不会假设这一点。
值得注意的是,在 OSX 中,接口/驱动程序在 MAC 之后似乎会混淆几秒钟,但它们确实会恢复。
稀有品牌不会喜欢它,在某些品牌中,不建议您更改前 3 个八位字节(前 6 位数字,减去“:”),即制造商 ID。
您经常会丢失默认路由,或者路由器/AP 可能会丢失您是谁的概念;虽然该过程大部分应该是自动的,但在某些情况下,在 Linux 中,您可能必须在更改 MAC 地址后重新启动 DHCP 服务。
答案2
我发现了问题:其中一个$iface
s 周围有引号,而它不应该有。