Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Polymorphic Code for Legitimate Purposes?

I recently came across the term Polymorphic Code, and was wondering if anyone could suggest a legitimate (i.e. in legal and business appropriate software) reason to use it in a computer program? Links to real world examples would be appreciated!

Before someone answers, telling us all about the benefits of polymorphism in object oriented programming, please read the following definition for polymorphic code (taken from Wikipedia):

"Polymorphic code is code that uses a polymorphic engine to mutate while keeping the original algorithm intact. That is, the code changes itself each time it runs, but the function of the code in whole will not change at all."

Thanks, MagicAndi.

Update

Summary of answers so far:

  • Runtime optimization of the original code
  • Assigning a "DNA fingerprint" to each individual copy of an application
  • Obfuscate a program to prevent reverse-engineering

I was also introduced to the term 'metamorphic code'.

like image 742
Tangiest Avatar asked Nov 22 '09 19:11

Tangiest


People also ask

What is purpose of polymorphic code?

Polymorphic viruses are complex file infectors that can create modified versions of itself to avoid detection yet retain the same basic routines after every infection. To vary their physical file makeup during each infection, polymorphic viruses encrypt their codes and use different encryption keys every time.

What is polymorphic coding?

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 change at all.

What is the purpose of polymorphism in malware?

Polymorphic techniques involve frequently changing identifiable characteristics like file names and types or encryption keys to make the malware unrecognizable to many detection techniques. Polymorphism is used to evade pattern-matching detection relied on by security solutions like antivirus software.

What is true polymorphic code?

Polymorphic code typically uses a mutation engine that accompanies the underlying malicious code. The mutation engine doesn't change the underlying code; instead, the engine generates new decryption routines for the code. The mutation engine can also alter the file names of the polymorphic code.


2 Answers

Runtime optimization of the original code, based on actual performance statistics gathered when running the application in its real environment and real inputs.

like image 177
Sami Avatar answered Oct 11 '22 11:10

Sami


Digitally watermarking music is something often done to determine who was responsible for leaking a track, for example. It makes each copy of the music unique so that copies can be traced back to the original owner, but doesn't affect the audible qualities of the track.

Something similar could be done for compiled software by running each individual copy through a polymorphic engine before distributing it. Then if a cracked version of this software is released onto the Internet, the developer might be able to tell who cracked it by looking for specific variations produced the polymorphic engine (a sort of DNA test). As far as I know, this technique has never been used in practice.

It's not exactly what you were looking for I guess, since the polymorphic engine is not distributed with the code, but I think it's the closest to a legitimate business use you will find for this kind of technique.

like image 42
Mark Byers Avatar answered Oct 11 '22 12:10

Mark Byers