]> cvs.zerfleddert.de Git - proxmark3-svn/commitdiff
ADD: a print_hex_break function,
authoriceman1001 <iceman@iuse.se>
Mon, 15 Feb 2016 21:05:26 +0000 (22:05 +0100)
committericeman1001 <iceman@iuse.se>
Mon, 15 Feb 2016 21:05:26 +0000 (22:05 +0100)
CHG: "hf legic decode" looks better.

client/cmdhflegic.c
client/util.c

index 0ef745342adb6983959c37ebe10d23ea967ce639..3a520f6ae63d341f30e8f14080251608384a013d 100644 (file)
@@ -165,13 +165,12 @@ int CmdLegicDecode(const char *Cmd) {
     
                if ( hasWRC ) {
                        PrintAndLog("WRC protected area:   (I %d | K %d| WRC %d)", i, k, wrc);
     
                if ( hasWRC ) {
                        PrintAndLog("WRC protected area:   (I %d | K %d| WRC %d)", i, k, wrc);
-                       
-                       for ( k=i; k < wrc; k++)
-                               data_buf[k] ^= crc;
-                       
-                       //is WRC / 8? 
-                       
-                       // for ( k=i; k < wrc; k += 8)
+
+                       // de-xor?  if not zero, assume it needs xoring.
+                       if ( data_buf[i] > 0) {
+                               for ( k=i; k < wrc; ++k)
+                                       data_buf[k] ^= crc;
+                       }
                        print_hex_break( data_buf+i, wrc, 16);
                        
                        i += wrc;
                        print_hex_break( data_buf+i, wrc, 16);
                        
                        i += wrc;
@@ -182,34 +181,32 @@ int CmdLegicDecode(const char *Cmd) {
 
                        // de-xor?  if not zero, assume it needs xoring.
                        if ( data_buf[i] > 0) {
 
                        // de-xor?  if not zero, assume it needs xoring.
                        if ( data_buf[i] > 0) {
-                               for (k=i; k < wrp_len; k++)
+                               for (k=i; k < wrp_len; ++k)
                                        data_buf[k] ^= crc;
                        }
                        
                                        data_buf[k] ^= crc;
                        }
                        
-                       // for (k=i; k < wrp_len; k += 16) {
-                               
                        print_hex_break( data_buf+i, wrp_len, 16);
                        print_hex_break( data_buf+i, wrp_len, 16);
-                       // }
                        
                        i += wrp_len;
                        
                        
                        i += wrp_len;
                        
+                       // does this one work?
                        if( wrp_len == 8 )
                                PrintAndLog("Card ID: %2X%02X%02X", data_buf[i-4]^crc, data_buf[i-3]^crc, data_buf[i-2]^crc);                   
                }
     
                        if( wrp_len == 8 )
                                PrintAndLog("Card ID: %2X%02X%02X", data_buf[i-4]^crc, data_buf[i-3]^crc, data_buf[i-2]^crc);                   
                }
     
-               PrintAndLog("Remaining segment payload:");
+               PrintAndLog("Remaining segment payload:  (I %d | K %d | Remain LEN %d)", i, k, remain_seg_payload_len);
                
                if ( data_buf[i] > 0 ) {
                
                if ( data_buf[i] > 0 ) {
-                       for ( k=i; k < remain_seg_payload_len; k++)
+                       for ( k=i; k < remain_seg_payload_len; ++k)
                                data_buf[k] ^= crc;
                }
                
                                data_buf[k] ^= crc;
                }
                
-               // for ( k=i; k < remain_seg_payload_len; k++)
                print_hex_break( data_buf+i, remain_seg_payload_len, 16);
     
                i += remain_seg_payload_len;
                
                printf("\n-------------------------------------\n");
                print_hex_break( data_buf+i, remain_seg_payload_len, 16);
     
                i += remain_seg_payload_len;
                
                printf("\n-------------------------------------\n");
+
                // end with last segment
                if (segment_flag & 0x8) return 0;
 
                // end with last segment
                if (segment_flag & 0x8) return 0;
 
index 2bc5b2ba02f4fc0fda66ba8a678c6d399c1de121..04daffc2e1249d8f9835ae0268e402d7e9d96023 100644 (file)
@@ -111,7 +111,7 @@ void print_hex_break(const uint8_t *data, const size_t len, uint8_t breaks) {
                
                // check if a line break is needed
                if ( (breaks > 0) && (i > 0) && !(i % breaks) )
                
                // check if a line break is needed
                if ( (breaks > 0) && (i > 0) && !(i % breaks) )
-                       printf("\n");
+                       printf("(%d %d)\n", i , breaks);
        }
        printf("\n");
 }
        }
        printf("\n");
 }
Impressum, Datenschutz