Redshirt2 decryption!

Anything and everything

Moderators: jelco, bert_the_turtle, Chris

User avatar
prophile
level5
level5
Posts: 1541
Joined: Fri Feb 18, 2005 4:17 pm
Location: Southampton, UK
Contact:

Postby prophile » Wed Apr 06, 2005 3:30 am

I'm already on to it, Xander.
User avatar
xander
level5
level5
Posts: 16869
Joined: Thu Oct 21, 2004 11:41 pm
Location: Highland, CA, USA
Contact:

Postby xander » Wed Apr 06, 2005 5:37 am

Cool, thanks.

xander
User avatar
jaysc
level4
level4
Posts: 523
Joined: Tue Mar 08, 2005 5:51 pm
Location: In mAyeeeee bedroom

Postby jaysc » Wed Apr 06, 2005 7:54 pm

I don't understand anything about this. Please HELP.
User avatar
xander
level5
level5
Posts: 16869
Joined: Thu Oct 21, 2004 11:41 pm
Location: Highland, CA, USA
Contact:

Postby xander » Wed Apr 06, 2005 9:03 pm

jaysc wrote:I don't understand anything about this. Please HELP.


There are certain files used by Darwinia that are encrypted using an algorithm called redshirt2. This topic is about decoding those files so that changes might be made. The rest you will have to figure out for yourself... there is more than enough information on the boards, so it shouldn't be too hard.

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

Postby Jackmn » Wed Apr 06, 2005 10:22 pm

Just download GCC (there should be some mac binaries floating around out there) read the docs, and compile one of the examples given. It should work fine.
User avatar
prophile
level5
level5
Posts: 1541
Joined: Fri Feb 18, 2005 4:17 pm
Location: Southampton, UK
Contact:

Postby prophile » Wed Apr 06, 2005 10:41 pm

I'm just building a UI to the C++ code gven earlier.
Samwise415
level1
level1
Posts: 42
Joined: Fri Mar 25, 2005 6:08 am

Postby Samwise415 » Wed Apr 06, 2005 10:43 pm

Jackmn wrote:Just download GCC (there should be some mac binaries floating around out there) read the docs, and compile one of the examples given. It should work fine.


You're scaring the end user.

Jaysc, this discussion is pretty much for decryption propellerheads, not for average Joes like you or I who just want to play the game. I recommend pretending this thread doesn't exist. :wink:
User avatar
prophile
level5
level5
Posts: 1541
Joined: Fri Feb 18, 2005 4:17 pm
Location: Southampton, UK
Contact:

Postby prophile » Wed Apr 06, 2005 11:00 pm

He started it. ;)
leonard
level0
Posts: 7
Joined: Mon Apr 04, 2005 3:09 pm
Location: France

Postby leonard » Thu Apr 07, 2005 1:55 pm

char cp, *line;
FILE *fp;

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

fgets(line, 10, fp);

if (strncmp(line, "redshirt2", 9) == 0) {
fseek(fp, 9L, SEEK_SET);
} else {
printf("Error: Not a redshirt2 file\n");
exit(1);
}

while (cp != EOF) {


Can I point out a potential bug ? :-) char cp is on the stack and not initialized. So if you are an un-lucky guy, cp may be EOF at the beginning of the func, and no data will be processed ( the while loop will exit immediatly)

Anyway how do you find the de-cyphering method ? By de-assembling or just by looking at the cyphered text files ?
User avatar
jaysc
level4
level4
Posts: 523
Joined: Tue Mar 08, 2005 5:51 pm
Location: In mAyeeeee bedroom

Postby jaysc » Thu Apr 07, 2005 6:09 pm

i figured how to decrypt but i don't understand what the code does and how to decrypt he game TXT file.
Eridius
level0
Posts: 4
Joined: Thu Oct 21, 2004 11:29 pm
Location: Concord, MA
Contact:

Ruby version

Postby Eridius » Thu Apr 07, 2005 6:43 pm

Ok, I just whipped up a Ruby version of the conversion. It supports both encryption and decryption, from both a filename or stdin, and seems to work properly.

Code: Select all

#!/usr/bin/env ruby

module Redshirt
   TABLE = [ 0x1f, 0x07, 0x09, 0x01, 0x0b, 0x02, 0x05, 0x05,
           0x03, 0x11, 0x28, 0x0c, 0x23, 0x16, 0x1b, 0x02 ]

   def self.deshirt(input, output)
      i = 0
      input.each_byte do |byte|
         if byte > 0x20
            i += 1
            i %= 16
            byte -= TABLE[i]

            if byte < 0x20
               byte += 0x5f
            end
         end
         output.putc byte
      end
   end

   def self.deshirtfile(filename)
      if filename != nil and filename.length > 0 and filename != "-"
         begin
            File.open(filename, 'r') do |file|
               if file.read("redshirt2".length) != "redshirt2"
                  STDERR.puts "Error: not a redshirt2 file"
                  exit 1
               else
                  deshirt(file, STDOUT)
               end
            end
         rescue Errno::ENOENT
            STDERR.puts "Error: Unable to open file `#{filename}'"
            exit 1
         end
      else
         if STDIN.read("redshirt2".length) != "redshirt2"
            STDIN.seek(0 - "redshirt2".length, IO::SEEK_CUR)
         end
         deshirt(STDIN, STDOUT)
      end
   end

   def self.enshirt(input, output)
      i = 0
      output.print "redshirt2"
      input.each_byte do |byte|
         if byte > 0x20
            i += 1
            i %= 16
            byte += TABLE[i]

            if byte < 0x20
               byte -= 0x5f
            end
         end
         output.putc byte
      end
   end

   def self.enshirtfile(filename)
      if filename != nil and filename.length > 0 and filename != "-"
         begin
            File.open(filename, 'r') do |file|
               enshirt(file, STDOUT)
            end
         rescue Errno::ENOENT
            STDERR.puts "Error: Unable to open file `#{filename}'"
            exit 1
         end
      else
         enshirt(STDIN, STDOUT)
      end
   end
end

if ARGV[0] == '-e'
   Redshirt.enshirtfile(ARGV[1])
elsif ARGV[0] == '-d'
   Redshirt.deshirtfile(ARGV[1])
else
   print <<END
Usage: #{File.basename $0} (-e|-d) [filename]

   -e      Encrypts the given file
   -d      Decrypts the given file

This script encrypts or decrypts a file with the redshirt2 algorithm.
The resulting text is printed on stdout.
If you pass no filename or a -, it reads from stdin instead of the file.
END
end


Just copy that code into a file, mark it executable, and run it. Or don't mark it executable and run it via the ruby interpreter (ex: `ruby redshirt2.rb -d game.txt`). Run it with no arguments for a short help text.
User avatar
jaysc
level4
level4
Posts: 523
Joined: Tue Mar 08, 2005 5:51 pm
Location: In mAyeeeee bedroom

Postby jaysc » Fri Apr 08, 2005 4:57 pm

Where do you put the code?
User avatar
Jackmn
level5
level5
Posts: 1378
Joined: Thu Feb 07, 2002 5:21 pm

Postby Jackmn » Fri Apr 08, 2005 7:56 pm

Run it in Ruby.
User avatar
jaysc
level4
level4
Posts: 523
Joined: Tue Mar 08, 2005 5:51 pm
Location: In mAyeeeee bedroom

Postby jaysc » Fri Apr 08, 2005 11:07 pm

ruby?
Samwise415
level1
level1
Posts: 42
Joined: Fri Mar 25, 2005 6:08 am

Postby Samwise415 » Fri Apr 08, 2005 11:08 pm

END.
USER.


I'm not sure if I can make it any more clear. :roll:

Return to “General”

Who is online

Users browsing this forum: No registered users and 1 guest