Identify the checksum algorithm

74 views Asked by At

I am trying to reverse-engineering a device (an 8 bit microcontroller) that comunicates with the PC. Each microcontroller has a Serial number of two digits (in decimal) that is used to calculated a checksum. For the same data message the checksum changes from device to device. Each message starts with an 0x02 and ends with a 0x03. The checksum is the number that appears between 0x04 and 0x03. These are the messages in Hexa and a translation to Ascii code:

02 41 42 42 04 31 30 03   .ABB.10.    //device ID :00
02 41 42 42 04 44 44 03    .ABB.DD.    //device ID : 01     
02 41 42 42 04 31 39 03    .ABB.19.    //device ID : 56  
02 41 42 42 04 35 34 03    .ABB.54.    //device ID : 99 


02 41 42 31 30 04 37 39 03  .AB10.79.   //device ID :00
02 41 42 31 30 04 34 45 03  .AB10.4E.   //device ID : 01
02 41 42 31 30 04 45 35 03  .AB10.E5.   //device ID : 56  
02 41 42 31 30 04 35 45 03  .AB10.5E.   //device ID : 99

02 41 42 70 04 41 43 03    .ABp.AC.    //device ID :00
02 41 42 70 04 36 31 03    .ABp.61.    //device ID : 01    
02 41 42 70 04 45 38 03    .ABp.E8.    //device ID : 56         
02 41 42 70 04 41 35 03     .ABp.A5.    //device ID : 99

02 41 42 30 46 46 46 46 04 46 30 03  .AB0FFFF.F0. //device ID:00
02 41 42 30 46 46 46 46 04 35 34 03  .AB0FFFF.54. //device ID : 01     
02 41 42 30 46 46 46 46 04 36 33 03  .AB0FFFF.63. //device ID : 56    
02 41 42 30 46 46 46 46 04 31 45 03  .AB0FFFF.1E. //device ID :99

I think that is making a kind of Xor but i cant figure how. Also as you can see , the checksum changes for different devices ID. I need to identify how the whole chekcsum is calculated with the data + device ID, or at least identify how the device ID is changing the checksum between different devices. The microcontroller is an 8 bit uc 8051. I will be very greatful if someone can give me any clue on how it its working.

Updat: Now i can modify the data of 1 message and see how the checksum varies according to the data that is given. Here is an example:

02 41 42 5a 43 30 30 38 30 30 30 30 30 30 30 30   .ABZC00800000000 
30 04 37 35 03                                    0.75.

For the command ABZC008 i can modify the data that comes after de number eight. in this case the checksum is 75.

Here is another example where i put the data to 1s:

02 41 42 5a 43 30 30 38 30 31 31 31 31 31 31 31   .ABZC00801111111 
20 04 39 44 03                                     .9D.      
0

There are 0 answers