mfterm.man 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. .\" mfterm Manual
  2. .\" Contact anders@4zm.org to correct errors or typos.
  3. .TH mfterm 1 "22 Apr 2013" "1.0.3" "mfterm Manual"
  4. .SH NAME
  5. mfterm \- The Mifare Terminal
  6. .SH SYNOPSIS
  7. .B mfterm
  8. [\fB-v\fR\]
  9. [\fB-h\fR\]
  10. [\fB-t\fR \fItagfile\fR]
  11. [\fB-k\fR \fIkeyfile\fR]
  12. [\fB-d\fR \fIdictionary\fR]
  13. .\" ---------------------- DESCRIPTION -----------------------------
  14. .SH DESCRIPTION
  15. .P
  16. mfterm is a terminal interface for working with Mifare tags.
  17. .PP
  18. The program is used as an interactive shell to read and write Mifare
  19. tags using libnfc and a libnfc compatible reader or to simply
  20. manipulate Mifare data dumps from files. See the \fBCOMMANDS\fR
  21. section below for a description of the commands available.
  22. .PP
  23. In mfterm, there are a number of global state variables. One for tag
  24. data, one for keys and some others. Data is read and loaded to this
  25. memory and written and saved from the same. The contents of the tag
  26. data variable is displayed using the \fBprint\fR command. The keys in
  27. the key variable are displayed using the \fBkeys\fR command. Both tag
  28. and key variables are 4k, but only the first 1k is used for 1k tags.
  29. .PP
  30. Please see the \fBREADME\fR and \fBINSTALL\fR files for further
  31. information.
  32. .\" --------------------------- OPTIONS ---------------------------
  33. .SH OPTIONS
  34. These are the command line options of mfterm.
  35. .TP 5
  36. .TP
  37. \fB-h\fR, \fB--help\fR
  38. Displays a help message.
  39. .TP
  40. \fB-v\fR, \fB--version\fR
  41. Display version information.
  42. .TP
  43. \fB-t\fR \fItagfile\fR, \fB--tag=\fR\fItagfile\fR
  44. Load a tag from the specified file. Before starting the terminal.
  45. .TP
  46. \fB-k\fR \fIkeyfile\fR, \fB--keys=\fR\fIkeyfile\fR
  47. Load keys from the specified file. Before starting the terminal.
  48. .TP
  49. \fB-d\fR \fIdictionary\fR, \fB--dict=\fR\fIdictionary\fR
  50. Load dictionary from the specified file. Before starting the terminal.
  51. .\" --------------------------- COMMANDS ---------------------------
  52. .SH COMMANDS
  53. These are the commands available from the mfterm prompt.
  54. .\" --------------------- TAG - COMMANDS ---------------------------
  55. .RS -4
  56. .B Tag Commands:
  57. .RE
  58. .TP
  59. \fBprint \fR[\fB1k\fR|\fB4k\fR]
  60. Print the current tag data. The data is formatted to show sectors and
  61. blocks in hexadecimal. Optionally specify tag size (default is 1k).
  62. .TP
  63. \fBread \fR[\fBA\fR|\fBB\fR]
  64. Read a tag. A libnfc compatible reader must be connected and a tag
  65. present. The keys in the key state variable will be used to
  66. authenticate each sector. Optionally specify witch key to use for
  67. reading (default is A).
  68. .TP
  69. \fBwrite \fR[\fBA\fR|\fBB\fR]
  70. Write a tag. A libnfc compatible reader must be connected and a tag
  71. present. The keys in the key state variable will be used to
  72. authenticate each sector. Optionally specify witch key to use for
  73. reading (default is A).
  74. .TP
  75. \fBload\fR
  76. Load tag data from a file. The file should be a raw binary file
  77. containing exactly 4k. If the tag data represents a 1k tag, the data
  78. should be padded.
  79. .TP
  80. \fBsave\fR
  81. Save tag data to a file. A raw binary dump of the data will be
  82. written. If the tag is a 1k tag, the data will be padded with zeroes
  83. to 4k size.
  84. .TP
  85. \fBclear\fR
  86. Clear the current tag data in memory.
  87. .TP
  88. \fBprint keys \fR[\fB1k\fR|\fB4k\fR]
  89. Extract the key information from the tag loaded into memory and
  90. display it. This is not the same as the keys command. The later will
  91. print the keys stored in the keys variable, this prints keys from the
  92. tag.
  93. .TP
  94. \fBprint ac\fR
  95. Print the access conditions for each block. Possible values are A, B,
  96. A|B or '-'. Their meanings are, in turn, that the A or B or both A and
  97. B keys or neither key can be used. The columns R, W, I, D represents
  98. read, write, increment and decrement. They apply for all non trailer
  99. blocks. For the trailer blocks the columns AR, AW, ACR, ACW, BR, BW
  100. apply. They are permissions for; reading the A-key, writing the A-key,
  101. reading the access control bits, writing the access control bits,
  102. reading the B-key and writing the B-key.
  103. .TP
  104. \fBset \fIblock offset\fR \fB=\fR \fIxx xx xx\fR
  105. Write some values to the tag variable in memory. Specify data as
  106. hexadecimal bytes separated by spaces.
  107. .\" --------------------- KEY - COMMANDS ---------------------------
  108. .RS -4
  109. .B Key Management Commands:
  110. .RE
  111. .TP
  112. \fBkeys\fR [\fB1k\fR|\fB4k\fR]
  113. Print the keys currently loaded. Optionally specify if keys for the
  114. full 4k tag should be displayed or just the ones for the first
  115. 1k. Default is 1k.
  116. .TP
  117. \fBkeys load\fR \fIfile\fR
  118. Load keys from a file into memory. The key file is a regular binary
  119. tag dump, but only the key fields are used. That means that any tag
  120. dump can be loaded as keys.
  121. .TP
  122. \fBkeys save\fR \fIfile\fR
  123. Save the current keys in memory to a file. The keys will be saved as a
  124. normal binary tag dump with all values except the keys cleared.
  125. .TP
  126. \fBkeys import\fR
  127. Import keys from the current tag.
  128. .TP
  129. \fBkeys clear\fR
  130. Clear the keys in memory.
  131. .TP
  132. \fBkeys set\fR \fBA\fR|\fBB\fR \fIsector\fR \fIkey\fR
  133. Set a specific key explicitly. Specify the key in hex, if it is an A-
  134. or B-key and what sector to set the key for.
  135. .TP
  136. \fBkeys test\fR
  137. Try to authenticate with the keys. Use this command to test a set of
  138. keys with a specific tag.
  139. .\" ------------------ PIRATE - COMMANDS ---------------------------
  140. .RS -4
  141. .B Pirate Card Commands:
  142. .RE
  143. These commands will only work on the back door:ed pirate cards (aka
  144. Chinese magic cards) with writable first block.
  145. .TP
  146. \fBread unlocked\fR
  147. Read the card without using keys and disregard access control bits.
  148. .TP
  149. \fBwrite unlocked\fR
  150. Write to a back door:ed 1k tag. This will write block 0 and possibly
  151. modify the UID.
  152. .\" -------------------- DICT - COMMANDS ---------------------------
  153. .RS -4
  154. .B Dictionary Attack Commands:
  155. .RE
  156. .TP
  157. \fBdict load\fR \fIfile\fR
  158. Load a dictionary key file. This is a regular text file with one key
  159. written in hex per line. Loading multiple dictionaries will merge
  160. their contents and remove duplicates.
  161. .TP
  162. \fBdict clear\fR
  163. Clear the key dictionary in memory.
  164. .TP
  165. \fBdict attack\fR
  166. Find keys of a physical tag by trying all keys in the loaded
  167. dictionary. If any keys are found the current keys variable will be
  168. updated.
  169. .TP
  170. \fBdict\fR
  171. Print the contents of the key dictionary currently loaded.
  172. .\" -------------------- SPEC - COMMANDS ---------------------------
  173. .RS -4
  174. .B Contents Specification Commands:
  175. .RE
  176. .TP
  177. \fBspec load\fR \fIfile\fR
  178. Load a specification file.
  179. .TP
  180. \fBspec clear\fR
  181. Unload the specification.
  182. .TP
  183. \fBspec\fR
  184. Print the specification.
  185. .\" --------------------- MAC - COMMANDS ---------------------------
  186. .RS -4
  187. .B MAC Commands:
  188. .RE
  189. These are commands for creating and validating DES MACs (message
  190. authentication codes) to sign the contents of specific blocks.
  191. .TP
  192. \fBmac key\fR [\fIkey\fR]
  193. Get or set MAC key.
  194. .TP
  195. \fBmac compute\fR \fI#block\fR
  196. Compute the MAC for a specified block.
  197. .TP
  198. \fBmac update\fR \fI#block\fR
  199. Compute the MAC for a specified block, truncate it and write it back
  200. into the current tag data.
  201. .TP
  202. \fBmac validate\fR [\fB1k\fR|\fB4k\fR]
  203. Validates MACs for every block of the tag.
  204. .\" -------------------- MISC - COMMANDS ---------------------------
  205. .RS -4
  206. .B General commands:
  207. .RE
  208. .TP 5
  209. .TP
  210. \fBquit\fR
  211. Exit the program.
  212. .TP
  213. \fBhelp\fR
  214. Show a list of available commands and a short description of each.
  215. .\" ------------------------- NOTES -------------------------------
  216. .SH NOTE
  217. The \fBmac\fR and \fBspec\fR command groups are experimental. They
  218. .\" ---------------------- TRAILER STUFF ---------------------------
  219. .SH SEE ALSO
  220. nfc-list(1)
  221. .SH LICENSE
  222. Copyright (C) 2011-2013 Anders Sundman <anders@4zm.org>
  223. License GPLv3+: GNU GPL version 3 or later. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
  224. .SH AUTHOR
  225. Anders Sundman <anders@4zm.org>