Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inno Setup mac id verification for multiple network adapters & Single network adaptors

Tags:

inno-setup

I am new to Inno setup ,

I have a Question here

when I execute "getmac" command from cmd line i got following output. I got multiple mac addresses ( I have installed VM Virtual player in my machine ) Screen shot of command for mac address before uninstalling VM player

And by the time when i uninstall VM virtual player and up on execution of same command i got different output, following is the screen shot for that .

Screen shot of command for mac address after uninstalling VM player

My issue here is,

1.Which mac address I need to consider among multiple mac address at the time of creating EXE file for MAC validation.

2.At the time of installation INNO Setup will fetch the MAC address from the local machine and it will compare the with the mac address what we have given at the time of creating the EXE file using mac address. In this case if the machine has multiple mac addresses, which mac address will Inno Setup will take to compare.

  1. In my case I have created EXE file using Inno setup with my mac address, at the time of creating the exe file my machine has single mac address later I installed VM player then my machine has couple of mac addresses and I try to install after installing VM palyer Inno setup is considering newly created MAC ADDRESS, and saying MAC address not valid **

Does any have idea how to solve this.**

Thanks in Advance :-)

like image 766
Sravan Avatar asked Jun 28 '14 16:06

Sravan


2 Answers

I do not think you have a technical problem; I think you need to understand ao Inno setup works. The person who does the installation needs to be aware that the MAC address chosen will be the one used to validate the product and that choosing the wrong MAC address will prevent the product from running if that MAC address is no longer in the system. For example, read poin 3 here https://support.minitab.com/en-us/installation/frequently-asked-questions/license-fulfillment/which-mac-address-to-fufill-license/

Now, keep in mind that MAC addresses can easily be spoofed. You can exert some control by not allowing certain MAC addresses, for example these https://macaddress.io/faq/how-to-recognise-a-vmwares-virtual-machine-by-its-mac-address and by taking into consideration what the IEEE Standards Association says in the Guidelines for Use of Extended Unique Identifier (EUI), Organizationally Unique Identifier (OUI), and Company ID (CID) available here: https://standards.ieee.org/content/dam/ieee-standards/standards/web/documents/tutorials/eui.pdf

This is about all you can do. If you don't exclude any MAC address than it would be very easy to run the installation on a different machine because one would be able to replicate the valid MAC address.

like image 71
Dan M Avatar answered Oct 17 '22 02:10

Dan M


If you need to find only permanent MAC address, you should begin by filtering the NICs that are physical:

wmic nic where "PhysicalAdapter='True'"

Once you have that list, you'll find that some virtual interfaces still appear as physical. A good way to filter them is to check their device path since only real network cards are connected to the PCI bus. This also would apply to USB bus, but since those cards aren't permanently connected, you can safely ignore them.

A good way to retrieve the device path togheter with the MAC address would be

wmic nic where "PhysicalAdapter='True'" get MACAddress,PNPDeviceID

which would output something like:

MACAddress         PNPDeviceID
E0:94:67:XX:XX:XX  PCI\VEN_8086&DEV_3165&SUBSYS_40108086&REV_81\E094XXXXXXXXXXXXXX
D8:CB:8A:XX:XX:XX  PCI\VEN_1969&DEV_E0A1&SUBSYS_115A1462&REV_10\FFEFXXXXXXXXXXXXXX
E0:94:67:XX:XX:XX  BTH\MS_BTHPAN\6&5XXXXXXXXXX

In the above example you can see two "real" ethernet network interfaces (wifi and eth), and a bluetooth device. Just filter by keyword PCI and you got yourself the list of non mutable mac addresses. You can filter via inno setup turbo pascal functions, or via cmd.

The final result could look like:

wmic nic where "PhysicalAdapter='True'" get MACAddress,PNPDeviceID | findstr "PCI"

If you want to show only the MAC addresses, you can wrap the whole thing in a batch script (which IMO isn't the best idea since it's a messy script language):

for /f "delims=" %%i in ('wmic nic where "PhysicalAdapter='True'" get MacAddress^,PNPDeviceID ^| findstr PCI') do (set res=%%i && echo %res:~0,17%)

Note the ^ sign before the comma and the pipe, that acts like an escape character so cmd doesn't take them as litterls.

There's also the Inno Setup way of doing by using a Pascal script. Here's one I've modified (original here) to only list the MAC addresses of physical permanent interfaces. Results in variable List:

WbemLocator := CreateOleObject('WbemScripting.SWbemLocator');
WbemServices := WbemLocator.ConnectServer('localhost', 'root\cimv2');

WQLQuery := 'Select MACAddress,PNPDeviceID from Win32_NetworkAdapter where PhysicalAdapter=true';
WbemObjectSet := WbemServices.ExecQuery(WQLQuery);
  if not VarIsNull(WbemObjectSet) and (WbemObjectSet.Count > 0) then
  begin
    Result := WbemObjectSet.Count;
    SetArrayLength(List, WbemObjectSet.Count);
    for I := 0 to WbemObjectSet.Count - 1 do
    begin
      WbemObject := WbemObjectSet.ItemIndex(I);
      if not VarIsNull(WbemObject) then
      begin
        if pos('PNP', WbemObject.PNPDeviceID) = 1 then
        begin
          List[I].MacAddress := WbemObject.MACAddress;   
        end;
      end;
    end;
  end;

Note that this pascal script only works with win7+.

Hope one of these solutions fits you.

like image 34
Orsiris de Jong Avatar answered Oct 17 '22 01:10

Orsiris de Jong