MAC 주소를 변경한 후 인터넷에 연결할 수 없습니다

MAC 주소를 변경한 후 인터넷에 연결할 수 없습니다

나는 귀하의 MAC 주소를 목록에서 선택한 제조업체의 MAC 주소로 변경하는 BASh 스크립트를 만들어 왔습니다. 실행되는 스크립트의 마지막 부분에서는 완료되기 전에 중지됩니다. 해당 부분의 코드는 다음과 같습니다.

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 routeLinux에서는 다음과 같은 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 주소 변경, 특히 Wi-Fi 인터페이스는 제대로 될 때까지 여러 번 수행되어야 합니다. 예를 들어 종종 루프에서 수행되어야 하기 때문에 특정 시간에 수행되어야 하기 때문입니다. 최신 버전의 OSX/MacOS에서는 처음에는 가정되지 않는 경우가 많습니다.

특히 OSX에서는 인터페이스/드라이버가 MAC 이후 몇 초 동안 혼란스러워 보이지만 복구됩니다.

희귀 브랜드는 이를 좋아하지 않을 것입니다. 일부 브랜드에서는 제조업체 ID인 처음 3옥텟(처음 6자리에서 ":" 제외)을 변경하지 않는 것이 좋습니다.

종종 기본 경로를 잃거나 라우터/AP가 귀하가 누구인지에 대한 개념을 잃을 수 있습니다. 프로세스는 대부분 자동으로 수행되지만 경우에 따라 Linux에서는 MAC 주소를 변경한 후 DHCP 서비스를 다시 시작해야 할 수도 있습니다.

답변2

문제를 발견했습니다. $ifaces 중 하나에 있어서는 안되는 따옴표가 있었습니다.

관련 정보