Recently, a user on Gaming.SE asked a question about whether the user password in the video game Uplink could be modified after being initially set. The game does not contain an option to change the password, and the password is repeatedly displayed in plain text throughout in the game. Obviously, this is a problem if a user accidentally uses a valuable password.

The game stores the password in the save file, which could be edited, except that the save file is encrypted using Introversion's REDSHIRT encryption scheme. How do the REDSHIRT and REDSHIRT2 encryption schemes work, and what is the decryption algorithm?

Be Aware: Details of REDSHIRT encryption have already been discovered and published:

I'm asking this question only to benefit future users. I do plan to post my own answer, but I'll be happy to upvote and accept anyone who explains it better than I can.

  • $\begingroup$ if you are a programmer and you already have source code to the decryption tool given by mario konrad then you don't need an answer to this question :) $\endgroup$ – Ahmed Masud Jan 1 '12 at 7:05
  • $\begingroup$ @AhmedMasud - I'm asking here because Mario may decide to someday take down his source. $\endgroup$ – Steve V. Jan 1 '12 at 7:07
  • $\begingroup$ Steve, it's good to think of future users, but this is not really a programming question. $\endgroup$ – Maarten Bodewes Jan 1 '12 at 22:39
  • 2
    $\begingroup$ This is kind of like worrying that the recipe for ice will be lost. $\endgroup$ – David Schwartz Jan 2 '12 at 12:59
  • 1
    $\begingroup$ "Is it practical" -> Yes, it is asking how to break a particular kind of encryption. "Is it answerable" -> Yes, there is one correct answer. "Is it based on an actual problem you face?" -> Yes "Is it okay to ask a question even when you know the answer?" -> Yes I asked the question in good faith - no spam intended. If you still disagree, please tell me. $\endgroup$ – Steve V. Jan 7 '12 at 21:19

I'm not going to explain this but after looking at redshirt.c; the core part of the program is that after skipping the header (which is "REDSHIRT" (9 bytes includes an ending null byte)), it has a loop which does:

int j;
j = (j & 0x7F) + (~j & 0x80);

Which, if you don't recognize it, maps 128-255 to 0-127 and 0-127 to 128-255. (I think this might be the same as swapping the nibbles of a byte.) and is the same as j = (j + 128) % 256.

  • 5
    $\begingroup$ I don't think it's swapping the nibbles, I think it's flipping the first bit. (It's also XOR'ing by 128) $\endgroup$ – Steve V. Jan 1 '12 at 7:53
  • 2
    $\begingroup$ Yep, it's the same as j ^= 128; $\endgroup$ – David Schwartz Jan 2 '12 at 12:58

REDSHIRT is a simple XOR encryption scheme, where each byte of the file (except the 9-byte header) is XOR'ed by 128.

The following Python code will decrypt it:

b = bytearray(open('a.in', 'rb').read())

#strip header
for i in range(9):

for i in range(len(b)):
    b[i] ^= 0x80
open('b.out', 'wb').write(b)

The same transformation will re-encrypt it, after which the header should be reapplied to the file.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.