Question

How I can protect MATLAB compiled .exe from:

  • reverse-engineering
  • unauthorised distibution?

Which packers, protection tools etc should I use?

Was it helpful?

Solution

I have been previously faced with exactly this problem. Here are some thoughts:

  • MATLAB compiled binaries are in fact ZIP archives, which are decompressed (possibly to a temp or home folder accessible to the user) at runtime.
  • The files themselves are encrypted using AES, which is not ideal, since the key can be theoretically recovered.
  • The above makes it senseless to additionally encrypt the final exe with user-based keys to limit the redistribution, since the decompressed files will be available during runtime. In that sense it is equivalent to just using mcc for protection.
  • As an additional catch: MEX files in the distribution are not encrypted. You can take the mex file from the MCR_CACHE and directly use it. The same goes for Java classes.
  • Hence, you need a solution which will encrypt/decrypt the disk writes/reads performed by MATLAB executable in addition to encrypting the executable itself
  • Obviously you need to be able to specify, which disk accesses to encrypt - you want the user to be able to provide input data, and to read his output
  • Ideally, this solution would also keep an encrypted copy of the binaries in the memory, and only decrypt them when needed, i.e., when a piece of code/data is being executed/accessed
  • In addition, the solution should detect that the code is executed from a debugger and shut down the program in such cases
  • It should be difficult to reverse-engineer the encryption process to extract the keys. With a software-only solution it is always possible (and easier than with a hardware solution) to obtain the keys.

We ended up using a solution, which involves a USB dongle. It performs the encryption/decryption on the fly and more-or-less addresses the above complexities. It works in a client/server setting, i.e., you can have a USB dongle on the server, and the clients contact the server to checkout the license and run the code. At that time however, the full encryption was only supported on Windows. I am not sure whether I should mention the company name here on SO (I am not in any way affiliated to it, but anyways). I can tell you privately what we used, or you could google around a bit - there are alternatives on this market.

Edit I made a mistake in my original statement. The archive is indeed extracted to MCR_CACHE directory, but the files are encrypted. However, this still does not prevent redistribution of the compiled program. Although the scripts are not available in clear text, so in this sense your intellectual property is secured. A more detailed description of what MATLAB deployment tool does and does not protect, and a short statement regarding the security of the scheme can be found here.

OTHER TIPS

There is a commercial utility called Taurus which can be used to copy protect Matlab apps, in both pcoded and compiled format. Taurus hosts a number of the typical copy protection schemes found in desktop applications. Please see http://www.algorithmprotection.com/index.php/component/content/article/34-products/46-taurus

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top