Redshirt2 decryption!

Anything and everything

Moderators: jelco, bert_the_turtle, Chris

User avatar
Jackmn
level5
level5
Posts: 1378
Joined: Thu Feb 07, 2002 5:21 pm

Postby Jackmn » Fri Apr 08, 2005 11:47 pm

Google is there for a reason.

I'm not developing software for the end user. I write code for fellow programmers.

If a person who isn't knowledgeable in a field jumps in a conversation dedicated to that field, I'm not going to spoonfeed that individual. Nor would I jump into a thread on complex modelling issues - a subjects that I am almost completely ignorant of - asking basic questions on how to load models. That is what google is for.
User avatar
xander
level5
level5
Posts: 16869
Joined: Thu Oct 21, 2004 11:41 pm
Location: Highland, CA, USA
Contact:

Postby xander » Sat Apr 09, 2005 3:23 am

Eridius: Thanks for the code. It works very nicely.

jaysc: From the man pages --

Code: Select all

NAME
       ruby - Interpreted object-oriented scripting language

<snip>

PREFACE
       Ruby is an interpreted scripting language for quick and easy object-
       oriented programming.  It has many features to process text files and
       to do system management tasks (as in Perl).  It is simple, straight-
       forward, and extensible.

       If you want a language for easy object-oriented programming, or you
       don't like the Perl ugliness, or you do like the concept of lisp, but
       don't like too much parentheses, Ruby may be the language of your
       choice.

&c. &c.

It came installed with OS X on my lappy. It also runs on *nix. Don't know about Windows.

xander
oldbushie
level0
Posts: 3
Joined: Mon Apr 11, 2005 12:35 am

Postby oldbushie » Mon Apr 11, 2005 12:41 am

I tried the ruby code in Windows, but it always crashes upon completion though the resulting file seems complete. When I encrypt back however, the result is different than the original file (this without editing). The only thing I changed in the ruby code is removing the first line as I am in Windows. Why would the same source code have such different results on the two OS's?
User avatar
Jackmn
level5
level5
Posts: 1378
Joined: Thu Feb 07, 2002 5:21 pm

Postby Jackmn » Mon Apr 11, 2005 12:45 am

Odds are you have to open the file in binary. (Windows differentiates between text and binary files, text is usually default for most languages).

Try changing 'r' to 'rb' in the File.open call.
oldbushie
level0
Posts: 3
Joined: Mon Apr 11, 2005 12:35 am

Postby oldbushie » Mon Apr 11, 2005 1:41 am

Hmm, it still has some of the characters turning out differently...

Ah well, I managed to get Uniter's source code working fine, thanks Uniter! :)
Eridius
level0
Posts: 4
Joined: Thu Oct 21, 2004 11:29 pm
Location: Concord, MA
Contact:

Different output

Postby Eridius » Mon Apr 11, 2005 11:54 pm

Ignore the fact that the re-encrypted output is different from the original. It doesn't matter. The reason for this is because the decryption process is a one-way transform - it loses data, so you can't do an identical reversion of the process. If you read the code, it loses data where it checks if the byte is less than 0x20 and adds 0x5f to it - when re-encrypting, if you have, say, 0x6c, there's no way to tell if 0x5f should be subtracted or not. However, it doesn't matter - the re-encrypted version decrypts to exactly the same text as the original version decrypted. So there's no problem with this.
oldbushie
level0
Posts: 3
Joined: Mon Apr 11, 2005 12:35 am

Postby oldbushie » Tue Apr 12, 2005 3:16 am

Uniter's code actually does a perfect transform there and back, I checked...
Eridius
level0
Posts: 4
Joined: Thu Oct 21, 2004 11:29 pm
Location: Concord, MA
Contact:

Postby Eridius » Mon Apr 18, 2005 2:23 am

oldbushie wrote:Uniter's code actually does a perfect transform there and back, I checked...


I just checked his code, and it's the same as my code (except in a different language). There's no way it should be able to produce different output from mine.

And again, the output from mine is equivalent to the existing file. Some data may be different, but it's not a one-to-one transform. Multiple inputs can equal the same output.
User avatar
Jackmn
level5
level5
Posts: 1378
Joined: Thu Feb 07, 2002 5:21 pm

Postby Jackmn » Mon Apr 18, 2005 3:34 am

In both programs, in one form another, the following is done:

Code: Select all

if (cp < 0x20)
       cp -= 0x5f;
Sure this is correct?
Eridius
level0
Posts: 4
Joined: Thu Oct 21, 2004 11:29 pm
Location: Concord, MA
Contact:

Postby Eridius » Sat Apr 23, 2005 9:36 pm

Jackmn wrote:In both programs, in one form another, the following is done:

Code: Select all

if (cp < 0x20)
       cp -= 0x5f;
Sure this is correct?


Yeah, it works. When printing the character the negative integer is wrapped around. It may not produce ASCII chars, but it does produce something that can be decrypted again.
User avatar
Jackmn
level5
level5
Posts: 1378
Joined: Thu Feb 07, 2002 5:21 pm

Postby Jackmn » Sat Apr 23, 2005 11:36 pm

The question is whether the game does that.
User avatar
xander
level5
level5
Posts: 16869
Joined: Thu Oct 21, 2004 11:41 pm
Location: Highland, CA, USA
Contact:

Postby xander » Sun Apr 24, 2005 2:39 am

My question is this: do you need to be able to re-encrypt files? As far as the game is concerned, you can place un-encrypted files in the directories, and they will work. So, other than the inherent |337-ness of it, why do you need an encrypter?

Please, this is not a flame, only a question. It is not meant to be incendiary.

xander
User avatar
NeoThermic
Introversion Staff
Introversion Staff
Posts: 6256
Joined: Sat Mar 02, 2002 10:55 am
Location: ::1
Contact:

Postby NeoThermic » Sun Apr 24, 2005 8:33 am

xander wrote:My question is this: do you need to be able to re-encrypt files? As far as the game is concerned, you can place un-encrypted files in the directories, and they will work. So, other than the inherent |337-ness of it, why do you need an encrypter?

Please, this is not a flame, only a question. It is not meant to be incendiary.

xander


The "defaults" of a level are in text format, yes. All your saves though, are not. Thus if you want to edit your progress, you'll need the redshirt2 stuff :)

NeoThermic
User avatar
Jackmn
level5
level5
Posts: 1378
Joined: Thu Feb 07, 2002 5:21 pm

Postby Jackmn » Sun Apr 24, 2005 8:54 am

He means that if you de-redshirt your profile info and don't re-redshirt it, the game will still load it properly.

I believe he is correct.
monochrome
level0
Posts: 6
Joined: Sun Apr 24, 2005 10:02 pm

Postby monochrome » Mon Apr 25, 2005 9:43 pm

Code: Select all

void deshirt(char *filename)
{
        int i;
        char cp, *line;
        FILE *fp;

        if ((fp = fopen(filename, "r")) == NULL) {
                printf("Unable to open: %s\n", filename);
                exit(1);
        }

        fgets(line, 10, fp);


The line pointer is never initialized, so the fgets writes to unallocated memory = kaboom in most cases. Replace with:

Code: Select all

void deshirt(char *filename)
{
        int i;
        char cp = 0;
        char line[10];
        FILE *fp;



The while statement in both funcitons can also be replaced with:

Code: Select all

while ((cp = fgetc(fp)) != EOF) {


which covers the case when fgetc actually returns EOF (you get an off-by-one error and encrypt / decrypt the EOF marker otherwise).

Return to “General”

Who is online

Users browsing this forum: No registered users and 1 guest