mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-07-30 19:40:37 -07:00
fix: 14a raw commands - running lua scripts works again for MIX/NG frames
This commit is contained in:
parent
2d972f8cb9
commit
abc66484e5
3 changed files with 54 additions and 31 deletions
|
@ -142,33 +142,18 @@ function Command:sendMIX( ignore_response, timeout )
|
|||
end
|
||||
|
||||
-- lets digest
|
||||
local data
|
||||
local count, cmd, length, magic, status, crc, arg1, arg2, arg3 = bin.unpack('SSIsSLLL', response)
|
||||
data = nil
|
||||
cmd = nil
|
||||
arg1 = nil
|
||||
arg2 = nil
|
||||
arg3 = nil
|
||||
local count, length, magic, status, crc, ng
|
||||
|
||||
-- S S I s S L L L
|
||||
count, cmd, length, magic, status, crc, arg1, arg2, arg3 = bin.unpack('SSIsSLLL', response)
|
||||
count, data, ng = bin.unpack('H'..length..'C', response, count)
|
||||
|
||||
--[[ uncomment if you want to debug
|
||||
self.resp_cmd = cmd
|
||||
self.resp_length = length
|
||||
self.resp_magic = magic
|
||||
self.resp_status = status
|
||||
self.resp_crc = crc
|
||||
self.resp_arg1 = arg1
|
||||
self.resp_arg2 = arg2
|
||||
self.resp_arg3 = arg3
|
||||
self.resp_data = data
|
||||
self.resp_ng = ng
|
||||
self:__responsetostring()
|
||||
--]]
|
||||
|
||||
local packed = bin.pack("LLLLH", cmd, arg1, arg2, arg3, data)
|
||||
--[[
|
||||
return { Cmd = cmd,
|
||||
Arg1 = arg1,
|
||||
Arg2 = arg2,
|
||||
Arg3 = arg3,
|
||||
Data = data,
|
||||
}
|
||||
--]]
|
||||
return packed, nil;
|
||||
end
|
||||
function Command:sendNG( ignore_response, timeout )
|
||||
|
@ -185,8 +170,12 @@ function Command:sendNG( ignore_response, timeout )
|
|||
if response == nil then
|
||||
return nil, 'Error, waiting for response timed out :: '..msg
|
||||
end
|
||||
local data
|
||||
local count, cmd, length, magic, status, crc, arg0, arg1, arg2 = bin.unpack('SSIsSLLL', response)
|
||||
|
||||
data = nil
|
||||
cmd = nil
|
||||
local count, length, magic, status, crc, arg0, arg1, arg2
|
||||
|
||||
count, cmd, length, magic, status, crc, arg0, arg1, arg2 = bin.unpack('SSIsSLLL', response)
|
||||
count, data, ng = bin.unpack('H'..length..'C', response, count)
|
||||
|
||||
--[[ uncomment if you want to debug
|
||||
|
|
|
@ -63,7 +63,7 @@ local function parse14443a(data)
|
|||
} __attribute__((__packed__)) iso14a_card_select_t;
|
||||
--]]
|
||||
|
||||
local count, uid, uidlen, atqa, sak, ats_len, ats = bin.unpack('H10CH2CC',data)
|
||||
local count, uid, uidlen, atqa, sak, ats_len, ats = bin.unpack('H10CH2CC', data)
|
||||
uid = uid:sub(1, 2 * uidlen)
|
||||
local man_byte = tonumber(uid:sub(1,2), 16)
|
||||
|
||||
|
@ -98,8 +98,8 @@ local function read14443a(dont_disconnect, no_rats)
|
|||
|
||||
local result, err = command:sendMIX()
|
||||
if result then
|
||||
local count,cmd,arg0,arg1,arg2 = bin.unpack('LLLL',result)
|
||||
if arg0 == 0 then
|
||||
local count, cmd, arg1, arg2, arg3 = bin.unpack('LLLL',result)
|
||||
if arg1 == 0 then
|
||||
return nil, 'iso14443a card select failed'
|
||||
end
|
||||
data = string.sub(result, count)
|
||||
|
|
|
@ -303,11 +303,45 @@ static int l_WaitForResponseTimeout(lua_State *L) {
|
|||
ms_timeout = luaL_checkunsigned(L, 2);
|
||||
|
||||
PacketResponseNG resp;
|
||||
if (WaitForResponseTimeout(cmd, &resp, ms_timeout) == 0)
|
||||
if (WaitForResponseTimeout(cmd, &resp, ms_timeout) == false)
|
||||
return returnToLuaWithError(L, "No response from the device");
|
||||
|
||||
char foo[sizeof(PacketResponseNG)];
|
||||
n = 0;
|
||||
|
||||
memcpy(foo + n, &resp.cmd, sizeof(resp.cmd));
|
||||
n += sizeof(resp.cmd);
|
||||
|
||||
memcpy(foo + n, &resp.length, sizeof(resp.length));
|
||||
n += sizeof(resp.length);
|
||||
|
||||
memcpy(foo + n, &resp.magic, sizeof(resp.magic));
|
||||
n += sizeof(resp.magic);
|
||||
|
||||
memcpy(foo + n, &resp.status, sizeof(resp.status));
|
||||
n += sizeof(resp.status);
|
||||
|
||||
memcpy(foo + n, &resp.crc, sizeof(resp.crc));
|
||||
n += sizeof(resp.crc);
|
||||
|
||||
memcpy(foo + n, &resp.oldarg[0], sizeof(resp.oldarg[0]));
|
||||
n += sizeof(resp.oldarg[0]);
|
||||
|
||||
memcpy(foo + n, &resp.oldarg[1], sizeof(resp.oldarg[1]));
|
||||
n += sizeof(resp.oldarg[1]);
|
||||
|
||||
memcpy(foo + n, &resp.oldarg[2], sizeof(resp.oldarg[2]));
|
||||
n += sizeof(resp.oldarg[2]);
|
||||
|
||||
memcpy(foo + n, resp.data.asBytes, sizeof(resp.data));
|
||||
n += sizeof(resp.data);
|
||||
|
||||
memcpy(foo + n, &resp.ng, sizeof(resp.ng));
|
||||
n += sizeof(resp.ng);
|
||||
|
||||
//Push it as a string
|
||||
lua_pushlstring(L, (const char *)&resp, sizeof(PacketResponseNG));
|
||||
lua_pushlstring(L, (const char *)&foo, sizeof(foo));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue