Open Smart Card Shell Test on dump.js

本文介绍如何利用OpenSmartCardShell工具及其提供的SmartCardShell脚本环境读取信用卡的基本信息。通过运行特定的JavaScript脚本,可以实现从一张过期的信用卡中提取应用标识符(AID)、应用标签等数据,并展示如何使用EMV TLV解码器分析读取到的数据。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Summary

Tested with Open Smart Card Shell tool , it is part of Open Smart Card Development Platform. I used my expired credit card, executed the script dump.js, and read out the basic credit card information.

Installing the Smart Card Shell

Installation is simple, just follow the guide.
GUI

You can also use [Eclipse plug-in] to use the Smart Card Shell.
Eclipse

Use the Smart Card Shell

It is easy to use, just click “SCSH3GUI.CMD” to start the Smart Card Shell Windows GUI.

Below is the command example:

Running setup script config.js ...

Smart Card Shell Scripting Engine (scdp4j) 3.13.220
----------------------------------------------------------------------------
(c) 2005-2016 CardContact Systems GmbH, Minden, Germany (www.cardcontact.de)
Enter 'help' for a command overview or 'quit' to close the shell

>r
0000  3B 69 00 00 80 65 A2 01 01 01 3D 72 D6           ;i...e....=r.

TS  : 3B  Direct logic
TO  : 69  K    =     9 byte [historical characters]
TB1 : 00  pa   =     4 %    [programming voltage accurancy]
          I    =    25 mA   [maximum current]
          P    =     0 V    [programming voltage]
TC1 : 00  N    =     0 etu  [extra guardtime]
Pre-issuing data       : A20101013D ¢...=
Error: Compact TLV length field exceeds historical bytes - truncated
Card capabilities      :
    DF selection by full DF name
    DF selection by partial DF name
    DF selection by file identifier
    Short EF identifier supported
    Record number supported

>help
q | quit                 Quit shell
r | reset                Reset card in reader
a | apdu(string)         Send APDU to card
print(string, ..)        Print string(s)
load(file)               Load and execute file
assert(expression, ..)   Assert that expressions are all true
defineClass(file)        Load Java class defining native objects
restart                  Restart shell (clears all variables)

or any other valid ECMAScript expression.
See doc/index.html for the complete documentation.

If this is the first time you use the Smart Card Shell and you want
to try it out, then insert a card into your reader and enter
 load("tools/explore.js")
>apdu('00A4000400')
Card error SW1/SW2=6b00 - Checking error: Wrong parameter P1-P2

>apdu('00A4040000')
6F 65 84 08 A0 00 00 00 03 00 00 00 A5 59 73 4A 06 07 2A 86 48 86 FC 6B 01 60 0C 06 0A 2A 86 48 86 FC 6B 02 02 01 01 63 09 06 07 2A 86 48 86 FC 6B 03 64 0B 06 09 2A 86 48 86 FC 6B 04 02 55 65 0B 06 09 2B 85 10 86 48 64 02 01 03 66 0C 06 0A 2B 06 01 04 01 2A 02 6E 01 02 9F 6E 06 19 81 22 02 01 00 9F 65 01 FF
>

To run the js script, you just need use load command, example:
load('emv/dump.js')

Test on dump.js

Used my expired Citibank credit card.
Credit Card

Used Omnikey 5321v2 reader.
Card Reader

dump.js shell test result

>load('emv/dump.js')
AIDA0 00 00 00 03 10 10
0000  83 02 02 76                                      ...v

<-----Read application data as indicated in the Application File Locator.------
---------------------Collect input to data authentication.--------------------->
Record No. 2
0000  70 4D 57 13 41 47 46 30 66 66 66 66 D1 70 82 01  pMW.AGF0.c(H.p..
0010  00 00 03 66 10 00 0F 5F 20 1A 58 49 4F 4E 47 20  ...&..._ .XIONG 
0020  48 55 49 4C 49 4E 20 20 20 20 20 20 20 20 20 20  HUILIN          
0030  20 20 20 20 9F 1F 18 30 30 30 30 30 30 30 30 30      ...000000000

Record No. 1
0000  70 81 B3 90 81 B0 67 51 D5 FE 44 74 C7 A7 F9 1D  p.....gQ..Dt....

//below raw date was deleted...
...
//above raw date was deleted...

------------------------------------------------------------------------------>
<----------------------------Display Data Elements----------------------------->

Application Identifier (AID) - card: A0000000031010

Application Label: 5649534120435245444954 - VISA CREDIT


Track 2 Equivalent Data (Magnetic Strip): 
  Primary Account Number: 4147463066666666
  Expiration Date (YYMM): 1705
  Service Code: 201
  Discretionary Data: 0000066660000


//below data element was deleted...
...
//above data element was deleted...

------------------------------------------------------------------------------>

>

EMV TLV Decoder

You can trace the log, and use EMV TLV Decoder to analyze the data, example as below,

00B20314F2
7081EF8F01089224CCE4335A1A3CD7E4271A50B8D804D95ABA4E349811244D73336D196A6D969F25025B27D99F3201039F4681B025EBB698F660FB9E177F4A611E2FD4AB4C14A86A159E8838D10B6E47C99956D78C2E04C870F525227ABAA8D46BFE09CF46A372CD6FEBF8B59CA22FC646B6B38C1A061A5AF1E4D7556303EA5F7924C519D6D5EA5E10A25B6F9A4F4421081F4E9C7865F7ADEC183D39489C0B4A34E947C2D535426A7545EF4A2B9BF3A19DC1A07252F70A63E7A94A85C46FD55AFDB2348C402FA53905123A97A161F07D8E712576DCC15E92A10E93E504804E09629048AE9F4701039F49039F37049F4A01829000

70 EMV Proprietary Template
    8F Certification Authority Public Key Index
        08
    92 Issuer Public Key Remainder
        CCE4335A1A3CD7E4271A50B8D804D95ABA4E349811244D73336D196A6D969F25025B27D9
    9F32 Issuer Public Key Exponent
        03
    9F46 Integrated Circuit Card (ICC) Public Key Certificate
        25EBB698F660FB9E177F4A611E2FD4AB4C14A86A159E8838D10B6E47C99956D78C2E04C870F525227ABAA8D46BFE09CF46A372CD6FEBF8B59CA22FC646B6B38C1A061A5AF1E4D7556303EA5F7924C519D6D5EA5E10A25B6F9A4F4421081F4E9C7865F7ADEC183D39489C0B4A34E947C2D535426A7545EF4A2B9BF3A19DC1A07252F70A63E7A94A85C46FD55AFDB2348C402FA53905123A97A161F07D8E712576DCC15E92A10E93E504804E09629048AE
    9F47 Integrated Circuit Card (ICC) Public Key Exponent
        03
    9F49 Dynamic Data Authentication Data Object List (DDOL)
        9F3704
    9F4A Static Data Authentication Tag List
        82

About the source code

It may not be easy to debug the source code, I use the print function to print out the intermediate data, as below read out application data example shows.

It read out Application Interchange Profile (AIP) and the Application File Locator (AFL). For detail, can refer to EMV_v4.3_Book_3_Application_Specification.

The APDU command example is as below,

80A800000483020276
6114
80C0000014
80127C00080202001001010010030400180102019000

The GET PROCESSING OPTIONS command initiates the transaction within the
ICC.
The ICC returns the Application Interchange Profile (AIP) and the Application
File Locator (AFL).

The source code is as below,

/**
 * Read application data as indicated in the Application File Locator.
 * Collect input to data authentication.
 *
 */
EMV.prototype.readApplData = function() {
    print("<-----Read application data as indicated in the Application File Locator.------");
    print("---------------------Collect input to data authentication.---------------------");
    // Application File Locator must exist
    assert(typeof(this.cardDE[EMV.AFL]) != "undefined");
    var afl = this.cardDE[EMV.AFL];

    //print("4444444444 " + afl);  //08 02 02 00 10 01 01 00 10 03 04 00 18 01 02 01
    // Must be a multiple of 4
    assert((afl.length & 0x03) == 0);

    // Collect input to data authentication 
    var da = new ByteBuffer();

    while(afl.length > 0) {
        var sfi = afl.byteAt(0) >> 3;   // Short file identifier
        var srec = afl.byteAt(1);   // Start record
        var erec = afl.byteAt(2);   // End record
        var dar = afl.byteAt(3);    // Number of records included in data authentication

    //print("4444444444 " + sfi + " " + srec + " " + erec+ " " +dar);

        for (; srec <= erec; srec++) {
            // Read all indicated records
            var data = this.readRecord(sfi, srec);
            print("Record No. " + srec);
            print(data);

            // Decode template
            var tl = new TLVList(data, TLV.EMV);

            //print("55555555 " + TLV.EMV + " 666 " + data);

            assert(tl.length == 1);
            var t = tl.index(0);
            assert(t.getTag() == EMV.TEMPLATE);

            // Add data authentication input            
            if (dar > 0) {
                if (sfi <= 10) {    // Only value
                    da.append(t.getValue());
                    //print("5555555 " + t.getValue());
                } else {        // Full template
                    da.append(data);
                    //print("6666666 " + data);
                }
                dar--;
            }

            // Add card based data elements to internal list
            var tl = new TLVList(t.getValue(), TLV.EMV);
            this.addCardDEFromList(tl);
        }

        // Continue with next entry in AFL
        afl = afl.bytes(4);
    }
    this.daInput = da.toByteString();
    print(this.daInput);
    print("------------------------------------------------------------------------------>\n");
}

Reference

EMV TLV Decoder https://www.emvlab.org/tlvutils/
Open Smart Card Shell
dump.js source code
https://github.com/CardContact/OpenSC
CardContact Github
Open Smart Card Development Platform
Installing the Smart Card Shell
The Smart Card Scripting Environment for Eclipse (SSE4E)
EMV_v4.3_Book_3_Application_Specification


<think>我们正在处理用户关于ADB指令的询问。用户希望了解每个指令的具体作用和功能,特别是以下指令:adbroot,setenforce,setpropvendor.debug.camera.dump.en,setpropvendor.debug.feature.forceEnableIMGO,setpropvendor.debug.camera.dump.p1.imgo,以及其他与相机调试相关的属性设置。根据提供的引用,我们可以总结如下:1.adbroot:以root权限重新启动adb守护进程,使得后续的adb命令可以以root权限执行(需要设备已root或userdebug版本)[^4]。2.setenforce:用于设置SELinux(安全增强型Linux)的执行模式。0表示Permissive(宽容模式,只记录不阻止),1表示Enforcing(强制模式)[^1]。3.setprop:用于设置系统属性。其格式为`setprop<属性名><值>`。针对相机调试的特定属性(通常以vendor.debug开头):-vendor.debug.camera.dump.en:设置为1表示启用相机dump功能(即保存相机数据到文件)[^1]。-vendor.debug.feature.forceEnableIMGO:设置为1表示强制启用IMGO(可能是某种图像输出格式)[^1]。-vendor.debug.camera.dump.p1.imgo:设置为1表示dumpP1Node输出的IMGO图像(P1Node可能是相机流水线中的一个节点)[^1]。-persist.vendor.mtk.camera.log_level:设置相机日志的级别,例如设置为3可能表示DEBUG级别(具体级别定义需看代码)[^2]。另外,引用中还提到了其他调试属性,如:-debug.hwui.show_dirty_regions:用于图形渲染调试,设置为true可显示脏区域(即需要重绘的区域)[^3]。-debug.hwui.render_dirty_regions:设置为true可渲染脏区域(可能以不同颜色标记)[^3]。用户的问题中列出的指令序列通常是用于开启相机调试和dump图像数据,以便分析相机问题。现在,我们按照用户要求,用清晰的结构解释每个指令的功能。注意:由于这些属性(尤其是vendor.debug.*)是设备厂商特定的,不同厂商可能有不同的属性名称和含义。这里以MTK平台为例(根据引用[2]提到MTK)。我们将逐一解释用户提到的指令:-adbroot:获取root权限(如果设备允许)-adbshell:进入设备的shell环境,或者直接执行shell命令-setenforce0:关闭SELinux的强制模式,以便进行一些调试操作(因为SELinux可能会阻止调试操作)-setpropvendor.debug.camera.dump.en1:开启相机dump总开关-setpropvendor.debug.feature.forceEnableIMGO1:强制启用IMGO(可能是相机硬件输出的一种RAW格式)-setpropvendor.debug.camera.dump.p1.imgo1:指定dumpIMGO图像此外,用户还提到`p2f`,但在引用中未出现,可能是`vendor.debug.camera.dump.p2f`之类的属性?但引用中没有直接提到。我们只能根据已有引用解释。我们还可以参考引用[2]中关于打开user版本相机LOGD的命令:adbshellsetproppersist.vendor.mtk.camera.log_level3这个命令设置MTK相机的日志级别为3(通常3对应DEBUG级别,但具体数值需要看具体实现)。因此,我们可以组织回答如下:</think>### ADB指令功能详解 以下是您查询的ADB指令具体作用和功能说明: #### 1. `adb root` - **作用**:以root权限重启ADB守护进程 - **功能**:获取设备的超级用户权限(需设备已解锁root) - **限制**:在user版本设备上通常无法直接使用,需要特殊修改系统[^4] - **示例**:`adb root` → 显示`restarting adbd as root` #### 2. `setenforce` - **作用**:设置SELinux安全策略的执行模式 - **参数**: - `0`:宽容模式(Permissive),仅记录不拦截违规行为 - `1`:强制模式(Enforcing),严格执行安全策略 - **使用场景**:调试时临时关闭SELinux限制[^1] - **示例**:`adb shell setenforce 0` #### 3. `setprop` - **作用**:动态修改Android系统属性值 - **语法**:`setprop <属性名> <值>` - **特性**: - 属性变更立即生效 - 重启后失效(除非使用`persist.`前缀的属性) #### 4. 相机调试属性组 | 属性名称 | 值 | 功能 | 引用 | |---------|----|------|------| | `vendor.debug.camera.dump.en` | 1 | 启用相机数据转储总开关 | [^1] | | `vendor.debug.feature.forceEnableIMGO` | 1 | 强制启用IMGO图像输出格式 | [^1] | | `vendor.debug.camera.dump.p1.imgo` | 1 | 开启P1Node的IMGO数据转储 | [^1] | | `persist.vendor.mtk.camera.log_level` | 3 | 设置MTK相机日志级别 | [^2] | #### 5. 其他相关指令 - `adb shell pkill camera*`:强制重启相机服务进程[^2] - `debug.hwui.show_dirty_regions true`:显示UI脏区域(界面刷新分析)[^3] - `adb shell`:进入设备Linux shell环境执行命令 ### 工作原理说明 1. **调试流程**: ```mermaid graph LR A[adb root] --> B[setenforce 0] B --> C[设置相机属性] C --> D[触发相机操作] D --> E[查看/data/vendor/camera_dump] ``` 2. **数据存储**: - 转储文件保存在`/data/vendor/camera_dump`目录[^1] - 需要root权限或调试版系统才能访问 3. **安全限制**: - User版本设备通常需要修改SELinux策略和adb守护进程[^4] - 生产环境默认禁用调试属性 > **注意**:相机相关属性名称可能因芯片平台(MTK/QCOM)和设备厂商不同存在差异,建议查阅具体平台的相机HAL文档。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值