spoof mac address
Posted
by
Cold-Blooded
on Stack Overflow
See other posts from Stack Overflow
or by Cold-Blooded
Published on 2011-01-09T12:41:36Z
Indexed on
2011/01/09
12:53 UTC
Read the original article
Hit count: 210
managed-c++
// macaddress.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <windows.h>
#include <iostream>
using namespace std;
void readregistry();
void spoofmac();
void main(int argc, char* argv[])
{
readregistry();
spoofmac();
}
void spoofmac()
{
//////////////////////
////////Write to Registry
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. 18\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 << "Invaild Network Adapter Chosen\n\n";
exit(0);
}
cout << "Please Enter the Desired Spoofed Mac Address Without Dashes\nE.g. 00123F0F6D7F\n\nNew Mac: ";
cin >> macaddress;
location = editlocation; //error line
strcpy(buffer,macaddress);
size=sizeof(buffer);
RegCreateKey(HKEY_LOCAL_MACHINE,location,&software);
//RegSetValueEx(software,"NetworkAddress",NULL,REG_SZ,(LPBYTE)buffer,size);
RegCloseKey(software);
cout << "\nMac Address Successfully Spoofed.\n\nWritten by Lyth0s\n\n";
}
void readregistry ()
{
////////////////////////////////////
// Read From Registry
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; //error line
// cout << location << "\n";
// cout << "Checking 00" << location[strlen(location)-2] << location[strlen(location)-1] << "\n\n";
RegCreateKey(HKEY_LOCAL_MACHINE,location,&software);
RegQueryValueEx(software,"DriverDesc",NULL,&type,(LPBYTE)driver,&driversize);
//RegCloseKey(software);
//RegCreateKey(HKEY_LOCAL_MACHINE,location,&software);
RegQueryValueEx(software,"NetworkAddress",NULL,&type,(LPBYTE)mac,&macsize);
RegCloseKey(software);
cout << x << ": " << driver << "| Mac: " << mac << "\n";
onescount+=1;
}
}
this program gives error as follows
error C2440: '=' : cannot convert from 'char [83]' to 'LPCTSTR'
why this error coming please explain
© Stack Overflow or respective owner