/
README.html
444 lines (407 loc) · 23 KB
/
README.html
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>PC/SC Relay — vsmartcard 2023-10-01 documentation</title>
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../_static/bootstrap-sphinx.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="../_static/graphviz.css" />
<script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<link rel="shortcut icon" href="../_static/chip.ico"/>
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="USB CCID Emulator" href="../ccid/README.html" />
<link rel="prev" title="Tizen Smart Card Emulator" href="../TCardEmulator/README.html" />
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'>
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1'>
<meta name="apple-mobile-web-app-capable" content="yes">
<script type="text/javascript" src="../_static/js/jquery-1.11.0.min.js "></script>
<script type="text/javascript" src="../_static/js/jquery-fix.js "></script>
<script type="text/javascript" src="../_static/bootstrap-3.3.7/js/bootstrap.min.js "></script>
<script type="text/javascript" src="../_static/bootstrap-sphinx.js "></script>
</head><body>
<a href="https://github.com/frankmorgner/vsmartcard"
class="visible-desktop hidden-xs"><img
id="gh-banner"
style="position: absolute; top: 50px; right: 0; border: 0;"
src="https://s3.amazonaws.com/github/ribbons/forkme_right_white_ffffff.png"
alt="Fork me on GitHub"></a>
<script>
// Adjust banner height.
$(function () {
var navHeight = $(".navbar .container").css("height");
$("#gh-banner").css("top", navHeight);
});
</script>
<div id="navbar" class="navbar navbar-default ">
<div class="container">
<div class="navbar-header">
<!-- .btn-navbar is used as the toggle for collapsed navbar content -->
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="../index.html">
vsmartcard</a>
<span class="navbar-text navbar-version pull-left"><b></b></span>
</div>
<div class="collapse navbar-collapse nav-collapse">
<ul class="nav navbar-nav">
<li class="dropdown globaltoc-container">
<a role="button"
id="dLabelGlobalToc"
data-toggle="dropdown"
data-target="#"
href="../index.html">Site <b class="caret"></b></a>
<ul class="dropdown-menu globaltoc"
role="menu"
aria-labelledby="dLabelGlobalToc"><ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../virtualsmartcard/README.html">Virtual Smart Card</a></li>
<li class="toctree-l1"><a class="reference internal" href="../remote-reader/README.html">Remote Smart Card Reader</a></li>
<li class="toctree-l1"><a class="reference internal" href="../ACardEmulator/README.html">Android Smart Card Emulator</a></li>
<li class="toctree-l1"><a class="reference internal" href="../TCardEmulator/README.html">Tizen Smart Card Emulator</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">PC/SC Relay</a></li>
<li class="toctree-l1"><a class="reference internal" href="../ccid/README.html">USB CCID Emulator</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../virtualsmartcard/api.html">Creating a Virtual Smart Card</a></li>
</ul>
</ul>
</li>
<li class="dropdown">
<a role="button"
id="dLabelLocalToc"
data-toggle="dropdown"
data-target="#"
href="#">Page <b class="caret"></b></a>
<ul class="dropdown-menu localtoc"
role="menu"
aria-labelledby="dLabelLocalToc"><ul>
<li><a class="reference internal" href="#">PC/SC Relay</a><ul>
<li><a class="reference internal" href="#download">Download</a></li>
<li><a class="reference internal" href="#installation">Installation</a><ul>
<li><a class="reference internal" href="#installation-on-linux-unix-and-similar">Installation on Linux, Unix and similar</a></li>
<li><a class="reference internal" href="#hints-on-libnfc">Hints on libnfc</a></li>
<li><a class="reference internal" href="#hints-on-android-smart-card-emulator">Hints on Android Smart Card Emulator</a></li>
<li><a class="reference internal" href="#hints-on-pc-sc-middleware">Hints on PC/SC middleware</a></li>
</ul>
</li>
<li><a class="reference internal" href="#usage">Usage</a></li>
<li><a class="reference internal" href="#question">Question</a></li>
<li><a class="reference internal" href="#notes-and-references">Notes and References</a></li>
</ul>
</li>
</ul>
</ul>
</li>
<li>
<a href="../TCardEmulator/README.html" title="Previous Chapter: Tizen Smart Card Emulator"><span class="glyphicon glyphicon-chevron-left visible-sm"></span><span class="hidden-sm hidden-tablet">« Tizen Smart C...</span>
</a>
</li>
<li>
<a href="../ccid/README.html" title="Next Chapter: USB CCID Emulator"><span class="glyphicon glyphicon-chevron-right visible-sm"></span><span class="hidden-sm hidden-tablet">USB CCID Emulator »</span>
</a>
</li>
<li class="hidden-sm"></li>
</ul>
<form class="navbar-form navbar-right" action="../search.html" method="get">
<div class="form-group">
<input type="text" name="q" class="form-control" placeholder="Search" />
</div>
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="body col-md-12 content" role="main">
<div class="section" id="pc-sc-relay">
<span id="pcsc-relay"></span><h1>PC/SC Relay<a class="headerlink" href="#pc-sc-relay" title="Permalink to this headline">¶</a></h1>
<div class="sidebar">
<p class="sidebar-title">Relay a smart card to a contactless interface</p>
<dl class="field-list simple">
<dt class="field-odd">License</dt>
<dd class="field-odd"><p>GPL version 3</p>
</dd>
<dt class="field-even">Tested Platforms</dt>
<dd class="field-even"><ul class="simple">
<li><p>Windows</p></li>
<li><p>Linux (Debian, Ubuntu, OpenMoko)</p></li>
</ul>
</dd>
</dl>
</div>
<p>Welcome to PC/SC Relay. The purpose of PC/SC Relay is to relay a smart
card using an contact-less interface. Currently the following contact-less
<strong>emulators</strong> are supported:</p>
<ul class="simple">
<li><p><a class="reference external" href="http://nfc-tools.org/index.php?title=Devices_compatibility_matrix">Hardware supported by libnfc</a> <a class="footnote-reference brackets" href="#id3" id="id4">1</a></p></li>
<li><p><a class="reference external" href="http://www.openpcd.org/OpenPICC">OpenPICC</a> <a class="footnote-reference brackets" href="#id5" id="id6">2</a></p></li>
<li><p><a class="reference internal" href="../ACardEmulator/README.html#acardemulator"><span class="std std-ref">Android Smart Card Emulator</span></a></p></li>
</ul>
<p>Command APDUs are received with the contact-less interface and relayed. The
Response APDUs are then sent back via RFID. The contact-less data will be
relayed to one of the following <strong>connectors</strong>:</p>
<ul class="simple">
<li><p>to a <em>real</em> smart card inserted into one of the systems’ smart card readers.
The smart card reader must be accessible with PC/SC. The smart card may be
contact-based <em>or</em> contact-less.</p></li>
<li><p>to a <a class="reference internal" href="../virtualsmartcard/README.html#vicc"><span class="std std-ref">Virtual Smart Card</span></a> that directly connects to <strong class="command">pcsc-relay</strong>. The virtual
smart card’s native interface is used and (despite its name) PC/SC Relay
does not need to access PC/SC in this case.</p></li>
</ul>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>┌────────┐ ┌──────────┐ ┌─────────┐
│Emulator│ │pcsc-relay│ │Connector│
└───┬────┘ └────┬─────┘ └────┬────┘
│ Command APDU │ │
│ ───────────────────> │
│ │ ───────────────────>│
│ │ <───────────────────│
│ Response APDU │ │
│ <─────────────────── │
┌───┴────┐ ┌────┴─────┐ ┌────┴────┐
│Emulator│ │pcsc-relay│ │Connector│
└────────┘ └──────────┘ └─────────┘
</pre></div>
</div>
<div class="figure" id="id1" style="text-align: center">
<p><img src="../_images/tikz-115ce7f91e19ed28b7af35a9f18aa096148209ea.svg" alt="Figure made with TikZ" /></p>
<p class="caption"><span class="caption-text">Debug, Analyze and Emulate with PC/SC Relay</span></p>
</div><p>With PC/SC Relay you can relay a contact-less or contact based smart card
over a long distance. Also you can use it in combination with the <a class="reference internal" href="../virtualsmartcard/README.html#vicc"><span class="std std-ref">Virtual Smart Card</span></a>
to completely emulate an ISO/IEC 14443 smart card.</p>
<div class="figure" id="id2" style="text-align: center">
<p><img src="../_images/tikz-0405e52eb98193c32482e91a30737e1e9684bad0.svg" alt="Figure made with TikZ" /></p>
<p class="caption"><span class="caption-text">Emulate a contact-less German ID card to perform sanity checks</span></p>
</div><p>PC/SC Relay has the following dependencies:</p>
<ul class="simple">
<li><p>PC/SC middleware</p></li>
</ul>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>This software can actually be used in a relay attack allowing full access
to the card. We discussed the impact especially on the <a class="reference external" href="http://media.ccc.de/browse/congress/2010/27c3-4297-de-die_gesamte_technik_ist_sicher.html">Relay attack
against the German ID card</a>,
but it generally concerns <em>all</em> contact-less smart cards.</p>
</div>
<div class="section" id="download">
<h2>Download<a class="headerlink" href="#download" title="Permalink to this headline">¶</a></h2>
<p>You can find the latest release of PC/SC Relay on <a class="reference external" href="https://github.com/frankmorgner/vsmartcard/releases">Github</a>. Older releases are
still available on <a class="reference external" href="http://sourceforge.net/projects/vsmartcard/files">Sourceforge</a>.</p>
<p>Alternatively, you can clone our git repository:</p>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>git clone https://github.com/frankmorgner/vsmartcard.git
<span class="nb">cd</span> vsmartcard
git submodule update --init --recursive
</pre></div>
</div>
</div>
<div class="section" id="installation">
<h2>Installation<a class="headerlink" href="#installation" title="Permalink to this headline">¶</a></h2>
<div class="section" id="installation-on-linux-unix-and-similar">
<h3>Installation on Linux, Unix and similar<a class="headerlink" href="#installation-on-linux-unix-and-similar" title="Permalink to this headline">¶</a></h3>
<p>The PC/SC Relay uses the GNU Build System to compile and install. If you are
unfamiliar with it, please have a look at <code class="file docutils literal notranslate"><span class="pre">INSTALL</span></code>. If you can not find
it, you are probably working bleeding edge in the repository. To generate the
missing standard auxiliary files you need to additionally install <cite>libtool</cite> and
<cite>pkg-config</cite> and run the following command in <code class="file docutils literal notranslate"><span class="pre">pcsc-relay</span></code>:</p>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>autoreconf --verbose --install
</pre></div>
</div>
<p>To configure (<strong class="command">configure --help</strong> lists possible options), build and
install the PC/SC Relay now do the following:</p>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>./configure
make
make install
</pre></div>
</div>
</div>
<div class="section" id="hints-on-libnfc">
<h3>Hints on libnfc<a class="headerlink" href="#hints-on-libnfc" title="Permalink to this headline">¶</a></h3>
<p>Here is an example of how to get the standard
installation of libnfc:</p>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span><span class="nv">PREFIX</span><span class="o">=</span>/tmp/install
<span class="nv">LIBNFC</span><span class="o">=</span>libnfc
git clone https://github.com/nfc-tools/libnfc <span class="nv">$LIBNFC</span>
<span class="nb">cd</span> <span class="nv">$LIBNFC</span>
autoreconf -i
<span class="c1"># See `./configure --help` for enabling support of additional hardware</span>
./configure --prefix<span class="o">=</span><span class="nv">$PREFIX</span>
make
make install
</pre></div>
</div>
<p>Building PC/SC Relay with libnfc is done best using <strong class="command">pkg-config</strong>. The file
<code class="file docutils literal notranslate"><span class="pre">libnfc.pc</span></code> should be located in <code class="docutils literal notranslate"><span class="pre">$INSTALL/lib/pkgconfig</span></code>. Here is how to
configure PC/SC Relay to use it:</p>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>./configure <span class="nv">PKG_CONFIG_PATH</span><span class="o">=</span><span class="nv">$PREFIX</span>/lib/pkgconfig
</pre></div>
</div>
</div>
<div class="section" id="hints-on-android-smart-card-emulator">
<h3>Hints on Android Smart Card Emulator<a class="headerlink" href="#hints-on-android-smart-card-emulator" title="Permalink to this headline">¶</a></h3>
<p>The Android Smart Card Emulator is build around the host card emulation mode of
Android 4.4 and later. This mode activates the app if the terminal issues a
SELECT command with one of the app’s application identifiers. By default, the
app only registers for the AIDs for which it has a built-in emulator (see
<code class="file docutils literal notranslate"><span class="pre">ACardEmulator/app/src/main/res/xml/aid_list.xml</span></code>).</p>
<p>If used together with PC/SC Relay, you need to change add AIDs to match the
applications on the relayed card. Otherwise the app will not be activated when
it should relay command APDUs to PC/SC Relay.</p>
<p>Modify the Smart Card Emulator settings to use <code class="docutils literal notranslate"><span class="pre">Remote</span> <span class="pre">Virtual</span> <span class="pre">Smart</span> <span class="pre">Card</span></code> as
<span class="guilabel">Smart Card Emulator</span>. Now start <strong class="command">pcsc-relay</strong> by specifying
usage of the vpcd emulator:</p>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>pcsc-relay --emulator vpcd
</pre></div>
</div>
<p>In the app, change the <span class="guilabel">VICC Hostname</span> and <span class="guilabel">VICC Port</span> to
match the location where <strong class="command">pcsc-relay</strong> is waiting for an incoming
connection. When the app receives a SELECT command to one of the configured
AIDs, it will connect to <strong class="command">pcsc-relay</strong>, which will then relay the
command for processing.</p>
<p>Compiling and installing Android Smart Card Emulator is covered in its
<a class="reference internal" href="../ACardEmulator/README.html#acardemulator-install"><span class="std std-ref">Download and Install</span></a> section.</p>
</div>
<div class="section" id="hints-on-pc-sc-middleware">
<h3>Hints on PC/SC middleware<a class="headerlink" href="#hints-on-pc-sc-middleware" title="Permalink to this headline">¶</a></h3>
<p>A PC/SC middleware is included by default in most modern operating systems. On
Unix-like systems (Linux, OS X, Sun OS) it is realized by <a class="reference external" href="https://pcsclite.apdu.fr/">PCSC-Lite</a> <a class="footnote-reference brackets" href="#id7" id="id8">3</a>. To
compile PC/SC Relay you will need to install the PCSC-Lite headers from
your distribution.</p>
<p>Windows also ships with a PC/SC middleware in form of the Winscard module.
PC/SC Relay can be (cross) compiled with MinGW-w64. Also, Microsoft’s
developement environment Visual Studio includes all necessary data for building
PC/SC Relay.</p>
</div>
</div>
<div class="section" id="usage">
<h2>Usage<a class="headerlink" href="#usage" title="Permalink to this headline">¶</a></h2>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>Usage: pcsc-relay [OPTION]...
Relay a smart card to a contactless interface
Using an contact-less interface (currently OpenPICC or libnfc) pcsc-relay
receives command APDUs which are forwared to an existing smart card via PC/SC.
pcsc-relay sends the response APDU back to the contact-less interface.
-h, --help Print help and exit
-V, --version Print version and exit
-e, --emulator=ENUM Contact-less emulator backend (possible
values="libnfc", "vpcd", "openpicc"
default=`libnfc')
-c, --connector=ENUM Smart card connector backend (possible
values="pcsc", "vicc" default=`pcsc')
-f, --foreground Stay in foreground (default=on)
-v, --verbose Use (several times) to be more verbose
PC/SC connector:
-r, --reader=INT Number of the PC/SC reader to use (-1 for
autodetect) (default=`-1')
Virtual Smart Card connector:
-p, --vpcd-port=INT Port for communicating virtual smart card
(default=`35963')
-n, --vpcd-hostname=STRING Hostname for connecting to virtual smart card
(default=`wait for an incoming connection')
Virtual Smart Card Reader emulator:
-P, --vicc-port=INT Port to listen for virtual smart card reader
(default=`35963')
-N, --vicc-hostname=STRING Hostname for connecting to virtual smart card
reader (default=`wait for an incoming
connection')
-A, --vicc-atr=STRING ATR (default=`3B80800101')
Report bugs to https://github.com/frankmorgner/vsmartcard/issues
Written by Frank Morgner and Dominik Oepen
</pre></div>
</div>
<p>Below we explain what option to choose for the emulator which receives a
command APDU and transmits a response APDU back to the terminal:</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 78%" />
<col style="width: 22%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Option</p></th>
<th class="head"><p><code class="docutils literal notranslate"><span class="pre">--emulator</span></code></p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>Emulation hardware supported via libnfc</p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">libnfc</span></code></p></td>
</tr>
<tr class="row-odd"><td><p>Emulation with OpenPICC</p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">openpicc</span></code></p></td>
</tr>
<tr class="row-even"><td><p>Android Smart Card Emulator</p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">vpcd</span></code></p></td>
</tr>
<tr class="row-odd"><td><p>Virtual Smart Card</p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">vpcd</span></code></p></td>
</tr>
</tbody>
</table>
<p>Below we explain what option to choose for the connector which calculates
a response APDU from a given command APDU:</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 77%" />
<col style="width: 23%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Option</p></th>
<th class="head"><p><code class="docutils literal notranslate"><span class="pre">--connector</span></code></p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>Contact-based Smart Card in PC/SC Reader</p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">pcsc</span></code></p></td>
</tr>
<tr class="row-odd"><td><p>Contact-less Smart Card in PC/SC Reader</p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">pcsc</span></code></p></td>
</tr>
<tr class="row-even"><td><p>Contact-less Smart Card in Remote Smart Card Reader</p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">vicc</span></code></p></td>
</tr>
<tr class="row-odd"><td><p>Virtual Smart Card</p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">vicc</span></code></p></td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="question">
<h2>Question<a class="headerlink" href="#question" title="Permalink to this headline">¶</a></h2>
<p>Do you have questions, suggestions or contributions? Feedback of any kind is
more than welcome! Please use our <a class="reference external" href="https://github.com/frankmorgner/vsmartcard/issues">project trackers</a>.</p>
</div>
<div class="section" id="notes-and-references">
<h2>Notes and References<a class="headerlink" href="#notes-and-references" title="Permalink to this headline">¶</a></h2>
<dl class="footnote brackets">
<dt class="label" id="id3"><span class="brackets"><a class="fn-backref" href="#id4">1</a></span></dt>
<dd><p><a class="reference external" href="http://nfc-tools.org/index.php?title=Devices_compatibility_matrix">http://nfc-tools.org/index.php?title=Devices_compatibility_matrix</a></p>
</dd>
<dt class="label" id="id5"><span class="brackets"><a class="fn-backref" href="#id6">2</a></span></dt>
<dd><p><a class="reference external" href="http://www.openpcd.org/OpenPICC">http://www.openpcd.org/OpenPICC</a></p>
</dd>
<dt class="label" id="id7"><span class="brackets"><a class="fn-backref" href="#id8">3</a></span></dt>
<dd><p><a class="reference external" href="https://pcsclite.apdu.fr/">https://pcsclite.apdu.fr/</a></p>
</dd>
</dl>
</div>
</div>
</div>
</div>
</div>
<footer class="footer">
<div class="container">
<p class="pull-right">
<a href="#">Back to top</a>
</p>
<p>
© Copyright 2009-2023 by Dominik Oepen and Frank Morgner.<br/>
</p>
</div>
</footer>
</body>
</html>