mirror of
				https://github.com/RfidResearchGroup/proxmark3.git
				synced 2025-11-04 11:38:03 +08:00 
			
		
		
		
	Replace WITH_FLASH by dynamic detection in client
This commit is contained in:
		
							parent
							
								
									c93eee5c72
								
							
						
					
					
						commit
						cad676a23c
					
				
					 6 changed files with 39 additions and 67 deletions
				
			
		| 
						 | 
				
			
			@ -7,8 +7,6 @@
 | 
			
		|||
//-----------------------------------------------------------------------------
 | 
			
		||||
// Proxmark3 RDV40 Flash memory commands
 | 
			
		||||
//-----------------------------------------------------------------------------
 | 
			
		||||
#ifdef WITH_FLASH
 | 
			
		||||
 | 
			
		||||
#include "cmdflashmem.h"
 | 
			
		||||
 | 
			
		||||
#include "mbedtls/rsa.h"
 | 
			
		||||
| 
						 | 
				
			
			@ -618,12 +616,12 @@ static int CmdFlashMemInfo(const char *Cmd) {
 | 
			
		|||
 | 
			
		||||
static command_t CommandTable[] = {
 | 
			
		||||
    {"help",    CmdHelp,            AlwaysAvailable, "This help"},
 | 
			
		||||
    {"spibaud", CmdFlashmemSpiBaudrate, AlwaysAvailable, "Set Flash memory Spi baudrate [rdv40]"},
 | 
			
		||||
    {"read",    CmdFlashMemRead,    AlwaysAvailable, "Read Flash memory [rdv40]"},
 | 
			
		||||
    {"info",    CmdFlashMemInfo,    AlwaysAvailable, "Flash memory information [rdv40]"},
 | 
			
		||||
    {"load",    CmdFlashMemLoad,    AlwaysAvailable, "Load data into flash memory [rdv40]"},
 | 
			
		||||
    {"save",    CmdFlashMemSave,    AlwaysAvailable, "Save data from flash memory [rdv40]"},
 | 
			
		||||
    {"wipe",    CmdFlashMemWipe,    AlwaysAvailable, "Wipe data from flash memory [rdv40]"},
 | 
			
		||||
    {"spibaud", CmdFlashmemSpiBaudrate, IfPm3Flash,  "Set Flash memory Spi baudrate [rdv40]"},
 | 
			
		||||
    {"read",    CmdFlashMemRead,    IfPm3Flash,      "Read Flash memory [rdv40]"},
 | 
			
		||||
    {"info",    CmdFlashMemInfo,    IfPm3Flash,      "Flash memory information [rdv40]"},
 | 
			
		||||
    {"load",    CmdFlashMemLoad,    IfPm3Flash,      "Load data into flash memory [rdv40]"},
 | 
			
		||||
    {"save",    CmdFlashMemSave,    IfPm3Flash,      "Save data from flash memory [rdv40]"},
 | 
			
		||||
    {"wipe",    CmdFlashMemWipe,    IfPm3Flash,      "Wipe data from flash memory [rdv40]"},
 | 
			
		||||
    {NULL, NULL, NULL, NULL}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -637,5 +635,3 @@ int CmdFlashMem(const char *Cmd) {
 | 
			
		|||
    clearCommandBuffer();
 | 
			
		||||
    return CmdsParse(CommandTable, Cmd);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,8 +8,6 @@
 | 
			
		|||
// Proxmark3 RDV40 Flash memory commands
 | 
			
		||||
//-----------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
#ifdef WITH_FLASH
 | 
			
		||||
 | 
			
		||||
#ifndef CMDFLASHMEM_H__
 | 
			
		||||
#define CMDFLASHMEM_H__
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -36,5 +34,3 @@ typedef enum {
 | 
			
		|||
int CmdFlashMem(const char *Cmd);
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -202,9 +202,8 @@ static int usage_hf14_chk_fast(void) {
 | 
			
		|||
    PrintAndLogEx(NORMAL, "      hf mf fchk 1 1234567890ab keys.dic    -- target 1K using key 1234567890ab, using dictionary file");
 | 
			
		||||
    PrintAndLogEx(NORMAL, "      hf mf fchk 1 t                        -- target 1K, write to emulator memory");
 | 
			
		||||
    PrintAndLogEx(NORMAL, "      hf mf fchk 1 d                        -- target 1K, write to file");
 | 
			
		||||
#ifdef WITH_FLASH
 | 
			
		||||
    PrintAndLogEx(NORMAL, "      hf mf fchk 1 m                        -- target 1K, use dictionary from flashmemory");
 | 
			
		||||
#endif
 | 
			
		||||
    if (IfPm3Flash())
 | 
			
		||||
        PrintAndLogEx(NORMAL, "      hf mf fchk 1 m                        -- target 1K, use dictionary from flashmemory");
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
static int usage_hf14_keybrute(void) {
 | 
			
		||||
| 
						 | 
				
			
			@ -1593,9 +1592,7 @@ static int CmdHF14AMfChk_fast(const char *Cmd) {
 | 
			
		|||
        } else if (clen == 1) {
 | 
			
		||||
            if (ctmp == 't') { transferToEml = 1; continue; }
 | 
			
		||||
            if (ctmp == 'd') { createDumpFile = 1; continue; }
 | 
			
		||||
#ifdef WITH_FLASH
 | 
			
		||||
            if (ctmp == 'm') { use_flashmemory = true; continue; }
 | 
			
		||||
#endif
 | 
			
		||||
            if ((ctmp == 'm') && (IfPm3Flash())){ use_flashmemory = true; continue; }
 | 
			
		||||
        } else {
 | 
			
		||||
            // May be a dic file
 | 
			
		||||
            if (param_getstr(Cmd, i, filename, FILE_PATH_SIZE) >= FILE_PATH_SIZE) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -500,25 +500,12 @@ void pm3_version(bool verbose) {
 | 
			
		|||
    SendCommandOLD(CMD_VERSION, 0, 0, 0, NULL, 0);
 | 
			
		||||
    if (WaitForResponseTimeout(CMD_ACK, &resp, 1000)) {
 | 
			
		||||
        PrintAndLogEx(NORMAL, "\n" _BLUE_(" [ Proxmark3 RFID instrument ]") "\n");
 | 
			
		||||
        char s[60] = {0};
 | 
			
		||||
#if defined(WITH_FLASH) || defined(WITH_SMARTCARD) || defined(WITH_FPC)
 | 
			
		||||
        strncat(s, "build for RDV40 with ", sizeof(s) - strlen(s) - 1);
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef WITH_FLASH
 | 
			
		||||
        strncat(s, "flashmem; ", sizeof(s) - strlen(s) - 1);
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef WITH_SMARTCARD
 | 
			
		||||
        strncat(s, "smartcard; ", sizeof(s) - strlen(s) - 1);
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef WITH_FPC
 | 
			
		||||
#ifdef WITH_FPC_HOST
 | 
			
		||||
        strncat(s, "fpc-host; ", sizeof(s) - strlen(s) - 1);
 | 
			
		||||
#else
 | 
			
		||||
        strncat(s, "fpc; ", sizeof(s) - strlen(s) - 1);
 | 
			
		||||
#endif
 | 
			
		||||
#endif
 | 
			
		||||
        PrintAndLogEx(NORMAL, "\n [ CLIENT ]");
 | 
			
		||||
        PrintAndLogEx(NORMAL, "  client: iceman %s \n", s);
 | 
			
		||||
        PrintAndLogEx(NORMAL, "  client: RRG/Iceman"); // TODO version info?
 | 
			
		||||
        PrintAndLogEx(NORMAL, "\n [ PROXMARK ]");
 | 
			
		||||
        PrintAndLogEx(NORMAL, "  external flash:          %s", IfPm3Flash() ? _GREEN_("present") : _YELLOW_("absent"));
 | 
			
		||||
        PrintAndLogEx(NORMAL, "  smartcard reader:        %s", IfPm3Smartcard() ? _GREEN_("present") : _YELLOW_("absent"));
 | 
			
		||||
        PrintAndLogEx(NORMAL, "  USART for addon support: %s\n", IfPm3FpcHost() ? _GREEN_("present") : _YELLOW_("absent"));
 | 
			
		||||
 | 
			
		||||
        PrintAndLogEx(NORMAL, (char *)resp.data.asBytes);
 | 
			
		||||
        lookupChipID(resp.oldarg[0], resp.oldarg[1]);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -53,12 +53,8 @@ static command_t CommandTable[] = {
 | 
			
		|||
    {"reveng",  CmdRev,       AlwaysAvailable, "{ Crc calculations from the RevEng software... }"},
 | 
			
		||||
    {"script",  CmdScript,    AlwaysAvailable, "{ Scripting commands }"},
 | 
			
		||||
    {"trace",   CmdTrace,     AlwaysAvailable, "{ Trace manipulation... }"},
 | 
			
		||||
#ifdef WITH_FLASH
 | 
			
		||||
    {"mem",     CmdFlashMem,  AlwaysAvailable, "{ Flash Memory manipulation... }"},
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef WITH_SMARTCARD
 | 
			
		||||
    {"sc",      CmdSmartcard, AlwaysAvailable, "{ Smart card ISO7816 commands... }"},
 | 
			
		||||
#endif
 | 
			
		||||
    {"mem",     CmdFlashMem,  IfPm3Flash,      "{ Flash Memory manipulation... }"},
 | 
			
		||||
    {"sc",      CmdSmartcard, IfPm3Smartcard,  "{ Smart card ISO7816 commands... }"},
 | 
			
		||||
    {"quit",    CmdQuit,      AlwaysAvailable, ""},
 | 
			
		||||
    {"exit",    CmdQuit,      AlwaysAvailable, "Exit program"},
 | 
			
		||||
    {NULL, NULL, NULL, NULL}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -264,36 +264,36 @@ static int l_GetFromBigBuf(lua_State *L) {
 | 
			
		|||
 */
 | 
			
		||||
static int l_GetFromFlashMem(lua_State *L) {
 | 
			
		||||
 | 
			
		||||
#ifndef WITH_FLASH
 | 
			
		||||
    return returnToLuaWithError(L, "Not compiled with FLASH MEM support");
 | 
			
		||||
#else
 | 
			
		||||
    int len = 0, startindex = 0;
 | 
			
		||||
    if (IfPm3Flash()) {
 | 
			
		||||
        int len = 0, startindex = 0;
 | 
			
		||||
 | 
			
		||||
    int n = lua_gettop(L);
 | 
			
		||||
    if (n == 0)
 | 
			
		||||
        return returnToLuaWithError(L, "You need to supply number of bytes and startindex");
 | 
			
		||||
        int n = lua_gettop(L);
 | 
			
		||||
        if (n == 0)
 | 
			
		||||
            return returnToLuaWithError(L, "You need to supply number of bytes and startindex");
 | 
			
		||||
 | 
			
		||||
    if (n >= 2) {
 | 
			
		||||
        startindex = luaL_checknumber(L, 1);
 | 
			
		||||
        len = luaL_checknumber(L, 2);
 | 
			
		||||
    }
 | 
			
		||||
        if (n >= 2) {
 | 
			
		||||
            startindex = luaL_checknumber(L, 1);
 | 
			
		||||
            len = luaL_checknumber(L, 2);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    if (len == 0)
 | 
			
		||||
        return returnToLuaWithError(L, "You need to supply number of bytes larger than zero");
 | 
			
		||||
        if (len == 0)
 | 
			
		||||
            return returnToLuaWithError(L, "You need to supply number of bytes larger than zero");
 | 
			
		||||
 | 
			
		||||
    uint8_t *data = calloc(len, sizeof(uint8_t));
 | 
			
		||||
    if (!data)
 | 
			
		||||
        return returnToLuaWithError(L, "Allocating memory failed");
 | 
			
		||||
        uint8_t *data = calloc(len, sizeof(uint8_t));
 | 
			
		||||
        if (!data)
 | 
			
		||||
            return returnToLuaWithError(L, "Allocating memory failed");
 | 
			
		||||
 | 
			
		||||
    if (!GetFromDevice(FLASH_MEM, data, len, startindex, NULL, -1, false)) {
 | 
			
		||||
        if (!GetFromDevice(FLASH_MEM, data, len, startindex, NULL, -1, false)) {
 | 
			
		||||
            free(data);
 | 
			
		||||
            return returnToLuaWithError(L, "command execution time out");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        lua_pushlstring(L, (const char *)data, len);
 | 
			
		||||
        free(data);
 | 
			
		||||
        return returnToLuaWithError(L, "command execution time out");
 | 
			
		||||
        return 1;
 | 
			
		||||
    } else {
 | 
			
		||||
        return returnToLuaWithError(L, "No FLASH MEM support");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    lua_pushlstring(L, (const char *)data, len);
 | 
			
		||||
    free(data);
 | 
			
		||||
    return 1;
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue