使用python中的智能卡在网站上进行身份验证 [英] Authentication on website using smart card in python

查看:189
本文介绍了使用python中的智能卡在网站上进行身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我有该公司提供的智能卡,它看起来像带有芯片的信用卡. 将卡插入读卡器后,该卡将在网站上登录.

So I have a smart card provided by the company which looks like a credit card with a chip. This card logins on a website after the card is inserted into the card reader.

现在,我必须使用python编写程序,该程序可以读取卡并使用Requests模块登录该网站. 我试图找出如何使用python脚本从卡中检索此身份验证数据,然后使用此数据,但我取得了部分成功.我安装了pyscard:

Now I have to write a program in python which can read the card and login on that website using Requests module. I tried to find out how to retrieve this authentication data from the card using python script and then use this data but I am partially successful. I installed the pyscard:

from smartcard.System import readers
from smartcard.util import toHexString

r=readers()
print(r)

connection = r[0].createConnection()
connection.connect()
SELECT = [0xA0, 0x88, 0x00, 0x00] # CLA, INS, P1, P2
DF_TELECOM = [ 0x02, 0x7F, 0x10]  # Lc, Data, Le
data, sw1, sw2 = connection.transmit( SELECT + DF_TELECOM )

到目前为止,我已经能够传输数据并从卡中检索一些数据. 我在INS (来源:ISO 7816)中发送了命令88,该命令用于某种内部身份验证(我假设此身份验证数据用于登录网站),但得到以下响应:

So far I am able to transmit data and retrieve some data from card. I sent the command 88 in INS (Source : ISO 7816) which is for some sort of internal authentication( I assume this authentication data is used to login on the website) but I get below response :

data = []
sw1 = 110
sw2 = 00

我在ISO 7816中找不到此响应的含义.有人可以告诉我我是否有正确的方法或提示从此处进一步进行操作?简而言之,我想知道如何使用python脚本和智能卡登录网站?

I couldn't find the meaning of this response in ISO 7816. Can somebody tell me whether I have the right approach or hint to proceed further from here? In short, i want to know how to login on the website using python script and smart card?

推荐答案

基本上,您得到的响应基本上是"6E00",这意味着不支持的类",只需将"INS"值替换为0x00,您应该很好

Basically, the response you're getting is essentially "6E00" which means "Class not supported", just replace the "INS" value with 0x00 and you should be fine

这篇关于使用python中的智能卡在网站上进行身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆