文件系统.txt 8.17 KB

;修改ATS历史字节
RESET 
SEND 00A4040010 486E656F730000000000000000000000
ASSERT 9000
SEND 80F2000010 4845442D484353502D41444D494E3030
ASSERT 9000
SEND FFCA0000 04

edit Hstring $UID$
edit $UID$ = g_GETSW()	
edit $UID$ = g_GETSTR ($UID$,0,4)
SEND 8012 0700 0D 0C  4D54 0081 3212 8698 $UID$ 

SEND FFCC000001 93;读ATS

RESET 
SEND 00A4040008A000000003000000
;ASSERT 6F108408A000000003000000A5049F6501FF9000

edit Hstring $HostRand$			;Host challenge
edit $HostRand$ = 1BAD288F2F19780D	
send 8050 00 00 08 $HostRand$
	edit Hstring $SWResult$			;卡片响应值
	edit Hstring $KeyDivData$		;Key diversification data 8bytes
	edit Hstring $KeyInfo$			;Key information 2bytes
	edit Hstring $SeqCNTR$			;Sequence Counter 2bytes
	edit Hstring $CardRand$			;Card challenge 6bytes
	edit Hstring $CardCrypt$		;Card cryptogram 8bytes
	edit Hstring $DerivationData$ 
	edit Hstring $SessionKey$
	edit Hstring $SCSKey$				;安全信道静态密钥
	edit Hstring $SMACKey$
	edit Hstring $SENCKey$
	edit Hstring $DESPadding$
	edit Hstring $InputData$			;要加密数据
	edit Hstring $ICV$
	edit $SWResult$ = g_GETSW()	
	watch 	$SWResult$
	edit $SeqCNTR$ = g_GETSTR($SWResult$,12,2)
	watch 	$SeqCNTR$	
	edit $CardRand$ = g_GETSTR($SWResult$,14,6)
	watch 	$CardRand$	
	edit $DerivationData$ = 0182 $SeqCNTR$ 000000000000000000000000 	
	watch $DerivationData$
	edit $SCSKey$ = 404142434445464748494A4B4C4D4E4F
	edit $ICV$ = 0000000000000000
	edit $SessionKey$ =g_TDESCBC(1 , $ICV$, $SCSKey$ , $DerivationData$)
	watch 	$SessionKey$
	edit $InputData$ = $HostRand$ $SeqCNTR$ $CardRand$ 
	watch $InputData$
	edit $ICV$ = 0000000000000000	
	edit $CardCrypt$ = g_ISO9797(1 , 2 ,$ICV$, $SessionKey$ , $InputData$)
	watch $CardCrypt$	
	watch $SWResult$	
	;host Crypt
	edit $InputData$ = $SeqCNTR$ $CardRand$ $HostRand$ 
	watch $InputData$
	;计算验证密文时ICV不需要加密
	edit Hstring $HostCrypt$
	edit $HostCrypt$ = g_ISO9797(1 , 2 ,$ICV$, $SessionKey$ , $InputData$)
	watch $HostCrypt$
	edit Hstring $CMACResult$
	edit Hstring $SMACKey$
	edit $SMACKey$ = 404142434445464748494A4B4C4D4E4F
	 watch $SMACKey$
	edit $DerivationData$ = 0101 $SeqCNTR$ 000000000000000000000000 
	watch $DerivationData$
	edit $SessionKey$ = g_TDESCBC(1 ,$ICV$,  $SMACKey$ , $DerivationData$)
	watch 	$SessionKey$
	edit $InputData$ = 8482000010$HostCrypt$
	watch $InputData$
	;Singal DES plus Final 3DES MAC
	edit $ICV$ = 0000000000000000
	edit $CMACResult$ = g_ISO9797(3 , 2 ,$ICV$, $SessionKey$ , $InputData$)
	watch $CMACResult$
	
send 8482 00 00 10 $HostCrypt$$CMACResult$
assert 9000

;###################################################################################################
;###                                删除应用和安装应用 
;###################################################################################################
;删除地利集团园区应用
SEND 80E4000012 4F10 D6C7D0C5C8DAB4B4D4B0C7F8D3A6D3C3
;ASSERT 6A88|009000

;安装地利集团园区应用
;SEND 80E60C004C 0FF168656400636974796170706C6574 10F168656400636974796170706C657401 10D6C7D0C5C8DAB4B4D4B0C7F8D3A6D3C3 0104 16C914 F2 3F00 4000 40 000000 15 31 00 00 0F03 F300 F70300 00
;ASSERT 009000
SEND 80E60C004E 0FF168656400636974796170706C6574 10F168656400636974796170706C657401 10D6C7D0C5C8DAB4B4D4B0C7F8D3A6D3C3 0104 18C916 F2 3F00 4000 40 000000 15 31 00 00 0F03 F300 F70300 F90400
ASSERT 009000

;###################################################################################################
;###                                    个人化地利集团园区应用
;###################################################################################################	
; 选择地利集团园区应用
SEND 00A4040010 D6C7D0C5C8DAB4B4D4B0C7F8D3A6D3C3
ASSERT 6F148410D6C7D0C5C8DAB4B4D4B0C7F8D3A6D3C3A5009000

;外部认证
edit Hstring $Random$
edit Hstring $DESKey$
edit Hstring $SourceData$
edit Hstring $DESResult$
edit Hstring $MACInit$

SEND 0084000008
edit  $Random$=g_GETSW()
watch $Random$
;3-DES           
edit  $DESKey$ = 00000000000000000000000000000000

edit  $Random$ = g_GETSTR($Random$,0,8)
watch $Random$
edit  $DESResult$ = g_TDES(1 , $DESKey$ , $Random$)	
watch $DESResult$
send 0082000008  $DESResult$
assert 9000

;开启快速个人化
SEND 80E5000000
ASSERT 9000

; 创建0010安全文件
SEND 80E0000B08 0010 0090 00 33 0000
ASSERT 9000
; 创建0001 Dir文件(变长记录)	明文+MAC(DCMK1)
SEND 80E000050E 0001 0050 0000 00 20 0000 0000 00 01
ASSERT 9000
; 创建0005基本信息文件(二进制文件)明文+MAC(DCMK1)
SEND 80E000030D 0005 00FA 00 00 20 0000 0000 00 01
ASSERT 9000
;创建0006保留文件(二进制文件)明文+MAC(DCMK2)
SEND 80E000030D 0006 00FA 00 00 20 0000 0000 00 02
ASSERT 9000

;****************装载密钥****************
;主控DCCK
SEND 80D40100 13 000000 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0
ASSERT 9000
;DCMK1和DCMK2
SEND 80D40010 18 0101000000000300 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF4
ASSERT 9000
SEND 80D40010 18 0102000000000300 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF4
ASSERT 9000
;DIRK1~3
SEND 80D40010 18 1C01010000000300 00000000000000000000000000000000
ASSERT 9000
SEND 80D40010 18 1C02010000000300 00000000000000000000000000000000
ASSERT 9000
SEND 80D40010 18 1C03010000000300 00000000000000000000000000000000
ASSERT 9000

;--------------------------------DF01地利在线平台应用-----------------------------
SEND 00A4000002 3F00
ASSERT 6F148410D6C7D0C5C8DAB4B4D4B0C7F8D3A6D3C3A5009000

SEND 0084000008
edit  $Random$=g_GETSW()
watch $Random$
;3-DES           
edit  $DESKey$ = FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0

edit  $Random$ = g_GETSTR($Random$,0,8)
watch $Random$
edit  $DESResult$ = g_TDES(1 , $DESKey$ , $Random$)	
watch $DESResult$
send 0082000008  $DESResult$
assert 9000

;开启快速个人化
SEND 80E5000000
ASSERT 9000

;创建DF01:地利在线平台应用
SEND 80E00002 1D DF01 07FF 00 000000 15 B9 00 01 03 B5D8C0FBD4DACFDF
ASSERT 9000

; 创建0010安全文件
SEND 80E0000B08 0010 0200 00 33 0000
;****************装载密钥****************
;主控
SEND 80D40100 13 000000 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF6
ASSERT 9000
;维护 DAMK1 DAMK2
SEND 80D40010 18 0101000000000300 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8
ASSERT 9000
SEND 80D40010 18 0102000000000300 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8
ASSERT 9000
;外部认证DEAK
SEND 80D40010 18 00010000 0000 03AA FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7
ASSERT 9000

; 创建0015卡务信息文件 读(外部认证)写(明文+MAC,DAMK1)
SEND 80E000030D 0015 00FA 00 00 20 00AA 0000 00 01
ASSERT 9000
SEND 00D69500 FA FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
ASSERT 9000
; 创建0016持卡人数据文件 读(自由)写(明文+MAC,DAMK2)
SEND 80E000030D 0016 00FA 00 00 20 0F11 0000 00 02
ASSERT 9000
SEND 00D69600 FA FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
ASSERT 9000

; 创建0019(复合)文件(明文+MAC,DAMK2)
SEND 80E000050E 0019 0119 0000 00 20 0000 0000 00 02
ASSERT 9000


;--------------------------------DF02地利扩展预留应用-----------------------------
SEND 00A4000002 3F00
ASSERT 6F148410D6C7D0C5C8DAB4B4D4B0C7F8D3A6D3C3A5009000

SEND 0084000008
edit  $Random$=g_GETSW()
watch $Random$
;3-DES           
edit  $DESKey$ = FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0

edit  $Random$ = g_GETSTR($Random$,0,8)
watch $Random$
edit  $DESResult$ = g_TDES(1 , $DESKey$ , $Random$)	
watch $DESResult$
send 0082000008  $DESResult$
assert 9000

;开启快速个人化
SEND 80E5000000
ASSERT 9000

;创建DF02:地利扩展预留应用
SEND 80E00002 1D DF02 07FF 00 000000 15 B9 00 01 03 B5D8C0FBC7AEB0FC
ASSERT 9000

; 创建0010安全文件
SEND 80E0000B08 0010 0200 00 33 0000
;****************装载密钥****************
;主控
SEND 80D40100 13 000000 88888888888888888888888888888888
ASSERT 9000