26-12-25, 10:10 AM
source code is below:
#include <windows.h>
#include <iostream>
#include <string>
#include <random>
#include <cstdlib>
std::string generateRandomMAC() {
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<> dis(0, 255);
char mac[13];
sprintf_s(mac, "%02X%02X%02X%02X%02X%02X",
0x02, // Locally administered, unicast
dis(gen),
dis(gen),
dis(gen),
dis(gen),
dis(gen));
return std::string(mac);
}
int run(const std::string& cmd) {
std::cout << "
[*]" << cmd << std::endl;
return system(cmd.c_str());
}
int main() {
std::string adapterName = "Wi-Fi"; // This is correct for most systems
std::string newMac = generateRandomMAC();
//CORRECT registry path for your MediaTek MT7902
std::string registryPath =
"HKLM\\SYSTEM\\CurrentControlSet\\Control\\Class\\"
"{4d36e972-e325-11ce-bfc1-08002be10318}\\0002";
std::cout << "[+] New MAC address: " << newMac << std::endl;
// 1. Disable Wi-Fi
run("netsh interface set interface \"" + adapterName + "\" admin=disable");
Sleep(2000);
// 2. Apply MAC address
run("reg add \"" + registryPath +
"\" /v NetworkAddress /t REG_SZ /d " +
newMac + " /f");
Sleep(2000);
// 3. Re-enable Wi-Fi
run("netsh interface set interface \"" + adapterName + "\" admin=enable");
std::cout << "[+] MAC address successfully changed.\n";
std::cout << "[!] Change is driver-level and may reset on reboot.\n";
return 0;
}
[*]how to use it step by step is below:
[*]Compile using Visual Studio (easiest)
[*]2. How to use the program
Once compiled:
[*]Command to delete the MAC override key
Replace
with your actual adapter instance (0000, 0001, 0002, etc.):
Code
Example (if your adapter is in
):
Code
After deleting the key, reload the adapter
You must disable and re-enable the interface so the driver reloads:
Code
#include <windows.h>
#include <iostream>
#include <string>
#include <random>
#include <cstdlib>
std::string generateRandomMAC() {
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<> dis(0, 255);
char mac[13];
sprintf_s(mac, "%02X%02X%02X%02X%02X%02X",
0x02, // Locally administered, unicast
dis(gen),
dis(gen),
dis(gen),
dis(gen),
dis(gen));
return std::string(mac);
}
int run(const std::string& cmd) {
std::cout << "
[*]" << cmd << std::endl;
return system(cmd.c_str());
}
int main() {
std::string adapterName = "Wi-Fi"; // This is correct for most systems
std::string newMac = generateRandomMAC();
//CORRECT registry path for your MediaTek MT7902
std::string registryPath =
"HKLM\\SYSTEM\\CurrentControlSet\\Control\\Class\\"
"{4d36e972-e325-11ce-bfc1-08002be10318}\\0002";
std::cout << "[+] New MAC address: " << newMac << std::endl;
// 1. Disable Wi-Fi
run("netsh interface set interface \"" + adapterName + "\" admin=disable");
Sleep(2000);
// 2. Apply MAC address
run("reg add \"" + registryPath +
"\" /v NetworkAddress /t REG_SZ /d " +
newMac + " /f");
Sleep(2000);
// 3. Re-enable Wi-Fi
run("netsh interface set interface \"" + adapterName + "\" admin=enable");
std::cout << "[+] MAC address successfully changed.\n";
std::cout << "[!] Change is driver-level and may reset on reboot.\n";
return 0;
}
[*]how to use it step by step is below:
[*]Compile using Visual Studio (easiest)
- Install Visual Studio Community
(choose the “Desktop development with C++” workload)
- Open Visual Studio →
Create a new project → Console App → C++
- Replace the auto‑generated code with your program.
- Build it:
Build → Build Solution
- Run it as Administrator:
- Right‑click the EXE in
orCode:bin/Debug
Code:bin/Release - Choose Run as administrator
- Right‑click the EXE in
- You’re editing HKLM registry keys
- You’re disabling/enabling network interfaces
[*]2. How to use the program
Once compiled:
- Make sure you updated:
- The correct adapter name
- The correct registry instance (0000, 0001, 0002, etc.)
- The correct adapter name
- Run the EXE as Administrator.
- The program will:
- Generate a random MAC
- Disable Wi‑Fi
- Write the registry override
- Re‑enable Wi‑Fi
- Generate a random MAC
- You can verify the MAC change with:
Code:
getmac /v[*]Command to delete the MAC override key
Replace
Code:
000XCode
Code:
reg delete "HKLM\SYSTEM\CurrentControlSet\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318}\000X" /v NetworkAddress /fCode:
0002Code
Code:
reg delete "HKLM\SYSTEM\CurrentControlSet\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318}\0002" /v NetworkAddress /fAfter deleting the key, reload the adapter
You must disable and re-enable the interface so the driver reloads:
Code
Code:
netsh interface set interface "Wi-Fi" admin=disable
netsh interface set interface "Wi-Fi" admin=enable