English 中文(简体)
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 .

最佳回答

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

问题回答

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.

Polymorphic code is a nice thing, but metamorphic is even nicer. To the legitimate uses: well, I can t think of anything other than anti-cracking and copy protection. Look at vx.org.ua if you wan t real world uses (not that legitimate though)

As Sami notes, on-the-fly optimisation is an excellent application of polymorphic code. A great example of this is the Fastest Fourier Transform in the West. It has a number of solvers at its disposal, which it combines with self-profiling to adjust the code path and solver parameters on subsequent executions. The result is the program optimises itself for your computing environment, getting faster with subsequent runs!

A related idea that may possibly be of interest is computational steering. This is the practice of altering the execution path of large simulations as the run proceeds, to focus on areas of interest to the researcher. The overall purpose of the simulation is not changed, but the feedback cycle acts to optimise the calculation. In this case the executable code is not being explicitly rewritten, but the effect from a user perspective is similar.

Polymorph code can be used to obfuscate weak or proprietary algorithms - that may use encryption e. g.. There re many "legitimate" uses for that. The term legitimate these days is kind of narrow-minded when it comes to IT. The core-paradigms of IT contain security. Whether you use polymorph shellcode in exploits or detect such code with an AV scanner. You have to know about it.

Obfuscate a program i.e. prevent reverse-engineering: goal being to protect IP (Intellectual Property).





相关问题
How do you set the class of an object to something else?

I ve seen this recently and now I can t find it … How do you set the class of an object to something else? --Update: Well, in Pharo! Like: d:=Object new. d setClass: Dictionary. Only that it isn ...

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? ...

How can I get this snippet to work?

I d like to port a little piece of code from Ruby to Groovy, and I m stuck at this: def given(array,closure) { closure.delegate = array closure() } given([1,2,3,4]) { findAll { it > 4} ...

Why can t I use attr_accessor inside initialize?

I m trying to do an instance_eval followed by a attr_accessor inside initialize, and I keep getting this: ``initialize : undefined method attr_accessor `. Why isn t this working? The code looks kind ...

热门标签