[ 用户登陆 ] [ 免费注册 

分类 >> 学习资料 > 电脑技术 >
终端机知识

Win7修改MAC地址方法
文 . 2013/11/16 14:10:25
1. 打开 PowerShell ,执行 Set-ExecutionPolicy Unrestricted
2. 将下面代码生成文件,在文件点右键选择“使用 PowerShell 运行”
3. 在“输入命令:”提示中输入cycle
4. 再输入s 1 0102030a0b0c
   说明 1 是指网上列表号
      0102030a0b0c 是新设置的网卡MAC地址,由于Win7之后MAC会有很多限制,不是随便设置。如果不清楚就试多几组数字。
5. 输入 quit 退出
6. 在 PowerShell 执行 Set-ExecutionPolicy Restricted

文件: MAC地址修改.ps1
#
# mcmkup.ps1 version 0.33 20110727
# Created by Marcello Gorlani
# http://www.gorlani.com/portal/
#
# You can freely use and distribute this junk as long you leave this credits
# This software comes with no warranty. It may destroy life on the Earth as we know it. Be warned.
#
# 汉化: 1788469
#
# 如果出现: 无法加载文件 MAC地址修改.ps1,因为在此系统中禁止执行脚本。有关详细信息,请参阅 "get-help about_signing"。
# 解决方法: 在PowerShell中执行 Set-ExecutionPolicy Unrestricted
# 运行脚本后执行 Set-ExecutionPolicy Restricted 恢复禁止执行脚本
#
#

$CLUTTER_STUFF="`nmcmkup.ps1 0.33 20110727 by Marcello Gorlani 汉化: 1788469`n"

# Me-big-hacker super-secret key and value. See http://technet.microsoft.com/en-us/library/cc780532(WS.10).aspx
$REGKEY='HKLM:\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}'
$VALUE_NAME='NetworkAddress'

$LOOKUP_REGKEY='HKLM:\SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}'

# This will be used to identify physical NICs
$NCF_PHYSICAL=4

# Various parsing parameters
$CMD_MIN_LEN=3
$MIN_CMD_TOKS=1
$QUITCMD='quit'

# For minimal validity checks
$GOOD_MAC_LEN=12

# Why bother about errors if you can hide them?
$ErrorActionPreference="SilentlyContinue"

######################################################################
# Global variables                                                   #
######################################################################

# By default, we DO NOT powercycle the interface after spoofing. Set this to $true to have the opposite default
[boolean] $global:bCycleInterface=$false

# Follow my lips: N-O
[boolean] $global:bIdontKnowWhatImDoingAndWantFuckUpThings=$false

######################################################################

######################################################################
# Find the visible name of the interface                             #
######################################################################
function getNICDesc([string] $sCfgKey) {
    $refKey=$LOOKUP_REGKEY+'\'+$sCfgKey+'\Connection'
    $nicName=Get-ItemProperty $refKey -Name 'Name'
    
    return $nicName.Name
}

######################################################################
# Build a list of physical interfaces                                #
######################################################################
function buildIntList([string] $sKey, [boolean] $bOnlyPhy=$True) {

$fillMe=@()

foreach ($subInt in Get-ChildItem -path $sKey | Get-ItemProperty -Name Characteristics,PSChildName,DriverDesc,NetWorkAddress,NetCfgInstanceId) {
    #$subInt.Characteristics
    #$subInt.PSChildName
    #$subInt.DriverDesc
    
    if ($subInt.Characteristics -bAND $NCF_PHYSICAL -or $global:bIdontKnowWhatImDoingAndWantFuckUpThings) {
        # We found a physical device
        
        $nicDesc=getNICDesc $subInt.NetCfgInstanceId
        $iDevID=[int32] $subInt.PSChildName
        $hElement=@{PSPath=$subInt.PSPath;DDesc=$subInt.DriverDesc;MAC=$subInt.NetWorkAddress;VisibleName=$nicDesc;DevID=$iDevID}
        $fillMe += $hElement
    }
}

return $fillMe
}

######################################################################
# Write out the list of physical interfaces                          #
######################################################################
function dumpArray([System.Array] $dumpMe) {
    if ($dumpMe.Count -lt 1) {
        Write-Host 出错,不能找到网卡
        return
    }
    
    Write-Host "`n下面是这台主机的物理网卡列表:`n"
    
    $iCount=0
    foreach ($nic in $dumpMe) {
        if ($nic.MAC.Length -gt 0) {
            $sMac='MAC设置为: ' + $nic.MAC
        } else {
            $sMac='保持原MAC'
        }
        [String] $sLine=$iCount.Tostring() + ') ' + $nic.VisibleName +', [' + $nic.DDesc + '], ' + $sMac
        Write-Host $sLine
        $iCount++
    }
    Write-Host "`n自动即时生效设置: $bCycleInterface`n"
}

######################################################################
# Write help                                                         #
######################################################################
function dumpCommands() {
    Write-Host $CLUTTER_STUFF
    Write-Host '命令:'
    Write-Host 'c <网卡号>'
    Write-Host 's <网卡号> <新mac>'
    Write-Host 'cycle'
    Write-Host $QUITCMD
    Write-Host ''
    Write-Host '命令 c 清除 MAC地址 (恢复原MAC地址)'
    Write-HOst '命令 s 设置新 MAC地址'
    Write-HOst '命令 cycle 设置自动启动使设置即时生效'
    Write-Host '命令 quit 退出设置'
    Write-Host ''
    Write-HOst '示例:'
    Write-Host 'cycle'
    Write-HOst 'c 0                  恢复 0 网卡的MAC'
    Write-HOst 's 1 0102030a0b0c     设置 1 网卡的MAC为 0102030a0b0c'
    Write-Host 'quit'
    Write-Host ''
}

######################################################################
# Parse the input to figure out if we must do something              #
######################################################################
function chkPowerCycle([int32] $iThisOne) {
if ($global:bCycleInterface -eq $False) {
  return
}

Write-Host 搜索设备...
$nicDevice=Get-WmiObject -Class win32_networkadapter | Where-Object {$_.DeviceId -eq $iThisOne }
if ($nicDevice -ne $null) {
    Write-Host 禁用...
    $nicDevice.Disable() | Out-Null
    Write-Host 启用...
    $nicDevice.Enable() | Out-Null
    Write-Host Windows 承认的 MAC 地址是: $nicDevice.MACAddress
} else {
    Write-Host 无法找到设备 $iThisOne
}
}

######################################################################
# Parse the input to figure out if we must do something              #
######################################################################
function runThisCmd([String] $sCmd, [System.Array] $nicArray) {
    $toks=$sCmd.Trim().Split(' ')
    if ($toks.Count -lt $MIN_CMD_TOKS) {
        Write-Host '缺少参数'
        return
    }
    
    if ($toks[0] -ne 'c' -and $toks[0] -ne 's' -and $toks[0] -ne 'cycle') {
        Write-Host '无效命令: ' $toks[0]
        dumpCommands
        return
    }
    
    [int32]$iArID=$toks[1]
    if ($iArID -lt 0 -or $iArID -gt $nicArray.count) {
        Write-Host 无效网卡号 $iArId
        return
    }
    
    $keyToModify=$nicArray[$iArId].PSPath
    
    switch ($toks) {
        's' {
                setMAC $keyToModify $sCmd
                chkPowerCycle $nicArray[$iArId].DevID
            }
        'c' {
                clearMAC $keyToModify
                chkPowerCycle $nicArray[$iArId].DevID
            }
        'cycle' { $global:bCycleInterface= -not $global:bCycleInterface }
    }
}


######################################################################
# Set the new MAC address                                            #
######################################################################
function setMAC([System.Object] $theKey, [string] $cmd) {
    $toks=$cmd.Trim().Split(' ')
    if ($toks.Count -ne 3) {
        Write-Host 命令参数无效
        return
    }
    
    [string]$sNewMac=$toks[2]
    if ($sNewMac.Length -ne $GOOD_MAC_LEN) {
        Write-Host 无效MAC $sNewMac
        return
    }
    
    Write-Host 设置...
    Set-ItemProperty $theKey -Name $VALUE_NAME -Value $sNewMac
    Write-Host 新的MAC地址已设置. 禁用网卡后再启用.
}

######################################################################
# Revert to original MAC                                             #
######################################################################
function clearMAC([System.Object] $theKey) {
    
    Write-Host 恢复...
    Clear-ItemProperty $theKey -Name $VALUE_NAME
    Write-Host 恢复原MAC地址. 禁用网卡后再启用.
}


######################################################################
# Entry point                                                        #
######################################################################

Clear
dumpCommands
while ($true) {
    $command=''

    # Figure out which interfaces we have and put it in an array of hash tables
    $intList=buildIntList $REGKEY $true
    # Give some hint
    #dumpCommands
    # List the NICs we found
    dumpArray $intList

    # Read commands from the user
    while ($command.Length -lt $CMD_MIN_LEN) {
        $command=read-Host '输入命令'
    }

    if ($command -ne $QUITCMD) {
        runThisCmd $command $intList
    } else {
        break
    }
} # Main Loop

Write-Out Bye

### DO NOT MODIFY BEYOND THIS LINE ###

 网址: http://www.gorlani.com/portal/projects/macmakeup-for-vista-seven-2008-windows-8 


最近后的内容
检验Windows 是否正版
解决“该项不适用于在指定状态下使用”
电脑通过安卓手机上网
“你已使用临时配置文件登录”的解决方法
最近前的内容
IIS 安装包下载
WinXP 支持2T硬盘GPT分区的方法
远程桌面问题解决
英文Win8变中文版
安全管理软件与木马病毒的区别
“当前安全设置不允许下载该文件”解决办法
Windows Server 2003 Service 管理工具包
远程桌面Mstsc 命令参数说明
用迅雷看看下载在线字幕
英文Win7 转中文
最受欢迎
Win XP USB大容量存储设备不能识别的解决办法
Vista 录音出现"WINDOWS SOUND RECORDER未正确安装,请运行REGSVR32 WAVDEST.DLL"错误处理办法
设置用户共享
开机错误提示02A2:BMC system error log (sel) full
Windows 注册表中的CLSID应用
防止U盘启动病毒,彻底禁用autorun.inf文件
windows操作系统快捷键大全
Microsoft 使用的关键字
复制中文时粘贴会出现乱码的解决方法
Windows 2003Server报无法加载安装程序库wbemupgd.dll,或找不到函数OcEntry解决办法
上网路由器设置
微软中文技术新闻组
XPS 文件阅读查看方式
修复Adobe Photoshop导致的剪贴板不可用问题
Win7 映像备份取代Ghost
测试管理系统连接故障的方法
Win7修改MAC地址方法
互联网访问路由器内网的设置方法
两台无线路由器连接(Bridge功能)
引导区病毒去除办法
 ©2005 - 2008 粤ICP备12037054号-1 用户登陆  |  互联说明  |  联系我们  |  网站地图