Protecting intellectual property in AutoCAD application modules

This is an interesting topic – and one that I'm far from being expert in – so it would be great if readers could submit comments with additional information.

Intellectual property protection is a major concern for software developers, and issues that are seen today with .NET languages have been troubling AutoCAD developers since the introduction of AutoLISP.

So, what are these issues?

As a professional software developer, if you ship source-code to your customers there is substantial risk of it being borrowed or stolen for use in other unlicensed situations. This is true if you ship the actual source code used to build your modules, or if the "compiled" modules are actually not fully compiled, but (for example) stored in a CPU-independent, intermediate language that can quite easily be decompiled and have source code reconstituted or reverse-engineered (albeit without comments and usually without the original symbol names).

ObjectARX

This is much less of an issue with languages that are compiled to CPU-specific executable or machine code, such as for ObjectARX (and before it, ADS): the output from a C++ compiler does not, for instance, included any source code, unless you choose to ship debugging-related files such as PDBs (files which include information about function prototypes – information that is considered by some software providers as intellectual property in and of itself).

LISP

Intellectual property protection was historically a big issue with AutoLISP: in its original incarnation (i.e. before the integration of Visual LISP) LISP code was always interpreted by AutoCAD. Interpreted languages do not have a compilation phase – the code is "made sense of" by the interpreter at runtime. There were, however, things that could be done to obfuscate and protect the code before distribution. Most developers used these two tools on their code before shipping it:

The Kelvinator – this nifty tool did a few things to obfuscate AutoLISP code:

Removed unnecessary whitespace

Stripped out comments

Mangled "internal" symbols (those not exposed as external variables or function names)

The Kelvinator was apparently written by Kelvin R. Throop, along with a number of other AutoLISP utilities. I wasn't around at the time (it was written in the late 80s and I joined in the mid 90s), so without ever having met Kelvin I do wonder whether he really exists, or whether this is just another use of the pseudonym used in a number of Science Fiction stories over the 20 or so years preceding the Kelvinator's development. This theory seems to be confirmed by this memo in the Autodesk File on John Walker's Fourmilab site. But if the real Kelvin R. Throop could step forward (or if someone else could confirm his existence or identity), then I'd willingly present my humble apologies. 🙂

In terms of its functionality the Kelvinator was really quite effective: the only step that could be effectively reversed was the whitespace removal – by any LISP pretty printer. Getting meaningful comments & function/variable names back was nigh on impossible (although you could work out what certain variables were used for in a particular algorithm pretty easily).

Protect.exe

This tool used very lightweight encryption to stop LISP files from being read by plain ASCII tools. From memory, I think a bit was reversed in each ASCII character – it was that level of encryption – which also meant that unprotection tools were also available (including one of the "c" versions of R13, if I remember correctly, which would print protected LISP as plain text to the AutoCAD text window :-).

Most professional developers at the time would Kelvinate and then Protect their LISP code before distributing it. Other options were to use LISP compilation – an early compiler was available pre-R13 versions, and Vital LISP (which later became Visual LISP) provided compilation capabilities.

Visual LISP changed the game for LISP developers: it allowed them to properly compile LISP into a protected format. Visual LISP supports two modes of compilation: each LISP file can be compiled to a format called FAS, which can be loaded directly into AutoCAD, and these can in turn be packaged into VLX modules. Originally Visual LISP allowed compilation to ARX, but these were essentially copies of the VL runtime with the compiled code stored as a resource, and clearly it's more efficient to not force distribution of the runtime when it's in any case a standard component.

Over the years I've not come across anyone raising concerns about the security of the FAS or VLX formats, which leads me to believe they're a "secure" way to protect and distribute LISP modules (which ultimately means the effort required to make sense of the underlying logic of the application would be too high for it to be considered a useful practice for those developers unscrupulous enough to otherwise attempt it).

VB6

The VB6 IDE allows compilation to executable code – albeit code that requires a runtime component – and, once again, to the best of my knowledge this code is considered "secure" (see above note).

VBA

The VBA component embedded in AutoCAD allows password protection of DVB files (see the Protection tab on the Project Properties dialog in the VBA IDE). This password protection uses standard encryption to lock away source code from prying eyes. I understand that cracking tools are available for protected VBA modules, but there is no secret back-door – my team occasionally gets asked to help access source code stored in protected DVB files (as the person working on the code left the company without telling anyone the password for the module – or at least that's what we're told :-). Ultimately there's nothing we can do to help in these cases, unfortunately. The cracking tools that are available seem to work on a brute force principle – they will cycle through possible passwords until one works – so if you want to really protect your code I'd recommend using a nice, long password.

.NET

So – life is basically good for LISP, ObjectARX, VBA and VB6 applications… what about .NET?

One of the major concerns shared by many .NET developers is around code security. Managed code gets compiled into assemblies that contain Microsoft Intermediate Language (MSIL) - basically CPU-independent instructions - in addition to metadata describing types, members and references to code in other assemblies. At runtime the MSIL gets converted to CPU-specific instructions by a just-in-time (JIT) compiler.

These assemblies are quite easy to disassemble into something resembling the original source code (albeit – once again – without comments or meaningful variable names, but internal function names and types get maintained).

Just as the Kelvinator was available for AutoLISP, there are obfuscation tools available for .NET languages. Visual Studio ships with one called the Dotfuscator Community Edition: this tools works on .NET assemblies, reducing the ease with which someone could reverse-engineer the source code.

At a basic level the tool strips namespace and member names - replacing them with symbols such as "a", "b", "c", ... - but it can only do so much to hide the logic of the code's execution, especially if there is no great dependency on functions and sub-routines (the more linear the code, the easier it is to understand, in my brief experience of analysing obfuscated code). That said, the Dotfuscator tool does have a number of options I haven't explored in depth, so it may well provide additional, helpful capabilities.

From taking a cursory look into what information is available by default in .NET assemblies, it's become clear to me that this should be an area of concern for anyone serious about protecting their source code investment. I strongly recommend that any professional software developer working with .NET spend time investigating obfuscation technologies for .NET assemblies. This guide, although a little dated, does seem to provide a fairly good background to .NET obfuscation, as well as presenting a number of different vendors' offerings.

In my next post I'm going to take a look at the Reflector tool - a very useful tool that can be used to disassemble .NET assemblies - and discuss how it might be used to help further one's understanding of .NET development.

One response to “Protecting intellectual property in AutoCAD application modules”

  1. "Over the years I've not come across anyone raising concerns about the security of the FAS or VLX formats, which leads me to believe they're a "secure" way to protect and distribute LISP modules (which ultimately means the effort required to make sense of the underlying logic of the application would be too high for it to be considered a useful practice for those developers unscrupulous enough to otherwise attempt it)."

    Hi Kean;

    I just have the curiosity, how it is possible to run most of the extensions fas, vlx, arx, etc... using, for example a 3rd party software like toolkit max for the autocad LT versions (I don't use LT by the way).

    About C#, I started writing some code with that language, end up using it for hobby or for code I simple do not care if someone end up viewing it... as can be seen with the reflector, and if it is an obfuscator, then it must be a way to break that too.

    For, some of my serious work (still as a hobby) I prefer now C++/ARX/MFC, having using it for the last two years now, still to much to learn...

    Great site you have, cheers!

  2. Hi Luis,

    Thanks for your comment.

    I'm not aware of how that's done, or whether the various file formats would need to be reverse-engineered for it to happen (that's not the case for ARX modules, for instance, which are executable module connecting to a set of DLLs).

    Cheers,

    Kean

  3. Hi Kean,

    Great article. Many years ago at the architectural engineering firm where I used to work I made the decision to do all of my programming in LISP instead of ADS or later ARX. One of the reasons for this is because I was trying to create a network of "non-IT" developers within the company to help with the creation of our menu system. It worked well - too well. Apparently the sharing concept extended outside of our company. I currenty work with someone who learned to write AutoLISP code by going through our well documented code - at another engineering firm.

    When our code wasn't so well documented or not as logical as it should have been, that is when we considered encrypting it - so no one would see how bad it was.

    I also appreciated the reference to the job titles memo from "K. R. Throop" - I made a business card the first time I saw this memo with the title "Intergalactic Exalted Cosmic Hyper Programmer."

    Later...
    Scott

  4. Hi Scott,

    Thanks for the comment - gave me a good chuckle.

    Cheers,

    Kean

  5. Hello Kean,
    Great introduction article. I am really interested in the topic of the apparent contradiction between the concepts of obfuscation and reflection. Reflection has been an invaluable tool for learning ... both with the IDE tools and with Lutz Roeder's .NET Reflector package.
    I'll buy some popcorn and sit back and wait for the posts to follow.

    Regards
    Kerry Brown

  6. Fernando Malard Avatar

    Hi Kean, great article!

    Exactly due all facts that you guys told here I still prefer to write my applications core with unmanaged C++.

    If your core are protected the chance someone stole your code and put it running is minimum. In other hand, inside your unmanaged C++ modules you won't have direct access to the huge API .NET provides.

    Maybe Microsoft or other company comes on a near future with an option to encrypt MSIL code and only the MSIL compiler will be able do decrypt the code.

    The real fact is that the chances of an application code to be reverse-engineered is proportional to the value and the number of potential users it has on the marked.

    I always say that if there are 20 engineers protecting a software or a code, using part time of their job, there are a thousand of crackers with much more energy and time available to brake it. It's really a matter of interest, crackers and time.

    Further, the encryption is a protection that only increases exponentialy the probability of a crack but still it's a matter of time and a capable machine to break the code. If you get some application which cracks passwords it will break simple in just a few seconds and stronge-named passwords will take more time to happen.

    Sometimes the code is self-encrypted because some developers does not like to comment the code and/or use strange names for functions and variables. I personally hate this code because it is really a shot in your own foot.

    Maybe the best solution is to mix and spread your application in several modules using a good set of languages (managed, unmanaged, scripts, etc.). This way your code will be much more difficult to understand and to be reverse-engineered.

    Any other ideas on that?
    Cheers!

  7. Hi Kean,
    Great article. Like everyone else, I'll be following it with great interest.

    It brings back memories of me getting worked up over someone else stealing my super secret LISP code and how relieved I was when I discovered The Kelvinator and Protect. Now days I worry very little about this issue, even though I develop most of my code with .NET, and most programmers writing add-on code for AutoCAD shouldn't either. It comes down to two basic reasons.

    The first is just as Fernando stated, supply and demand. There's just not enough demand for most AutoCAD add-ons that anyone would spend the time and energy to reverse engineer them.

    Second is that most AutoCAD add-ons don't contain any revolutionary algorithms that are worth stealing. Anyone that thinks they've tapped into a secret area of an AutoCAD API and are using it in a way that no one else on the planet can ever reproduce without looking at their source code, is wrong.

    I’m sure that there are some readers who have applications that need protecting, because of heavy demand and competition or because they really do have an algorithm worth protecting. But most are going to be OK with simple obfuscation, or even nothing at all.

    Have a good one,
    Bobby

  8. I think the other interesting topic on the issue of Obfuscating Autodesk-based add-ons is the library issue. While the obfuscator can successfully obfuscate your own code, it can't obfuscate your calls into the AutoCAD.NET library, for example.

    I agree that the reality is that it's probably not that necessary - but I also feel like many of the "tricks" that I might like to protect deal with what or how I'm calling a particular API. This issue makes everything one step harder to protect.

    -Matt

  9. J. Daniel Smith Avatar

    Personally, I would not make technology decision based on the ability to protect one's IP (keeping in mind the context of this discussion). Thus, I would not choose ObjectARX/unmanaged C++ over .NET/C# and the managed APIs just because MSIL is easier to disassemble than x86 assembly.

    First, you have to really consider the actual value of your IP: I’ve seen (and probably written! 🙂 ) a lot of source code that at the end of the day really isn’t all that interesting. There is a tremendous productivity gain from .NET which allows developers to focus on delivering functionality quickly rather than chasing down memory leaks.

    Second, Microsoft is aware of the problem and is presumably taking steps to improve the situation (in addition to the options already available). For example, it is rumored that future versions of the CLR will require that all assemblies be strongly signed--regardless of them being GAC’d.

    Finally, there are often legal options such as copyrights, trade-secrets, license agreements, etc. With enough effort, someone can reverse engineer an unmanaged C++ ARX; but just because they’ve done that, they still may not have the right to use the IP embedded in the ARX.

  10. Kean,

    Kelvin does indeed exist although he runs around in real life with another name. He even wrote some of the early AutoCAD manuals. You even worked and lived near him but may have not realized this.

    Cheers!

  11. Kean,

    About a year and a half ago, I started writing all of code in VB-.NET instead of VBA because I had discovered that the password protection was pretty much worthless (for our purposes) because in order to run the code you had to have the password. We were selling our software to another company, which of course meant that they had to be able to run the program, but we would rather they not be able to see the code, much less change it. Password protecting the code, then giving them the password so they could use it, didn't seem to make much sense.

  12. Kean,

    About a year and a half ago, I started writing all of code in VB-.NET instead of VBA because I had discovered that the password protection was pretty much worthless (for our purposes) because in order to run the code you had to have the password. We were selling our software to another company, which of course meant that they had to be able to run the program, but we would rather they not be able to see the code, much less change it. Password protecting the code, then giving them the password so they could use it, didn't seem to make much sense.

  13. Wow, great blog. I learned many things on those programming languages. Anyway, true, it is really not safe to ship codes since it can definitely be stolen by just anybody over the net.

  14. Hi folks is there any way of securing code via a password? Rather than use obfuscators - a simple password (entered every month) upon the netloading of the dll to prevent it's unauthorised use should work perfectly. I myself am not too concerned about folks reverse engineering. Any ideas/thoughts on password protection for c# .net plugins?

    1. I don't know of a straightforward way to achieve this. It's possible you could have a small loader that requests a password and unencrypts the main module before loading it.

      But it sounds as though you're more concerned about user authorization than having your source stolen. Which is another topic entirely: you can certainly integrate a number of "software locking" technologies to make sure your applications are copy-protected. I suggest posting to the online discussion groups - someone there will have real-world experience of implementing such a system they can share.

      Kean

  15. Abolghasem Dankoob Avatar
    Abolghasem Dankoob

    Hi Kean,
    Someone decompiled one of my vlx files using kali linux and autopsy tool, but I don't know how.
    I have only seen a picture of his desktop.

Leave a Reply to Matt M Cancel reply

Your email address will not be published. Required fields are marked *