Giter VIP home page Giter VIP logo

emvcap's Introduction

noswpatv3

NOTE: the original author relicenced this software under GPLv3 here: https://github.com/doegox/EMV-CAP

NOTE2: I will update this repo with Doegox's changes and Python2 and Python3 support when I will have some time

About

This tool emulates an EMV-CAP device, to illustrate the article "Banque en ligne : a la decouverte d'EMV-CAP" published in MISC #56.

Example of EMV-CAP calculators:

EMV-CAP calculators

Screenshots

USB smartcard reader with a bank card connected to a laptop running Linux:

USB smartcard reader with a bank card

Command line help:

$ ./EMV-CAP -h
usage: EMV-CAP [-h] [-l] [-L] [--tlv PARSETLV]
               [-r {<index>, <reader_substring>}] [-d] [-v] [-m {1,2}]
               [--warmreset {auto,yes,no}]
               [N [N ...]]

EMV-CAP calculator

optional arguments:
  -h, --help            show this help message and exit

Standalone options:
  -l, --listreaders     print list of available readers and exit
  -L, --listapps        print list of available applications on the card and
                        exit
  --tlv PARSETLV        parse a hex string into TLV elements

Global options:
  -r {<index>, <reader_substring>}, --reader {<index>, <reader_substring>}
                        select one specific reader with reader index, name
                        string or sub-string otherwise first reader found will
                        be used.
  -d, --debug           print exchanged APDU for debugging
  -v, --verbose         print APDU parsing

Modes and data:
  -m {1,2}, --mode {1,2}
                        M1/M2 mode selection (mandatory, unless -l or -L is
                        used)
  N                     number(s) as M1/M2 data: max one 8-digit number for M1
                        and max 10 10-digit numbers for M2
  --warmreset {auto,yes,no}
                        Warm reset: yes / no / auto (default) If 'auto' it
                        will perform a warm reset if the ATR starts with 3F
                        (indirect convention)

Examples:
    EMV-CAP --listreaders
    EMV-CAP --listapps
    EMV-CAP --listapps --debug --reader foo
    EMV-CAP -m1 123456
    EMV-CAP -m2
    EMV-CAP -m2 1000 3101234567

Mac OSX support

EMV-CAP also works on Mac OSX (tested with Yosemite 10.10.5), you will need to install few dependencies though (you need to have pip and brew installed as prerequesite):

  • brew: see the Brew homepage on how to install it
  • pip: $ sudo easy_install pip
  • swig: $ brew install swig
  • pycrypto and pyscard: $ sudo pip install pycrypto pyscard

Windows 10 support

I have attempted to install the same dependencies for OSX, with cygwin installed, python, gcc, python-pip, etc... I managed to do a pip install pycrypto pyscard (Successfully installed pycrypto-2.6.1 pyscard-1.9.7). But when I try to run the M2 from bash, I got a protocol error (I have to force the second reader with the -r flag):

$ EMV-CAP -r 2 -m2 1000 123456
Traceback (most recent call last):
  File "/usr/bin/EMV-CAP", line 321, in <module>
    (RAPDU, sw1, sw2) = myTransmit(connection, CAPDU, args.debug)
  File "/usr/bin/EMV-CAP", line 188, in myTransmit
    (RAPDU, sw1, sw2) = connection.transmit(hex2lint(CAPDU))
  File "/usr/lib/python2.7/site-packages/smartcard/CardConnectionDecorator.py", line 82, in transmit
    return self.component.transmit(bytes, protocol)
  File "/usr/lib/python2.7/site-packages/smartcard/CardConnection.py", line 146, in transmit
    data, sw1, sw2 = self.doTransmit(bytes, protocol)
  File "/usr/lib/python2.7/site-packages/smartcard/pcsc/PCSCCardConnection.py", line 196, in doTransmit
    'CardConnection.RAW_protocol')
smartcard.Exceptions.CardConnectionException: Invalid protocol in transmit: must be CardConnection.T0_protocol, CardConnection.T1_protocol, or CardConnection.RAW_protocol

Todo

License

Creative Commons Paternité - Pas de Modification 2.0 Belgique (CC BY-ND 2.0 BE): https://creativecommons.org/licenses/by-nd/2.0/be/

Links

emvcap's People

Contributors

h4soft avatar zoobab avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

emvcap's Issues

BUY button on the newer readers

I know that SIGN/LOGIN matches with M1 and M2 but new readers, for example the KBC reader has a BUY button which needs to be used.
image

Tried to get a valid code using M2 but seems that this requires something different.
Anyone who has more information about this BUY button?

parsedRAPDU: TypeError: argument of type 'bool' is not iterable

Traceback (most recent call last):
  File "/usr/local/bin/EMV-CAP", line 453, in <module>
    if 0x80 in parsedRAPDU:
TypeError: argument of type 'bool' is not iterable

the referred line is:
if 0x80 in parsedRAPDU:

This happens after upgrading my system to Debian 11.
I'm no good at python, so I'm pretty clueless...

Some more documentation

Been looking for this for some time! Is it only an emulator that fakes it or can it be used as a replacement of the EMV/CAP reader?

Want to automate the 2FA process and this would be a good start to do it right?

Also you might want to add a donation method, I'm happy to donate something if it works.

ImportError: No module named Crypto.Cipher

After upgrading my system de Debian 11 and python3, I get that error:

/usr/local/bin/EMV-CAP 
Traceback (most recent call last):
  File "/usr/local/bin/EMV-CAP", line 58, in <module>
    from EMVCAPfoo  import *
  File "/usr/local/lib/python2.7/dist-packages/EMVCAPfoo.py", line 2, in <module>
    from EMVCAPcore import hex2lint
  File "/usr/local/lib/python2.7/dist-packages/EMVCAPcore.py", line 2, in <module>
    from Crypto.Cipher import DES
ImportError: No module named Crypto.Cipher

even after installing pycrypto:

pip install pycrypto
Collecting pycrypto
  Downloading pycrypto-2.6.1.tar.gz (446 kB)
     |████████████████████████████████| 446 kB 4.4 MB/s 
Building wheels for collected packages: pycrypto
  Building wheel for pycrypto (setup.py) ... done
  Created wheel for pycrypto: filename=pycrypto-2.6.1-cp39-cp39-linux_x86_64.whl size=526405 sha256=2e1d3d539ed972aa772c15d39ad8d30229fdbdeae2cd70f28623663ed50ff060
  Stored in directory: /root/.cache/pip/wheels/9d/29/32/8b8f22481bec8b0fbe7087927336ec167faff2ed9db849448f
Successfully built pycrypto
Installing collected packages: pycrypto
Successfully installed pycrypto-2.6.1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.