DE102007059798B3 - Executable program code i.e. executable file, coding method for computer, involves combining chains of sequential instructions to code fragments, and coding and storing detected code fragments belonging to methods in program library - Google Patents

Executable program code i.e. executable file, coding method for computer, involves combining chains of sequential instructions to code fragments, and coding and storing detected code fragments belonging to methods in program library Download PDF

Info

Publication number
DE102007059798B3
DE102007059798B3 DE200710059798 DE102007059798A DE102007059798B3 DE 102007059798 B3 DE102007059798 B3 DE 102007059798B3 DE 200710059798 DE200710059798 DE 200710059798 DE 102007059798 A DE102007059798 A DE 102007059798A DE 102007059798 B3 DE102007059798 B3 DE 102007059798B3
Authority
DE
Germany
Prior art keywords
code
program
address
program code
fragments
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Fee Related
Application number
DE200710059798
Other languages
German (de)
Inventor
Gerhard Gappmeier
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
ASCOLAB GmbH
Original Assignee
ASCOLAB GmbH
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by ASCOLAB GmbH filed Critical ASCOLAB GmbH
Priority to DE200710059798 priority Critical patent/DE102007059798B3/en
Application granted granted Critical
Publication of DE102007059798B3 publication Critical patent/DE102007059798B3/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/10Protecting distributed programs or content, e.g. vending or licensing of copyrighted material ; Digital rights management [DRM]
    • G06F21/12Protecting executable software
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/10Protecting distributed programs or content, e.g. vending or licensing of copyrighted material ; Digital rights management [DRM]
    • G06F21/12Protecting executable software
    • G06F21/14Protecting executable software against software analysis or reverse engineering, e.g. by obfuscation

Abstract

The method involves copying unmodified program code directly into a main memory of a processing unit. Structural data e.g. portable executable file format data, is evaluated directly for identification of methods of the program code. Volatile components are detected by parsing the program code of methods, which cause an interruption and/or a branching in a sequential process of the program code in a run time. Chains of sequential instructions are combined to code fragments in the code. Detected code fragments belonging to the methods are individually coded and stored in a program library.

Description

Die Erfindung betrifft ein Verfahren zur Verschlüsselung von ausführbarem Programmcode. Bei dem Programmcode kann es sich z. B. um eine ausführbare Datei im bekannten EXE Format oder z. B. eine Dynamic Link Library DLL handelt, welche Maschinencode, Daten und Ressourcen in beliebigen Kombinationen enthalten können.The The invention relates to a method for encrypting executable Program code. The program code may be z. For example, an executable file in the known EXE format or z. For example, a dynamic link library DLL is what machine code, data and resources in any Combinations may contain.

Bekannte Verfahren zum Schutz von Anwenderprogrammen gegen unautorisierten Betrieb, Manipulation und unautorisierte Vervielfältigung beruhen darauf, dass mit Hilfe einer speziellen Schutzsoftware diverse Sicherheitschecks mit einem positiven Ergebnis durchgeführt werden müssen, bevor diese Anwenderprogramme ausgeführt werden kann. Derartige Schutzsoftware führen hierzu bekannte Sicherheitschecks durch, wie z. B. die Verifikation von Checksummen, eine Debugger Detection, u. s. w.. Doch wie das zu schützende Programm, sind auch diese Sicherheitschecks in Software implementiert. Selbst wenn zusätzliche Hardware eingesetzt wird, wie z. B. ein Dongle, welcher zur Freigabe des Betriebs von Programmen an einer Schnittstelle eines ausführenden Rechners gesteckt sein muss, überprüfen die Sicherheitschecks somit die zu schützende Software wiederum mit Software.Known Method for protecting user programs against unauthorized Operation, manipulation and unauthorized duplication are based on the fact that with the help of a special protection software diverse Safety checks are carried out with a positive result have to, before these application programs can be executed. such Protective software lead this known security checks by, such. B. the verification of checksums, a debugger detection, u. s. w .. But like that program to protect These security checks are also implemented in software. Even if additional Hardware is used, such. B. a dongle, which for release the operation of programs at an interface of an executing Calculator must be plugged, check the Security checks thus the software to be protected with turn Software.

Bei derartigen Sicherheitschecks tritt das Problem auf, dass diese trotz aller Komplexität am Ende zu einer bedingten Entscheidung führen, ob nämlich das Programm tatsächlich ausgeführt bzw. fortgesetzt werden darf oder blockiert bzw. abgebrochen werden muss. Eine solche bedingte Entscheidung stellt wiederum selbst einen in der Regel kurzen, klar abgrenzbaren Bereich von Programmcode dar. Es ist somit möglich, den Bereich an Programmcode, welcher eine derartige finale bedingte Entscheidung über die Ausführung oder Sperrung eines übergeordneten Programms repräsentiert, selbst in einem umfangreichen Programmlisting einer Schutzsoftware zu identifizieren. Es ist dann ohne weiteres möglich, selektiv die bedingte Entscheidung durch Manipulation unwirksam zu machen, also quasi die Bedingung zu überschreiben, so dass das auszuführende Programm unabhängig von dieser Bedingung in jedem Fall uneingeschränkt ausgeführt wird. Auf dieses Weise kann ein Sicherheitscheck unabhängig von der Vielzahl und Komplexität der von ihm während des Prüfablaufes vorgenommenen Plausibilitätsüberprüfungen unwirksam gemacht werden.at such safety checks, the problem arises that this despite of all complexity lead to a conditional decision as to whether the program is actually executed or may be continued or blocked or aborted. Such a conditional decision, in turn, sets one yourself usually short, clearly demarcated area of program code. It is thus possible the range of program code which has such a final conditional Decision over execution or blocking a parent Program represents, even in a comprehensive program listing of a protection software to identify. It is then readily possible to selectively conditional Decision by manipulation ineffective, so to speak to override the condition so that the executable Program independent In any case, this condition is executed without restriction. In this way can be a security check independently from the variety and complexity the one from him while the test procedure made plausibility checks ineffective be made.

Ein weiteres Problem einer Vielzahl von kommerziellen Implementierungen von Schutzsoftware z. B. gegen unautorisierte Vervielfältigung eines Programms wird darin gesehen, dass die darin implementierten Sicherheitschecks quasi statisch sind. Dies hat zur Folge, dass unabhängig davon, welches Programm mit einer bestimmten Schutzsoftware abgesichert werden soll, die darin implementierten Sicherheitschecks immer identisch sind. Derartig wiederkehrende Schutzsoftware stellt somit eine Art von „digitalem Fingerprint" dar. Dieser kann selbst dann, wenn er im umfangreichen Listing eines beliebigen Programms implementiert ist, gefunden und durch eine manipulierte Version ersetzt werden. Es ist sogar möglich, derartige Manipulationen quasi zu automatisieren. Hierzu ist es möglich, einen so genannten „Crack" zu erstellen. Hierbei handelt es sich um ein Computerprogramm, welches zur Manipulation einer bestimmten, bekannten Schutzsoftware dient. Ein solcher „Crack" kann z. B. über das Internet verteilt werden, und steht dann zur universellen Manipulation eines jeden Programms zur Verfügung, bei dem die bekannte Schutzsoftware verwendet wird.One further problem of a variety of commercial implementations of protection software z. B. against unauthorized duplication of a program is seen to be implemented in it Security checks are virtually static. This has the consequence that independently of which program is secured with a specific protection software should always be identical to the security checks implemented in it are. Such recurrent protection software is thus a kind from "digital Fingerprint "dar. This can be even if he is in the extensive listing of a any program is implemented, found and by a be replaced manipulated version. It is even possible, such Automating manipulations, so to speak. For this it is possible to have a so-called "crack" to create it is a computer program used for manipulation a specific, known protection software is used. Such a "crack" can, for example, over the Internet are distributed, and then stands for universal manipulation of every program available, where the known protection software is used.

Zur Vermeidung der oben dargestellten Probleme kann in einem ersten Schritt die Schutzsoftware selbst vor Manipulationen geschützt werden. Dies kann z. B. durch den Einsatz einer Verschlüsselung erreicht werden. Dazu können gängige Verschlüsselungsstandards, wie z. B. AES, d. h. Advanced Encryption Standard, verwendet werden. Es ist jedoch bekannt, dass die einfache Verschlüsselung von ausführbaren Programmen, wie z. B. ausführbare Dateien mit der Dateina menserweiterung EXE oder dynamisch ladbare Bibliotheken, d. h. eine Dynamic Link Library DLL, unter dem Betriebssystem WINDOWS, ebenfalls nicht sicher gegen Manipulation ist. Zur berechtigten Ausführung solcher Programme müssen diese nämlich in den Arbeitsspeicher eines Rechners geladen und dort dekodiert werden. Nachdem diese Schritte ausgeführt wurden, kann das gesamte Programm nun unverschlüsselt wieder aus dem Speicher ausgelesen werden. Es liegt nun in völlig ungeschützter Form vor und kann auf einfache Weise zum Ziel von herkömmlichen Manipulationen werden.to Avoiding the problems outlined above can be a first Step the protection software itself are protected from manipulation. This can be z. B. be achieved by the use of encryption. To can common Encryption standards, such as AES, d. H. Advanced Encryption Standard, to be used. However, it is known that the simple encryption of executable Programs, such. B. executable Files with file extension EXE or dynamically loadable Libraries, d. H. a dynamic link library DLL, under the operating system WINDOWS, too, is not safe against manipulation. To the legitimate execution of such programs these namely loaded into the memory of a computer and decoded there become. After these steps have been performed, the entire Program now unencrypted be read out of memory again. It is now in completely unprotected form before and can easily become the target of conventional Manipulations are.

Aus der US 2004/0193987 A1 sind weiterhin ein Verfahren und eine Vorrichtung zum Schutz von Softwareprogrammen gegen unerlaubte Benutzung bekannt. Hierzu ist ein Softwareprogramm in zwei Codeteile aufgeteilt. Während der erste Teil des Codes auf einem ersten Computer ausgeführt wird, umfasst der zweite Teil ein oder mehrere Codefragmente des Softwareprogramms, welche von einer externen Einheit verarbeitet werden. Die externe Einheit steht dabei in einer Datenkommunikation mit dem Computer. Gemäß einer Weiterführung ist dieser zweite Teil des Programmcodes verschlüsselt. Vor der eigentlichen Programmausführung werden die Codefragmente dieses zweiten Teils zum Zwecke der Entschlüsselung zu einer maniplulationssicheren externen Einheit übertragen. Dabei können diese einzelnen Codefragmente im ersten Teil des Softwareprogrammcodes auch verteilt sein.From the US 2004/0193987 A1 Furthermore, a method and a device for the protection of software programs against unauthorized use are known. For this purpose, a software program is divided into two code parts. While the first part of the code is being executed on a first computer, the second part comprises one or more code fragments of the software program being processed by an external unit. The external unit is in a data communication with the computer. According to a continuation of this second part of the program code is encrypted. Before the actual program execution, the code fragments of this second part become a maniplulation for the purpose of decryption transferred to the external unit. These individual code fragments may also be distributed in the first part of the software program code.

Der Erfindung liegt die Aufgabe zu Grunde ein Verschlüsselungsverfahren anzugeben, welches ein programmspezifisches und damit gegen Angriffe erheblich robusteres Verschlüsselungsergebnis bereitstellt.Of the The invention is based on the object of an encryption method specify which program-specific and thus against attacks much more robust encryption result provides.

Die Aufgabe der Erfindung wird mit den Merkmalen der im Anspruch 1 angegebenen gelöst. Weitere vorteilhafte Ausführungsformen der Erfindung sind in den Unteransprüchen angegeben.The The object of the invention is specified with the features of claim 1 solved. Further advantageous embodiments The invention are specified in the subclaims.

Für die Definition der Erfindung und die Erläuterung von in den Figuren dargestellten Beispielen wird nachfolgend der Begriff METHODEN verwendet. Hierunter werden die von einer Programmiersprache bereitgestellten Funktionen oder Prozeduren verstanden. Handelt es sich z. B. um eine objektorientierte Programmiersprache, so entsprechen die METHODEN den einer Klasse von Objekten zugeordneten Algorithmen.For the definition the invention and the explanation of examples shown in the figures is hereinafter the Term METHODS used. Below are those of a programming language understood functions or procedures. These it is z. B. to an object-oriented programming language, so correspond the METHODS are the algorithms associated with a class of objects.

Zur Durchführung des erfindungsgemäßen Verfahrens wird in einem ersten Schritt von einer Verarbeitungseinheit ausführbarer Programmcode unmodifiziert direkt in den Arbeitsspeicher einer Verarbeitungseinheit kopiert. Vorteilhaft erfolgt dies durch ein manuelles Laden des zu extrahierenden Programmcodes in den Speicher. Dies hat den Zweck zu verhindern, dass der zu extrahierende Programmcode durch den Ladevorgang in irgendeiner Weise verändert wird. Würde stattdessen der Ladevorgang mit Hilfe von Mitteln eines Betriebssys stems, z. B. mit dem Loader eines Betriebssystems, durchgeführt werden, so würde dabei der Maschinencode bereits für eine spätere Ausführung durch das Betriebssystem vorbereitet werden, d. h. Maschinencode Relocation würde durchgeführt und damit der Maschinencode modifiziert werden. Dies wäre aber hinderlich für einen erfolgreichen Ablauf des erfindungsgemäßen Verfahrens.to execution the method according to the invention becomes more executable by a processing unit in a first step Program code unmodified directly into the memory of a processing unit copied. This is advantageously done by manually loading the to be extracted program codes in the memory. This has the purpose to prevent the program code to be extracted by the Charging process is changed in any way. Would instead the charging process by means of a Betriebsssys stems, z. With the loader of an operating system, so would while the machine code already for later execution by the operating system be prepared, d. H. Machine code relocation would be done and so that the machine code can be modified. But that would be hindering for a successful operation of the method according to the invention.

In einem zweiten Schritt werden zur Identifikation der einzelnen Methoden des Programmcodes Strukturdaten direkt ausgewertet. Hierzu geeignete Strukturdaten sind insbesondere z. B. PE-Header-Daten, d. h. Portable Executable File Format Daten, mit denen einer symbolischen Adressierung eine reale Adressierung zugeordnet werden kann, und z. B. Relocation Tabellen. In diesem zweiten Schritt wird die komplette datentechnisch Strukturierung des Programmcodes in dessen einzelne Funktionen bzw. Methoden analysiert. Dabei werden insbesondere die Funktions-Einsprungadressen der DLL ermittelt. Zur Erhaltung der ursprünglichen Form der Daten ist es auch hier notwendig, dass die Auswertung der Strukturdaten direkt und nicht unter zu Hilfenahme von Befehlen eines Betriebssystems erfolgt.In a second step will be to identify the individual methods of the program code structure data is evaluated directly. Suitable for this purpose Structure data are in particular z. B. PE Header Data, d. H. Portable Executable file format data that uses a symbolic addressing a real addressing can be assigned, and z. Eg relocation Tables. In this second step, the complete data technology Structuring the program code into its individual functions or Methods analyzed. In particular, the function entry addresses the DLL detects. To preserve the original form of the data is it also necessary here that the evaluation of the structural data directly and not with the help of commands from an operating system he follows.

Nach dieser Identifikation der Methoden, d. h. insbesondere der Erfassung von deren Einsprungsadressen, wird in einem dritten Schritt eine vollständige Analyse bzw. Disassemblierung des Programmcodes durchgeführt. Dieser Vorgang wird auch statische Maschinencode Analyse oder Parsing von Maschinencode genannt. Hierzu wird der Programmcode von jeder Methode bzw. Funktion auf Bestandteile abgesucht, welche zur Runtime eine Unterbrechung in der sequentiellen Abarbeitung des Programmcodes verursachen würden. Bei diesen Bestandteilen handelt es sich insbesondere um bedingte und unbedingte Sprungbefehle und Rücksprungsbefehle, welche den Programmablauf beenden. Bedingte Sprünge entsprechen logischen Abzweigungen. Falls solche Abzweigungen im Maschinencode entdeckt werden, so werden auch alle davon abgehenden Programmpfade weiter verfolgt und in entsprechender Weise abgesucht.To this identification of the methods, d. H. in particular the detection of their entry addresses, in a third step, a full Analysis or disassembly of the program code performed. This Operation will also static machine code analysis or parsing of Machine code called. This will be the program code of each method or function scanned for components, which at runtime a Interruption in the sequential processing of the program code would cause. at these components are in particular conditional and unconditional jump instructions and return instructions, which terminate the program. Conditional jumps correspond to logical branches. If such branches are detected in the machine code, then also pursued all outgoing program paths and in searched accordingly.

In der Praxis wird beim Parsing in der Regel ausgehend von der Einsprungsadresse einer jeden Methode der sich anschließende Maschinencode durch Auslesen des Speichers disassembliert und auf die oben genannten Elemente abgesucht, welche eine Unterbrechung des linearen Programmablaufes, d. h. eine Unterbrechung der Abarbeitung von in unmittelbar aufeinander folgenden Speicherzellen des Arbeitsspeichers enthaltenem Maschinencode, verursachen.In The practice is parsing usually starting from the entry address each method of the subsequent machine code by reading of the memory disassembled and on the above elements which interrupts the linear program sequence, d. H. an interruption of the processing of in immediate succession following memory cells of the main memory contained machine code, cause.

Nach Abschluss der Ablaufverfolgung des Programmcodes werden in einem vierten Schritt Codefragmente gebildet. Dies kann auch als Extraktion bezeichnet werden. Derartige Codefragmente sind Ketten von unmittelbar aufeinander folgenden, zur Rumtime linear hintereinander ausgeführten Anweisungen im Programmcode. Codefragmente sind also zusammenhängende Gruppen von Maschinencode. In der Praxis werden hierbei die Codefragmente in der Regel derart aus dem ursprünglichen Programmcode extrahiert, dass diese z. B. durch entsprechende Adressbezüge miteinander verbunden sind, so dass bei einem Ablauf dieser Codefragmente zur Runtime die gleichen Funktionen bereitgestellt werden, wie sie bei einem Ablauf des ursprünglichen, nicht mit dem erfindungsgemäßen Verfahren behandelten Programmcodes auftreten würden.To Completing the trace of the program code will be in one fourth step formed code fragments. This can also be as an extraction be designated. Such code fragments are chains of immediate successive, to the Rumtime linear consecutively executed instructions in the program code. Code fragments are thus contiguous groups of machine code. In practice, here are the code fragments usually extracted in such a way from the original program code, that these z. B. are interconnected by appropriate address references, so that at expiration of these code fragments at runtime the same Functions are provided, as in the expiration of the original, not with the method according to the invention treated program codes would occur.

Das erfindungsgemäße Verfahren hat zur Folge, dass ein gemäß der Erfindung gebildetes Codefragment insbesondere entweder mit der zur jeweiligen Methode gehörigen Einsprungadresse oder mit der Zieladresse einer Abzweigung beginnt. Weiterhin endet ein Codefragment insbesondere dann, wenn während der Programmablaufverfolgung entweder eine übliche programmtechnische Endebedingung, wie z. B. ein RET Befehl, oder ein absoluter Sprungbefehl, wie z. B. ein JMP Befehl, detektiert wurden. Gemäß einer weiteren Ausführung der Erfindung können diese Codefragmente vorteilhaft durch ihre Startadresse und Länge definiert werden. Als LÄNGE kann hierzu z. B. die Anzahl der zwischen End- und Startadresse eines Codefragments liegenden Bytes an Maschinencode dienen. Es wird also für jede einzelne der Methoden, die z. B. ein Programm oder eine DLL repräsentieren, ein kompletter Baum aus den Codefragmenten erstellt, welche die einzelne Methode repräsentieren.The result of the method according to the invention is that a code fragment formed according to the invention can be used in particular either with the entry address belonging to the respective method or with the destination address of a branch begins. Furthermore, a code fragment ends, in particular, when during program tracing either a common program-technical end condition, such. As a RET command, or an absolute jump command such. As a JMP command were detected. According to a further embodiment of the invention, these code fragments can be advantageously defined by their start address and length. As a LENGTH z. B. serve the number of lying between the end and start address of a code fragment bytes of machine code. So it is for each of the methods that z. For example, to represent a program or a DLL, a complete tree is created from the code fragments that represent the single method.

Die Extraktion der Codefragmente aus dem Maschinencode eines Programms oder einer DLL in der erfindungsgemäßen Weise bietet nun den besonderen Vorteil, dass in einem fünften und letzten Schritt die gefundenen Codefragmente, welche zu einer Methode gehören, individuell verschlüsselt und in einer Programmbibliothek abgelegt werden können. Vorteilhaft kann diese Programmbibliothek kann wiederum selbst zusätzlich speziell verschlüsselt werden.The Extraction of the code fragments from the machine code of a program or a DLL in the manner according to the invention now offers the special Advantage that in a fifth and last step, the found code fragments, which to a Include method, individually encrypted and can be stored in a program library. Advantageous In turn, this library can be self specific in addition encoded become.

Im Ergebnis wird also ein dem erfindungsgemäßen Verfahren unterzogenes ausführbares Programm oder eine Dynamic Link Library DLL durch die Programmbibliothek der einzeln verschlüsselten Codefragmente repräsentiert. Hiermit ist der besondere Vorteil verbunden, dass diese Programmbibliothek genauso individuell ist wie der ursprüngliche Programmcode selbst. Die Art der Verschlüsselung ist also vom jeweiligen Aufbau des Programmcodes abhängig und führt somit bei jedem Programmcode zu einem völlig unterschiedlichen Ergebnis. Dies macht es für einen Angreifer im Vergleich zum oben beschriebenen Stand der Technik erheblich viel schwerer, in die verschlüsselte Programmbibliothek der einzeln verschlüsselten Codefragmente eines individuellen Programmcodes einzudringen.in the The result is therefore subjected to the process according to the invention executable Program or a dynamic link library dll through the program library the individually encrypted Represents code fragments. This has the special advantage that this program library just as individual as the original program code itself. The type of encryption So depends on the particular structure of the program code and thus leads with each program code to a completely different result. This makes it for an attacker compared to the prior art described above much heavier in the encrypted program library of individually encrypted Code fragments of an individual program code.

Zusammengefasst werden bei dem erfindungsgemäßen Verfahren ausführbare Dateien bzw. Programme einer statischen Maschinencodeanalyse unterzogen, und dabei methodengranular extrahiert und verschlüsselt. Hierzu wird ein zu verschlüsselndes Programm mit dem erfindungsgemäßen Verfahren derart fragmentiert, dass alle darin enthaltenen Methoden in Form von geschlossenen Codefragmenten extrahiert, separat verschlüsselt und dann getrennt abgespeichert werden. Dabei stellt ein geschlossenes Codefragment eine Folge von Befehlen z. B. in einer Assemblerprogrammiersprache dar, deren Maschinencode in einem Arbeitsspeicher eine lückenlose Kette von aufeinander folgend abzuarbeitenden Anweisungen darstellt. Abhängig vom Umfang des zu verschlüsselnden Programms können dabei natürlich Methoden des gleichen Typs, aber mit unterschiedlichen Parametern, in großer Vielzahl auftreten. Alle diese Methoden werden erfindungsgemäß in einzelne, methodenbezogene und separat verschlüsselte Codefragmente extrahiert, durch deren Summe dann die ausführbare Datei bzw. das Programm repräsentiert wird.Summarized be in the inventive method executable Subjected files or programs to a static machine code analysis, and methodically extracted and encrypted. For this becomes a to be encrypted Program with the method according to the invention so fragmented that all the methods contained in it in form extracted from closed code fragments, encrypted separately and then be stored separately. It represents a closed Code fragment a sequence of commands e.g. In an assembler programming language whose machine code in a working memory a gapless Chain of instructions to be processed sequentially. Depending on Scope of the program to be encrypted can of course Methods of the same type but with different parameters, in big Variety occur. All these methods are inventively in individual, extracted method-related and separately encrypted code fragments, by the sum then the executable File or program represents becomes.

Das erfindungsgemäße Verfahren hat den Vorteil, dass ausführbare Dateien bzw. Programme weder linear noch vollständig verschlüsselt, anschließend wieder linear entschlüsselt und geschlossen von einem Prozessor ausgeführt werden. Vielmehr werden diese nach dem erfindungsgemäßen Verfahren methodenbezogen in separat verschlüsselte Codefragmente zerteilt. Nur die während eines Programmablaufs aktuell benötigten Codefragmente werden zur Runtime entschlüsselt und separat ausgeführt. Selbst wenn einem Angreifer das Auslesen einer momentan entschlüsselten Methode gelänge, so erlaubt dies weder eine Manipulation der verschlüsselten Bibliothek, noch einen Rückschluss auf die Gesamtheit des Programms, in dem diese Methode neben vielen anderen enthalten ist.The inventive method has the advantage of being executable Files or programs neither linear nor fully encrypted, then again decoded linearly and closed by a processor. Rather, be this according to the inventive method methodically divided into separately encrypted code snippets. Only the while program fragments are currently required code fragments decrypted for runtime and executed separately. Even if an attacker reading a currently decrypted Method, so this does not allow any manipulation of the encrypted Library, one more conclusion on the whole of the program in which this method in addition to many other is included.

Das erfindungsgemäße Verfahren hat den weiteren Vorteil, dass bei der späteren Ausführung eines gemäß der Erfindung verschlüsselten Programms dessen methodenbezogenen Unterprogramme nur bei Bedarf an eine zufällige Stelle in den Arbeitsspeicher geladen, dekodiert und ausgeführt werden können. Anschließend werden diese Unterprogramme wieder aus dem Speicher entfernt. Auf diese Art befindet sich zu keinem Zeitpunkt der gesamte Maschinencode unverschlüsselt im Arbeitsspeicher und kann folglich auch nicht geschlossen ausgelesen werden. Selbst einzelne methodenbezogene Unterprogramme können nur mit Aufwand ausgelesen werden, da diese sich nur für die Zeit der Ausführung, d. h. zur Runtime, im Arbeitsspeicher befinden und nicht vorgesagt werden kann, an welcher Stelle diese in den Arbeitsspeicher geladen wurden.The inventive method has the further advantage that in the later execution of one according to the invention encrypted Program whose method-related subroutines only when needed to a random one Place in the memory loaded, decoded and executed can. Subsequently these subprograms are removed from memory again. On this type is at no time the entire machine code unencrypted in memory and therefore can not be read closed become. Even individual method-related subroutines can only be read with effort, as these are only for the time the execution, d. H. at runtime, in memory and not predicted can be where they are loaded into memory were.

In Ausnahmefällen kann bei der Durchführung des erfindungsgemäßen Verfah rens der Fall eintreten, dass beim Parsing einer Methode nicht nur absolute, sondern auch dynamische Sprungadressen zu speziellen Codefunktionen detektiert werden. Die tatsächlichen Adresswerte dieser Sprungziele stehen während der Durchführung des Verfahrens noch nicht zur Verfügung, sondern sind erst im Moment der Laufzeit des Programms dynamisch ermittelbar. Derartige Ausnahmefälle welche bei Verwendung von Funktionspointern auftreten, können gemäß einer vorteilhaften, weiteren Ausführung der Erfindung durch eine explizite Referenzierung der dynamischen Sprungziele korrigiert werden. Hierdurch können auch Funktionen, welche durch Funktionspointer aufgerufen werden, in die erfindungsgemäße Maschinencode Extraktion miteinbezogen werden, und stehen zur Laufzeit zur Verfügung.In exceptional cases, when carrying out the method according to the invention, it may happen that during the parsing of a method not only absolute, but also dynamic jump addresses to specific code functions are detected. The actual address values of these jump destinations are not yet available during the execution of the method, but can only be determined dynamically at the moment the program is running. Such exceptional cases which occur when using function pointers, according to an advantageous, further embodiment of the invention by an explicit Referenzie correcting the dynamic jump targets. As a result, functions which are called by function pointers can also be included in the machine code extraction according to the invention, and are available at runtime.

Weiterhin kann der Fall eintreten, dass sich die nach Durchführung des erfindungsgemäßen Verfahrens ergebenden Codefragmente überlappen. Eine solche Überlappung tritt vor allem dann auf, wenn ein Sprungbefehl nicht den Anfang eines bereits bekannten Codefragments referenziert, sondern nachfolgende Befehle davon referenziert. Dies bedeutet also, dass die Anfangs- und/oder Endadresse eines Codefragments im Inneren eines anderen Codefragments liegt. Dies würde zu einem inkorrekten Ergebnis führen, welches nicht ablauffähig wäre. Gemäß einer weiteren Ausgestaltung der Erfindung kann eine derartige Überlappung von Codefragmenten dadurch vermieden werden, dass überlappende Codefragmente zu einem resultierenden Codefragment vereinigt werden.Farther the case may arise that after the implementation of the inventive method overlap resulting code fragments. Such an overlap especially occurs when a jump command is not the beginning referenced an already known code fragment, but subsequent commands referenced. This means that the beginning and / or End address of a code fragment inside another code fragment lies. This would lead to an incorrect result, which is not executable would. According to one Another embodiment of the invention, such an overlap of Code snippets are avoided by overlapping code snippets a resulting code fragment.

Schließlich kann der weitere Ausnahmefall eintreten, dass nach Durchführung des erfindungsgemäßen Verfahrens ein Codefragment im Inneren eine Einsprungadresse aufweist, welche von einem anderen Codefragment stammt. Eine solche, zwischen der Anfangs- und Endadresse des Codefragments liegende Einsprungadresse kann von einem im anderen Codefragment befindlichen Programmaufruf, z. B. einem CALL Befehl, oder von einem Sprungbefehl, z. B. einem JNE oder JMP Befehl, verursacht werden.Finally, can the further exceptional case occur that after completion of the inventive method a code fragment inside has an entry address which comes from another code fragment. Such, between the Start and end address of the code fragment lying entry address can be from a program call in the other code snippet, z. A CALL command, or a jump command, e.g. B. one JNE or JMP command, caused.

Gemäß einer besonders vorteilhaften Ausführung der Erfindung kann dies durch Berücksichtigung eines so genannten Adressen OFFSETs gelöst werden. Die im anderen Codefragment im jeweiligen Verzweigungsbefehl enthaltene absolute Einsprungadresse wird dann durch einen Bezug auf das Ziel Codefragment und einen den relativen Abstand zwischen der Anfangsadresse und der Einsprungadresse beschreibenden OFFSET berücksichtigt.According to one particularly advantageous embodiment The invention can do this by taking into account a so-called Addresses OFFSETs solved become. The code fragment in the other branch instruction in the respective branch instruction contained absolute entry address is then by a reference on the target code fragment and a the relative distance between the start address and the entry address descriptive OFFSET considered.

Weitere vorteilhafte Ausführungen der Erfindung sind in den Unteransprüchen angegeben. Die Erfindung und die weiteren Ausführungsformen werden an Hand der kurz angeführten Figuren nachfolgend näher erläutert. Dabei zeigenFurther advantageous embodiments The invention are specified in the subclaims. The invention and the other embodiments be on hand of the short listed Figures explained in more detail below. there demonstrate

1 eine erste, beispielhafte Methode mit dem Namen HELLO, wobei die Befehle des Programmcodes in der Programmiersprache C dargestellt sind, 1 a first, exemplary method with the name HELLO, wherein the instructions of the program code are shown in the programming language C,

2 die Befehle der ersten Methode von 1 in Form eines Programmablaufplanes, 2 the commands of the first method of 1 in the form of a program schedule,

3 die erste Methode von 1 und 2, wobei die Befehle des Programmcodes in Assemblersprache und mit beispielhaften Adresszuordnungen dargestellt sind, welche sich beim Laden der Befehle in einen Arbeitsspeicher ergeben können, 3 the first method of 1 and 2 wherein the instructions of the program code are shown in assembly language and with exemplary address assignments which may result when the instructions are loaded into a working memory,

4 die sich nach Durchführung einer Programmablaufverfolgung der insbesondere in 3 in Assemblersprache dargestellten ersten Methode nach dem erfindungsgemäßen Verfahren ergebenden Codefragmente, 4 which after execution of a program trace of the particular in 3 written in assembler language first method according to the method resulting code fragments,

5 eine zweite, beispielhafte Methode, wobei die Befehle des Programmcodes ebenfalls in Assemblersprache und wiederum mit beispielhaften Adresszuordnungen dargestellt sind, welche sich beim Laden der Befehle in einen Arbeitsspeicher ergeben, 5 a second, exemplary method wherein the instructions of the program code are also shown in assembly language and again with exemplary address assignments resulting from loading the instructions into a working memory,

6 die sich nach Durchführung einer Programmablaufverfolgung der in 5 in Assemblersprache dargestellten zweiten Methode nach dem erfindungsgemäßen Verfahren ergebenden Codefragmente, und 6 which, after performing a program trace of the in 5 in assembly language illustrated second method by the method according to the invention resulting code fragments, and

7 die sich gemäß einer weiteren Ausführung des erfindungsgemäßen Verfahrens nach Zusammenfassung von überschneidenden Codefragmenten ergebenden endgültigen Codefragmente für die zweite Methode von 5. 7 in accordance with a further embodiment of the method according to the invention after summarizing overlapping code fragments resulting final code fragments for the second method of 5 ,

Um die nachfolgenden Erläuterungen der in den Figuren dargestellten Ausführungsbeispiele zu vereinfachen, wurden Kurzbegriffe eingeführt. Hierbei gilt:

  • – Die Nummern von Speicherzellen in einem Arbeitsspeicher, welche bei den in den Figuren dargestellten Beispielen achtstellige Hexadezimalzahlen darstellen, werden mit dem Begriff ADRESSE abgekürzt.
  • – Die Anzahl der von einem Codefragment in einem Arbeitsspeicher belegten Speicherzellen wird mit dem Begriff LÄNGE abgekürzt
  • – Die in Hexadezimalcode vorliegende Differenz zwischen einer, im Inneren eines Codefragments liegenden Einsprungadresse von einem anderen Codefragment und der Anfangsadresse des Codefragments wird mit dem Begriff OFFSET abgekürzt.
To simplify the following explanations of the embodiments shown in the figures, short terms have been introduced. Where:
  • - The numbers of memory cells in a random access memory, which represent eight-digit hexadecimal numbers in the examples shown in the figures, are abbreviated by the term ADDRESS.
  • The number of memory cells occupied by a code fragment in a working memory is abbreviated by the term LENGTH
  • - The difference in hexadecimal code between one, inside a code fragment the entry address of another code fragment and the start address of the code fragment is abbreviated by the term OFFSET.

Ein OFFSET = 0 bedeutet also, dass die Einsprungadresse in ein Codefragment mit der Anfangsadresse des Codefragments übereinstimmt. Dies ist der Normalfall nach Ablauf des erfindungsgemäßen Verfahrens.One OFFSET = 0 thus means that the entry address into a code fragment matches the start address of the code fragment. this is the Normal case after expiration of the method according to the invention.

Es spielt dabei keine Rolle, an welcher Stelle sich der Befehl, welcher diese Ein sprungsadresse aufweist, im Programmcode des aufrufenden Codefragments befindet. Er kann sich also, wie aus den Beispielen der 3 und 5 ersichtlich sein wird, im Inneren eines aufrufenden Codefragments befinden. Andererseits kann er sich, wie an anderen Stellen ebenfalls aus den Beispielen der der 3 und 5 ersichtlich sein wird, auch am Ende oder sogar am Anfang des aufrufenden Codefragments befinden.It does not matter at which point the command, which has an entry address, is located in the code of the calling code fragment. So he can, as from the examples of the 3 and 5 will be apparent inside a calling code fragment. On the other hand, he can, as in other places also from the examples of the 3 and 5 will also be at the end or even at the beginning of the calling code fragment.

So zeigt 1 eine erste, beispielhafte Methode mit dem Namen HELLO, wobei die Befehle des Programmcodes in der Programmiersprache C dargestellt sind. Weiterhin zeigt 2 die Befehle der Methode von 1 in Form eines Programmablaufplanes. An diesem besonders einfachen, exemplarischen Beispiel soll das erfindungsgemäße Verfahren veranschaulicht werden. Zur Erleichterung des Verständnisses werden beide Figuren nachfolgend gemeinsam erläutert.So shows 1 a first, exemplary method called HELLO, the commands of the program code in the programming language C are shown. Further shows 2 the commands of the method of 1 in the form of a program schedule. In this particularly simple, exemplary example, the inventive method is to be illustrated. To facilitate understanding, both figures are explained together below.

Die Methode HELLO wird mit dem Programmaufruf 1 gestartet. Dabei wird zunächst die Referenzgröße a definiert und dieser ein Referenzwert von 0 zugeordnet. Mit der folgenden Anweisung 3 wird weiterhin eine Variable x eingeführt, deren aktueller Wert bei der weiteren Bearbeitung der Methode abhängig von Ergebnis eines Vergleiches der Referenzgröße mit dem Referenzwert 0 verändert werden soll. Hierzu ist ein bedingter Vergleich 5 vorgesehen. Falls in einem Fall das Ergebnis dieses Vergleichs 5 positiv ist, also die Referenzgröße a den gewünschten Referenzwert 0 einnimmt, so wird die Variable x in einem Multiplikator 7 mit dem Wert 5 vervielfacht.The HELLO method is called with the program call 1 started. The reference variable a is first defined and assigned a reference value of 0. With the following statement 3 Furthermore, a variable x is introduced whose current value should be changed during the further processing of the method depending on the result of a comparison of the reference variable with the reference value 0. This is a conditional comparison 5 intended. If in one case the result of this comparison 5 is positive, ie the reference variable a assumes the desired reference value 0, then the variable x becomes a multiplier 7 multiplied by the value 5.

Falls andererseits das Ergebnis des Vergleichs 5 negativ sein sollte, also die Referenzgröße a einen anderen Wert als 0 aufweisen sollte, so wird ein bedingter Sprung 9 ausgeführt. Dieser verzweigt zu einer Additionsoperation 11, wodurch der aktuelle Wert der Variablen x um den Wert 3 vergrößert wird. Der bedingte Sprung 11 wird nun programmtechnisch über entsprechende Anweisungen 13 wieder mit den an den Multiplikator 7 folgenden Anweisungen zusammengeführt und einem Programm Ende- bzw. Rücksprungbefehl 15 zugeführt.If, on the other hand, the result of the comparison 5 should be negative, so the reference size a should have a value other than 0, then a conditional jump 9 executed. This branches to an addition operation 11 , whereby the current value of the variable x is increased by the value 3. The conditional jump 11 is now programmatically via appropriate instructions 13 again with the to the multiplier 7 following instructions combined and a program end or return command 15 fed.

In 3 sind nun die Befehle des Programmcodes dieser ersten Methode in Assemblersprache mit den zugehörigen Operationscodes dargestellt. Weiterhin sind in der Spalte Offset beispielhafte Adresszuordnungen verzeichnet, welche sich beim Laden der Befehle in einen Arbeitsspeicher ergeben können. Die Zahlen von 1 bis 54 in der linken Spalte stellen Zeilennummern für das Programmlisting von 3 dar. Die sich nach Durchführung einer Programmablaufverfolgung der in 3 in Assemblersprache dargestellten ersten Methode nach dem erfindungsgemäßen Verfahren ergebenden Codefragmente sind in 4 dargestellt. Zur Erleichterung des Verständnisses werden auch diese beiden Figuren nachfolgend gemeinsam erläutert.In 3 Now the commands of the program code of this first method in assembly language with the associated operation codes are shown. Furthermore, in the column offset exemplary address assignments are listed, which can result when loading the commands into a working memory. The numbers from 1 to 54 in the left column represent line numbers for the program listing 3 which, after performing a program trace of the in 3 are in code language shown first method according to the method resulting code fragments are in 4 shown. To facilitate understanding, these two figures will be explained together below.

So beginnt die Methode in Zeile 1 mit der Anfangsadresse 1000100A in hexadezimaler Codierung. Diese stellt eine Einsprungadresse dar. Der dort geladene Sprungsbefehl JMP zweigt auf die Adresse 1001050 ab. Dies ist auf der linken Seite des Programmlistings in 3 mit einem durchgezogenen Pfeil gekennzeichnet. Die nach dieser Abzweigung ab Adresse 1001050 bis einschließlich der Zeile 27 folgenden Befehle dienen zur programmtechnischen Vorbereitung des bedingten Sprungbefehls JNE, d. h. jump if not equal, mit der Adresse 100106F in Zeile 28. Mit diesen vorbereitenden Befehlen wird festgestellt, ob die Bedingung a = 0 erfüllt ist oder nicht.Thus the method in line 1 starts with the start address 1000100A in hexadecimal coding. This represents an entry address. The jump instruction JMP loaded there branches off to the address 1001050. This is on the left side of the program listing in 3 marked with a solid arrow. The instructions following this branch from address 1001050 up to and including line 27 serve for the program-technical preparation of the conditional branch instruction JNE, ie jump if not equal, with the address 100106F in line 28. With these preparatory instructions, it is determined whether the condition a = 0 is satisfied or not.

Falls die Bedingung nicht erfüllt ist, wird der Befehl JNE aktiv, unterbricht die weitere Bearbeitung der folgenden Befehle, und setzt den Programmablauf bei der Adresse 1000107C fort. Dies ist auf der linken Seite des Programmlistings in 3 mit einem strichlierten Pfeil gekennzeichnet. Hierdurch werden also die auf die Adresse 1000106F folgenden Befehle bis einschließlich des Befehls mit der Adresse 1000107A übergangen. Bei der Abarbeitung der angesprungenen Befehle von Adresse 1000107C bis zur Adresse 10001084 in Zeile 43 wird die Variable x entsprechend der Darstellung im Flussdiagramm der 2 um den Wert 3 erhöht. Die sich dann ab Adresse 10001085 anschließenden Befehle schließen den Programmlauf der Methode HELLO ab und enden im Rück sprungbefehl RET bei der Adresse 1000108E.If the condition is not met, the JNE command becomes active, suspends further processing of the following instructions, and continues program execution at address 1000107C. This is on the left side of the program listing in 3 marked with a dotted arrow. As a result, the commands following the address 1000106F are skipped up to and including the command with the address 1000107A. When executing the command jumped from address 1000107C to the address 10001084 in line 43, the variable x is as shown in the flowchart of 2 increased by the value 3. The commands which follow from the address 10001085 complete the program run of the HELLO method and end in the return command RET at the address 1000108E.

Falls dagegen mit den vorbereitenden Befehlen zwischen den Adressen 100001050 bis vor 1000106F festgestellt wird, dass die Bedingung a = 0 erfüllt ist, wird der Befehl JNE nicht aktiv, und der Programmablauf wird mit den auf die Adresse 1000106F folgenden Befehle fortgesetzt. Dabei wird die Variable x entsprechend der Darstellung im Flussdiagramm der 2 mit dem Wert 5 multipliziert. Dieser Programmlauf endet bei der Adresse 1000107A mit dem absoluten Sprungbefehl JMP. Hierdurch wird die weitere Bearbeitung der folgenden Befehle unterbrochen und der Programmablauf bei der Adresse 10001085 fortgesetzt. Wie oben bereits beschrieben wurde, schließen die dann ab Adresse 10001085 folgenden Befehle den Programmlauf der Methode HELLO ab und enden im Rücksprungbefehl RET bei der Adresse 1000108E.If, on the other hand, with the preparatory commands between the addresses 100001050 to before 1000106F If it is determined that the condition a = 0 is fulfilled, the command JNE does not become active and the program sequence is continued with the commands following the address 1000106F. In this case, the variable x corresponding to the representation in the flowchart of 2 multiplied by the value 5. This program ends at the address 1000107A with the absolute jump command JMP. This stops further processing of the following commands and continues the program at address 10001085. As described above, the commands that follow from address 10001085 close the program run of the HELLO method and end at the address 1000108E in the return command RET.

Wird auf den in 3 dargestellten Programmcode das erfindungsgemäße Verfahren angewendet, so wird insbesondere beim Parsing des Programmcodes festgestellt, dass diverse Unterbrechungen und Abzweigungen vorhanden sind, welche bei der Runtime zu einer nicht sukzessiven Abarbeitung des Maschinencodes führen. So ist einerseits bei der Adresse 1000100A der absolute Sprungbefehl JMP mit der Einsprungadresse 10001050 vorhanden. Weiterhin ist bei der Adresse 1000107A ein absoluter Sprungbefehl JMP mit der Einsprungadresse 10001085 vorhanden. Schließlich ist bei der Adresse 1000106F der bedingte Sprungbefehl JNE mit der Einsprungsadresse 1000107C vorhanden.Will be on the in 3 program code used the method according to the invention applied, it is found in particular when parsing the program code that various interruptions and branches are present, which lead to a non-successive processing of the machine code at runtime. Thus, on the one hand, the absolute jump command JMP with the entry address 10001050 is available at address 1000100A. Furthermore, an absolute branch instruction JMP with the entry address 10001085 is available at address 1000107A. Finally, the address 1000106F contains the conditional jump instruction JNE with the entry address 1000107C.

Werden nun gemäß dem erfindungsgemäßen Verfahren Ketten von aufeinander folgenden, zur Runtime linear hintereinander ausführbaren Anweisungen im Programmcode zu Codefragmenten zusammengefasst, so entstehen dabei drei Codefragmente 1, 2 und 3, welche in der 3 bereits durch Umrahmungen dargestellt sind.If, according to the method of the invention, chains of consecutive instructions which can be executed linearly one after the other in runtime are combined in the program code into code fragments, this results in three code fragments 1, 2 and 3, which in the 3 already represented by frames.

Im Detail lassen sich diese Codefragmente durch folgende Werte beschreiben: Anfangsadresse Endadresse Länge in Byte Codefragment 1 1000100A 1000100E 5 Codefragment 2 10001050 1000107B 2C Codefragment 3 1000107C 1000108E 13 Tabelle 1 In detail, these code fragments can be described by the following values: start address end address Length in bytes Code fragment 1 1000100A 1000100E 5 Code fragment 2 10001050 1000107B 2C Code fragment 3 1000107C 1000108E 13 Table 1

So beginnt das Codefragment 1 bei der Einsprungadresse 1000100A und endet unmittelbar darauf mit dem absoluten Sprungbefehl JMP bei 1000100E. Weiterhin beginnt das Codefragment 2 bei der Einsprungadresse 10001050, welche die Zieladresse des Sprungbefehls JMP ist, und endet mit dem weiteren Sprungbefehl JMP bei der Adresse 1000107B. Schließlich beginnt das Codefragment 3 bei der Einsprungadresse 1000107C, welche die Zieladresse des bedingten Sprungbefehls 1000106F ist, und endet bei der programmtechnischen Endebedingung RET bei der Adresse 1000108E.So Code fragment 1 starts at entry address 1000100A and immediately ends with the absolute jump command JMP 1000100E. Furthermore, the code fragment 2 starts at the entry address 10001050, which is the destination address of the branch instruction JMP, and ends with the further jump command JMP at address 1000107B. After all the code fragment 3 starts at the entry address 1000107C, which is the destination address of the conditional jump instruction 1000106F, and ends at the program end condition RET at the address 1000108E.

Diese nach dem erfindungsgemäßen Verfahren gebildeten Codefragmente sind in 4 nochmals dargestellt und gemäß einer vorteilhaften weiteren Ausbildung der Erfindung durch ihre Anfangsadressen und Längen beschrieben, so wie sie in obiger Tabelle verzeichnet sind. Dabei bedeutet Offset = 0, dass ein Sprungbefehl den Anfang des Codefragments referenziert. Mindestes eine Referenz mit Offset 0 muss zwangsläufig existieren.These code fragments formed by the method according to the invention are in 4 shown again and described according to an advantageous further embodiment of the invention by their starting addresses and lengths, as listed in the above table. Offset = 0 means that a jump instruction references the beginning of the code fragment. At least one reference with offset 0 must exist.

Auf Grund des oben beschriebenen, bedingten Sprungbefehls JNE ist aber auch ein Programmablauf möglich, bei dem nur ein Teil des Codefragments 3 abgearbeitet wird, da im Codefragment 2 dieser Sprungsbefehl eine im Inneren des Codefragments 3 liegende Einsprungadresse bei 100010085 aufweist. Dieser Fall kann gemäß einer vorteilhaften, weiteren Ausführung der Erfindung am besten dadurch gelöst werden, dass hierzu bei Codefragment ein Offset berücksichtigt wird.On However, the reason for the conditional branch instruction JNE described above is also a program sequence possible, in which only a part of the code fragment 3 is processed, as in Code fragment 2 of this jump instruction one inside the code fragment 3 lying entry address at 100010085 has. This case can according to a advantageous, further embodiment the invention best be solved by this Code fragment considered an offset becomes.

Da die Anfangsadresse des Codefragments 3 bei 1000107C und die ursprüngliche Zieladresse des bedingten Sprungbefehls vor Durchführung der erfindungsgemäßen Fragmentierung bei 10001085 lag, bestimmt sich der relativer Adressabstand innerhalb von Codefragment 3 für den bedingten Sprung aus Codefragment 2, d. h. der Offset, wie folgt: Offset = 10001085 – 1000107C = 9. Since the starting address of the code fragment 3 at 1000107C and the original destination address of the conditional branch instruction before carrying out the fragmentation according to the invention was 10001085, the relative address distance within code fragment 3 for the conditional branch from code fragment 2, ie the offset, is determined as follows: Offset = 10001085 - 1000107C = 9.

Die auf diese Weise gebildeten Codefragmente 1 bis 3, welche zu der Methode „HELLO" gehören, werden nun zusammen extrahiert und verschlüsselt und in einer Programmbibliothek hinterlegt, welche vorteilhaft wiederum selbst verschlüsselt ist.The Code fragments 1 to 3 formed in this way, which correspond to the Method "HELLO" belong now extracted and encrypted together and in a program library deposited, which in turn is advantageous itself encrypted.

5 zeigt eine zweite, beispielhafte Methode. Dabei sind die Befehle des Programmcodes ebenfalls in Assemblersprache und wiederum mit beispielhaften Adresszuordnungen dargestellt, welche sich beim Laden der Befehle in einen Arbeitsspeicher ergeben. 6 zeigt die sich nach Durchführung einer Programmablaufverfolgung auf die zweite Methode von 5 nach dem erfindungsgemäßen Verfahren ergebende Codefragmente. Zur Erleichterung des Verständnisses werden auch diese Figuren nachfolgend gemeinsam erläutert. 5 shows a second, exemplary method. The commands of the program code are also shown in assembly language and again with exemplary address assignments, which result when loading the commands into a main memory. 6 shows after running a program trace on the second method of 5 Code fragments resulting from the process according to the invention. To facilitate understanding, these figures will be explained together below.

So beginnt diese Methode bei der Adresse 1000100A mit einem Programmaufruf CALL, der auf die Adresse 10001010E verzweigt. Dies ist auf der linken Seite des Programmlistings in 5 mit einem außen liegenden, durchgezogenen Pfeil gekennzeichnet. Der Programmlauf wird nun mit den Befehlen ab Adresse 1000101E fortgesetzt und endet im Rücksprungbefehl RET bei der Adresse 10001020.Thus, this method starts at the address 1000100A with a program call CALL, which branches to the address 10001010E. This is on the left side of the program listing in 5 marked with an outside, solid arrow. The program run is now continued with the commands from address 1000101E and ends in the return command RET at address 10001020.

Nun wird der Programmcode mit den auf die Adresse 1000100A folgenden Befehlen fortgesetzt. Bei dieser Bearbeitung tritt bei der Adresse 10001010 ein weiterer Programmaufruf CALL auf, der auf die Adresse 1000101B verzweigt.Now the program code will follow with the address 1000100A Commands continued. In this editing occurs at the address 10001010 Another program call CALL on, the address 1000101B branched.

Dies ist auf der linken Seite des Programmlistings in 5 mit einem innen liegenden, durchgezogenen Pfeil gekennzeichnet. Der Programmlauf wird nun mit den Befehlen ab Adresse 1000101B fortgesetzt und endet wieder mit dem Rücksprungbefehl RET bei der Adresse 10001020. Der Programmlauf wird schließlich mit den auf die Adresse 10001010 folgenden Befehlen fortgesetzt und endet endgültig im Rücksprungbefehl RET bei der Adresse 10001016.This is on the left side of the program listing in 5 marked with an inside, solid arrow. The program run is now continued with the commands from address 1000101B and ends again with the return command RET at the address 10001020. The program run is finally continued with the commands following the address 10001010 and finally ends in the return command RET at the address 10001016.

Werden nun gemäß dem erfindungsgemäßen Verfahren wiederum Ketten von aufeinander folgenden, zur Runtime linear hintereinander ausführbaren Anweisungen im Programmcode zu Codefragmenten zusammengefasst, so entstehen dabei drei Codefragmente 1, 2 und 3, welche in der 5 ebenfalls bereits durch Umrahmungen dargestellt sind.If, in accordance with the inventive method, chains of consecutive instructions which can be executed linearly one after the other in runtime are thus combined in the program code to form code fragments, this results in three code fragments 1, 2 and 3, which in the 5 also already represented by frames.

Im Detail lassen sich diese Codefragmente durch folgende Werte beschreiben: Anfangsadresse Endadresse Länge in Byte Codefragment 1 1000100A 10001016 C Codefragment 2 1000101E 10001020 3 Codefragment 3 1000101B 10001020 6 Codefragment 2* 1000101B 10001020 6 Tabelle 2 In detail, these code fragments can be described by the following values: start address end address Length in bytes Code fragment 1 1000100A 10001016 C Code fragment 2 1000101E 10001020 3 Code fragment 3 1000101B 10001020 6 Code fragment 2 * 1000101B 10001020 6 Table 2

In 6 sind diese nach dem erfindungsgemäßen Verfahren gebildeten Codefragmente sind nochmals dargestellt und gemäß einer vorteilhaften weiteren Ausbildung der Erfindung durch ihre Anfangsadressen und Längen beschrieben, so wie sie in obiger Tabelle verzeichnet sind.In 6 These code fragments formed by the method according to the invention are shown again and described according to an advantageous further embodiment of the invention by their starting addresses and lengths, as they are listed in the above table.

So beginnt das Codefragment 1 bei der Einsprungadresse 1000100A und endet mit der programmtechnischen Endebedingung RET bei der Adresse 10001016.So Code fragment 1 starts at entry address 1000100A and ends with the program-technical end condition RET at the address 10,001,016th

Weiterhin beginnt das Codefragment 2 bei der Einsprungadresse 1000101E, welche die Zieladresse des ersten Programmaufrufs CALL bei Adresse 1000100A ist, und endet mit der programmtechnischen Endebedingung RET bei der Adresse 10001020. Schließlich beginnt das Codefragment 3 bei der Einsprungadresse 1000101B, welche die Zieladresse des zweiten Programmaufrufs CALL bei der Adresse 10001010 ist, und endet ebenfalls mit der programmtechnischen Endebedingung RET bei der Adresse 10001020.Farther Code fragment 2 begins at the entry address 1000101E, which the destination address of the first program call CALL at address 1000100A is, and ends with the program end condition RET at the address 10001020. Finally the code fragment 3 starts at the entry address 1000101B, which the destination address of the second program call CALL at the address 10001010, and also ends with the program-technical end condition RET at the address 10001020.

Wie aus 5 zu ersehen ist, überlappen sich in diesem Falle die Codefragmente 2 und 3 derart, dass das Codefragment 2 sogar vollständig im Codefragment 3 liegt. Bei einer Abarbeitung der Codefragmente 1 bis 3 wird also der Programmcode des Codefragments 2 zweimal ausgeführt. Dies kann gemäß einer vorteilhaften weiteren Ausführung der Erfindung dadurch vermieden werden, dass die Codefragmente 2 und 3 zu einem resultierenden Codefragment 2* zusammengefasst werden. Dieses ist im Beispiel der 5 umrahmt.How out 5 can be seen overlap in this case, the code fragments 2 and 3 such that the code fragment 2 is even completely in the code fragment 3. In a processing of the code fragments 1 to 3, therefore, the program code of the code fragment 2 is executed twice. This can be avoided according to an advantageous further embodiment of the invention in that the code fragments 2 and 3 are combined to form a resulting code fragment 2 *. This is in the example of 5 framed.

Nach dieser Bildung der Codefragmente 1 und 2* ist wiederum aus 5 ersichtlich, dass das Codefragment bei der Adresse 1000100A einen Programmaufruf CALL aufweist, welcher nun eine im Inneren des Codefragments 2* liegende Einsprungadresse aufweist. Es ist also ebenfalls notwendig, den Offset, d. h. den relativen Adressabstand der Einsprungsadresse 1000101E zur Anfangsadresse 1000101B des Codefragments 2* zu bestimmen. Dieser errechnet sich wie folgt: Offset = 1000101E – 1000101B = 3 After this formation of the code fragments 1 and 2 * is again off 5 It can be seen that the code fragment at the address 1000100A has a program call CALL, which now has an entry address located inside the code fragment 2 *. It is therefore also necessary to determine the offset, ie the relative address spacing of the entry address 1000101E to the start address 1000101B of the code fragment 2 *. This is calculated as follows: Offset = 1000101E - 1000101B = 3

Gemäß der Darstellung in 7 können beide Codefragmente 1 und 2* somit einmal ohne relativen Adressabstand unmittel aufeinander folgend bearbeitet werden, d. h. deren Offset ist 0. Andererseits kann sich auch ein Programmablauf ergeben, bei dem auf Grund des zweiten Programmaufrufs CALL im Codesegment 1 für das Codesegment 2* ein Offset von 3 zu berücksichtigen ist.As shown in 7 Thus, both code fragments 1 and 2 * can be processed one after the other without relative address spacing, ie their offset is 0. On the other hand, a program sequence may result in which an offset is generated in code segment 1 for code segment 2 * due to the second program call CALL of 3 is to be considered.

Die auf diese Weise gebildeten Codefragmente 1 und 2* werden schließlich separat verschlüsselt und in einer Programmbibliothek hinterlegt, welche vorteilhaft wiederum selbst verschlüsselt ist.The Code fragments 1 and 2 * formed in this way eventually become separate encoded and stored in a program library, which in turn advantageous even encrypted is.

Claims (14)

Verfahren zur Verschlüsselung von ausführbarem Programmcode, wobei a) in einem ersten Schritt der Programmcode unmodifiziert direkt in einen Arbeitsspeicher einer Verarbeitungseinheit kopiert wird, b) in einem zweiten Schritt zur Identifikation der Methoden des Programmcodes Strukturdaten direkt ausgewertet werden, c) in einem dritten Schritt durch Parsing im Programmcode von jeder Methode Bestandteile erfasst werden, welche zur Runtime eine Unterbrechung bzw. Abzweigung in der sequentielle Bearbeitung des Programmcodes verursachen würden, d) in einem vierten Schritt Ketten von aufeinander folgenden, zur Runtime linear hintereinander ausgeführten Anweisungen im Programmcode zu Codefragmenten zusammengefasst werden, und e) in einem fünften Schritt die gefundenen, zu einer Methode gehörigen Codefragmente individuell verschlüsselt und in einer Programmbibliothek gespeichert werden.Method for encrypting executable Program code, where a) in a first step the program code unmodified directly into a working memory of a processing unit is copied, b) in a second step for identification the methods of the program code structure data directly evaluated become, c) in a third step by parsing in the program code From each method, components are captured which are at runtime a break in sequential processing of the program code would cause d) in a fourth step, chains of consecutive, at runtime linear consecutively executed instructions in the program code to code fragments, and e) in a fifth Step the found code fragments belonging to a method individually encoded and stored in a program library. Verfahren nach Anspruch 1, wobei die Programmbibliothek als solche zusätzlich verschlüsselt wird.The method of claim 1, wherein the program library as such in addition encoded becomes. Verfahren nach Anspruch 1 oder 2, wobei der Programmcode durch manuelles Laden, insbesondere ohne die Hilfe von Lademitteln eines Betriebssystems, unmodifizierten direkt in einen Arbeitsspeicher kopiert wird.Method according to claim 1 or 2, wherein the program code by manual loading, in particular without the help of loading means an operating system, unmodified directly into a working memory is copied. Verfahren nach Anspruch 1, 2 oder 3, wobei als Strukturdaten PE-Header-Daten, d. h. Portable Executable File Format Daten, ausgewertet werden.The method of claim 1, 2 or 3, wherein as structural data PE header data, d. H. Portable Executable File Format data, to be evaluated. Verfahren nach einem der vorangegangenen Ansprüche, wobei als Strukturdaten Relocation Tabellen ausgewertet werden.Method according to one of the preceding claims, wherein be evaluated as structural data relocation tables. Verfahren nach einem der vorangegangenen Ansprüche, wobei beim Parsing des Programmcodes von jeder Methode als Bestandteile die Adressen von absoluten Sprungbefehlen und/oder Rücksprungsbefehlen, welche den Programmablauf beenden erfasst werden.Method according to one of the preceding claims, wherein when parsing the program code from each method as components the addresses of absolute branch instructions and / or return instructions which to end the program. Verfahren nach einem der vorangegangenen Ansprüche, wobei beim Parsing des Programmcodes von jeder Methode als Bestandteile die Einsprungadressen von Abzweigungen erfasst werden.Method according to one of the preceding claims, wherein when parsing the program code from each method as components the entry addresses of branches are detected. Verfahren nach Anspruch 7, wobei als Bestandteile die Einsprungadressen von als Abzweigung dienenden Programmaufrufen, absoluten und/oder relativen Sprungbefehlen erfasst werden.A method according to claim 7, wherein as constituents the entry addresses of branching program calls, absolute and / or relative jump commands are detected. Verfahren nach einem der vorangegangenen Ansprüche, wobei ein Codefragment entweder mit einer beim Parsing detektierten Einsprungadresse einer Methode oder einer Zieladresse einer Abzweigung beginnt.Method according to one of the preceding claims, wherein a code fragment either with an entry address detected during parsing a method or a destination address of a branch begins. Verfahren nach einem der vorangegangenen Ansprüche, wobei ein Codefragment entweder mit einer beim Parsing detektierten programmtechnischen Endebedingung oder einem absoluten Sprungbefehl endet.Method according to one of the preceding claims, wherein a code fragment either with a program detected during parsing End condition or an absolute jump instruction ends. Verfahren nach einem der vorangegangenen Ansprüche, wobei ein Codefragment durch seine Startadresse und Länge definiert wird.Method according to one of the preceding claims, wherein a code fragment is defined by its start address and length. Verfahren nach einem der vorangegangenen Ansprüche, wobei eine beim Parsen detektierte dynamische Sprungadresse durch eine explizite Referenzierung ersetzt wird.Method according to one of the preceding claims, wherein a dynamic jump address detected during parsing by a explicit referencing is replaced. Verfahren nach einem der vorangegangenen Ansprüche, wobei Codefragmente zu einem resultierenden Codefragment zusammengefasst werden, wenn sich die Codefragmente überlappen.Method according to one of the preceding claims, wherein Code fragments are combined into a resulting code fragment when the code fragments overlap. Verfahren nach einem der vorangegangenen Ansprüche, wobei in einem Codefragment eine zu einem Sprungbefehl oder Programmaufruf gehörige Einsprungsadresse, welche auf ein weiteres Codefragment verweist, durch einen Bezug auf das weiteres Codefragment und einen den relativen Adressenabstand zwischen Einsprungs- und Anfangsadresse im weiteren Codefragment kennzeichnenden Offset berücksichtigt wird.Method according to one of the preceding claims, wherein in a code snippet one to a jump command or program call associated Entry address, which refers to another code fragment, by reference to the further code fragment and the relative one Address distance between entry and start address in the following Code fragment characteristic offset is taken into account.
DE200710059798 2007-12-11 2007-12-11 Executable program code i.e. executable file, coding method for computer, involves combining chains of sequential instructions to code fragments, and coding and storing detected code fragments belonging to methods in program library Expired - Fee Related DE102007059798B3 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
DE200710059798 DE102007059798B3 (en) 2007-12-11 2007-12-11 Executable program code i.e. executable file, coding method for computer, involves combining chains of sequential instructions to code fragments, and coding and storing detected code fragments belonging to methods in program library

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
DE200710059798 DE102007059798B3 (en) 2007-12-11 2007-12-11 Executable program code i.e. executable file, coding method for computer, involves combining chains of sequential instructions to code fragments, and coding and storing detected code fragments belonging to methods in program library

Publications (1)

Publication Number Publication Date
DE102007059798B3 true DE102007059798B3 (en) 2009-04-09

Family

ID=40418418

Family Applications (1)

Application Number Title Priority Date Filing Date
DE200710059798 Expired - Fee Related DE102007059798B3 (en) 2007-12-11 2007-12-11 Executable program code i.e. executable file, coding method for computer, involves combining chains of sequential instructions to code fragments, and coding and storing detected code fragments belonging to methods in program library

Country Status (1)

Country Link
DE (1) DE102007059798B3 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105608345A (en) * 2015-12-21 2016-05-25 上海华测导航技术股份有限公司 Stm32 boot program encryption method

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040193987A1 (en) * 1995-07-13 2004-09-30 Sospita As Protection of software code from unauthorized use by executing portions of the code in a secure computer environment separate from the environment that executes the remaining portions of the code

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040193987A1 (en) * 1995-07-13 2004-09-30 Sospita As Protection of software code from unauthorized use by executing portions of the code in a secure computer environment separate from the environment that executes the remaining portions of the code

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105608345A (en) * 2015-12-21 2016-05-25 上海华测导航技术股份有限公司 Stm32 boot program encryption method

Similar Documents

Publication Publication Date Title
DE60127310T2 (en) DEVICE FOR PROTECTING DIGITAL DATA
DE102005021064B4 (en) Method and apparatus for protection against buffer overrun attacks
DE102009041176B4 (en) A compiler system and method for compiling a source code into an encrypted machine language code
DE102012212343A1 (en) Distributed compilation process with command signature support
EP1798653B1 (en) Method, computer program product and device for protecting a program comprising a function block
WO2015128301A1 (en) Method for protecting a computer program from being influenced, and computer system
DE102007059798B3 (en) Executable program code i.e. executable file, coding method for computer, involves combining chains of sequential instructions to code fragments, and coding and storing detected code fragments belonging to methods in program library
WO2004114131A1 (en) Method for booting up a software in the boot sector of a programmable read-only memory
EP2394232B1 (en) Device and method for preventing unauthorized use and/or manipulation of software
DE10002203B4 (en) Method for protecting a microcomputer system against manipulation of data stored in a memory arrangement of the microcomputer system
WO2016169646A1 (en) System and method for monitoring the integrity of a component delivered by a server system to a client system
DE102005046696B4 (en) A method for generating protected program code and method for executing program code of a protected computer program and computer program product
EP2302554A2 (en) Method for identifying a section of computer program contained in a computer storage system
WO2006119928A1 (en) Method for adding functionality to an executable first module of a program package
EP1892639B1 (en) Secure program code execution
EP3588340B1 (en) Computer-implemented method for operating a data storage device
DE102006035662A1 (en) Monitoring correct operation of data processing unit, displaces subsystem from allowed state into non-allowed state before executing partial operational run
WO2021170316A1 (en) Analysis of a container instance of an operating system
DE10357032A1 (en) Method for reloading software in the boot sector of a programmable read only memory
EP1318451B1 (en) Method to execute a program on a computer
WO2006063876A1 (en) Method and device for encoding and for carrying out a software library
DE102004047191A1 (en) Tamper-proof microprocessor system and operating method therefor
DE102004008180A1 (en) Secure operating method for a portable data carrier, especially a chip card, in which operating parameter values are checked during a memory access or data output process to see if their values have been changed
DE102021212994B3 (en) Method for detecting anomalies indicating tampering during a secure boot process of a software-controlled device
DE102017208199A1 (en) Arithmetic unit and operating method for a computing unit

Legal Events

Date Code Title Description
8364 No opposition during term of opposition
R119 Application deemed withdrawn, or ip right lapsed, due to non-payment of renewal fee
R079 Amendment of ipc main class

Free format text: PREVIOUS MAIN CLASS: G06F0021220000

Ipc: G06F0021100000