Sign in to follow this  
Followers 0
Wus

changing the mac address via autoIT

16 posts in this topic

At my college they prohibit the use to bittorrent programs and they have smart switches that 'quarentine' people that they detect using torrent programs. Well I found that they quarentined by mac address so naturally I automated the task of getting un-quarentined.

I figured out how to enable/disable a network connection (this proved to be pretty difficult with no wmi method)

This function came from a vbs script found at http://channel9.msdn.com/ShowPost.aspx?PostID=158556

more can be found at

http://groups.google.com/group/microsoft.p...b3fab1141c6c93e

The first param tells whether you want to disable or reenable the connection

The 2nd param is the name of the network connection (default to 'Local Area Connection')

The 3rd param i put in to account for versions of windows other than xp. The folder isnt called 'Network Connection' on all versions fo windows so this might be modfied to 'Networking and Dialup connections' or whater it was callled in older versions of windows. I have not tested this on any other version of windows.

Func NicToggle($Toggle, $sConnectionName = "Local Area Connection", $sNetworkFolder = "Network Connections")
    
    $ssfCONTROLS = 3
    $sEnableVerb = "En&able"
    $sDisableVerb = "Disa&ble"
    $shellApp = ObjCreate("shell.application")
    $oControlPanel = $shellApp.Namespace ($ssfCONTROLS)
    $oNetConnections = "nothing"
    
    For $folderitem In $oControlPanel.items
        If $folderitem.name = $sNetworkFolder Then
            $oNetConnections = $folderitem.getfolder
            ExitLoop
        EndIf
    Next
    If $oNetConnections = "nothing" Then
        MsgBox(48, "Error", "Couldn't find " & $sNetworkFolder & " folder")
        Exit
    EndIf
    
    $oLanConnection = "nothing"
    For $folderitem In $oNetConnections.items
        If StringLower($folderitem.name) = StringLower($sConnectionName) Then
            $oLanConnection = $folderitem
            ExitLoop
        EndIf
    Next
    If $oLanConnection = "nothing" Then
        MsgBox(48, "Error", "Couldn't find '" & $sConnectionName & "' item")
        Exit
    EndIf
    
    $bEnabled = True
    $oEnableVerb = "nothing"
    $oDisableVerb = "nothing"
    $s = "Verbs: " & @CRLF
    For $verb In $oLanConnection.verbs
        $s = $s & @CRLF & $verb.name
        
    ;enables
        If $verb.name = $sEnableVerb And $Toggle = 1 Then
            $oEnableVerb = $verb
            $oEnableVerb.DoIt
            ExitLoop
            
        ;disables
        ElseIf $verb.name = $sDisableVerb And $Toggle = 0 Then
            $oDisableVerb = $verb
            $oDisableVerb.DoIt
            ExitLoop
        Else
            MsgBox(48, "Error", "Tried to disable when already disabled" & @CRLF & "or enable when already enabled")
            Exit
        EndIf
    Next
    Sleep(1000)
EndFunc  ;==>NicToggle

This function generates a sorta-kinda random mac address. It could be much more random, but it was good enough for me. The first two are zero because it was easier to do that than to check for even or odd leading bytes (some rules for mac addressing).

Func RandomMAC()
    Local $newMAC = "00"
    For $i = 1 To 5
        $newMAC &= Hex( Random(0, 255, 1), 2)
    Next
    Return $newMAC
EndFunc  ;==>RandomMAC

This code finds the hwid for the connected connection, this combined with some reg searching makes it possible to find the relavent regkey that the mac address can be changed in. It requires two includes (not really sure if it needs the contstants).

#include <Constants.au3>

#include <array.au3>

$stdout = Run(@ComSpec & " /c net config rdr", '', @SW_HIDE, 2)
    Global $all
    While 1
        $data = StdoutRead($stdout)
        If @error Then ExitLoop
        If $data Then
            $all &= $data
        Else
            Sleep(10)
        EndIf
    WEnd
    $DataArray = StringSplit($all, @CRLF)
    $id = StringTrimLeft( StringTrimRight($DataArray[13], 15), 13)

Non of the code is that pretty, but some of it I thought might be worth posting. I may try to clean the functions up later.

Attached is the actual script I used to disable->generate a mac->change the mac->enable

changeMAC.au3


Share this post


Link to post
Share on other sites



Very cool. :lmao: I think I may alter this so I can change my MAC to a specific MAC as well as a random MAC. Also I would want a way to set the MAC back to the original.

I think it would be more realistic to build a list of manufacturers MAC addresses and use those for the first part. That way it would at least look like a real NIC if a person was looking at it. I'll post any changes I make.


www.TomTheGeek.com - All the geeky stuff that gets me hot

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Hood college in MD

http://maps.google.com/?ll=39.422437,-77.4....032223,0.05888

@Tomthegee

yeh i found out about that manufacturer thing and it could be implemented along with the reset to default and set to specified

I just wanted it to work for my purposes first. I can work on that when i get a chance.

BTW can anyone tell me if it works on older versions of windows if the correct params are specified.

Edited by Wus

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

WUS, this script is great!!! Thank you for sharing it. :)

I have a broadband modem here at home, which is configured by my provider to connect to my home PC's NIC useing it's MAC address. I also have a laptop from work and sometimes i need to connect it to internet at home.

So I modified your script a bit, to be able to enter desired MAC manualy. :mellow: (see the attachment)

It needs some more modifications (for example checking if entered value is a valid MAC address), but don't have much time and it works for me as it is. :)

10x again for shareing it !

EDIT: Here is a great freeware (with C++ source code included) for Win2000 and WinXP which i use for the purpose, but it would be nice to see similar freeware made with AutoIt. :o

ModifiedChangeMAC.au3

Edited by dv8

Share this post


Link to post
Share on other sites

hey, i like the idea. I want to do this to but I want to do it to my wifi adapter. do I just change the name to "intel" because thats the name of my adapter???

thanks


[center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center]

Share this post


Link to post
Share on other sites

hey, i like the idea. I want to do this to but I want to do it to my wifi adapter. do I just change the name to "intel" because thats the name of my adapter???

thanks

zerocool60544, if you use the script it should change the addres of the active adapter, i think. And it is tested only on Win XP.

If you use the program from the link i put in my last post, then you should first chose the adapter and then input the new MAC.

NOTE, that this program to work your Windows version should be XP or 2003. And there are some adapters whose MAC address can't be changed.

Share this post


Link to post
Share on other sites

zerocool60544, if you use the script it should change the addres of the active adapter, i think. And it is tested only on Win XP.

If you use the program from the link i put in my last post, then you should first chose the adapter and then input the new MAC.

NOTE, that this program to work your Windows version should be XP or 2003. And there are some adapters whose MAC address can't be changed.

I tried the script at my school, jjc, and they block that stuff, I got an error from the pc, insafitiant priviliages

is there away around that


[center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center]

Share this post


Link to post
Share on other sites

I tried the script at my school, jjc, and they block that stuff, I got an error from the pc, insafitiant priviliages

is there away around that

I don't think so. This script changes some registry keys, so you must have admin rights to execute it correctly. :)

Share this post


Link to post
Share on other sites

ok, i figured, thanks


[center]AutoIT + Finger Print Reader/Scanner = COOL STUFF -> Check Out Topic![/center][center][font=Arial Black]Check out ConsultingJoe.com[/font][/center][center]My Scripts~~~~~~~~~~~~~~Web Protocol Managing - Simple WiFi Scanner - AutoTunes - Remote PC Control V2 - Audio SpectrascopePie Chart UDF - At&t's TTS - Custom Progress Bar - Windows Media Player Embed[/center]

Share this post


Link to post
Share on other sites

Okay, I'm new to "Windows". I don't have a lot of time right now (who does ;-p) to learn a new scripting language (last time I scripted was in 1995 using apple script). This script looks VERY close to what I am looking for, and if I have to write the script myself this is where I will start.

Goal: Cycel through my networks.

I have 3 network cards installed. They are connected to 3 differant networks. More to come soon. I need a script that will check to see what network connection is active. Disable that network connection. Then enable the next one. A,B,C,A,B,C... and so on.

Pertanent Info:

OS-

Windows XP Pro

Network connection names-

Local Area A

Local Area B

Local Area C

Reward:

I am not some big company with money to through around; I'm just a home user. But if someone comes up with a functional script. I would give them something for thair time. I would like to PayPal them 20-30 bucks, so they can buy a DVD or something as a thank you.

Any questions I check my eMail often:

ebridenbecker@yahoo.com

Share this post


Link to post
Share on other sites

I made a script similar to this with Macro Scheduler. It's kinda exspensive to get the compiler so I searched around and found auto-it. Great program.

Anyway, my school has a 5gb/week bandwidth limit. When you connect an unknown computer to the network you have to register it via your school login/password. After a while I figured out they were measuring how much bandwidth you used via your mac address. There is no limit to how many computers you can register.

I use bandwidth monitor pro to monitor the total upload+download /week and then execute the script at 4.5gb. I have a batch file stored locally with 10 possible mac addresses, which it will it will roll though. After the 10 has been registered, it can keep going on on its own. I don't have a lot of experience with auto-it yet so most of the work is done in batch. Copying and pasting from log files is done via auto-it. Right now you have to put in a load of info into the batch file such as hardware id, hardware # for smac-cl, possible mac address, and for the first time you run it, the current mac. It doesnt sound bad but it's a lot of command line work to get some of that info. My goal is to have a simple config file that auto-it will read from, but that might be a while.

I'm currently using the following utilities to do the work:

ipconfig

smac-cl (cmd line utility for changing the mac address)

devcon (microsoft utility to control hardware from cmd prompt, for disabling/renabling the network adapter)

I had to buy smac-cl. Macshift is a freebie program but dosen't work on Intel adapters for some reason.

If anyone cares to see all the code work, let me know and Ill clean it up and share it.

:think:

Share this post


Link to post
Share on other sites

Nice script..I will try it soon.

I allways thought that the MAC address is hard coded in NIC and the only one who can change it is the manufacturer....

RK


"When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

I allways thought that the MAC address is hard coded in NIC and the only one who can change it is the manufacturer....

Yes, and No. The operating system can report whatever MAC address you want it to.... In fact, many manufactures have nic drivers that allow you specify a MAC address, as shown in screenshot below. (If you don't override it, the default value hard-coded in the NIC is used as the MAC address.)

Interesting read: http://www.klcconsulting.net/Change_MAC_w2k.htm

Posted Image

Edited by CyberSlug

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

Share this post


Link to post
Share on other sites

Nice tool, I heard about MAC spoofing many times but never caught my interest until now.

Thanks for the link.

RK


"When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix

Share this post


Link to post
Share on other sites

I do not suggest using this script until you find or make a backup of those registry keys he does change, because if it runs into an error, there is nothing but a msgbox to tell you so, and thus leaving you without internet until you set it back to normal.


Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0