asp tutorials, asp.net tutorials, sample code, and Microsoft news from 15Seconds
Data Access  |   Troubleshooting  |   Security  |   Performance  |   ADSI  |   Upload  |   Email  |   Control Building  |   Component Building  |   Forms  |   XML  |   Web Services  |   ASP.NET  |   .NET Features  |   .NET 2.0  |   App Development  |   App Architecture  |   IIS  |   Wireless
 
Pioneering Active Server
 Power Search








Active News
15 Seconds Weekly Newsletter
• Complete Coverage
• Site Updates
• Upcoming Features

More Free Newsletters
Reference
News
Articles
Archive
Writers
Code Samples
Components
Tools
FAQ
Feedback
Books
Links
DL Archives
Community
Messageboard
List Servers
Mailing List
WebHosts
Consultants
Tech Jobs
15 Seconds
Home
Site Map
Press
Legal
Privacy Policy
internet.commerce














internet.com
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

HardwareCentral
Compare products, prices, and stores at Hardware Central!

Intellectual Property Protection and Code Obfuscation -- Cont'd
By Adnan Masood


  • email this article to a colleague
  • suggest an article

    Code Obfuscation

    Defining code obfuscation is difficult; it's different from encryption or sheer mangling of code. Code obfuscation is the generation of code, which is still understandable by the compiler, but is very difficult for humans to comprehend. From a computer science point of view it's merely a translation. Computer scientist and software developer Gregory Wroblewski considers it to be a one-way translation but with proper code changes and logging. Professional obfuscation software exists which can un-obfuscate or even help by re-obfuscating. There are three generalized methods for source code protection.

    • Code Authentication and Verification
    • Server Side Invocation
    • Source Code Obfuscation

    More specifically, source code obfuscation can be further classified into more transformations:

    • Layout i.e. source or binary structure obfuscation.
    • Data Obfuscation i.e. the string and hard coded representation.
    • Control Obfuscation i.e. changing the control hierarchy with logic preservation.
    • Preventive Obfuscation i.e. focused protection against decompilers and reverse engineering tools.

    There are various algorithms used for code obfuscation, providing various degrees of transformation and protection against potential reverse engineering. Christian S. Collberg, Algorithm for Watermarking, Tamper-Proofing, and Obfuscation - Tools for Software Protection and Cullen Linn's Obfuscation of executable code to improve resistance to static disassembly are important papers in this discipline. In fact the techniques explained by Torok & Leech defined in MSDN magazine Nov 2003 article "Thwart Reverse Engineering of Your Visual Basic .NET or C# Code" used in PreEmptive's Dotfuscator gives a good overall review of how effective code obfuscation could be.

    Renaming metadata to gibberish or less obvious identifiers is one of several defense mechanisms. It's obvious that a function definition called InsterestRatesCalcuator () will give any cracker a leading edge over various functions called x(). As you'll see in the example below and as they stated, "Typically, an overload-induced project will have up to 35 percent of the methods renamed to 'a'", it's an effective obfuscation strategy. Similarly, some of the obfuscation techniques which DotFuscator uses include removing nonessential metadata, control flow obfuscation, string encryption, incremental obfuscation, and size reduction -- all different ways to make decompilation and disassembling produce incomprehensible output. Some generic techniques used by other obfuscation utilities include reordering the instantiation and methods, manipulating inheritance relationships, variable scope modification, mapping unboxed scalars (int, byte, etc) to corresponding object types, etc. However, its very important to keep into consideration that obfuscation shouldn't end up changing a program's logic or flow, as its purpose is to protect and not deform.

    DotFuscator Community Edition

    PreEmptive's Dotfuscator is a source code obfuscator for Microsoft's .NET platform. The community edition is available with Visual Studio .NET

    Figure: DotFuscator Community Edition in Visual Studio.NET IDE

    Figure: DotFuscator Community Edition running in Visual Studio.NET, ready to obfuscate

    Dotfuscator provides increamental, control flow, and string obfuscation facilities. Further details on its techniques can be found in its FAQ's section. Dotfuscator is highly customizable and can be configured for different purposes. Below is an example of how it protects the code from being disassembled. In this sample Chess program, I have an abstract class called piece which has members moveCount, boardXPOS, boardYPOS and two abstract methods movePiece and isLegalMove(). I'll use ILDASM to disassemble it before and after running dotFuscator on it.

    Figure: dotNetChess class view in Visual Studio.NET IDE

    After compilation, I ran ILDASM on the first assembly; results were no different than expected.

    Figure: Running ILDASM on First Assembly

    All the members were disclosed in their entirety and any intelligent cracker can reconstruct my code easily. Now I ran Dotfuscator Community Edition from Visual Studio.NET IDE .

    Figure: Running Dotfuscator

    As mentioned before, dotfuscator is highly customizable; therefore, you can choose renaming, control flow, string encryption and various other options.

    Figure: DotFuscator Community Edition exploring dotNetChess.exe in Visual Studio IDE.

    Now click on trigger after setting the directories, and Dotfuscator will start obfuscating the assembly. Assembly will change its shape and representation but will be the exact logical equivalent of what we had before.

    Figure: Dotfuscator community Edition Obfuscating code.

    In the figure above, Dotfuscator is making the assembly source more difficult to understand. Therefore, running ILDASM over the obfuscated version is quite difficult. Various members are named 'a' and much shorter code is enough to keep a reverse engineer busy for days before they gain any information about the source code. The compiler's output log can be seen below.

    Assembling 'C:\Documents and Settings\Adnan Masood\My Documents\Visual Studio Projects\dotNetChess\bin\Debug\dotNetChess.exe.il' , no listing file, to EXE --> 'C:\Documents and Settings\Adnan Masood\My Documents\Visual Studio Projects\dotNetChess\bin\Debug\Obfuscated\dotNetChess.exe'

    Source file is UTF-8

     

    Assembled method b::.ctor

    Assembled method b::a

    Assembled method b::a

    Assembled method b::Main

    Assembled method b::a

    Assembled method a::.ctor

    Assembled method a::a

    Assembled method a::b

    Assembled method DotfuscatorAttribute::.ctor

    Assembled method DotfuscatorAttribute::a

    Creating PE file

     

    Emitting members:

    Global  

    Class 1Fields: 9;           Methods: 5;      

    Class 2Fields: 3;           Methods: 3;      

    Class 3Fields: 1;           Methods: 2;       Props: 1;          

    Method Implementations (total): 1

    Resolving member refs: 37 -> 37 defs, 0 refs

    Writing PE file

    Operation completed successfully

     

    Build Finished.

     

    Log file of Dotfuscator Build.

    After processing the source code from Dotfuscator, I ran ILDASM to see the results.

    Figure: DotFuscator Community Edition in Visual Studio.NET IDE

    Assembly exploration no longer tells us much about the original code. Most of the members are now named using a deducing functional logic. The figure below shows the Hex Editor comparing the two executables.

    Figure: Hex Editor Comparison

    Dotnetchess.exe is now quite different from the way it was before. The difference in metadata and reduced assembly size are evidence enough of functioning obfuscation and how it makes decompilation difficult. Before closing I'll briefly discuss open source and NMI, a decompiler for Java.

    Open Source advocates have often claimed Closed Source systems to be evil (and visa versa), and they have their own reasons. Discussion wouldn't be complete without showing the other side of coin. So I've included a short subsection on Open Source fundamentals.

    << PEManifest •       • How Open Source Works? >>

  • Supporting Products/Tools
    AspEncrypt
    Built around the Microsoft CryptoAPI, AspEncrypt helps you harness all major encryption and hashing algorithms such as DES, Triple-DES, RC2, RC4, RSA, MD5 and SHA1 in just a few lines of code. The component can be used in tandem with AspEmail to send encrypted and signed mail in the industry-standard S/MIME format, or with AspUpload to encrypt files as they are being uploaded. AspEncrypt can also be used to issue and manage X.509 digital certificates.
    [Top]
    AspPDF
    AspPDF is an ASP/ASP.NET component which enables generation and management of documents in PDF format. Features include advanced text formatting, font embedding, form fill-in, images, tables, content and page extraction, document stitching, encryption, digital signatures, and more.
    [Top]
    Other Articles
    Feb 3, 2005 - ASP.NET Mixed Mode Authentication
    In many web applications it is desirable for both intranet users and external parties to be able to seamlessly log onto the system. The problem this raises is that it is not easy to allow intranet users to log in via Windows integrated authentication while also allowing external parties to log in to the same application using standard forms authentication. This article will show you one way to achieve the best of both worlds when it comes to authentication.
    [Read This Article]  [Top]
    Dec 8, 2004 - Designing Role-Based Security Models for .NET
    In this article, Michele Leroux Bustamante discusses authentication, authorization and role-based security in .NET. Along the way, he provides some best practices for implementing role-based security in some typical .NET application scenarios including rich clients, Web applications, and Web services.
    [Read This Article]  [Top]
    May 11, 2004 - SharePoint Security and .NET Impersonation
    When implementing custom components that require access to restricted resources, implicit impersonation must be used. Jay Nathan shows how to create a class that makes using .NET Impersonation a snap.
    [Read This Article]  [Top]
    Mar 10, 2004 - Intellectual Property Protection and Code Obfuscation
    Learn about the execution process of CLR-based programs and how to protect your applications from being easily disassembled back into source code.
    [Read This Article]  [Top]
    Feb 24, 2004 - How to Send Secure Mail in ASP-Based E-Commerce Applications - Part II
    Businesses that utilize encrypted e-mail may find Secure Multipurpose Internet Mail Extensions (S/MIME) to be somewhat restrictive. This article shows how to use security features in PDF as an alternative to S/MIME.
    [Read This Article]  [Top]
    Feb 2, 2004 - Fighting Spambots with .NET and AI
    Bill Gates, in a recent interview, predicted the end of spam by 2006. One of the methods he mentioned involved a challenge only a real live person could handle. Adnan Masood shows how to use AI and .NET to create a user verification scheme that incorporates similar concepts Gates alluded to.
    [Read This Article]  [Top]
    Jan 21, 2004 - Configuring .NET Code Access Security
    Code Access Security (CAS) is the .NET Framework security model that grants code permission to resources based on "evidence" pertaining to the encapsulating assembly. In this article, David Myers examines CAS and explains different configuration methods.
    [Read This Article]  [Top]
    Mar 10, 2003 - Platform Neutral and Transparent Encryption of Sensitive Customer Information
    Zhenlei Cai combines an open source C++ encryption library with SQL Server extended stored procedures to create a platform neutral, transparent encryption solution that resides at the database layer.
    [Read This Article]  [Top]
    Jan 15, 2003 - Exploring Machine.Config - User Security and More
    Christopher Spann offers a .NET configuration tip that should help ease system administrators' fears of security compromise and thus assuage growing developer demand for a .NET environment.
    [Read This Article]  [Top]
    Dec 10, 2002 - Encrypting Cookie Data with ASP.NET
    You don't have to be a cryptography expert or spend lots of money on third-party components to secure sensitive data in .NET. In this article, Wayne Plourde shows just how easy it is to encrypt cookie data using encryption classes in the .NET System.Security.Cryptography namespace.
    [Read This Article]  [Top]
    Mailing List
    Want to receive email when the next article is published? Just Click Here to sign up.

    Support the Active Server Industry



    JupiterOnlineMedia

    internet.comearthweb.comDevx.commediabistro.comGraphics.com

    Search:

    Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

    Jupitermedia Corporate Info


    Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

    Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

    Solutions
    Whitepapers and eBooks
    Microsoft Article: HyperV-The Killer Feature in WinServer ‘08
    Avaya Article: How to Feed Data into the Avaya Event Processor
    Microsoft Article: Install What You Need with Win Server ‘08
    HP eBook: Putting the Green into IT
    Whitepaper: HP Integrated Citrix XenServer for HP ProLiant Servers
    Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 1
    Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 2--The Future of Concurrency
    Avaya Article: Setting Up a SIP A/S Development Environment
    IBM Article: How Cool Is Your Data Center?
    Microsoft Article: Managing Virtual Machines with Microsoft System Center
    HP eBook: Storage Networking , Part 1
    Microsoft Article: Solving Data Center Complexity with Microsoft System Center Configuration Manager 2007
    MORE WHITEPAPERS, EBOOKS, AND ARTICLES
    Webcasts
    Intel Video: Are Multi-core Processors Here to Stay?
    On-Demand Webcast: Five Virtualization Trends to Watch
    HP Video: Page Cost Calculator
    Intel Video: APIs for Parallel Programming
    HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
    Microsoft Silverlight Video: Creating Fading Controls with Expression Design and Expression Blend 2
    MORE WEBCASTS, PODCASTS, AND VIDEOS
    Downloads and eKits
    Sun Download: Solaris 8 Migration Assistant
    Sybase Download: SQL Anywhere Developer Edition
    Red Gate Download: SQL Backup Pro and free DBA Best Practices eBook
    Red Gate Download: SQL Compare Pro 6
    Iron Speed Designer Application Generator
    MORE DOWNLOADS, EKITS, AND FREE TRIALS
    Tutorials and Demos
    How-to-Article: Preparing for Hyper-Threading Technology and Dual Core Technology
    eTouch PDF: Conquering the Tyranny of E-Mail and Word Processors
    IBM Article: Collaborating in the High-Performance Workplace
    HP Demo: StorageWorks EVA4400
    Intel Featured Algorhythm: Intel Threading Building Blocks--The Pipeline Class
    Microsoft How-to Article: Get Going with Silverlight and Windows Live
    MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES