def stress(reader): cardConnection = reader.createConnection() cardConnection.connect(mode=SCARD_SHARE_DIRECT, disposition=SCARD_LEAVE_CARD) get_firmware = [0x02] IOCTL_SMARTCARD_VENDOR_IFD_EXCHANGE = SCARD_CTL_CODE(1) i = 0 while True: before = time() res = cardConnection.control(IOCTL_SMARTCARD_VENDOR_IFD_EXCHANGE, get_firmware) after = time() delta = after - before print "%d Reader: %s, delta: %d" % (i, reader, delta) print "Firmware:", "".join([chr(x) for x in res]) if delta > 1: sys.stderr.write(ctime() + " %f\n" % delta) i += 1
# (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, see <http://www.gnu.org/licenses/>. from smartcard.System import readers from smartcard.pcsc.PCSCPart10 import (SCARD_SHARE_DIRECT, SCARD_LEAVE_CARD, SCARD_CTL_CODE) from smartcard.Exceptions import SmartcardException IOCTL_SMARTCARD_VENDOR_IFD_EXCHANGE = SCARD_CTL_CODE(1) def switch_interface(interface): """ switch from contact to contactless (or reverse) on a GemProx DU reader """ for reader in readers(): cardConnection = reader.createConnection() cardConnection.connect(mode=SCARD_SHARE_DIRECT, disposition=SCARD_LEAVE_CARD) switch_interface_cmd = [0x52, 0xF8, 0x04, 0x01, 0x00, interface] print("Reader:", reader, "=>", end=' ') try: res = cardConnection.control(IOCTL_SMARTCARD_VENDOR_IFD_EXCHANGE, switch_interface_cmd)