checking physical address of the computer
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have a matlab m file and I want to create executable file by the matlab compiler. I want to distribute this exe file with one condition. Before uploading this exe file into any ftp, I'll ask MAC address of the user who want to download this exe file. In this situation, I need to append this MAC address into my m file then I need to check the MAC address of the user tries to run the software. If MAC addresses are not matched software shouldn't be run. Is there any code available for this issue?
0 Commenti
Risposta accettata
Guillaume
il 12 Giu 2016
There's no built-in function in matlab to get MAC addresses (or other hardware related information). You would have to delegate that to either a mex file, system commands (calling e.g. ipconfig on windows), .Net (windows only), or java. For example, using java, you could do:
localhost = java.net.InetAddress.getLocalHost;
networkinterface = java.net.NetworkInterface.getByInetAddress(localhost);
macaddress = typecast(networkinterface.getHardwareAddress, 'uint8')
This will give you the MAC address of one of the network adapter of the machine it is run on. Instead of using the localhost network adapter you could enumerate them instead with
networkinterfaces = java.net.NetworkInterface.getNetworkInterfaces
nimacs = cell(0, 2);
while networkinterfaces.hasMoreElements
networkinterface = networkinterfaces.nextElement;
macstring = strjoin(cellstr(dec2hex(typecast(networkinterface.getHardwareAddress, 'uint8'))), ':');
nimacs = [nimacs; {char(networkinterface.getDisplayName), macstring}];
end
cell2table(nimacs, 'VariableNames', {'Interface', 'MAC'})
And there you'll see the first problem with your question. There is usually no ONE mac address for a machine. My laptop has five useful for example.
Of course, if what you're trying to do is some sort of copy protection, it is doomed from the start. For most network adapters, it's not particularly hard to change their MAC address to whatever you want.
Plus, if you embed the MAC address in the .m file, the user can simply edit the .m file to remove the check or change the embedded value.
0 Commenti
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!