C program for mac address spoofing in windows sounds little bit weird but its 100% possible and I have written a C program to spoof mac address. MAC is unique to a system and we all know it can be manipulated or spoofed using windows registry. Now to do so every time we need to go to that registry key and have to change the MAC address manually. So to do it automatically i have written a C program for Mac address spoofing in windows which reads all the network adapters in windows and displays them in sorted (numerical) order and ask user which network address he want to spoof. Then asks user to enter the new spoofed Mac address, after entering spoofed address just press enter. Now go to command prompt and type ipconfig/all to check that network address is changed or not.
Note: This program also displays the Serial Ports and Parallel ports also but please avoid changing address of those as it can harm your ports settings.
Let us see how to write C program for Mac address spoofing in windows.
C program to spoof Mac address in windows :
#include <windows.h>
#include <iostream>
#include <conio.h>
using namespace std;
void readregistry();
char* spoofmac();
int main(int argc, char* argv[])
{
readregistry();
spoofmac();
}
char* spoofmac()
{
char buffer[60];
unsigned long size = sizeof(buffer);
HKEY software;
LPCTSTR location;
char adapternum[10]="";
char numbers[11]="0123456789";
char editlocation[]="System\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002bE10318}\\0000";
char macaddress[60];
cout << "\n//////////////////////////////////////////////////////////////////\nPlease Enter number of Network Adapter to Spoof or type 'E' to Exit.\nE.g. 6\n\nNumber: ";
cin >> adapternum;
if (adapternum[0]=='E')
{
exit(0);
}
if (strlen(adapternum)==2)
{
editlocation[strlen(editlocation)-2]=adapternum[0];
editlocation[strlen(editlocation)-1]=adapternum[1];
}
if (strlen(adapternum)==1)
{
editlocation[strlen(editlocation)-1]=adapternum[0];
}
if (strlen(adapternum)!=1 && strlen(adapternum)!=2)
{
cout << "Invalid Network Adapter Selected\n\n";
exit(0);
}
cout << "Please enter the desired Spoofed Mac Address\nE.g. 02113A0D4D66\n\nNew Mac Address: ";
cin >> macaddress;
location = editlocation;
strcpy(buffer,macaddress);
size=sizeof(buffer);
RegCreateKey(HKEY_LOCAL_MACHINE,location,&software);
RegSetValueEx(software,"NetworkAddress",0,REG_SZ,(LPBYTE)buffer,size);
RegCloseKey(software);
cout << "\nMac Address Successfully Spoofed.\n\n";
cout << "********************************************************\n";
cout << "************Written by C code champ ********************\n";
cout << "********************************************************\n";
getch();
}
void readregistry ()
{
char driver[60]="";
char mac[60]="";
char numbers[11]="0123456789";
char editlocation[]="System\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002bE10318}\\0000";
unsigned long driversize = sizeof(driver);
unsigned long macsize = sizeof(mac);
DWORD type;
HKEY software;
LPCTSTR location;
int tenscount=0;
int onescount=0;
for (int x =0;x<=19; x+=1)
{
strcpy(driver,"");
driversize=sizeof(driver);
strcpy(mac,"");
macsize=sizeof(mac);
if (editlocation[strlen(editlocation)-1]=='9')
{
tenscount+=1;
onescount=0;
editlocation[strlen(editlocation)-2]=numbers[tenscount];
}
editlocation[strlen(editlocation)-1]=numbers[onescount];
location=editlocation;
RegCreateKey(HKEY_LOCAL_MACHINE,location,&software);
RegQueryValueEx(software,"DriverDesc",0,&type,(LPBYTE)driver,&driversize);
RegQueryValueEx(software,"NetworkAddress",0,&type,(LPBYTE)mac,&macsize);
RegCloseKey(software);
cout << x << ": " << driver << "| Mac: " << mac << "\n";
onescount+=1;
}
}
I hope you all have enjoyed the code. If you have any doubts or queries ask us in form of comments.

Amazing things here. I’m very satisfied to peer your article. Thank you so much and I’m taking a look forward to touch you. Will you kindly drop me a mail?
Dear Lokesh,
How do you manage your time brother ? Really I feel astonished.
But wanna input on few general things, The website design is perfect, the subject matter is real excellent : D.
mac spoofing code mis not working…………