Redshirt2 decryption!
Moderators: jelco, bert_the_turtle, Chris
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
-
Samwise415
- level1

- Posts: 42
- Joined: Fri Mar 25, 2005 6:08 am
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.
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 ?
Anyway how do you find the de-cyphering method ? By de-assembling or just by looking at the cyphered text files ?
Ruby version
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.
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.
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.
-
Samwise415
- level1

- Posts: 42
- Joined: Fri Mar 25, 2005 6:08 am
Who is online
Users browsing this forum: No registered users and 1 guest





