]> cvs.zerfleddert.de Git - proxmark3-svn/commitdiff
FIX: this fixes the "hf mf sniff l d f" command, which has been broken for a while...
authoriceman1001 <iceman@iuse.se>
Mon, 18 Apr 2016 11:18:02 +0000 (13:18 +0200)
committericeman1001 <iceman@iuse.se>
Mon, 18 Apr 2016 11:18:02 +0000 (13:18 +0200)
FIX: The flushing of logentries.
ADD: "hf mf sniff" - added the sniffing of UID's with a uidlen of 10.

Whats left? The key is not always found even if we use the "mfkey64" approach.

ADD: added the parity_zero attack in "hf mf mifare".  Still not working since piwi's changes to the iso14443a.c,  maybe needs a param to tell it to collect nonces for this special attack.
CHG: extracted some help-texts into usage_* methods. Changed some text as well

FIX:  "hf mf sim" command now uses both  mfkey32 and mfkey32_moebius version to find the key in attack mode.
CHG:  "hf mf sim" also now defaults to emul_memory to read a 4 byte UID.

client/cmdhfmf.c
client/mifarehost.c
client/mifarehost.h
client/scripting.c

index 797b5657d3e1c0e73e982e1fffc913941cc5d25c..ec5d4487ce90068bc63794b2db2f85c5050a570d 100644 (file)
 #include "nonce2key/nonce2key.h"\r
 \r
 static int CmdHelp(const char *Cmd);\r
+int usage_hf14_mifare(void){\r
+       PrintAndLog("Usage:  hf mf mifare [h] <block number>");\r
+       PrintAndLog("options:");\r
+       PrintAndLog("           h    this help");\r
+       PrintAndLog("           <block number>  (Optional) target other key A than block 0.");\r
+       PrintAndLog("sample:");\r
+       PrintAndLog("           hf mf mifare");\r
+       PrintAndLog("           hf mf mifare 16");\r
+       return 0;\r
+}\r
+int usage_hf14_mf1ksim(void){\r
+       PrintAndLog("Usage:  hf mf sim  [h] u <uid (8,14,20 hex symbols)> n <numreads> i x");\r
+       PrintAndLog("options:");\r
+       PrintAndLog("           h    this help");\r
+       PrintAndLog("           u    (Optional) UID 4,7 or 10bytes. If not specified, the UID 4b from emulator memory will be used");\r
+       PrintAndLog("           n    (Optional) Automatically exit simulation after <numreads> blocks have been read by reader. 0 = infinite");\r
+       PrintAndLog("           i    (Optional) Interactive, means that console will not be returned until simulation finishes or is aborted");\r
+       PrintAndLog("           x    (Optional) Crack, performs the 'reader attack', nr/ar attack against a legitimate reader, fishes out the key(s)");\r
+       PrintAndLog("samples:");\r
+       PrintAndLog("           hf mf sim u 0a0a0a0a");\r
+       PrintAndLog("           hf mf sim u 11223344556677");\r
+       PrintAndLog("           hf mf sim u 112233445566778899AA");     \r
+       return 0;\r
+}\r
+int usage_hf14_dbg(void){\r
+       PrintAndLog("Usage:  hf mf dbg [h] <debug level>");\r
+       PrintAndLog("options:");\r
+       PrintAndLog("           h    this help");       \r
+       PrintAndLog("       <debug level>  (Optional) see list for valid levels");\r
+       PrintAndLog("           0 - no debug messages");\r
+       PrintAndLog("           1 - error messages");\r
+       PrintAndLog("           2 - plus information messages");\r
+       PrintAndLog("           3 - plus debug messages");\r
+       PrintAndLog("           4 - print even debug messages in timing critical functions");\r
+       PrintAndLog("               Note: this option therefore may cause malfunction itself");\r
+       PrintAndLog("samples:");\r
+       PrintAndLog("           hf mf dbg 3");\r
+       return 0;\r
+}\r
+int usage_hf14_sniff(void){\r
+       PrintAndLog("It continuously gets data from the field and saves it to: log, emulator, emulator file.");\r
+       PrintAndLog("Usage:  hf mf sniff [h] [l] [d] [f]");\r
+       PrintAndLog("options:");\r
+       PrintAndLog("           h    this help");\r
+       PrintAndLog("           l    save encrypted sequence to logfile `uid.log`");\r
+       PrintAndLog("           d    decrypt sequence and put it to log file `uid.log`");\r
+//     PrintAndLog(" n/a   e     decrypt sequence, collect read and write commands and save the result of the sequence to emulator memory");\r
+       PrintAndLog("           f    decrypt sequence, collect read and write commands and save the result of the sequence to emulator dump file `uid.eml`");\r
+       PrintAndLog("sample:");\r
+       PrintAndLog("           hf mf sniff l d f");\r
+       return 0;\r
+}\r
 \r
-int CmdHF14AMifare(const char *Cmd)\r
-{\r
+int CmdHF14AMifare(const char *Cmd) {\r
        uint32_t uid = 0;\r
        uint32_t nt = 0, nr = 0;\r
        uint64_t par_list = 0, ks_list = 0, r_key = 0;\r
@@ -24,21 +75,16 @@ int CmdHF14AMifare(const char *Cmd)
        uint8_t blockNo = 0;\r
        \r
        char cmdp = param_getchar(Cmd, 0);      \r
-       if ( cmdp == 'H' || cmdp == 'h') {\r
-               PrintAndLog("Usage:  hf mf mifare <block number>");\r
-               PrintAndLog("        sample: hf mf mifare 0");\r
-               return 0;\r
-       }       \r
+       if ( cmdp == 'H' || cmdp == 'h') return usage_hf14_mifare();\r
        \r
        blockNo = param_get8(Cmd, 0);\r
        UsbCommand c = {CMD_READER_MIFARE, {true, blockNo, 0}};\r
 \r
        // message\r
        printf("-------------------------------------------------------------------------\n");\r
-       printf("Executing command. Expected execution time: 25sec on average  :-)\n");\r
+       printf("Executing darkside attack. Expected execution time: 25sec on average :-)\n");\r
        printf("Press button on the proxmark3 device to abort both proxmark3 and client.\n");\r
        printf("-------------------------------------------------------------------------\n");\r
-\r
        clock_t t1 = clock();\r
        \r
 start:\r
@@ -65,7 +111,13 @@ start:
                UsbCommand resp;\r
                if (WaitForResponseTimeout(CMD_ACK, &resp, 1500)) {\r
                        isOK  = resp.arg[0];\r
-                       printf("\n\n");\r
+                       printf("\n");\r
+                       uid = (uint32_t)bytes_to_num(resp.d.asBytes +  0, 4);\r
+                       nt =  (uint32_t)bytes_to_num(resp.d.asBytes +  4, 4);\r
+                       par_list = bytes_to_num(resp.d.asBytes +  8, 8);\r
+                       ks_list = bytes_to_num(resp.d.asBytes +  16, 8);\r
+                       nr = bytes_to_num(resp.d.asBytes + 24, 4);\r
+\r
                        switch (isOK) {\r
                                case -1 : PrintAndLog("Button pressed. Aborted.\n"); break;\r
                                case -2 : PrintAndLog("Card is not vulnerable to Darkside attack (doesn't send NACK on authentication requests).\n"); break;\r
@@ -74,17 +126,19 @@ start:
                                                  PrintAndLog("generating polynomial with 16 effective bits only, but shows unexpected behaviour.\n"); break;\r
                                default: ;\r
                        }\r
-                       uid = (uint32_t)bytes_to_num(resp.d.asBytes +  0, 4);\r
-                       nt =  (uint32_t)bytes_to_num(resp.d.asBytes +  4, 4);\r
-                       par_list = bytes_to_num(resp.d.asBytes +  8, 8);\r
-                       ks_list = bytes_to_num(resp.d.asBytes +  16, 8);\r
-                       nr = bytes_to_num(resp.d.asBytes + 24, 4);\r
                        break;\r
                }\r
        }       \r
-\r
        printf("\n");\r
        \r
+       // par == 0\r
+       if (isOK == -1 && par_list == 0) {\r
+               if (!nonce2key_ex(uid, nt, nr, ks_list, &r_key) ){\r
+                       PrintAndLog("Found valid key: %012"llx" \n", r_key);\r
+                       goto END;\r
+               }\r
+       }\r
+       \r
        // error\r
        if (isOK != 1) return 1;\r
        \r
@@ -98,7 +152,7 @@ start:
        } else {\r
                PrintAndLog("Found valid key: %012"llx" \n", r_key);\r
        }\r
-       \r
+END:\r
        t1 = clock() - t1;\r
        if ( t1 > 0 )\r
                PrintAndLog("Time in darkside: %.0f ticks\n", (float)t1);\r
@@ -280,8 +334,7 @@ uint8_t NumBlocksPerSector(uint8_t sectorNo)
        }\r
 }\r
 \r
-int CmdHF14AMfDump(const char *Cmd)\r
-{\r
+int CmdHF14AMfDump(const char *Cmd) {\r
        uint8_t sectorNo, blockNo;\r
        \r
        uint8_t keyA[40][6];\r
@@ -453,8 +506,7 @@ int CmdHF14AMfDump(const char *Cmd)
        return 0;\r
 }\r
 \r
-int CmdHF14AMfRestore(const char *Cmd)\r
-{\r
+int CmdHF14AMfRestore(const char *Cmd) {\r
        uint8_t sectorNo,blockNo;\r
        uint8_t keyType = 0;\r
        uint8_t key[6] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};\r
@@ -563,8 +615,7 @@ int CmdHF14AMfRestore(const char *Cmd)
        return 0;\r
 }\r
 \r
-int CmdHF14AMfNested(const char *Cmd)\r
-{\r
+int CmdHF14AMfNested(const char *Cmd) {\r
        int i, j, res, iterations;\r
        sector *e_sector = NULL;\r
        uint8_t blockNo = 0;\r
@@ -830,8 +881,7 @@ int CmdHF14AMfNested(const char *Cmd)
        return 0;\r
 }\r
 \r
-int CmdHF14AMfNestedHard(const char *Cmd)\r
-{\r
+int CmdHF14AMfNestedHard(const char *Cmd) {\r
        uint8_t blockNo = 0;\r
        uint8_t keyType = 0;\r
        uint8_t trgBlockNo = 0;\r
@@ -946,8 +996,7 @@ int CmdHF14AMfNestedHard(const char *Cmd)
        return 0;\r
 }\r
 \r
-int CmdHF14AMfChk(const char *Cmd)\r
-{\r
+int CmdHF14AMfChk(const char *Cmd) {\r
        if (strlen(Cmd)<3) {\r
                PrintAndLog("Usage:  hf mf chk <block number>|<*card memory> <key type (A/B/?)> [t|d] [<key (12 hex symbols)>] [<dic (*.dic)>]");\r
                PrintAndLog("          * - all sectors");\r
@@ -1236,116 +1285,242 @@ int CmdHF14AMfChk(const char *Cmd)
        return 0;\r
 }\r
 \r
-\r
 int CmdHF14AMf1kSim(const char *Cmd) {\r
        uint8_t uid[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};\r
        uint8_t exitAfterNReads = 0;\r
-       uint8_t flags = 0;\r
+       uint8_t flags = (FLAG_UID_IN_EMUL | FLAG_4B_UID_IN_DATA);\r
        int uidlen = 0;\r
+       uint8_t pnr = 0;\r
        uint8_t cmdp = param_getchar(Cmd, 0);\r
 \r
-       if (cmdp == 'h' || cmdp == 'H') {\r
-               PrintAndLog("Usage:  hf mf sim  u <uid (8 hex symbols)> n <numreads> i x");\r
-               PrintAndLog("           h    this help");\r
-               PrintAndLog("           u    (Optional) UID 4,7 or 10bytes. If not specified, the UID from emulator memory will be used");\r
-               PrintAndLog("           n    (Optional) Automatically exit simulation after <numreads> blocks have been read by reader. 0 = infinite");\r
-               PrintAndLog("           i    (Optional) Interactive, means that console will not be returned until simulation finishes or is aborted");\r
-               PrintAndLog("           x    (Optional) Crack, performs the 'reader attack', nr/ar attack against a legitimate reader, fishes out the key(s)");\r
-               PrintAndLog("samples:");\r
-               PrintAndLog("           hf mf sim u 0a0a0a0a");\r
-               PrintAndLog("           hf mf sim u 11223344556677");\r
-               PrintAndLog("           hf mf sim u 112233445566778899AA");\r
-               return 0;\r
-       }\r
-       uint8_t pnr = 0;\r
-       if (param_getchar(Cmd, pnr) == 'u') {\r
-               \r
+       if (cmdp == 'h' || cmdp == 'H') return usage_hf14_mf1ksim();\r
+\r
+       cmdp = param_getchar(Cmd, pnr);\r
+       if (cmdp == 'u' || cmdp == 'U') {\r
                param_gethex_ex(Cmd, pnr+1, uid, &uidlen);\r
                switch(uidlen){\r
-                       case 20: flags |= FLAG_10B_UID_IN_DATA; break;\r
-                       case 14: flags |= FLAG_7B_UID_IN_DATA; break;\r
-                       case  8: flags |= FLAG_4B_UID_IN_DATA; break;\r
-                       default:\r
-                               PrintAndLog("UID, if specified, must include 8, 14 or 20 HEX symbols , %d", uidlen>>1);\r
-                               return 1;\r
+                       case 20: flags = FLAG_10B_UID_IN_DATA;  break;\r
+                       case 14: flags = FLAG_7B_UID_IN_DATA; break;\r
+                       case  8: flags = FLAG_4B_UID_IN_DATA; break;\r
+                       default: return usage_hf14_mf1ksim();\r
                }\r
                pnr +=2;\r
        }\r
-       \r
-       if (param_getchar(Cmd, pnr) == 'n') {\r
-               exitAfterNReads = param_get8(Cmd,pnr+1);\r
+\r
+       cmdp = param_getchar(Cmd, pnr); \r
+       if (cmdp == 'n' || cmdp == 'N') {\r
+               exitAfterNReads = param_get8(Cmd, pnr+1);\r
                pnr += 2;\r
        }\r
-       \r
-       if (param_getchar(Cmd, pnr) == 'i' ) {\r
+\r
+       cmdp = param_getchar(Cmd, pnr);         \r
+       if (cmdp == 'i' || cmdp == 'I' ) {\r
                flags |= FLAG_INTERACTIVE;\r
                pnr++;\r
        }\r
 \r
-       if (param_getchar(Cmd, pnr) == 'x' ) {\r
+       cmdp = param_getchar(Cmd, pnr); \r
+       if (cmdp == 'x' || cmdp == 'X') {\r
                flags |= FLAG_NR_AR_ATTACK;\r
        }\r
        \r
        PrintAndLog(" uid:%s, numreads:%d, flags:%d (0x%02x) "\r
-                               , (uidlen == 0 ) ? "N/A" : sprint_hex(uid, uidlen)\r
+                               , (uidlen == 0 ) ? "N/A" : sprint_hex(uid, uidlen>>1)\r
                                , exitAfterNReads\r
                                , flags\r
                                , flags);\r
 \r
-       UsbCommand c = {CMD_SIMULATE_MIFARE_CARD, {flags, exitAfterNReads,0}};\r
+       UsbCommand c = {CMD_SIMULATE_MIFARE_CARD, {flags, exitAfterNReads, 0}};\r
        memcpy(c.d.asBytes, uid, sizeof(uid));\r
        clearCommandBuffer();\r
        SendCommand(&c);\r
 \r
-       if(flags & FLAG_INTERACTIVE)\r
-       {               \r
-               uint8_t data[40];\r
-               uint8_t key[6];\r
-\r
+       if(flags & FLAG_INTERACTIVE) {          \r
+               uint8_t data[32];\r
+               uint64_t key;\r
                UsbCommand resp;                \r
                PrintAndLog("Press pm3-button or send another cmd to abort simulation");\r
-\r
                while( !ukbhit() ){\r
                        if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500) ) continue;\r
 \r
                        if ( !(flags & FLAG_NR_AR_ATTACK) ) break;\r
                        if ( (resp.arg[0] & 0xffff) != CMD_SIMULATE_MIFARE_CARD ) break;\r
 \r
-                       memset(data, 0x00, sizeof(data));\r
-                       memset(key, 0x00, sizeof(key));\r
+                       memset(data, 0x00, sizeof(data));       \r
                        int len = (resp.arg[1] > sizeof(data)) ? sizeof(data) : resp.arg[1];\r
-                       \r
-                       memcpy(data, resp.d.asBytes, len);\r
-                       \r
-                       // CUID is always 4 first bytes.\r
-                       uint64_t cuid = bytes_to_num(data, 4 );\r
-                       \r
-                       // this needs to be fixed. ICEMAN\r
-                       if ( memcmp(data, "\x00\x00\x00\x00", 4) == 0 ) {\r
-                               tryMfk32(cuid, data, key);\r
-                       } else {\r
-                               tryMfk64(cuid, data, key);\r
-                       }\r
+\r
+                       memcpy(data, resp.d.asBytes, len);                      \r
+                       key = 0;\r
+                       bool found = tryMfk32(data, &key);\r
+                       found ^= tryMfk32_moebius(data, &key);\r
+                       if ( found ) break;\r
                }\r
        }\r
        return 0;\r
 }\r
 \r
+int CmdHF14AMfSniff(const char *Cmd){\r
+       bool wantLogToFile = FALSE;\r
+       bool wantDecrypt = FALSE;\r
+       //bool wantSaveToEml = FALSE; TODO\r
+       bool wantSaveToEmlFile = FALSE;\r
+\r
+       //var \r
+       int tmpchar;\r
+       int res = 0;\r
+       int len = 0;\r
+       int blockLen = 0;\r
+       int pckNum = 0;\r
+       int num = 0;\r
+       uint8_t uid[10];\r
+       uint8_t uid_len = 0;\r
+       uint8_t atqa[2] = {0x00, 0x00};\r
+       uint8_t sak = 0;\r
+       bool isTag = FALSE;\r
+       uint8_t *buf = NULL;\r
+       uint16_t bufsize = 0;\r
+       uint8_t *bufPtr = NULL;\r
+       uint16_t traceLen = 0;\r
+       \r
+       memset(uid, 0x00, sizeof(uid));\r
+       \r
+       char ctmp = param_getchar(Cmd, 0);\r
+       if ( ctmp == 'h' || ctmp == 'H' ) return usage_hf14_sniff();\r
+       \r
+       for (int i = 0; i < 4; i++) {\r
+               ctmp = param_getchar(Cmd, i);\r
+               if (ctmp == 'l' || ctmp == 'L') wantLogToFile = true;\r
+               if (ctmp == 'd' || ctmp == 'D') wantDecrypt = true;\r
+               //if (ctmp == 'e' || ctmp == 'E') wantSaveToEml = true; TODO\r
+               if (ctmp == 'f' || ctmp == 'F') wantSaveToEmlFile = true;\r
+       }\r
+       \r
+       printf("-------------------------------------------------------------------------\n");\r
+       printf("Executing mifare sniffing command. \n");\r
+       printf("Press the key on the proxmark3 device to abort both proxmark3 and client.\n");\r
+       printf("Press the key on pc keyboard to abort the client.\n");\r
+       printf("-------------------------------------------------------------------------\n");\r
+\r
+       UsbCommand c = {CMD_MIFARE_SNIFFER, {0, 0, 0}};\r
+       clearCommandBuffer();\r
+       SendCommand(&c);\r
+\r
+       // wait cycle\r
+       while (true) {\r
+               printf(".");\r
+               fflush(stdout);\r
+               if (ukbhit()) {\r
+                       tmpchar = getchar();\r
+                       (void)tmpchar;\r
+                       printf("\naborted via keyboard!\n");\r
+                       break;\r
+               }\r
+               \r
+               UsbCommand resp;\r
+               if (WaitForResponseTimeout(CMD_ACK, &resp, 2000)) {\r
+                       res = resp.arg[0] & 0xff;\r
+                       traceLen = resp.arg[1];\r
+                       len = resp.arg[2];\r
+\r
+                       // we are done?\r
+                       if (res == 0) {\r
+                               free(buf);\r
+                               return 0;\r
+                       }\r
+\r
+                       if (res == 1) {                                                         // there is (more) data to be transferred\r
+                               if (pckNum == 0) {                                              // first packet, (re)allocate necessary buffer\r
+                                       if (traceLen > bufsize) {\r
+                                               uint8_t *p;\r
+                                               if (buf == NULL)                                // not yet allocated\r
+                                                       p = malloc(traceLen);\r
+                                               else                                            // need more memory\r
+                                                       p = realloc(buf, traceLen);\r
+                                               \r
+                                               if (p == NULL) {\r
+                                                       PrintAndLog("Cannot allocate memory for trace");\r
+                                                       free(buf);\r
+                                                       return 2;\r
+                                               }\r
+                                               buf = p;\r
+                                       }\r
+                                       bufPtr = buf;\r
+                                       bufsize = traceLen;\r
+                                       memset(buf, 0x00, traceLen);\r
+                               }\r
+                               if (bufPtr == NULL) {\r
+                                       PrintAndLog("Cannot allocate memory for trace");\r
+                                       free(buf);\r
+                                       return 2;\r
+                               }\r
+                               // what happens if LEN is bigger then TRACELEN --iceman\r
+                               memcpy(bufPtr, resp.d.asBytes, len);\r
+                               bufPtr += len;\r
+                               pckNum++;\r
+                       }\r
+\r
+                       if (res == 2) {                                                         // received all data, start displaying\r
+                               blockLen = bufPtr - buf;\r
+                               bufPtr = buf;\r
+                               printf(">\n");\r
+                               PrintAndLog("received trace len: %d packages: %d", blockLen, pckNum);\r
+                               while (bufPtr - buf < blockLen) {\r
+                                       bufPtr += 6;                                            // skip (void) timing information\r
+                                       len = *((uint16_t *)bufPtr);\r
+                                       if(len & 0x8000) {\r
+                                               isTag = true;\r
+                                               len &= 0x7fff;\r
+                                       } else {\r
+                                               isTag = false;\r
+                                       }\r
+                                       bufPtr += 2;\r
+                                       if ((len == 17) && (bufPtr[0] == 0xff) && (bufPtr[1] == 0xff) && (bufPtr[15] == 0xff) && (bufPtr[16] == 0xff)) {\r
+                                               memcpy(uid, bufPtr + 2, 10);\r
+                                               memcpy(atqa, bufPtr + 2 + 10, 2);\r
+                                               switch (atqa[0] & 0xC0) {\r
+                                                       case 0x80: uid_len = 10; break;\r
+                                                       case 0x40: uid_len = 7; break;\r
+                                                       default:   uid_len = 4; break;\r
+                                               }\r
+                                               sak = bufPtr[14];\r
+                                               PrintAndLog("tag select uid| %s atqa:0x%02x%02x sak:0x%02x", \r
+                                                       sprint_hex(uid, uid_len),\r
+                                                       atqa[1], \r
+                                                       atqa[0], \r
+                                                       sak);\r
+                                               if (wantLogToFile || wantDecrypt) {\r
+                                                       FillFileNameByUID(logHexFileName, uid, ".log", uid_len);\r
+                                                       AddLogCurrentDT(logHexFileName);\r
+                                               }                                               \r
+                                               if (wantDecrypt)\r
+                                                       mfTraceInit(uid, uid_len, atqa, sak, wantSaveToEmlFile);\r
+                                       } else {\r
+                                               PrintAndLog("%03d| %s |%s", num, isTag ? "TAG" : "RDR", sprint_hex(bufPtr, len));\r
+                                               if (wantLogToFile) \r
+                                                       AddLogHex(logHexFileName, isTag ? "TAG| ":"RDR| ", bufPtr, len);\r
+                                               if (wantDecrypt) \r
+                                                       mfTraceDecode(bufPtr, len, wantSaveToEmlFile);\r
+                                               num++;  \r
+                                       }\r
+                                       bufPtr += len;\r
+                                       bufPtr += ((len-1)/8+1);        // ignore parity\r
+                               }\r
+                               pckNum = 0;\r
+                       }\r
+               } // resp not NULL\r
+       } // while (true)\r
+\r
+       free(buf);\r
+       return 0;\r
+}\r
+\r
 int CmdHF14AMfDbg(const char *Cmd) {\r
-       int dbgMode = param_get32ex(Cmd, 0, 0, 10);\r
-       if (dbgMode > 4)\r
-               PrintAndLog("Max debug mode parameter is 4 \n");\r
-\r
-       if (strlen(Cmd) < 1 || !param_getchar(Cmd, 0) || dbgMode > 4) {\r
-               PrintAndLog("Usage:  hf mf dbg  <debug level>");\r
-               PrintAndLog(" 0 - no debug messages");\r
-               PrintAndLog(" 1 - error messages");\r
-               PrintAndLog(" 2 - plus information messages");\r
-               PrintAndLog(" 3 - plus debug messages");\r
-               PrintAndLog(" 4 - print even debug messages in timing critical functions");\r
-               PrintAndLog("     Note: this option therefore may cause malfunction itself");\r
-               return 0;\r
-       }       \r
+\r
+       char ctmp = param_getchar(Cmd, 0);\r
+       if (strlen(Cmd) < 1  || ctmp == 'h'|| ctmp == 'H') return usage_hf14_dbg();\r
+       \r
+       uint8_t dbgMode = param_get8ex(Cmd, 0, 0, 10);\r
+       if (dbgMode > 4) return usage_hf14_dbg();\r
 \r
        UsbCommand c = {CMD_MIFARE_SET_DBGMODE, {dbgMode, 0, 0}};\r
        SendCommand(&c);\r
@@ -2066,172 +2241,9 @@ int CmdHF14AMfCSave(const char *Cmd) {
        }\r
 }\r
 \r
-\r
-\r
-int CmdHF14AMfSniff(const char *Cmd){\r
-\r
-       bool wantLogToFile = 0;\r
-       bool wantDecrypt = 0;\r
-       //bool wantSaveToEml = 0; TODO\r
-       bool wantSaveToEmlFile = 0;\r
-\r
-       //var \r
-       int tmpchar;\r
-       int res = 0;\r
-       int len = 0;\r
-       int blockLen = 0;\r
-       int pckNum = 0;\r
-       int num = 0;\r
-       uint8_t uid[10];\r
-       uint8_t uid_len = 0;\r
-       uint8_t atqa[2] = {0x00, 0x00};\r
-       uint8_t sak = 0;\r
-       bool isTag;\r
-       uint8_t *buf = NULL;\r
-       uint16_t bufsize = 0;\r
-       uint8_t *bufPtr = NULL;\r
-       \r
-       memset(uid, 0x00, sizeof(uid));\r
-       \r
-       char ctmp = param_getchar(Cmd, 0);\r
-       if ( ctmp == 'h' || ctmp == 'H' ) {\r
-               PrintAndLog("It continuously gets data from the field and saves it to: log, emulator, emulator file.");\r
-               PrintAndLog("You can specify:");\r
-               PrintAndLog("    l - save encrypted sequence to logfile `uid.log`");\r
-               PrintAndLog("    d - decrypt sequence and put it to log file `uid.log`");\r
-               PrintAndLog(" n/a   e - decrypt sequence, collect read and write commands and save the result of the sequence to emulator memory");\r
-               PrintAndLog("    f - decrypt sequence, collect read and write commands and save the result of the sequence to emulator dump file `uid.eml`");\r
-               PrintAndLog("Usage:  hf mf sniff [l][d][e][f]");\r
-               PrintAndLog("  sample: hf mf sniff l d e");\r
-               return 0;\r
-       }       \r
-       \r
-       for (int i = 0; i < 4; i++) {\r
-               ctmp = param_getchar(Cmd, i);\r
-               if (ctmp == 'l' || ctmp == 'L') wantLogToFile = true;\r
-               if (ctmp == 'd' || ctmp == 'D') wantDecrypt = true;\r
-               //if (ctmp == 'e' || ctmp == 'E') wantSaveToEml = true; TODO\r
-               if (ctmp == 'f' || ctmp == 'F') wantSaveToEmlFile = true;\r
-       }\r
-       \r
-       printf("-------------------------------------------------------------------------\n");\r
-       printf("Executing command. \n");\r
-       printf("Press the key on the proxmark3 device to abort both proxmark3 and client.\n");\r
-       printf("Press the key on pc keyboard to abort the client.\n");\r
-       printf("-------------------------------------------------------------------------\n");\r
-\r
-       UsbCommand c = {CMD_MIFARE_SNIFFER, {0, 0, 0}};\r
-       clearCommandBuffer();\r
-       SendCommand(&c);\r
-\r
-       // wait cycle\r
-       while (true) {\r
-               printf(".");\r
-               fflush(stdout);\r
-               if (ukbhit()) {\r
-                       tmpchar = getchar();\r
-                       (void)tmpchar;\r
-                       printf("\naborted via keyboard!\n");\r
-                       break;\r
-               }\r
-               \r
-               UsbCommand resp;\r
-               if (WaitForResponseTimeout(CMD_ACK,&resp,2000)) {\r
-                       res = resp.arg[0] & 0xff;\r
-                       uint16_t traceLen = resp.arg[1];\r
-                       len = resp.arg[2];\r
-\r
-                       // we are done?\r
-                       if (res == 0) {\r
-                               free(buf);\r
-                               return 0;\r
-                       }\r
-\r
-                       if (res == 1) {                                                         // there is (more) data to be transferred\r
-                               if (pckNum == 0) {                                              // first packet, (re)allocate necessary buffer\r
-                                       if (traceLen > bufsize) {\r
-                                               uint8_t *p;\r
-                                               if (buf == NULL) {                              // not yet allocated\r
-                                                       p = malloc(traceLen);\r
-                                               } else {                                                // need more memory\r
-                                                       p = realloc(buf, traceLen);\r
-                                               }\r
-                                               if (p == NULL) {\r
-                                                       PrintAndLog("Cannot allocate memory for trace");\r
-                                                       free(buf);\r
-                                                       return 2;\r
-                                               }\r
-                                               buf = p;\r
-                                       }\r
-                                       bufPtr = buf;\r
-                                       bufsize = traceLen;\r
-                                       memset(buf, 0x00, traceLen);\r
-                               }\r
-                               if (bufPtr == NULL) {\r
-                                       PrintAndLog("Cannot allocate memory for trace");\r
-                                       free(buf);\r
-                                       return 2;\r
-                               }\r
-                               memcpy(bufPtr, resp.d.asBytes, len);\r
-                               bufPtr += len;\r
-                               pckNum++;\r
-                       }\r
-\r
-                       if (res == 2) {                                                         // received all data, start displaying\r
-                               blockLen = bufPtr - buf;\r
-                               bufPtr = buf;\r
-                               printf(">\n");\r
-                               PrintAndLog("received trace len: %d packages: %d", blockLen, pckNum);\r
-                               while (bufPtr - buf < blockLen) {\r
-                                       bufPtr += 6;                                            // skip (void) timing information\r
-                                       len = *((uint16_t *)bufPtr);\r
-                                       if(len & 0x8000) {\r
-                                               isTag = true;\r
-                                               len &= 0x7fff;\r
-                                       } else {\r
-                                               isTag = false;\r
-                                       }\r
-                                       bufPtr += 2;\r
-                                       if ((len == 14) && (bufPtr[0] == 0xff) && (bufPtr[1] == 0xff) && (bufPtr[12] == 0xff) && (bufPtr[13] == 0xff)) {\r
-                                               memcpy(uid, bufPtr + 2, 7);\r
-                                               memcpy(atqa, bufPtr + 2 + 7, 2);\r
-                                               uid_len = (atqa[0] & 0xC0) == 0x40 ? 7 : 4;\r
-                                               sak = bufPtr[11];\r
-                                               PrintAndLog("tag select uid| %s atqa:0x%02x%02x sak:0x%02x", \r
-                                                       sprint_hex(uid + (7 - uid_len), uid_len),\r
-                                                       atqa[1], \r
-                                                       atqa[0], \r
-                                                       sak);\r
-                                               if (wantLogToFile || wantDecrypt) {\r
-                                                       FillFileNameByUID(logHexFileName, uid + (10 - uid_len), ".log", uid_len);\r
-                                                       AddLogCurrentDT(logHexFileName);\r
-                                               }                                               \r
-                                               if (wantDecrypt) \r
-                                                       mfTraceInit(uid, atqa, sak, wantSaveToEmlFile);\r
-                                       } else {\r
-                                               PrintAndLog("%03d| %s |%s", num, isTag ? "TAG" : "RDR", sprint_hex(bufPtr, len));\r
-                                               if (wantLogToFile) \r
-                                                       AddLogHex(logHexFileName, isTag ? "TAG| ":"RDR| ", bufPtr, len);\r
-                                               if (wantDecrypt) \r
-                                                       mfTraceDecode(bufPtr, len, wantSaveToEmlFile);\r
-                                               num++;  \r
-                                       }\r
-                                       bufPtr += len;\r
-                                       bufPtr += ((len-1)/8+1);        // ignore parity\r
-                               }\r
-                               pckNum = 0;\r
-                       }\r
-               } // resp not NULL\r
-       } // while (true)\r
-\r
-       free(buf);\r
-       return 0;\r
-}\r
-\r
 //needs nt, ar, at, Data to decrypt\r
 int CmdHf14MfDecryptBytes(const char *Cmd){\r
        uint8_t data[50];\r
-       \r
        uint32_t nt     = param_get32ex(Cmd,0,0,16);\r
        uint32_t ar_enc = param_get32ex(Cmd,1,0,16);\r
        uint32_t at_enc = param_get32ex(Cmd,2,0,16);\r
@@ -2280,9 +2292,7 @@ static command_t CommandTable[] = {
 };\r
 \r
 int CmdHFMF(const char *Cmd) {\r
-       // flush\r
        clearCommandBuffer();\r
-       //WaitForResponseTimeout(CMD_ACK,NULL,100);\r
        CmdsParse(CommandTable, Cmd);\r
        return 0;\r
 }\r
index 3e8362c564ffa525ade6950be0a8dd787c330701..1939b92bdca16ca1c8e76a0deca7cd6da57b8454 100644 (file)
@@ -342,12 +342,11 @@ static uint8_t traceCurKey = 0;
 \r
 struct Crypto1State *traceCrypto1 = NULL;\r
 struct Crypto1State *revstate = NULL;\r
-\r
 uint64_t key = 0;\r
 uint32_t ks2 = 0;\r
 uint32_t ks3 = 0;\r
 \r
-uint32_t uid = 0;     // serial number\r
+uint32_t cuid = 0;    // serial number\r
 uint32_t nt =0;      // tag challenge\r
 uint32_t nr_enc =0;  // encrypted reader challenge\r
 uint32_t ar_enc =0;  // encrypted reader response\r
@@ -368,7 +367,7 @@ int isBlockTrailer(int blockN) {
        return ((blockN & 0x03) == 0x03);\r
 }\r
 \r
-int loadTraceCard(uint8_t *tuid) {\r
+int loadTraceCard(uint8_t *tuid, uint8_t uidlen) {\r
        FILE * f;\r
        char buf[64] = {0x00};\r
        uint8_t buf8[64] = {0x00};\r
@@ -378,9 +377,9 @@ int loadTraceCard(uint8_t *tuid) {
                saveTraceCard();\r
                \r
        memset(traceCard, 0x00, 4096);\r
-       memcpy(traceCard, tuid + 3, 4);\r
+       memcpy(traceCard, tuid, uidlen);\r
 \r
-       FillFileNameByUID(traceFileName, tuid, ".eml", 7);\r
+       FillFileNameByUID(traceFileName, tuid, ".eml", uidlen);\r
 \r
        f = fopen(traceFileName, "r");\r
        if (!f) return 1;\r
@@ -391,7 +390,7 @@ int loadTraceCard(uint8_t *tuid) {
        \r
                memset(buf, 0, sizeof(buf));\r
                if (fgets(buf, sizeof(buf), f) == NULL) {\r
-                       PrintAndLog("File reading error.");\r
+                       PrintAndLog("No trace file found or reading error.");\r
                        fclose(f);\r
                        return 2;\r
                }\r
@@ -403,35 +402,35 @@ int loadTraceCard(uint8_t *tuid) {
                        return 2;\r
                }\r
                for (i = 0; i < 32; i += 2)\r
-                       sscanf(&buf[i], "%02x", (unsigned int *)&buf8[i / 2]);\r
+                       sscanf(&buf[i], "%02X", (unsigned int *)&buf8[i / 2]);\r
 \r
                memcpy(traceCard + blockNum * 16, buf8, 16);\r
 \r
                blockNum++;\r
        }\r
        fclose(f);\r
-\r
        return 0;\r
 }\r
 \r
 int saveTraceCard(void) {\r
-       FILE * f;\r
        \r
        if ((!strlen(traceFileName)) || (isTraceCardEmpty())) return 0;\r
        \r
+       FILE * f;\r
        f = fopen(traceFileName, "w+");\r
        if ( !f ) return 1;\r
        \r
        for (int i = 0; i < 64; i++) {  // blocks\r
                for (int j = 0; j < 16; j++)  // bytes\r
-                       fprintf(f, "%02x", *(traceCard + i * 16 + j)); \r
+                       fprintf(f, "%02X", *(traceCard + i * 16 + j)); \r
                fprintf(f,"\n");\r
        }\r
+       fflush(f);\r
        fclose(f);\r
        return 0;\r
 }\r
 \r
-int mfTraceInit(uint8_t *tuid, uint8_t *atqa, uint8_t sak, bool wantSaveToEmlFile) {\r
+int mfTraceInit(uint8_t *tuid, uint8_t uidlen, uint8_t *atqa, uint8_t sak, bool wantSaveToEmlFile) {\r
 \r
        if (traceCrypto1) \r
                crypto1_destroy(traceCrypto1);\r
@@ -439,16 +438,14 @@ int mfTraceInit(uint8_t *tuid, uint8_t *atqa, uint8_t sak, bool wantSaveToEmlFil
        traceCrypto1 = NULL;\r
 \r
        if (wantSaveToEmlFile) \r
-               loadTraceCard(tuid);\r
+               loadTraceCard(tuid, uidlen);\r
                \r
        traceCard[4] = traceCard[0] ^ traceCard[1] ^ traceCard[2] ^ traceCard[3];\r
        traceCard[5] = sak;\r
        memcpy(&traceCard[6], atqa, 2);\r
        traceCurBlock = 0;\r
-       uid = bytes_to_num(tuid + 3, 4);\r
-       \r
+       cuid = bytes_to_num(tuid+(uidlen-4), 4);\r
        traceState = TRACE_IDLE;\r
-\r
        return 0;\r
 }\r
 \r
@@ -471,30 +468,31 @@ void mf_crypto1_decrypt(struct Crypto1State *pcs, uint8_t *data, int len, bool i
 }\r
 \r
 int mfTraceDecode(uint8_t *data_src, int len, bool wantSaveToEmlFile) {\r
-       \r
-       uint8_t data[64];\r
-       memset(data, 0x00, sizeof(data));\r
-       \r
+\r
        if (traceState == TRACE_ERROR) return 1;\r
-       \r
+\r
        if (len > 64) {\r
                traceState = TRACE_ERROR;\r
                return 1;\r
        }\r
        \r
+       uint8_t data[64];\r
+       memset(data, 0x00, sizeof(data));\r
+       \r
        memcpy(data, data_src, len);\r
+       \r
        if ((traceCrypto1) && ((traceState == TRACE_IDLE) || (traceState > TRACE_AUTH_OK))) {\r
                mf_crypto1_decrypt(traceCrypto1, data, len, 0);\r
-               PrintAndLog("dec> %s", sprint_hex(data, len));\r
-               AddLogHex(logHexFileName, "dec> ", data, len); \r
+               PrintAndLog("DEC| %s", sprint_hex(data, len));\r
+               AddLogHex(logHexFileName, "DEC| ", data, len); \r
        }\r
        \r
        switch (traceState) {\r
        case TRACE_IDLE: \r
                // check packet crc16!\r
                if ((len >= 4) && (!CheckCrc14443(CRC_14443_A, data, len))) {\r
-                       PrintAndLog("dec> CRC ERROR!!!");\r
-                       AddLogLine(logHexFileName, "dec> ", "CRC ERROR!!!"); \r
+                       PrintAndLog("DEC| CRC ERROR!!!");\r
+                       AddLogLine(logHexFileName, "DEC| ", "CRC ERROR!!!"); \r
                        traceState = TRACE_ERROR;  // do not decrypt the next commands\r
                        return 1;\r
                }\r
@@ -526,10 +524,7 @@ int mfTraceDecode(uint8_t *data_src, int len, bool wantSaveToEmlFile) {
                        traceState = TRACE_ERROR;  // do not decrypt the next commands\r
                        return 0;\r
                }\r
-               \r
                return 0;\r
-       break;\r
-       \r
        case TRACE_READ_DATA: \r
                if (len == 18) {\r
                        traceState = TRACE_IDLE;\r
@@ -545,23 +540,19 @@ int mfTraceDecode(uint8_t *data_src, int len, bool wantSaveToEmlFile) {
                        traceState = TRACE_ERROR;\r
                        return 1;\r
                }\r
-       break;\r
-\r
+               break;\r
        case TRACE_WRITE_OK: \r
                if ((len == 1) && (data[0] == 0x0a)) {\r
                        traceState = TRACE_WRITE_DATA;\r
-\r
                        return 0;\r
                } else {\r
                        traceState = TRACE_ERROR;\r
                        return 1;\r
                }\r
-       break;\r
-\r
+               break;\r
        case TRACE_WRITE_DATA: \r
                if (len == 18) {\r
                        traceState = TRACE_IDLE;\r
-\r
                        memcpy(traceCard + traceCurBlock * 16, data, 16);\r
                        if (wantSaveToEmlFile) saveTraceCard();\r
                        return 0;\r
@@ -569,8 +560,7 @@ int mfTraceDecode(uint8_t *data_src, int len, bool wantSaveToEmlFile) {
                        traceState = TRACE_ERROR;\r
                        return 1;\r
                }\r
-       break;\r
-\r
+               break;\r
        case TRACE_AUTH1: \r
                if (len == 4) {\r
                        traceState = TRACE_AUTH2;\r
@@ -580,12 +570,10 @@ int mfTraceDecode(uint8_t *data_src, int len, bool wantSaveToEmlFile) {
                        traceState = TRACE_ERROR;\r
                        return 1;\r
                }\r
-       break;\r
-\r
+               break;\r
        case TRACE_AUTH2: \r
                if (len == 8) {\r
                        traceState = TRACE_AUTH_OK;\r
-\r
                        nr_enc = bytes_to_num(data, 4);\r
                        ar_enc = bytes_to_num(data + 4, 4);\r
                        return 0;\r
@@ -593,12 +581,10 @@ int mfTraceDecode(uint8_t *data_src, int len, bool wantSaveToEmlFile) {
                        traceState = TRACE_ERROR;\r
                        return 1;\r
                }\r
-       break;\r
-\r
+               break;\r
        case TRACE_AUTH_OK: \r
-               if (len ==4) {\r
+               if (len == 4) {\r
                        traceState = TRACE_IDLE;\r
-\r
                        at_enc = bytes_to_num(data, 4);\r
                        \r
                        //  decode key here)\r
@@ -608,73 +594,51 @@ int mfTraceDecode(uint8_t *data_src, int len, bool wantSaveToEmlFile) {
                        lfsr_rollback_word(revstate, 0, 0);\r
                        lfsr_rollback_word(revstate, 0, 0);\r
                        lfsr_rollback_word(revstate, nr_enc, 1);\r
-                       lfsr_rollback_word(revstate, uid ^ nt, 0);\r
-\r
+                       lfsr_rollback_word(revstate, cuid ^ nt, 0);\r
                        crypto1_get_lfsr(revstate, &key);\r
-                       printf("Key: %012"llx"\n",key);\r
-                       AddLogUint64(logHexFileName, "key: ", key); \r
+                       PrintAndLog("Found Key: [%012"llx"]", key);\r
+                       \r
+                       //if ( tryMfk64(cuid, nt, nr_enc, ar_enc, at_enc, &key) )\r
+                       AddLogUint64(logHexFileName, "Found Key: ", key); \r
                        \r
                        int blockShift = ((traceCurBlock & 0xFC) + 3) * 16;\r
                        if (isBlockEmpty((traceCurBlock & 0xFC) + 3)) memcpy(traceCard + blockShift + 6, trailerAccessBytes, 4);\r
                        \r
-                       if (traceCurKey) {\r
+                       if (traceCurKey)\r
                                num_to_bytes(key, 6, traceCard + blockShift + 10);\r
-                       } else {\r
+                       else\r
                                num_to_bytes(key, 6, traceCard + blockShift);\r
-                       }\r
-                       if (wantSaveToEmlFile) saveTraceCard();\r
+                       \r
+                       if (wantSaveToEmlFile)\r
+                               saveTraceCard();\r
 \r
-                       if (traceCrypto1) {\r
+                       if (traceCrypto1)\r
                                crypto1_destroy(traceCrypto1);\r
-                       }\r
                        \r
                        // set cryptosystem state\r
                        traceCrypto1 = lfsr_recovery64(ks2, ks3);\r
                        \r
-//     nt = crypto1_word(traceCrypto1, nt ^ uid, 1) ^ nt;\r
-\r
-       /*      traceCrypto1 = crypto1_create(key); // key in lfsr\r
-               crypto1_word(traceCrypto1, nt ^ uid, 0);\r
-               crypto1_word(traceCrypto1, ar, 1);\r
-               crypto1_word(traceCrypto1, 0, 0);\r
-               crypto1_word(traceCrypto1, 0, 0);*/\r
-       \r
                        return 0;\r
                } else {\r
                        traceState = TRACE_ERROR;\r
                        return 1;\r
                }\r
-       break;\r
-\r
+               break;\r
        default: \r
                traceState = TRACE_ERROR;\r
                return 1;\r
        }\r
-\r
        return 0;\r
 }\r
 \r
 int tryDecryptWord(uint32_t nt, uint32_t ar_enc, uint32_t at_enc, uint8_t *data, int len){\r
-       /*\r
-       uint32_t nt;      // tag challenge\r
-       uint32_t nr_enc;  // encrypted reader challenge\r
-       uint32_t ar_enc;  // encrypted reader response\r
-       uint32_t at_enc;  // encrypted tag response\r
-       */\r
+       PrintAndLog("\nEncrypted data: [%s]", sprint_hex(data, len) );\r
        struct Crypto1State *pcs = NULL;\r
-       \r
        ks2 = ar_enc ^ prng_successor(nt, 64);\r
        ks3 = at_enc ^ prng_successor(nt, 96);\r
-       \r
-       PrintAndLog("Decrypting data with:");\r
-       PrintAndLog("      nt: %08x",nt);\r
-       PrintAndLog("  ar_enc: %08x",ar_enc);\r
-       PrintAndLog("  at_enc: %08x",at_enc);\r
-       PrintAndLog("\nEncrypted data: [%s]", sprint_hex(data,len) );\r
-\r
        pcs = lfsr_recovery64(ks2, ks3);\r
        mf_crypto1_decrypt(pcs, data, len, FALSE);\r
-       PrintAndLog("Decrypted data: [%s]", sprint_hex(data,len) );\r
+       PrintAndLog("Decrypted data: [%s]", sprint_hex(data, len) );\r
        crypto1_destroy(pcs);\r
        return 0;\r
 }\r
index a214ede48868cf3f04e3ea23282cb2d92ecf2c80..2355017cab9b03a4fdafbd0e2631f13a39940d6d 100644 (file)
@@ -40,6 +40,7 @@ typedef struct {
        int foundKey[2];\r
 } sector;\r
  \r
+int compar_int(const void * a, const void * b);\r
 extern char logHexFileName[FILE_PATH_SIZE];\r
 \r
 int mfnested(uint8_t blockNo, uint8_t keyType, uint8_t * key, uint8_t trgBlockNo, uint8_t trgKeyType, uint8_t * ResultKeys, bool calibrate);\r
@@ -53,12 +54,12 @@ int mfCSetUID(uint8_t *uid, uint8_t *atqa, uint8_t *sak, uint8_t *oldUID, uint8_
 int mfCSetBlock(uint8_t blockNo, uint8_t *data, uint8_t *uid, uint8_t params);\r
 int mfCGetBlock(uint8_t blockNo, uint8_t *data, uint8_t params);\r
 \r
-int mfTraceInit(uint8_t *tuid, uint8_t *atqa, uint8_t sak, bool wantSaveToEmlFile);\r
+int mfTraceInit(uint8_t *tuid, uint8_t uidlen, uint8_t *atqa, uint8_t sak, bool wantSaveToEmlFile);\r
 int mfTraceDecode(uint8_t *data_src, int len, bool wantSaveToEmlFile);\r
 \r
 int isTraceCardEmpty(void);\r
 int isBlockEmpty(int blockN);\r
 int isBlockTrailer(int blockN);\r
-int loadTraceCard(uint8_t *tuid);\r
+int loadTraceCard(uint8_t *tuid, uint8_t uidlen);\r
 int saveTraceCard(void);\r
 int tryDecryptWord(uint32_t nt, uint32_t ar_enc, uint32_t at_enc, uint8_t *data, int len);\r
index 5189f59a686b56dfd69f79d7db88fe8f33c0a5d8..64fb2a8fe0da78afea2f8f425b6ceea162fd5998 100644 (file)
@@ -487,7 +487,6 @@ int setLuaPath( lua_State* L, const char* path )
        return 0; // all done!
 }
 
-
 int set_pm3_libraries(lua_State *L)
 {
 
Impressum, Datenschutz