mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-14 18:48:13 -07:00
enable 4x05_read via lua
This commit is contained in:
parent
6454e168fb
commit
2098a6113b
3 changed files with 44 additions and 1 deletions
|
@ -922,7 +922,7 @@ static int demodEM4x05resp(uint32_t *word, bool onlyPreamble) {
|
|||
|
||||
//////////////// 4205 / 4305 commands
|
||||
#include "util_posix.h" // msclock
|
||||
static int EM4x05ReadWord_ext(uint8_t addr, uint32_t pwd, bool usePwd, uint32_t *word) {
|
||||
int EM4x05ReadWord_ext(uint8_t addr, uint32_t pwd, bool usePwd, uint32_t *word) {
|
||||
|
||||
struct {
|
||||
uint32_t password;
|
||||
|
|
|
@ -17,6 +17,7 @@ int CmdLFEM4X(const char *Cmd);
|
|||
|
||||
int demodEM410x(bool verbose);
|
||||
bool EM4x05IsBlock0(uint32_t *word);
|
||||
int EM4x05ReadWord_ext(uint8_t addr, uint32_t pwd, bool usePwd, uint32_t *word);
|
||||
|
||||
void printEM410x(uint32_t hi, uint64_t id);
|
||||
int AskEm410xDecode(bool verbose, uint32_t *hi, uint64_t *lo);
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "fileutils.h" // searchfile
|
||||
#include "cmdlf.h" // lf_config
|
||||
#include "generator.h"
|
||||
#include "cmdlfem4x.h" // read 4305
|
||||
|
||||
static int returnToLuaWithError(lua_State *L, const char *fmt, ...) {
|
||||
char buffer[200];
|
||||
|
@ -1087,6 +1088,46 @@ static int l_T55xx_detect(lua_State *L) {
|
|||
return 2;
|
||||
}
|
||||
|
||||
//
|
||||
static int l_em4x05_read(lua_State *L) {
|
||||
|
||||
bool use_pwd = false;
|
||||
uint32_t addr, password = 0;
|
||||
|
||||
//Check number of arguments
|
||||
//int n = lua_gettop(L);
|
||||
|
||||
// get addr
|
||||
size_t size = 0;
|
||||
const char *p_addr = luaL_checklstring(L, 1, &size);
|
||||
sscanf(p_addr, "%u", &addr);
|
||||
|
||||
// get password
|
||||
const char *p_pwd = luaL_checklstring(L, 2, &size);
|
||||
if (size == 0) {
|
||||
use_pwd = false;
|
||||
} else {
|
||||
if (size != 8)
|
||||
return returnToLuaWithError(L, "Wrong size of password, got %zu , expected 8", size);
|
||||
|
||||
sscanf(p_pwd, "%08x", &password);
|
||||
use_pwd = true;
|
||||
}
|
||||
|
||||
PrintAndLogEx(INFO, "Addr %u", addr);
|
||||
if (use_pwd)
|
||||
PrintAndLogEx(INFO, " Pwd %08X", password);
|
||||
|
||||
uint32_t word = 0;
|
||||
int res = EM4x05ReadWord_ext(addr, password, use_pwd, &word);
|
||||
if (res != PM3_SUCCESS) {
|
||||
return returnToLuaWithError(L, "Failed to read EM4x05 data");
|
||||
}
|
||||
|
||||
lua_pushinteger(L, word);
|
||||
return 1;
|
||||
}
|
||||
|
||||
//
|
||||
static int l_ndefparse(lua_State *L) {
|
||||
|
||||
|
@ -1278,6 +1319,7 @@ int set_pm3_libraries(lua_State *L) {
|
|||
{"ewd", l_ewd},
|
||||
{"ud", l_ud},
|
||||
{"rem", l_remark},
|
||||
{"em4x05_read", l_em4x05_read},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue