Comments on: Unique computer ID https://undocumentedmatlab.com/blog_old/unique-computer-id Charting Matlab's unsupported hidden underbelly Mon, 13 Jun 2022 09:41:08 +0000 hourly 1 https://wordpress.org/?v=4.4.1 By: Yair Altmanhttps://undocumentedmatlab.com/blog_old/unique-computer-id#comment-511842 Mon, 13 Jun 2022 09:41:08 +0000 https://undocumentedmatlab.com/?p=2353#comment-511842 @Mitchell – in most cases the user wants a single string identifier for the computer, that uniquely identifies it with a distinct fingerprint that is different from any other computer. The network interface (MAC) addresses are reported by the operating system, and naturally change when you add or remove a network card or adapter. It is up to you to decide which of the MAC addresses should be included in the fingerprint: if you include all of them, it certainly makes your fingerprint unique, but might include addresses that change frequently (e.g. VPN, WiFi, or virtual interfaces). On the other hand, if you ignore too many interfaces, your SID might be easier to spoof. Different operating systems have different ways of handling network interface MAC addresses, and you should consider this as well. For example, Windows and Linux addresses are pretty stable, but MacOS constantly changes the addresses when you connect/disconnect a network interface. MacOS also changes the computer’s hostname automatically, without any user approval, which is a PITA. In short, having a stable, unique SID that is less prone to spoofing requires some thought. If you need my assistance with this, please contact me privately (altmany at gmail).

]]>
By: Mitchellhttps://undocumentedmatlab.com/blog_old/unique-computer-id#comment-511840 Mon, 13 Jun 2022 00:58:39 +0000 https://undocumentedmatlab.com/?p=2353#comment-511840 Great post! I’m not very familiar with the network interfaces being referenced here, but it seems like the java-based cross-platform method concatenates all network interfaces. Does that mean that the SID returned by this method will change if a network interface is added or removed? Is it even possible to add or remove this type of network interface? Thanks!

]]>
By: Xiangrui Lihttps://undocumentedmatlab.com/blog_old/unique-computer-id#comment-405763 Mon, 01 May 2017 20:06:18 +0000 https://undocumentedmatlab.com/?p=2353#comment-405763 Here is my practice for regexp. For all OS, always take the first mac_add pattern in the string output.

if ispc
    [~, a] = system('getmac');
    mac_add = regexp(a, '([0-9A-F]{2}-){5}[0-9A-F]{2}', 'match', 'once');
elseif isunix % OSX and Linux
    [~, a] = system('ifconfig');
    mac_add = regexp(a, '([0-9a-f]{2}:){5}[0-9a-f]{2}', 'match', 'once');
else
    mac_add = [];
end
]]>
By: Jeff E Mandel MD MShttps://undocumentedmatlab.com/blog_old/unique-computer-id#comment-392076 Mon, 31 Oct 2016 13:41:06 +0000 https://undocumentedmatlab.com/?p=2353#comment-392076 Newer Macs have a hardware UUID. Note that Apple won’t allow a program that uses this in the App Store, but this probably won’t affect too many people writing deployed applications. Here is a little routine that accesses the system profile using the system_profiler command.

function profile = getMacProfile
% Retrieves all of the information from the OSX system profile and returns
% it in a structure, replacing spaces with underscores in the names and
% removing the attributes in parentheses.
 
[~,out]=system('system_profiler SPHardwareDataType');
theLines = splitlines(out);
for i = 1:length(theLines)
    if ~isempty(theLines{i})
        try
            c=strsplit(theLines{i},': ');
            if length(c) == 2
                d=strip(c{1});
                e=regexprep(d,' \(.*\)','');
                tag =strrep(e, ' ','_');
                profile.(tag) = c{2};
            end
        catch
            % In case Apple comes up with a new entry
            disp(theLines{i});
        end
    end
end

The UDID (unique device ID) is returned in profile.Hardware_UUID. This is probably more reliable than the MAC address of EN0.

]]>
By: Yair Altmanhttps://undocumentedmatlab.com/blog_old/unique-computer-id#comment-315055 Thu, 20 Feb 2014 17:20:36 +0000 https://undocumentedmatlab.com/?p=2353#comment-315055 Next time don’t post on a public blog something that you don’t want to appear publicly!

]]>
By: thomashttps://undocumentedmatlab.com/blog_old/unique-computer-id#comment-315054 Thu, 20 Feb 2014 17:09:44 +0000 https://undocumentedmatlab.com/?p=2353#comment-315054 oh, i see.. the new method indeed gives .00000000000000E0.50E54950537A :)

thank you for your clarification. could you please delete my mac addresses, they were not intended to go public :)

]]>
By: Yair Altmanhttps://undocumentedmatlab.com/blog_old/unique-computer-id#comment-315048 Thu, 20 Feb 2014 16:56:43 +0000 https://undocumentedmatlab.com/?p=2353#comment-315048 @Thomas – it’s simply a different representation of the data. Here’s an implementation that should return more legible results:

ni = java.net.NetworkInterface.getNetworkInterfaces;
macStrs = {};
while ni.hasMoreElements
    macAddr = ni.nextElement.getHardwareAddress;
    if ~isempty(macAddr)
        macAddrStr = ['.' sprintf('%02X',mod(int16(macAddr),256))];
        macStrs{end+1} = macAddrStr; %#ok
    end
end
macStrs = sort(unique(macStrs));
sid = [macStrs{:}];
]]>
By: thomashttps://undocumentedmatlab.com/blog_old/unique-computer-id#comment-315044 Thu, 20 Feb 2014 16:40:03 +0000 https://undocumentedmatlab.com/?p=2353#comment-315044 Yes, they are different, this is why i am confused a bit. The SID method gives .D6CDDF05903C.8888888600000000.8888888600000000.8888888600000000
IPconfig says:
50-E5-49-50-53-7A (this is the ethernet adapter)
00-00-00-00-00-00-00-E0
00-00-00-00-00-00-00-E0
00-00-00-00-00-00-00-E0

]]>
By: Yair Altmanhttps://undocumentedmatlab.com/blog_old/unique-computer-id#comment-315042 Thu, 20 Feb 2014 16:29:31 +0000 https://undocumentedmatlab.com/?p=2353#comment-315042 @Thomas – in this case you have 4 separate MAC addresses, from 4 separate network devices. Run the following in your Matlab command prompt to see the list (look at the “Physical Address” rows):

system('ipconfig /all')

This again is only unique if the user does not fool around with the MACs…

]]>
By: thomashttps://undocumentedmatlab.com/blog_old/unique-computer-id#comment-315041 Thu, 20 Feb 2014 16:26:30 +0000 https://undocumentedmatlab.com/?p=2353#comment-315041 @Yair – sorry, I meant not SID but that second method, where sid = .89ECC872C85C.8AFE928FEDB4.8262278A1CCA.899919B50FC9

Is it the MAC address? Because MAC address has 12 digits. My SID (this 48 digits long) is different from my MAC. Thanks.

]]>
By: Yair Altmanhttps://undocumentedmatlab.com/blog_old/unique-computer-id#comment-315040 Thu, 20 Feb 2014 16:23:31 +0000 https://undocumentedmatlab.com/?p=2353#comment-315040 Thomas – of course: any computer-generated id can be spoofed and hacked. You can never fully protect yourself from this. But if you’re looking at normal legal behavior, then it should be unique for any practical purposes.

]]>
By: thomashttps://undocumentedmatlab.com/blog_old/unique-computer-id#comment-315035 Thu, 20 Feb 2014 15:50:32 +0000 https://undocumentedmatlab.com/?p=2353#comment-315035 How unique is SID? Can be there 2 identical SIDs in the world?

]]>
By: Samihttps://undocumentedmatlab.com/blog_old/unique-computer-id#comment-165256 Fri, 01 Mar 2013 11:10:11 +0000 https://undocumentedmatlab.com/?p=2353#comment-165256 Thanks for the code, it’s very helpful, however in the {‘win32′,’win64’} i had to add “+1” to get the right MAC address. without the preceding “=” :

mac_add = a(b(end)+1:b(end)+19);
]]>
By: Pritihttps://undocumentedmatlab.com/blog_old/unique-computer-id#comment-160196 Wed, 20 Feb 2013 14:33:56 +0000 https://undocumentedmatlab.com/?p=2353#comment-160196 really helpful

]]>
By: damayihttps://undocumentedmatlab.com/blog_old/unique-computer-id#comment-87264 Wed, 23 May 2012 03:43:21 +0000 https://undocumentedmatlab.com/?p=2353#comment-87264 SID is not an absolutely secure way to protect your license.
There are many software tool which can modify computer sid, such as NewSid software.

]]>
By: itrentalshttps://undocumentedmatlab.com/blog_old/unique-computer-id#comment-83902 Mon, 30 Apr 2012 12:46:15 +0000 https://undocumentedmatlab.com/?p=2353#comment-83902 This is a really good guide, especially for those developing software (like you say) who are fearful that it will get copied.

]]>
By: Jayveerhttps://undocumentedmatlab.com/blog_old/unique-computer-id#comment-62004 Wed, 16 Nov 2011 08:24:07 +0000 https://undocumentedmatlab.com/?p=2353#comment-62004
switch computer('arch')
    case {'maci','maci64'}
        [~,a]=system('ifconfig');
        c=strfind(a,'en0');if ~isempty(c),a=a(c:end);end
        c=strfind(a,'en1');if ~isempty(c),a=a(1:c-1);end
        % find the mac address
        b=strfind(a,'ether');
        mac_add=a(1,b(1)+6:b(1)+22);
    case {'win32','win64'}
        [~,a]=system('getmac');b=strfind(a,'=');
        mac_add=a(b(end):b(end)+19);
    case {'glnx86','glnxa64'}
        [~,a]=system('ifconfig');b=strfind(a,'Ether');
        mac_add=a(1,b(1)+17:b(1)+33);
    otherwise,mac_add=[];
end
]]>
By: Yair Altmanhttps://undocumentedmatlab.com/blog_old/unique-computer-id#comment-57232 Tue, 20 Sep 2011 22:35:35 +0000 https://undocumentedmatlab.com/?p=2353#comment-57232 @Matthias – thanks :-) The code I posted above does exactly what you say, specifying the MAC addresses of all the computer’s network controllers. Please take a look – it’s actually quite simple and does not require any DLL, so it works on both Windows and non-Windows platforms.

]]>
By: Matthiashttps://undocumentedmatlab.com/blog_old/unique-computer-id#comment-57231 Tue, 20 Sep 2011 22:21:46 +0000 https://undocumentedmatlab.com/?p=2353#comment-57231 Hi,

for licensing I always use the MAC address of (one of) the network controllers. This address is absolutley unique for each network device worldwide.

The only way to access this I know of is using C/C++ compiled to a *.dll which can then be called from MATLAB using calllib

If interested I can post the code from the function to access the device.

And yes, this is a great site, learned a lot about Java in MATLAB and using lots of it.
Keep up Yair!

Matthias

]]>
By: Yair Altmanhttps://undocumentedmatlab.com/blog_old/unique-computer-id#comment-51854 Wed, 20 Jul 2011 19:06:05 +0000 https://undocumentedmatlab.com/?p=2353#comment-51854 @Jan – I humbly stand corrected :-)

]]>