|
|
View previous topic :: View next topic |
Author |
Message |
hmmpic
Joined: 09 Mar 2010 Posts: 314 Location: Denmark
|
Data stream dump and CS calculation puzzle. |
Posted: Sat Sep 17, 2011 2:35 pm |
|
|
I have this funny byte puzzle.
It is a data stream taken from a running system. I want to change some of the bit, but to get it work the checksum byte must fit.
So the CS byte is the puzzle.
The first 12 first byte is data i think (99% sure). The last byte is a CS byte I know! The CS byte change if something in the 12 other byte is changed.
My problem is to calculate the CS byte. I have now tried all what i can come over. XOR, SUM, Swapping byte in H-L order, Invert byte, and so on. It wont fit.
In the CS byte i have only seen a 1 in the Low part of the byte, and i have dumped a lot more data than what showing hare.
Is someone smart enough to find the solution?
Code: | /*
rom int8 key_0[13] = {0xaa,0x5a,0xcf,0x10,0x01,0x11,0x21,0x07,0x08,0x80,0x00,0xf0,0x61};
rom int8 key_1[13] = {0xaa,0x5a,0xcf,0x10,0x00,0x31,0x21,0x07,0x08,0x80,0x04,0xf0,0x11};
rom int8 key_2[13] = {0xaa,0x5a,0xcf,0x10,0x01,0x31,0x21,0x07,0x08,0x80,0x04,0xf0,0x01};
rom int8 key_3[13] = {0xaa,0x5a,0xcf,0x10,0x02,0x31,0x21,0x07,0x08,0x80,0x04,0xf0,0x31};
rom int8 key_4[13] = {0xaa,0x5a,0xcf,0x10,0x03,0x31,0x21,0x07,0x08,0x80,0x04,0xf0,0x21};
rom int8 key_5[13] = {0xaa,0x5a,0xcf,0x10,0x04,0x31,0x21,0x07,0x08,0x80,0x04,0xf0,0x51};
rom int8 key_6[13] = {0xaa,0x5a,0xcf,0x10,0x05,0x31,0x21,0x07,0x08,0x80,0x04,0xf0,0x41};
rom int8 key_7[13] = {0xaa,0x5a,0xcf,0x10,0x06,0x31,0x21,0x07,0x08,0x80,0x04,0xf0,0x71};
rom int8 key_8[13] = {0xaa,0x5a,0xcf,0x10,0x07,0x31,0x21,0x07,0x08,0x80,0x04,0xf0,0x61};
*/
|
|
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9240 Location: Greensville,Ontario
|
|
Posted: Mon Sep 19, 2011 11:49 am |
|
|
I've got 3 solutions..
the simplest is
... to look at the programs function or subroutine that reads the 12 bytes of data and computes the internal checksum to compare against the 13th byte, the 'known' checksum.
This is also the fastest and most accurate way of reverse engineering the checksum.
The others involve taking the data and plugging them into a quickbasic program I wrote a 1/4 century ago to come up with the algorithm. Have to admit it was kinda nice to see that program running again....
sigh, time flies.... |
|
|
hmmpic
Joined: 09 Mar 2010 Posts: 314 Location: Denmark
|
|
Posted: Tue Sep 20, 2011 8:24 am |
|
|
Hi
There are no more help than what I show here.
I made a simple testing program in C, it work on 90% of the data.
It is compiled with "codeblock"
Code: | #include <iostream>
#include "stdio.h"
#include "string.h"
#include "stdlib.h"
#define byte short unsigned int
using namespace std;
const byte RawData[12][13]={
{0xaa,0x5a,0xcf,0x10,0x01,0x11,0x21,0x07,0x08,0x80,0x00,0xf0,0x61},
{0xaa,0x5a,0xcf,0x10,0x00,0x31,0x21,0x07,0x08,0x80,0x04,0xf0,0x11},
{0xaa,0x5a,0xcf,0x10,0x01,0x31,0x21,0x07,0x08,0x80,0x04,0xf0,0x01},
{0xaa,0x5a,0xcf,0x10,0x02,0x31,0x21,0x07,0x08,0x80,0x04,0xf0,0x31},
{0xaa,0x5a,0xcf,0x10,0x03,0x31,0x21,0x07,0x08,0x80,0x04,0xf0,0x21},
{0xaa,0x5a,0xcf,0x10,0x04,0x31,0x21,0x07,0x08,0x80,0x04,0xf0,0x51},
{0xaa,0x5a,0xcf,0x10,0x05,0x31,0x21,0x07,0x08,0x80,0x04,0xf0,0x41},
{0xaa,0x5a,0xcf,0x10,0x06,0x31,0x21,0x07,0x08,0x80,0x04,0xf0,0x71},
{0xaa,0x5a,0xcf,0x10,0x07,0x31,0x21,0x07,0x08,0x80,0x04,0xf0,0x61},
{0xaa,0x5a,0xcf,0x10,0x07,0x21,0x21,0x07,0x08,0x80,0x00,0xf0,0x31},
{0xaa,0x5a,0xcf,0x10,0x05,0x21,0x21,0x07,0x18,0x80,0x00,0xf0,0x01},
{0xaa,0x5a,0xcf,0x10,0x05,0x11,0x21,0x07,0x18,0x80,0x00,0xf0,0x31}
};
byte HI(byte d){
return ((d>>4)&0x0f);
}
byte LO(byte d){
return (d&0x0f);
}
byte HLSwap(byte d){
byte res;
res=LO(d)<<4|HI(d);
return (res);
}
byte HLInv(byte d){
byte res;
res=d^0xff;
return (res);
}
void CS1(){
byte j,i,res;
for (j=0; j<12; j++){
res=0x00;
for (i=0; i<12; i++){
res^=(RawData[j][i]);
}
res^=0x55;
printf("*CS:%02x CS:%02x Line:%2u\r\n",HLSwap(res),RawData[j][i],j);
}
}
int main(void)
{
CS1();
return 0;
} |
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|