mirror of
https://github.com/Proxmark/proxmark3.git
synced 2025-08-22 06:13:27 -07:00
Got rid of unnecessary code which was being used for debugging.
This commit is contained in:
parent
d4c01572c7
commit
7b2e196dcb
3 changed files with 35 additions and 69 deletions
|
@ -111,7 +111,6 @@ local function read14443a(dont_disconnect, no_rats)
|
||||||
end
|
end
|
||||||
local result,err = sendToDevice(command)
|
local result,err = sendToDevice(command)
|
||||||
if result then
|
if result then
|
||||||
print("Currently trying to decode the UsbCommand packet just received (an ACK of the connection).")
|
|
||||||
local count,cmd,arg0,arg1,arg2 = bin.unpack('LLLL',result)
|
local count,cmd,arg0,arg1,arg2 = bin.unpack('LLLL',result)
|
||||||
if arg0 == 0 then
|
if arg0 == 0 then
|
||||||
return nil, "iso14443a card select failed"
|
return nil, "iso14443a card select failed"
|
||||||
|
|
|
@ -102,36 +102,35 @@ static int l_WaitForResponseTimeout(lua_State *L){
|
||||||
|
|
||||||
if(WaitForResponseTimeout(cmd, &response, ms_timeout))
|
if(WaitForResponseTimeout(cmd, &response, ms_timeout))
|
||||||
{
|
{
|
||||||
//BEGIN ADDED CODE
|
/* Uncomment code below to print the bytes which were received from the C code before they get passed to Lua. */
|
||||||
uint8_t *recv;
|
// uint8_t *recv;
|
||||||
char *hexout;
|
// char *hexout;
|
||||||
recv = response.d.asBytes;
|
// recv = response.d.asBytes;
|
||||||
uint8_t iLen = response.arg[0];
|
// uint8_t iLen = response.arg[0];
|
||||||
if (0){
|
// if (0){
|
||||||
iLen = response.arg[1];
|
// iLen = response.arg[1];
|
||||||
if (iLen){
|
// if (iLen){
|
||||||
PrintAndLog("Card selected. UID[%i]:", iLen);
|
// PrintAndLog("Card selected. UID[%i]:", iLen);
|
||||||
} else {
|
// } else {
|
||||||
PrintAndLog("Can't select card.");
|
// PrintAndLog("Can't select card.");
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
PrintAndLog("received %i bytes:", iLen);
|
// PrintAndLog("received %i bytes:", iLen);
|
||||||
}
|
// }
|
||||||
if(!iLen)
|
// if(!iLen)
|
||||||
return 1;
|
// return 1;
|
||||||
hexout = (char *)malloc(iLen * 3 + 1);
|
// hexout = (char *)malloc(iLen * 3 + 1);
|
||||||
if (hexout != NULL) {
|
// if (hexout != NULL) {
|
||||||
for (int i = 0; i < iLen; i++) { // data in hex
|
// for (int i = 0; i < iLen; i++) { // data in hex
|
||||||
sprintf(&hexout[i * 3], "%02X ", recv[i]);
|
// sprintf(&hexout[i * 3], "%02X ", recv[i]);
|
||||||
}
|
// }
|
||||||
PrintAndLog("%s", hexout);
|
// PrintAndLog("%s", hexout);
|
||||||
free(hexout);
|
// free(hexout);
|
||||||
} else {
|
// } else {
|
||||||
PrintAndLog("malloc failed your client has low memory?");
|
// PrintAndLog("malloc failed your client has low memory?");
|
||||||
return 2;
|
// return 2;
|
||||||
}
|
// }
|
||||||
printf("Command response just sent back to Lua script with the bytes which were just printed. Should get sent to read14a.lua.\n");
|
// printf("Command response just sent back to Lua script with the bytes which were just printed.\n");
|
||||||
//END ADDED CODE
|
|
||||||
|
|
||||||
|
|
||||||
//Push it as a string
|
//Push it as a string
|
||||||
|
|
|
@ -10,16 +10,10 @@ end
|
||||||
|
|
||||||
function sendRaw(rawdata, crc)
|
function sendRaw(rawdata, crc)
|
||||||
print(">> ", rawdata)
|
print(">> ", rawdata)
|
||||||
|
|
||||||
-- if crc
|
|
||||||
-- then local flags = lib14a.ISO14A_COMMAND.ISO14A_NO_DISCONNECT + lib14a.ISO14A_COMMAND.ISO14A_RAW
|
|
||||||
-- else local flags = lib14a.ISO14A_COMMAND.ISO14A_NO_DISCONNECT + lib14a.ISO14A_COMMAND.ISO14A_RAW + lib14a.ISO14A_APPEND_CRC
|
|
||||||
-- end
|
|
||||||
|
|
||||||
|
--get rid of the ISO14A_APPEND_CRC flag if we don't want a CRC to be appended to the raw bytes.
|
||||||
local flags = lib14a.ISO14A_COMMAND.ISO14A_NO_DISCONNECT + lib14a.ISO14A_COMMAND.ISO14A_RAW + lib14a.ISO14A_COMMAND.ISO14A_APPEND_CRC
|
local flags = lib14a.ISO14A_COMMAND.ISO14A_NO_DISCONNECT + lib14a.ISO14A_COMMAND.ISO14A_RAW + lib14a.ISO14A_COMMAND.ISO14A_APPEND_CRC
|
||||||
|
|
||||||
-- local flags = lib14a.ISO14A_COMMAND.ISO14A_NO_DISCONNECT + lib14a.ISO14A_COMMAND.ISO14A_RAW
|
|
||||||
|
|
||||||
local command = Command:new{cmd = cmds.CMD_READER_ISO_14443a,
|
local command = Command:new{cmd = cmds.CMD_READER_ISO_14443a,
|
||||||
arg1 = flags, -- Send raw
|
arg1 = flags, -- Send raw
|
||||||
arg2 = string.len(rawdata) / 2, -- arg2 contains the length, which is half the length of the ASCII-string rawdata
|
arg2 = string.len(rawdata) / 2, -- arg2 contains the length, which is half the length of the ASCII-string rawdata
|
||||||
|
@ -32,53 +26,27 @@ end
|
||||||
-- The main entry point
|
-- The main entry point
|
||||||
function main(args)
|
function main(args)
|
||||||
|
|
||||||
|
-- Initialize the card using the read14a library
|
||||||
|
|
||||||
-- Manually send the card the init commands
|
|
||||||
-- firstcommand = Command:new{cmd = cmds.CMD_READER_ISO_14443a,
|
|
||||||
-- arg1 = lib14a.ISO14A_COMMAND.ISO14A_CONNECT + lib14a.ISO14A_COMMAND.ISO14A_NO_DISCONNECT,
|
|
||||||
-- arg2 = 0,
|
|
||||||
-- data = ""}
|
|
||||||
-- local restwo,errtwo = lib14a.sendToDevice(firstcommand)
|
|
||||||
-- print(firstcommand.arg1)
|
|
||||||
|
|
||||||
-- Call the program via the command line
|
|
||||||
-- result = core.console("hf 14a raw -p -b 7 -a 26") --I can do this from the command line, but I can't capture the output easily
|
|
||||||
-- print(result)
|
|
||||||
|
|
||||||
-- Send the card the init commands using the read14a library, reusing the connect functionality from a common library
|
|
||||||
info,err = lib14a.read14443a(true, no_rats)
|
info,err = lib14a.read14443a(true, no_rats)
|
||||||
if err
|
if err
|
||||||
then oops(err)
|
then oops(err)
|
||||||
else print(("Connected to card with a UID of %s"):format(info.uid))
|
else print(("Connected to card with a UID of %s"):format(info.uid))
|
||||||
end
|
end
|
||||||
|
|
||||||
--Attempt to send raw data
|
-- Now that the card is initialized, attempt to send raw data and read the response.
|
||||||
getvers = "0360" -- 0x0360 should begin the "get version" commands
|
getvers = "0360" -- 0x0360 begins the "get version" commands
|
||||||
--print(string.byte(getvers, 1, 99999))
|
|
||||||
--crc = core.crc16(getvers) -- under the hood, calls ComputeCrc14443, which is the same function which is called by "hf 14a raw"
|
|
||||||
--print(string.byte(crc, 1, 99999))
|
|
||||||
|
|
||||||
local result,err = sendRaw(getvers, true)
|
local result,err = sendRaw(getvers, true)
|
||||||
if result then
|
if result then
|
||||||
print("Currently trying to decode raw UsbCommand packet received.")
|
print("Currently trying to decode raw UsbCommand packet received.")
|
||||||
print(result)
|
|
||||||
|
|
||||||
local count,cmd,arg1,arg2,arg3,data = bin.unpack('LLLLH512',result)
|
local count,cmd,arg1,arg2,arg3,data = bin.unpack('LLLLH512',result)
|
||||||
print(data)
|
print(data)
|
||||||
--data = string.sub(result,count)
|
|
||||||
--local cmd_response = Command.parse(res)
|
|
||||||
else
|
else
|
||||||
err ="No response from card"
|
err = "No response from sending the card raw data."
|
||||||
|
oops(err)
|
||||||
end
|
end
|
||||||
-- local cmd_response = Command.parse(res)
|
|
||||||
-- local len = tonumber(cmd_response.arg1) *2
|
|
||||||
-- print("data length:",len)
|
|
||||||
-- local data = string.sub(tostring(cmd_response.data), 0, len);
|
|
||||||
-- print("<< ",data)
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
main(args) -- Call the main function
|
main(args) -- Call the main function
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue