]> git.zerfleddert.de Git - proxmark3-svn/commitdiff
FIX: "LF PYRAMID CLONE" now works.
authoriceman1001 <iceman@iuse.se>
Fri, 26 Feb 2016 21:10:27 +0000 (22:10 +0100)
committericeman1001 <iceman@iuse.se>
Fri, 26 Feb 2016 21:10:27 +0000 (22:10 +0100)
client/cmdlfpyramid.c
client/util.c

index c1c237299f8f98b256e84c72a92283a1ab135af1..067900120fd3b5e916404604651d383033c05f67 100644 (file)
@@ -49,15 +49,17 @@ int GetPyramidBits(uint32_t fc, uint32_t cn, uint8_t *pyramidBits) {
        memset(pre, 0x00, sizeof(pre));
 
        // format start bit
+       pre[79] = 1;
        
        // Get 26 wiegand from FacilityCode, CardNumber 
-       uint8_t wiegand[26];
+       uint8_t wiegand[24];
+       memset(wiegand, 0x00, sizeof(wiegand));
        num_to_bytebits(fc, 8, wiegand);
        num_to_bytebits(cn, 16, wiegand+8);
 
        // add wiegand parity bits (dest, source, len)
-       wiegand_add_parity(pre+71, wiegand, 26);
-
+       wiegand_add_parity(pre+80, wiegand, 24);
+       
        // add paritybits       (bitsource, dest, sourcelen, paritylen, parityType (odd, even,)
        addParity(pre+8, pyramidBits+8, 112, 8, 1);
        
@@ -68,15 +70,10 @@ int GetPyramidBits(uint32_t fc, uint32_t cn, uint8_t *pyramidBits) {
 
        uint32_t crc = CRC8Maxim(csBuff, 13);
        num_to_bytebits(crc, 8, pyramidBits+120);
+
        return 1;
 }
-/*
-9     - 00001001
-33278 -         1000000111111110
-               10000100110000001
-000101010101010101010101082602
 
-*/
 int CmdPyramidRead(const char *Cmd) {
        // read lf silently
        CmdLFRead("s");
@@ -93,9 +90,8 @@ int CmdPyramidClone(const char *Cmd) {
 
        uint32_t facilitycode=0, cardnumber=0, fc = 0, cn = 0;
        
-       uint8_t bits[128];
-       uint8_t *bs = bits;
-       memset(bs, 0x00, sizeof(bits));
+       uint8_t bs[129];
+       memset(bs, 0x00, sizeof(bs));
        
        //Pyramid - compat mode, FSK2a, data rate 50, 4 data blocks
        uint32_t blocks[5] = {T55x7_MODULATION_FSK2a | T55x7_BITRATE_RF_50 | 4<<T55x7_MAXBLOCK_SHIFT, 0, 0, 0, 0};
index ce5d9f162c58c90e3f3295798405e0bd856cddd7..ae8e4fecdf526af18fa46d088d7fbfd35fdb78b0 100644 (file)
@@ -135,8 +135,10 @@ char *sprint_hex(const uint8_t *data, const size_t len) {
 }
 
 char *sprint_bin_break(const uint8_t *data, const size_t len, const uint8_t breaks) {
+       
        // make sure we don't go beyond our char array memory
-       int max_len;
+       size_t in_index = 0, out_index = 0;
+       int max_len;    
        if (breaks==0)
                max_len = ( len > MAX_BIN_BREAK_LENGTH ) ? MAX_BIN_BREAK_LENGTH : len;
        else
@@ -147,9 +149,8 @@ char *sprint_bin_break(const uint8_t *data, const size_t len, const uint8_t brea
        memset(buf, 0x00, sizeof(buf));
        char *tmp = buf;
 
-       size_t in_index = 0;
        // loop through the out_index to make sure we don't go too far
-       for (size_t out_index=0; out_index < max_len-2; out_index++) {
+       for (out_index=0; out_index < max_len-2; out_index++) {
                // set character
                sprintf(tmp++, "%u", (unsigned int) data[in_index]);
                // check if a line break is needed and we have room to print it in our array
@@ -157,10 +158,11 @@ char *sprint_bin_break(const uint8_t *data, const size_t len, const uint8_t brea
                        // increment and print line break
                        out_index++;
                        sprintf(tmp++, "%s","\n");
-       }
+               }
                in_index++;
        }
-
+       // last char.
+       sprintf(tmp++, "%u", (unsigned int) data[in_index]);
        return buf;
 }
 
Impressum, Datenschutz