Skip to main content
gamedev.net
🔒 Locked

Encryption/Decryption

Started by ScottC 22 replies 6.6k views
Original Post
ScottC
ScottC
I am mostly interested in Decryption. Would anyone know of any forums with it where I can get some help? Maybe some articles? thanks.
Ravuya
Ravuya
This is more of a question for the General Programming board, and maybe the Math & Physics board.

I'll move it for you.
ScottC
ScottC
Encryption and Decryption doesn't really seem like it'd be programming specifically, sure it can be applied to programming, I think math would be more like it
Monder
Monder
Quote:
I am mostly interested in Decryption.


Well that goes pretty much hand in hand with Encryption, if you're going to learn how to decrypt things you're going to have to learn how to encrypt them as well (or at least you will do if you want a proper understanding of how it works rather than just a code dump of the algorithm that does it).

Do you prehaps means Cryptanalysis which is the study of breaking encryption?

As for information on cryptography Wikipedia may be a good place to start off, check out the article here. This book may be worth taking a look at, I've got it on my Amazon wishlist though I've never actually read it so I can't attest as to it's quality.
ScottC
ScottC
Quote:
Original post by Monder
Quote:
I am mostly interested in Decryption.


Well that goes pretty much hand in hand with Encryption, if you're going to learn how to decrypt things you're going to have to learn how to encrypt them as well (or at least you will do if you want a proper understanding of how it works rather than just a code dump of the algorithm that does it).

Do you prehaps means Cryptanalysis which is the study of breaking encryption?

As for information on cryptography Wikipedia may be a good place to start off, check out the article here. This book may be worth taking a look at, I've got it on my Amazon wishlist though I've never actually read it so I can't attest as to it's quality.


Cryptanalysis sounds about right. Thing is, some folks wrote a mod for Half-Life, they stored their script files in a dll file. They have their own compiler they wrote for it. I would like to decompile/decrypt it and modify the scripts so I can play around with it, learn the scripting language, and use it to make cool custom maps. I was thinking maybe I could read it with the fstream as binary, but if that didn't work I would like to know other ways I can spend all my time figuring out.

Excerpt of the file opened in notepad:
éíñõùý	!%)-159=AEIÍÑÕÙÝáåéíñõùý	!%)-159=AEIÍÑÕÙÝáåéíñõùý…‘HLƒˆ‡Ž…’‰™•tx|€„ÑàÕá×ðovkt0I<@DHLPTX\`tUVptx½ÄÈÛàßæÝåtiu,0glkrivm}yX\`dh´µµÄÐÈÃÉÜààÝœ


I'm thinking its just binary...
ScottC
ScottC
Quote:
Original post by DrEvil
I don't see why they would be storing their scripts in a dll file when it might as well be native code at that point.


Who knows... their team members are idiots at times...

DHLPTX catches my eye in the excerpt.
Monder
Monder
Well unless it's actually encrypted (and I don't really see why they'd do that) then it's just a reverse engineering task, one that may be rather difficult. As a first step I'd recomend looking at the file with a hex editor instead of notepad. Actually forget that, as a first step I'd recomend emailing the developers and seeing what they'll tell you, they may even give you the tools and scripts you need to make modifications.

Also what exactly do you mean by storing their scripts in a DLL file? A DLL file seems a slightly odd thing to use for exclusively storing script files.
Zipster
Zipster
I would just e-mail the team and ask. If the DLL file contains their compiled bytecode them maybe they have a decompiler, or you can ask them for the specs.
ScottC
ScottC
The team likes to keep their mouth shut, and they are afraid that everybody wants to cheat. I've already tried asking. They have one coder who for some reason leaves huge memory leaks in his projects that he releases. They are paranoid and won't hire another coder.
ScottC
ScottC
Quote:
Original post by Monder
Well unless it's actually encrypted (and I don't really see why they'd do that) then it's just a reverse engineering task, one that may be rather difficult. As a first step I'd recomend looking at the file with a hex editor instead of notepad. Actually forget that, as a first step I'd recomend emailing the developers and seeing what they'll tell you, they may even give you the tools and scripts you need to make modifications.

Also what exactly do you mean by storing their scripts in a DLL file? A DLL file seems a slightly odd thing to use for exclusively storing script files.


I see just about the same as I see with notepad as I do with a hex editor. :P

Their scripts are typed into a txt and then compiled with their own custom compiler into a dll file which is then put into memory when the game is loaded.
ScottC
ScottC
So far this is what i've found.

SIMPLE ROUTE TRANSPOSITIONS (TRAMPS)

Transposition ciphers have been defined as that type of
cipher in which the elements or units of the plain text,
whether one is dealing with individual letters or groups
of letters, retain their original identities but undergo
some change in their relative positions or sequences so
that the message becomes unintelligible. The majority
of transposition methods involve the use of a design or
geometric figure, such as a square, rectangle, triangle,
trapezoid, etc., in which the letters of the plain text
are first inscribed or written into the design according
to a previously agreed upon direction of writing and
then transcribed or taken off according to another and
different previously agreed-upon direction, to form the
text of the cryptogram.

In their simplest form, TRAMPS may take any of the
following routes when employing rectangles or squares
for transposing text of a message as illustrated below.
The plain-text message is assumed to be merely the
normal sequence from A to X, for ease in following the
route.

Any geometrical form can be used, but it must be full
block; if the letters of a message do not complete the
assigned block, nulls (arbitrary letters) must be added.

b) Simple Vertical:

AEIMQU DHLPTX UQMIEA XTPLHD
BFJNRV CGKOSW VRNJFB WSOKGC
CGKOSW BFJNRV WSOKGC VRNJFB
DHLPTX AEIMQU XTPLHD UQMIEA

So I guess DHLPTX is a form of encryption, or something like that. I wish I could find more information on it.
ScottC
ScottC
Quote:
Original post by Telastyn
More than likely DHLPTX is an arbitrary pattern with completely nothing to do with anything.


probably!
Extrarius
Extrarius
If their custom compiler doesn't compile to machine code (and it could 'easily' do so by emitting C/asm/etc code and invoking a compiler/assembler on it, using 'softwire', containing a custom assembler, or being a front end for gcc), then it's probably just plain-data(not encrypted) bytecode.

To understand the bytecode, you will have to understand the interpreter, which means you'll have to disassemble the mod itself and study it quite intensively. I seriously doubt they used any form of encryption simply because it would be unneccesary. Even if they did, studying the interpreter and other mod code would tell you how to edit the scripts.

If it does compile to machine code, you'll have to reverse engineer the way the mod uses the dll in order to create your own. You likely won't be able to use any of their 'script' since it's been effectively destroyed in the translation to machine code.

If they are insanely paranoid, they might have used a public key encryption method, which means that in order to edit the script, you'll also have to edit the decryption key since you won't have the corresponding encryption key, but compared to reverse engineering a custom interpreter and/or the mod itself, that shouldn't be too difficult at all.

I'd reccomend OllyDbg as the tool to start with.
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
ScottC
ScottC
Quote:
Original post by Extrarius
If their custom compiler doesn't compile to machine code (and it could 'easily' do so by emitting C/asm/etc code and invoking a compiler/assembler on it, using 'softwire', containing a custom assembler, or being a front end for gcc), then it's probably just plain-data(not encrypted) bytecode.

To understand the bytecode, you will have to understand the interpreter, which means you'll have to disassemble the mod itself and study it quite intensively. I seriously doubt they used any form of encryption simply because it would be unneccesary. Even if they did, studying the interpreter and other mod code would tell you how to edit the scripts.

If it does compile to machine code, you'll have to reverse engineer the way the mod uses the dll in order to create your own. You likely won't be able to use any of their 'script' since it's been effectively destroyed in the translation to machine code.

If they are insanely paranoid, they might have used a public key encryption method, which means that in order to edit the script, you'll also have to edit the decryption key since you won't have the corresponding encryption key, but compared to reverse engineering a custom interpreter and/or the mod itself, that shouldn't be too difficult at all.

I'd reccomend OllyDbg as the tool to start with.

no, its able to compile back fully, I was looking through the memory with CheatEngine and I found the scripts in plain text, fully understandable, so they are encrypting it some how. I've been trying to find someone who can help me out by getting me the encryption algorithm from the mod's main dll so I can reconstruct it all and stick it in a text file. Anyone here know ASM that will help me?
Monder
Monder
Quote:
Their scripts are typed into a txt and then compiled with their own custom compiler into a dll file which is then put into memory when the game is loaded.


How exactly do they store the stuff in the DLL though?

Can you post a sample on the script here?
joanusdmentia
joanusdmentia
Quote:
Original post by ScottC
no, its able to compile back fully, I was looking through the memory with CheatEngine and I found the scripts in plain text, fully understandable, so they are encrypting it some how.


That doesn't mean it's encrypted (if anything the exact opposite if a 3rd party program can read it). Have you ever tried decompiling Java? It produces lovely full-text code from the byte-code. Another possibility is that the script is compressed, not encrypted.

You could also ask the guys that wrote CheatEngine to shed some light on it for you, since they're able to read it....
"Voilà! In view, a humble vaudevillian veteran, cast vicariously as both victim and villain by the vicissitudes of Fate. This visage, no mere veneer of vanity, is a vestige of the vox populi, now vacant, vanished. However, this valorous visitation of a bygone vexation stands vivified, and has vowed to vanquish these venal and virulent vermin vanguarding vice and vouchsafing the violently vicious and voracious violation of volition. The nly verdict is vengeance; a vendett o

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.