Research, development and trades concerning the powerful Proxmark3 device.
Remember; sharing is caring. Bring something back to the community.
"Learn the tools of the trade the hard way." +Fravia
You are not logged in.
Time changes and with it the technology
Proxmark3 @ discord
Users of this forum, please be aware that information stored on this site is not private.
Pages: 1
Hello all,
I have a problem while trying to use utils.input or io.read in my script.
The first reading is ok, but the next one is not. It looks like I have a carriage return in the input captured.
I use io.flush before, but it still doesn't work.
Helllllp
Offline
After further investigations, i've found someting quite strange.
The problem occurs only after calling a core method which calculates CRCs.
Here is a short example which shows the problem : enter 'yes' how many times you want, and it displays that you keyed in 'yes'.
If you enter 'crc', it displays a crc.
After having tried 'crc', try to enter again whatever crc or yes, it won't work anymore ...
local utils = require('utils')
local function main()
local crcD
local bool = true
local kbinput
repeat
kbinput = utils.input("Enter 'yes' or 'crc' :")
if kbinput == "crc" then
crcD = utils.SwapEndianness(core.reveng_runmodel("CRC-16/ARC", "A00000000000000F", false, '0'),16)
print("***********************************************************Calc of a CRC :"..crcD)
end
if kbinput == "yes" then
print("********************You keyed in :"..kbinput)
end
until bool == false
end
main()
Offline
Here is a quick and dirty way of getting rid of the bug :
input = utils.input(message)
if string.byte(string.sub(input,-1)) == 13 then input = string.sub(input,1,(string.len(input)-1)) end
Offline
I don't follow, the input function works just fine.
local utils = require('utils')
local function main()
local crcD
local bool = true
local kbinput
repeat
kbinput = utils.input("Enter 'yes' or 'crc' :")
if kbinput == "crc" then
crcD = utils.SwapEndianness(core.reveng_runmodel("CRC-16/ARC", "A00000000000000F", false, '0'),16)
print("***********************************************************Calc of a CRC :"..crcD)
end
if kbinput == "yes" then
print("********************You keyed in :"..kbinput)
end
until bool == false
end
main()
result
[usb] pm3 --> scr run a
[+] executing lua /home/iceman/rdv4/client/luascripts/a.lua
[+] args ''
Enter 'yes' or 'crc' :
> yes
********************You keyed in :yes
Enter 'yes' or 'crc' :
> yes
********************You keyed in :yes
Enter 'yes' or 'crc' :
> sad
Enter 'yes' or 'crc' :
> crc
***********************************************************Calc of a CRC :31818
Enter 'yes' or 'crc' :
> crc
***********************************************************Calc of a CRC :31818
Enter 'yes' or 'crc' :
> cr
Enter 'yes' or 'crc' :
> ys
Enter 'yes' or 'crc' :
> yes
********************You keyed in :yes
Enter 'yes' or 'crc' :
> yes
********************You keyed in :yes
Enter 'yes' or 'crc' :
> calc
Enter 'yes' or 'crc' :
> crc
***********************************************************Calc of a CRC :31818
Enter 'yes' or 'crc' :
> yes
********************You keyed in :yes
Enter 'yes' or 'crc' :
> crc
***********************************************************Calc of a CRC :31818
Enter 'yes' or 'crc' :
> crc
***********************************************************Calc of a CRC :31818
Enter 'yes' or 'crc' :
> ^C
Offline
Strange ...
Maybe relative to the fact you have compiled your environnement for RDV4 whereas I have compiled for other models ?
This is the results I have :
[usb] pm3 --> script run lou2
[+] executing lua C:\ProxSpace-master\pm3\client\luascripts/lou2.lua
[+] args ''
Enter 'yes' or 'crc' :
> crc
***********************************************************Calc of a CRC :31818
Enter 'yes' or 'crc' :
> yes
Enter 'yes' or 'crc' :
> yes
Enter 'yes' or 'crc' :
> crc
Enter 'yes' or 'crc' :
> crc
Enter 'yes' or 'crc' :
>
Offline
that should not affect the lua part in regards to the utils.lua.
try doing some print of the variables you are using.
Offline
New code with some more prints
local utils = require('utils')
local function main()
local crcD
local bool = true
local kbinput
repeat
kbinput = utils.input("Enter 'yes' or 'crc' :")
print("Lenght of input keyed in : "..string.len(kbinput))
print("Last char of the input : "..string.sub(kbinput,-1).."("..string.byte(string.sub(kbinput,-1))..")")
if kbinput == "crc" then
crcD = utils.SwapEndianness(core.reveng_runmodel("CRC-16/ARC", "A00000000000000F", false, '0'),16)
print("***********************************************************Calc of a CRC :"..crcD)
end
if kbinput == "yes" then
print("********************You keyed in :"..kbinput)
end
until bool == false
end
main()
Result is :
[usb] pm3 --> script run lou2
[+] executing lua C:\ProxSpace-master\pm3\client\luascripts/lou2.lua
[+] args ''
Enter 'yes' or 'crc' :
> yes
Lenght of input keyed in : 3
Last char of the input : s(115)
********************You keyed in :yes
Enter 'yes' or 'crc' :
> crc
Lenght of input keyed in : 3
Last char of the input : c(99)
***********************************************************Calc of a CRC :31818
Enter 'yes' or 'crc' :
> yes
Lenght of input keyed in : 4
(13) char of the input :
Enter 'yes' or 'crc' :
Notice (13) char of the input : : it should have outputed (13) at the end of the line.
Unfortunately, (13) is a carriage return thus the output start at the beginning of the current line, and then scratches the beginning of the line.
Last edited by loupetre (2020-03-24 11:17:09)
Offline
Just had a quick play and got the same results as loupetre (windows 10)
I split the code a little
-- crcD = utils.SwapEndianness(core.reveng_runmodel("CRC-16/ARC", "A00000000000000F", false, '0'),16)
data1 = core.reveng_runmodel("CRC-16/ARC", "A00000000000000F", false, '0');
print (" data len "..string.len(data1).."["..data1.."]")
crcD = utils.SwapEndianness(data1,16)
and found it happens when core.reveng_runmodel line is run.
If i dont run that, the swapendianness call works and no issue happens.
Its almost as if the function changes an EOL from LF to CR & LF.
Offline
Verifed the bug, tried it in Proxspace 3.2, same error.
io.read suddenly goes to add newline after the call to reveng_runmodel...
Offline
pull latest source and see if your problem still exists
Offline
I am on your repo RfidResearchGroup/proxmark3, not on Proxmark/proxmark3.
You 've merged on which one ?
Offline
rrg/iceman.
Offline
Well done, it works like a charm
[usb] pm3 --> script run lou2
[+] executing lua C:\ProxSpace-master\pm3\client\luascripts/lou2.lua
[+] args ''
Enter 'yes' or 'crc' :
> yes
Lenght of input keyed in : 3
Last char of the input : s(115)
********************You keyed in :yes
Enter 'yes' or 'crc' :
> crc
Lenght of input keyed in : 3
Last char of the input : c(99)
***********************************************************Calc of a CRC :31818
Enter 'yes' or 'crc' :
> yes
Lenght of input keyed in : 3
Last char of the input : s(115)
********************You keyed in :yes
Enter 'yes' or 'crc' :
> crc
Lenght of input keyed in : 3
Last char of the input : c(99)
***********************************************************Calc of a CRC :31818
Enter 'yes' or 'crc' :
>
Thank you very much, it will be easier to handle keyboard inputs for me now !
Last edited by loupetre (2020-03-25 22:07:21)
Offline
Pages: 1