Page 1 of 2

how to find the decompressed size of CX OS

Unread postPosted: 08 Feb 2017, 23:22
by parrotgeek1
I know how to dump RAM, but how do I find out the exact size of the OS so there is not extra data at the end?

Re: how to find the decompressed size of CX OS

Unread postPosted: 08 Feb 2017, 23:27
by critor
That's something I was wondering about, as I don't use the publicly available decrypting method.

Re: how to find the decompressed size of CX OS

Unread postPosted: 08 Feb 2017, 23:33
by parrotgeek1
critor wrote:That's something I was wondering about, as I don't use the publicly available decrypting method.

What is that method?

Re: how to find the decompressed size of CX OS

Unread postPosted: 08 Feb 2017, 23:37
by critor
parrotgeek1 wrote:
critor wrote:That's something I was wondering about, as I don't use the publicly available decrypting method.

What is that method?

archives_voir.php?id=4281 with the complete source code I'm not allowed to share.
In the public source code, the decryption key is missing.

Ok, all CX, CX CAS and CM raw images I've checked so far seems to end with the following pattern :
Code: Select all
12 0C F0 8F 12 0C 00 90 12 0C 10 90 12 0C 00 A0
1A 0C 00 A4 12 0C 00 AC 12 0C 00 B0 12 0C 00 B4
12 0C 00 B8 12 0C 00 BC 12 0C 00 C0 12 0C 00 C4
12 0C 00 C8 12 0C 00 CC 12 0C 00 DC 12 0C 00 A9
12 0C 00 81 12 0C 10 81 12 0C 20 81 12 0C 30 81
12 0C 40 81 12 0C 50 81 12 0C 60 81 12 0C 70 81
12 0C 80 81 12 0C 90 81 12 0C A0 81 12 0C B0 81

Re: how to find the decompressed size of CX OS

Unread postPosted: 08 Feb 2017, 23:47
by parrotgeek1
critor wrote:
parrotgeek1 wrote:
critor wrote:That's something I was wondering about, as I don't use the publicly available decrypting method.

What is that method?

archives_voir.php?id=4281 with the complete source code I'm not allowed to share.
In the public source code, the decryption key is missing.

Ok, all CX, CX CAS and CM raw images I've checked so far seem to end with the following pattern :
Code: Select all
12 0C F0 8F 12 0C 00 90 12 0C 10 90 12 0C 00 A0
1A 0C 00 A4 12 0C 00 AC 12 0C 00 B0 12 0C 00 B4
12 0C 00 B8 12 0C 00 BC 12 0C 00 C0 12 0C 00 C4
12 0C 00 C8 12 0C 00 CC 12 0C 00 DC 12 0C 00 A9
12 0C 00 81 12 0C 10 81 12 0C 20 81 12 0C 30 81
12 0C 40 81 12 0C 50 81 12 0C 60 81 12 0C 70 81
12 0C 80 81 12 0C 90 81 12 0C A0 81 12 0C B0 81

Thanks, it works EDIT: IT DOESN"T
Code: Select all
import java.io.*;
import java.util.*;
import java.nio.*;
import java.nio.file.*;

public class CutOS {
   public static int indexOf(byte[] outerArray, byte[] smallerArray) {
      for(int i = 0; i < outerArray.length - smallerArray.length+1; ++i) {
         boolean found = true;
         for(int j = 0; j < smallerArray.length; ++j) {
            if (outerArray[i+j] != smallerArray[j]) {
               found = false;
               break;
            }
         }
         if (found) return i;
      }
      return -1;
   }
   
   public static void main(String args[]) throws Exception {
      String in = args[0];
      String out = args[1];
      byte[] bytes = Files.readAllBytes(Paths.get(in));
      String text = new String(bytes);
      // thanks critor
      byte[] patt = new byte[]{
         (byte)0x12, (byte)0x0C, (byte)0xF0, (byte)0x8F, (byte)0x12, (byte)0x0C, (byte)0x00, (byte)0x90, (byte)0x12, (byte)0x0C, (byte)0x10, (byte)0x90, (byte)0x12, (byte)0x0C, (byte)0x00, (byte)0xA0,
         (byte)0x1A, (byte)0x0C, (byte)0x00, (byte)0xA4, (byte)0x12, (byte)0x0C, (byte)0x00, (byte)0xAC, (byte)0x12, (byte)0x0C, (byte)0x00, (byte)0xB0, (byte)0x12, (byte)0x0C, (byte)0x00, (byte)0xB4,
         (byte)0x12, (byte)0x0C, (byte)0x00, (byte)0xB8, (byte)0x12, (byte)0x0C, (byte)0x00, (byte)0xBC, (byte)0x12, (byte)0x0C, (byte)0x00, (byte)0xC0, (byte)0x12, (byte)0x0C, (byte)0x00, (byte)0xC4,
         (byte)0x12, (byte)0x0C, (byte)0x00, (byte)0xC8, (byte)0x12, (byte)0x0C, (byte)0x00, (byte)0xCC, (byte)0x12, (byte)0x0C, (byte)0x00, (byte)0xDC, (byte)0x12, (byte)0x0C, (byte)0x00, (byte)0xA9,
         (byte)0x12, (byte)0x0C, (byte)0x00, (byte)0x81, (byte)0x12, (byte)0x0C, (byte)0x10, (byte)0x81, (byte)0x12, (byte)0x0C, (byte)0x20, (byte)0x81, (byte)0x12, (byte)0x0C, (byte)0x30, (byte)0x81,
         (byte)0x12, (byte)0x0C, (byte)0x40, (byte)0x81, (byte)0x12, (byte)0x0C, (byte)0x50, (byte)0x81, (byte)0x12, (byte)0x0C, (byte)0x60, (byte)0x81, (byte)0x12, (byte)0x0C, (byte)0x70, (byte)0x81,
         (byte)0x12, (byte)0x0C, (byte)0x80, (byte)0x81, (byte)0x12, (byte)0x0C, (byte)0x90, (byte)0x81, (byte)0x12, (byte)0x0C, (byte)0xA0, (byte)0x81, (byte)0x12, (byte)0x0C, (byte)0xB0, (byte)0x81
      };
      int w = indexOf(bytes,patt);
      byte [] subArray = Arrays.copyOfRange(bytes, w+patt.length, bytes.length);
      FileOutputStream fos = new FileOutputStream(out);
      fos.write(subArray);
      fos.close();
   }
}

Re: how to find the decompressed size of CX OS

Unread postPosted: 09 Feb 2017, 00:30
by critor
In what way does it not work ?

Re: how to find the decompressed size of CX OS

Unread postPosted: 09 Feb 2017, 00:51
by parrotgeek1
critor wrote:In what way does it not work ?

I fixed it. it has to go from 0 to the end of the pattern. It was my mistake

Re: how to find the decompressed size of CX OS

Unread postPosted: 09 Feb 2017, 09:12
by Lionel Debroux
This is a brittle way to do the job, though it happens to work... you'd much better use imgmanip ;)
The set of decryption keys isn't that hard to build. Maybe imgmanip itself (or something close to that) can do it.

Re: how to find the decompressed size of CX OS

Unread postPosted: 09 Feb 2017, 16:39
by parrotgeek1
Lionel Debroux wrote:This is a brittle way to do the job, though it happens to work... you'd much better use imgmanip ;)
The set of decryption keys isn't that hard to build. Maybe imgmanip itself (or something close to that) can do it.

I'm confused. Can you PM me?

Re: how to find the decompressed size of CX OS

Unread postPosted: 09 Feb 2017, 20:37
by Legimet
You can modify imgmanip to output the keys. Take a look at the source code ;)