forked from eIDuy/apdu-parser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparseAPDU.bat
More file actions
63 lines (48 loc) · 1.02 KB
/
Copy pathparseAPDU.bat
File metadata and controls
63 lines (48 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
@ECHO off
setlocal enabledelayedexpansion
if [%~1]==[] goto :ask_input
set bytes=
call :insert_space_each_byte %* bytes
REM echo bytes=%bytes%
echo %bytes%>abc.txt
py apdu_parser.py -T -i abc.txt
del abc.txt
REM pause
goto :EOF
:ask_input
echo input APDU cmds as parameter
echo example:
echo parseAPDU.bat 00B2011400
echo parseAPDU.bat \x00\xB2\x01\x14\x00
pause
goto :EOF
:insert_space_each_byte
set v=%1
REM echo input=%v%
set var=
set /a l=0
:loop_insert_space_each_byte
set c=!v:~%l%,2!
if "%c%"=="" goto end_insert_space_each_byte
if "%c%"=="\x" set /a l+=2 && goto loop_insert_space_each_byte
set "var=%var%%c% "
set /a l+=2
goto loop_insert_space_each_byte
:end_insert_space_each_byte
REM echo output=%var%
set %2=%var%
REM echo !%2!
goto :EOF
:insert_space
set v=%*
set var=
set /a l=0
:loop_insert_space
set c=!v:~%l%,2!
if "%c%"=="" goto end_insert_space
set "var=%var%%c% "
set /a l+=2
goto loop_insert_space
:end_insert_space
echo %var%
goto :EOF