programmatically change Mac address-Android

3.2k views Asked by At

I'm writing a program to spoof the mac address of a device. So far I was able to get root access by running the command:

Runtime.getRuntime().exec("su");

Now I want to run commands by doing:

for (String currCommand : commands)
{
    os.writeBytes(currCommand + "\n");
    os.flush();
}

but I'm not sure which commands will do this for me? Does anyone know the commands to run to get into the mac address and modify it?

2

There are 2 answers

0
Peter Paul Kiefer On BEST ANSWER

According to this link http://www.gohacking.com/spoof-mac-address-on-android-phones/ the phone must be rooted and busybox must be installed.

After entering su the commands are:

# show the actual mac address
busybox iplink show eth0
# change the mac adress 
busybox ifconfig eth0 hw ether XX:XX:XX:XX:XX:XX
0
Rasoul Miri On

you can use this way

use ADB shell and ifconfig

adb shell
su
ip link show wlan0
ifconfig wlan0 down;
ifconfig wlan0 hw ether 12:13:15:16:18:19  
ifconfig wlan0 up;

check this post https://stackoverflow.com/a/63251530/4797289