In
software development
Software development is the process of conceiving, specifying, designing, programming, documenting, testing, and bug fixing involved in creating and maintaining applications, frameworks, or other software components. Software development inv ...
, obfuscation is the act of creating
source or
machine code
In computer programming, machine code is any low-level programming language, consisting of machine language instructions, which are used to control a computer's central processing unit (CPU). Each instruction causes the CPU to perform a ver ...
that is difficult for humans or computers to understand. Like
obfuscation
Obfuscation is the obscuring of the intended meaning of communication by making the message difficult to understand, usually with confusing and ambiguous language. The obfuscation might be either unintentional or intentional (although intent u ...
in
natural language
In neuropsychology, linguistics, and philosophy of language, a natural language or ordinary language is any language that has evolved naturally in humans through use and repetition without conscious planning or premeditation. Natural languag ...
, it may use needlessly roundabout expressions to compose statements. Programmers may deliberately obfuscate code to conceal its purpose (
security through obscurity
Security through obscurity (or security by obscurity) is the reliance in security engineering on design or implementation secrecy as the main method of providing security to a system or component.
History
An early opponent of security through ob ...
) or its logic or implicit values embedded in it, primarily, in order to prevent tampering, deter
reverse engineering
Reverse engineering (also known as backwards engineering or back engineering) is a process or method through which one attempts to understand through deductive reasoning how a previously made device, process, system, or piece of software accompli ...
, or even to create a
puzzle
A puzzle is a game, problem, or toy that tests a person's ingenuity or knowledge. In a puzzle, the solver is expected to put pieces together ( or take them apart) in a logical way, in order to arrive at the correct or fun solution of the puzzle ...
or recreational challenge for someone reading the source code. This can be done manually or by using an automated tool, the latter being the preferred technique in industry.
Overview
The architecture and characteristics of some languages may make them easier to obfuscate than others.
C,
C++, and the
Perl
Perl is a family of two High-level programming language, high-level, General-purpose programming language, general-purpose, Interpreter (computing), interpreted, dynamic programming languages. "Perl" refers to Perl 5, but from 2000 to 2019 it ...
programming language
A programming language is a system of notation for writing computer programs. Most programming languages are text-based formal languages, but they may also be graphical. They are a kind of computer language.
The description of a programming l ...
are some examples of languages easy to obfuscate.
Haskell is also quite obfuscatable despite being quite different in structure.
The properties that make a language obfuscatable are not immediately obvious.
Recreational obfuscation
Writing and reading obfuscated source code can be a
brain teaser. A number of programming contests reward the most creatively obfuscated code, such as the
International Obfuscated C Code Contest
The International Obfuscated C Code Contest (abbreviated IOCCC) is a computer programming contest for the most creatively obfuscated C code. Held annually, it is described as "celebrating 'ssyntactical opaqueness". The winning code for the 27 ...
and the
Obfuscated Perl Contest.
Types of obfuscations include simple keyword substitution, use or non-use of whitespace to create artistic effects, and self-generating or heavily compressed programs.
According to
Nick Montfort
Nick Montfort is a poet and professor of digital media at MIT, where he directs a lab called The Trope Tank. He also holds a part-time position at the University of Bergen where he leads a node on computational narrative systems at the Center fo ...
, techniques may include:
# naming obfuscation, which includes naming variables in a meaningless or deceptive way;
# data/code/comment confusion, which includes making some actual code look like comments or confusing syntax with data;
# double coding, which can be displaying code in poetry form or interesting shapes.
Short obfuscated
Perl
Perl is a family of two High-level programming language, high-level, General-purpose programming language, general-purpose, Interpreter (computing), interpreted, dynamic programming languages. "Perl" refers to Perl 5, but from 2000 to 2019 it ...
programs may be used in
signatures of Perl programmers. These are JAPHs ("
Just another Perl hacker").
Examples
* Some
Python examples can be found in th
official Python programming FAQand elsewhere.
* The ''movfuscator''
C compiler
In computing, a compiler is a computer program that translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primarily used for programs that ...
for the
x86_32 ISA uses only the
''mov'' instruction in order to obfuscate
Disadvantages of obfuscation
* While obfuscation can make reading, writing, and reverse-engineering a program difficult and time-consuming, it will not necessarily make it impossible.
* It adds time and complexity to the build process for the developers.
* It can make debugging issues after the software has been obfuscated extremely difficult.
* Once code becomes
abandonware
Abandonware is a product, typically software, ignored by its owner and manufacturer, and for which no official support is available.
Within an intellectual rights contextual background, abandonware is a software (or hardware) sub-case of the ...
and is no longer maintained, hobbyists may want to maintain the program, add mods, or understand it better. Obfuscation makes it hard for end users to do useful things with the code.
* Certain kinds of obfuscation (i.e. code that isn't just a local binary and downloads mini binaries from a web server as needed) can degrade performance and/or require Internet.
Decompilers
A
decompiler can reverse-engineer source code from an executable or library. Decompilation is sometimes called a man-at-the-end attack, based on the traditional cryptographic attack known as "
man-in-the-middle". It puts source code in the hands of the user, although this source code is often difficult to read. The source code is likely to have random function and variable names, incorrect variable types, and use different logic than the original source code (due to compiler optimizations).
Cryptographic obfuscation
Cryptographers have explored the idea of obfuscating code so that reverse-engineering the code is ''cryptographically'' hard. This is formalized in the many proposals for
indistinguishability obfuscation, a cryptographic primitive that, if possible to build securely, would allow one to construct many other kinds of cryptography, including completely novel types that no one knows how to make. (A stronger notion,
black-box obfuscation, was shown impossible in 2001 when researchers constructed programs that cannot be obfuscated in this notion.)
Notifying users of obfuscated code
Some anti-virus softwares, such as
AVG AntiVirus, will also alert their users when they land on a website with code that is manually obfuscated, as one of the purposes of obfuscation can be to hide malicious code. However, some developers may employ code obfuscation for the purpose of reducing file size or increasing security. The average user may not expect their antivirus software to provide alerts about an otherwise harmless piece of code, especially from trusted corporations, so such a feature may actually deter users from using legitimate software.
Mozilla and Google disallow browser extensions containing obfuscated code in their add-ons store.
Obfuscating software
A variety of tools exist to perform or assist with code obfuscation. These include experimental research tools created by academics, hobbyist tools, commercial products written by professionals, and
open-source software
Open-source software (OSS) is computer software that is released under a license in which the copyright holder grants users the rights to use, study, change, and distribute the software and its source code to anyone and for any purpose. Ope ...
. Deobfuscation tools also exist that attempt to perform the reverse transformation.
Although the majority of commercial obfuscation solutions work by transforming either program source code, or platform-independent bytecode as used by Java and .NET, there are also some that work directly on compiled binaries.
Obfuscation and copyleft licenses
There has been debate on whether it is illegal to skirt
copyleft
Copyleft is the legal technique of granting certain freedoms over copies of copyrighted works with the requirement that the same rights be preserved in derivative works. In this sense, ''freedoms'' refers to the use of the work for any purpose, ...
software licenses
A software license is a legal instrument (usually by way of contract law, with or without printed material) governing the use or redistribution of software. Under United States copyright law, all software is copyright protected, in both source c ...
by releasing source code in obfuscated form, such as in cases in which the author is less willing to make the source code available. The issue is addressed in the
GNU General Public License
The GNU General Public License (GNU GPL or simply GPL) is a series of widely used free software licenses that guarantee end user
In product development, an end user (sometimes end-user) is a person who ultimately uses or is intended to ulti ...
by requiring the "preferred form for making modifications" to be made available. The GNU website states "Obfuscated 'source code' is not real source code and does not count as source code."
See also
*
AARD code
The AARD code was a segment of code in a beta release of Microsoft Windows 3.1 that would determine whether Windows was running on MS-DOS or PC DOS, rather than a competing workalike such as DR-DOS, and would result in a cryptic error mess ...
*
Spaghetti code
*
Write-only language
*
Decompilation
*
Esoteric programming language
*
Quine
Quine may refer to:
* Quine (surname), people with the surname ''Quine''
* Willard Van Orman Quine, the philosopher, or things named after him:
** Quine (computing), a program that produces its source code as output
** Quine–McCluskey algorithm, ...
*
Overlapping instructions
*
Polymorphic code
In computing, polymorphic code is code that uses a polymorphic engine to mutate while keeping the original algorithm intact - that is, the ''code'' changes itself every time it runs, but the ''function'' of the code (its semantics) will not chang ...
*
Hardware obfuscation
*
Underhanded C Contest
*
Source-to-source compiler
*
ProGuard (Java Obfuscator)
*
Dotfuscator (.Net Obfuscator)
*
Digital rights management
Digital rights management (DRM) is the management of legal access to digital content. Various tools or technological protection measures (TPM) such as access control technologies can restrict the use of proprietary hardware and copyrighted work ...
*
Indistinguishability obfuscation
*
Source code beautification
Pretty-printing (or prettyprinting) is the application of any of various stylistic formatting conventions to text files, such as source code, markup, and similar kinds of content. These formatting conventions may entail adhering to an indentatio ...
Notes
References
* Seyyedhamzeh, Javad
ABCME: A Novel Metamorphic Engine 17th National Computer Conference, Sharif University of Technology, Tehran, Iran, 2012.
*B. Barak, O. Goldreich, R. Impagliazzo, S. Rudich, A. Sahai, S. Vadhan and K. Yang
"On the (Im)possibility of Obfuscating Programs" ''21st Annual International Cryptology Conference'', Santa Barbara, California, USA. Springer Verlag LNCS Volume 2139, 2001.
*
External links
The International Obfuscated C Code Contest ACM Crossroads, Spring 1998 issue
*
*
c2:BlackBoxComputation
{{DEFAULTSORT:Obfuscated Code
Anti-patterns
Articles with example C code
Obfuscation
Source code
Program transformation
es:Ofuscación#Informática