我要讀我的健保卡

759 views
Skip to first unread message

jidanni

unread,
Dec 4, 2012, 4:16:18 AM12/4/12
to hacking...@googlegroups.com
我很好奇,我要讀我的健保卡,看看有拿些東西。
我有 EZ100, 玉山銀行沒問題, pcsc_scan OK.
亦看過

  *  http://www.google.com.tw/search?q=讀健保卡 LINUX&ie=utf-8&oe=utf-8
  *  http://www.nhi.gov.tw/Resource/webdata/Attach_4614_1_cs_linux_solaris_910612公告.zip
  *  http://www.nhi.gov.tw/Resource/webdata/Attach_3587_1_讀卡機控制軟體說明檔正式版1.0.zip
  *  http://www.nhi.gov.tw/webdata/webdata.aspx?menu=6&menu_id=817&webdata_id=1058&WD_ID=199
  *  http://www.google.com.tw/search?q=健保卡 LINUX&ie=utf-8&oe=utf-8
  *  http://www.nhi.gov.tw/webdata/webdata.aspx?menu=6&menu_id=817&webdata_id=1041&WD_ID=199
  *  http://www.nhi.gov.tw/Resource/webdata/21719_2_健保IC卡資料上傳作業說明.pdf
  *  http://www.nhi.gov.tw/Resource/webdata/21718_2_健保IC卡存放內容.pdf
  *  http://www.nhi.gov.tw/Resource/webdata/21718_1_健保IC卡存放內容.xls
  *  http://www.google.com.tw/search?q=健保卡 格式&ie=utf-8&oe=utf-8
  *  http://www.google.com.tw/search?q=pcsc 健保卡&ie=utf-8&oe=utf-8

烏沙沙。
How can I dump the contents of 健保卡 so I can compare it with
健保IC卡存放內容.pdf or are there any better ideas?

dlin

unread,
Dec 6, 2012, 1:43:26 AM12/6/12
to hacking...@googlegroups.com
請問這要怎樣的硬體設備呢?

jidanni

unread,
Dec 6, 2012, 1:54:30 AM12/6/12
to hacking...@googlegroups.com

jidanni

unread,
Dec 6, 2012, 1:56:30 AM12/6/12
to hacking...@googlegroups.com

幸延

unread,
Dec 16, 2012, 8:22:52 AM12/16/12
to HackingThursday
# apt-get install python-pyscard




from smartcard.System import readers                                                                                        

# define the APDUs used in this script
SelectAPDU = [ 0x00, 0xA4, 0x04, 0x00, 0x10, 0xD1, 0x58, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00 ]

ReadProfileAPDU = [ 0x00, 0xca, 0x11, 0x00, 0x02, 0x00, 0x00 ]

# get all the available readers
r = readers()
print "Available readers:", r

reader = r[0]
print "Using:", reader

connection = reader.createConnection()
connection.connect()

data, sw1, sw2 = connection.transmit(SelectAPDU)
print "Select Applet: %02X %02X" % (sw1, sw2)

data, sw1, sw2 = connection.transmit(ReadProfileAPDU)
#print data
print "Command: %02X %02X" % (sw1, sw2)
print  'Card Number : %s' % ''.join(chr(i) for i in data[0:12])
print  'Name : %s' % ''.join(chr(i) for i in data[12:18])
print  'ID Number : %s' % ''.join(chr(i) for i in data[32:42])
print  'Birthday : %s' % ''.join(chr(i) for i in data[43:49])
print  'Sex : %s' % ''.join(chr(i) for i in data[49:50])
print  'Card Date : %s' % ''.join(chr(i) for i in data[51:57])

jidanni

unread,
Dec 18, 2012, 8:10:17 PM12/18/12
to hacking...@googlegroups.com
謝惟如合庫卡插著
$ /usr/share/doc/python-pyscard/examples/Examples/simple/getATR.py
CASTLES EZ100PU 00 00 3B F7 11 00 00 81 71 FE...
健保卡則無。
再以 pcsc_scan(1)
合庫卡很多東西,健保則
  Card state: Card inserted, Unresponsive card,
至於貴 program,
smartcard.Exceptions.CardConnectionException: Unable to connect with protocol: T0 or T1...

幸延

unread,
Dec 18, 2012, 8:22:00 PM12/18/12
to HackingThursday
雖然 pcsc_scan 辨認不出這張卡,可是還是可以自己讀 byte 然後解析

除了 pcscd 以外,其他存取讀卡機的程式先不要啟動,讀卡機接上電腦,插入健保卡,紅燈變綠燈後,執行 python 程式,試試看


2012/12/19 jidanni <jid...@jidanni.org>

jidanni

unread,
Dec 18, 2012, 8:38:18 PM12/18/12
to hacking...@googlegroups.com
/etc/init.d/pcscd stop 後更沒用。
恐必供逐步例,自 apt-get 起。
另我只有 CASTLES EZ100PU.

幸延

unread,
Dec 18, 2012, 8:43:36 PM12/18/12
to HackingThursday
pcscd 要啟動
# /etc/init.d/pcscd start

另外,那是 python 的程式碼
http://a0726h77.blogspot.tw/2012/12/linux-python.html

我也是用 EZ100PU 測試的 :)


幸延

unread,
Dec 18, 2012, 8:45:27 PM12/18/12
to HackingThursday
我電腦沒帶出來,不然我今晚再測試看看


2012/12/19 幸延 <a072...@gmail.com>



--
陳幸延
0963268330
a072...@gmail.com

jidanni

unread,
Dec 18, 2012, 8:59:28 PM12/18/12
to hacking...@googlegroups.com
必漏列一步,靜待結果。

jidanni

unread,
Dec 18, 2012, 9:09:27 PM12/18/12
to hacking...@googlegroups.com
或雙管齊下,
我把健保卡燒壞了,
烏白插的結果,
都有可能。

幸延

unread,
Dec 18, 2012, 9:26:45 PM12/18/12
to HackingThursday
pcsc_scan 已有辨認到讀卡機與金融卡,而健保卡部分我的也是不在 pcsc_scan 的查詢表內,硬體部分應該沒有問題

軟體部分,看 python 程式的錯誤訊息,估計是連接不上讀卡機,但不確定是版本關係或者其他,請稍等晚上再追踪

jidanni

unread,
Dec 18, 2012, 9:45:23 PM12/18/12
to hacking...@googlegroups.com
輪插多卡,僅健保卡不講話。

$ dpkg -l
ii  pcscd                 1.8.7-1
ii  python-pyscard        1.6.12.1-4
un  python-wxgtk2.8       <none>
un  systemd               <none>

希望下場非
http://www.nhi.gov.tw/webdata/webdata.aspx?menu=18&menu_id=681&webdata_id=2665&WD_ID=739

幸延

unread,
Dec 18, 2012, 9:48:55 PM12/18/12
to HackingThursday
使用 pcsc_scan 至少要有 card insert 的訊息吧 @@a


2012/12/19 jidanni <jid...@jidanni.org>

jid...@jidanni.org

unread,
Dec 18, 2012, 9:59:45 PM12/18/12
to a072...@gmail.com, hacking...@googlegroups.com
對呀有上床證明卻未做事。

Rex Tsai

unread,
Dec 19, 2012, 1:11:24 AM12/19/12
to hackingthursday
I have no problem running yan's python script. :-)
Regards
-Rex



2012/12/19 jidanni <jid...@jidanni.org>

jid...@jidanni.org

unread,
Dec 19, 2012, 1:54:52 AM12/19/12
to chih...@kalug.linux.org.tw, hacking...@googlegroups.com
好了多插幾次的確可以!
此插不行再插或可。

Available readers: ['CASTLES EZ100PU 00 00']
Using: CASTLES EZ100PU 00 00
Select Applet: 90 00
Command: 90 00
Card Number : 000051708702
Name : 友媽媽
ID Number : LP000**3838
Birthday : 010203
Sex : ?
Card Date : 040506
Alive : 仍在世

謝謝大家。

jidanni

unread,
Dec 19, 2012, 2:09:33 AM12/19/12
to hacking...@googlegroups.com, chih...@kalug.linux.org.tw
僅能讀至第57個 byte?
不過癮怎辦?

幸延

unread,
Dec 19, 2012, 2:14:03 AM12/19/12
to HackingThursday, Rex Tsai


2012/12/19 jidanni <jid...@jidanni.org>
僅能讀至第57個 byte?
不過癮怎辦?

--
http://groups.google.com/group/hackingthursday



--
陳幸延
0963268330
a072...@gmail.com

jid...@jidanni.org

unread,
Dec 19, 2012, 2:29:08 AM12/19/12
to a072...@gmail.com, hacking...@googlegroups.com, chih...@kalug.linux.org.tw
哦「隱性」大家就玩不下去。囧。

jid...@jidanni.org

unread,
Dec 20, 2012, 1:53:42 AM12/20/12
to a072...@gmail.com, hacking...@googlegroups.com, chih...@kalug.linux.org.tw
好了,
|因涉及個人隱私問題,因此健保卡規範較為嚴僅,不只有加密問題,還需要醫師卡,透過 |
|VPN連線至健保局。因此我只從最基本的資訊得知了以下內容。 |
http://blog.roodo.com/kreall/archives/7114021.html
我看像郵局VISA卡應該差不多,真沒得玩☻
Reply all
Reply to author
Forward
0 new messages