【问题标题】:Decrypt 3DES DUKPT per the ANSI X9.24 part 1 standard根据 ANSI X9.24 第 1 部分标准解密 3DES DUKPT
【发布时间】:2016-09-13 21:00:35
【问题描述】:

我有一个 Magtek uDynamo,正在尝试解密轨道 1。我已阅读以下内容并了解一点,但不知道如何实际解密数据。供应商说要使用 ANSI 测试密钥来解密,但我找不到任何东西。我有 KSN、会话和序列号。我也尝试了一些我发现的 Java 代码,但它似乎不起作用。它返回 null 或者我可能输入了错误的 BDK。我只是使用我在某处读到的序列号。我在安卓上做这个。最好我希望代码在服务器上而不是在设备上运行,以便它与 HTTPS 一起通过线路加密。

How ciphertext was generated in card reader using DUKPT encryption?

3DES-DUKPT (CBC) decryption confirmation

https://github.com/yinheli/dukpt/blob/master/src/main/java/com/yinheli/tool/DukptDecrypt.java

更新 我希望根据 ANSI X9.24 第 1 部分标准解密 3DES DUKPT

我正在使用这个https://github.com/camcima/dukpt-php/tree/e8fceb4df8757e7e097c435221b4e93e097d3c9f

我必须更新文件并确保我获得了最新的 phpseclib 并且它可以运行,但是数据会像 C���������4A�fr���(Wb����� �f�7z�n:�w�9��,��f7�,m=z�CRW�

我一定错过了什么。我尝试了不同的模式,并且正在尝试寻找编码。如果您有解决方案或想法,请告诉我。他们的测试数据也确实有效,所以我不确定我的和他们的有什么区别

我在根目录下运行 index.php 的代码:

include 'vendor/autoload.php';

use DUKPT\DerivedKey;
use DUKPT\KeySerialNumber;
use DUKPT\Utility;

$encryptedHexData = 'de8bfe769dca885cf3cc312135fe2cccfacf176235f4bdee773d1865334315ed2aefcab613f1884b5d63051703d5a0e2bd5d1988eeabe641bd5d1988eeabe641';
$ksn = '00000232100117e00027';
$bdk = '0123456789ABCDEFFEDCBA9876543210';

$key = new KeySerialNumber($ksn);
$encryptionKey = DerivedKey::calculateDataEncryptionRequestKey($key, $bdk);
$actual = Utility::hex2bin(Utility::removePadding(Utility::tripleDesDecrypt($encryptedHexData, $encryptionKey, true)));


echo $encryptionKey.'<br />';

echo $actual.'<br /><br />';

【问题讨论】:

  • This blog entry 过去曾帮助过我。
  • 我刚试过这个57f4dad48e7a4f7cd171c654226feb5a.proxysheep.com/questions/…,但是你如何从中得到信用卡号码,谢谢
  • 你现在指的是如何通过track1? Track1 在此 wiki 中进行了描述
  • 我有 bdk 和 ksn 和 track1,我如何从中获取 CC 号码,谢谢
  • 如果您有使用 DUKPT 密钥加密形式的 track1,请查看我链接的博客。这不是一个简单的过程,但该博客非常准确并提供了一个工作示例。当您拥有清晰的轨道数据时,使用 wiki 描述从中抄送编号相当简单。

标签: encryption cryptography credit-card 3des dukpt


【解决方案1】:

有了合适的 BDK 和 KSN,您现在需要做的就是尝试不同的模式。

现在你正在使用DerivedKey::calculateDataEncryptionRequestKey($key, $bdk);

您需要尝试其他模式才能确定您的设备正在使用哪种模式。这是我用来为我的设备找到正确结果的代码。

include 'vendor/autoload.php';

use DUKPT\DerivedKey;
use DUKPT\KeySerialNumber;
use DUKPT\Utility;

$encryptedHexData = 'C25C1D1197D31CAA87285D59A892047426D9182EC11353C051ADD6D0F072A6CB3436560B3071FC1FD11D9F7E74886742D9BEE0CFD1EA1064C213BB55278B2F12';
$ksn = 'FFFF9876543210E00008';
$bdk = '0123456789ABCDEFFEDCBA9876543210';

$key = new KeySerialNumber($ksn);

$encryptionKey = DerivedKey::calculatePinEncryptionKey($key, $bdk);
$decryptedOutput = Utility::hex2bin(Utility::tripleDesDecrypt($encryptedHexData, $encryptionKey, true));
echo '<br /><br />Pin Encryption Key: '.$encryptionKey;
echo '<br />Decrypted Output: '.$decryptedOutput;

$encryptionKey = DerivedKey::calculateMacRequestKey($key, $bdk);
$decryptedOutput = Utility::hex2bin(Utility::tripleDesDecrypt($encryptedHexData, $encryptionKey, true));
echo '<br /><br />Mac Request Key: '.$encryptionKey;
echo '<br />Decrypted Output: '.$decryptedOutput;

$encryptionKey = DerivedKey::calculateMacResponseKey($key, $bdk);
$decryptedOutput = Utility::hex2bin(Utility::tripleDesDecrypt($encryptedHexData, $encryptionKey, true));
echo '<br /><br />Mac Response Key: '.$encryptionKey;
echo '<br />Decrypted Output: '.$decryptedOutput;

$encryptionKey = DerivedKey::calculateDataEncryptionRequestKey($key, $bdk);
$decryptedOutput = Utility::hex2bin(Utility::tripleDesDecrypt($encryptedHexData, $encryptionKey, true));
echo '<br /><br />Data Encryption Request Key: '.$encryptionKey;
echo '<br />Decrypted Output: '.$decryptedOutput;

$encryptionKey = DerivedKey::calculateDataEncryptionResponseKey($key, $bdk);
$decryptedOutput = Utility::hex2bin(Utility::tripleDesDecrypt($encryptedHexData, $encryptionKey, true));
echo '<br /><br />Data Encryption Response Key: '.$encryptionKey;
echo '<br />Decrypted Output: '.$decryptedOutput;

所以对于这个 BDK 和 KSN,下面是结果输出。

Pin Encryption Key: 27F66D5244FF621EAA6F6120EDEB427F
Decrypted Output: %B5452300551227189^HOGAN/PAUL ^08043210000000725000000?

Mac Request Key: 27F66D5244FF9DE1AA6F6120EDEBBD80
Decrypted Output: W����U�P�TfB/`����þ&��f��3y;�U�Zy��UK�[��s�;�>�[�b

Mac Response Key: 27F66D52BBFF62E1AA6F612012EB4280
Decrypted Output: b�K2a�S0��9�Mb-����*L�J���� ��s�\���H�����=���e�]�,���Hwq�

Data Encryption Request Key: C39B2778B058AC376FB18DC906F75CBA
Decrypted Output: RA]�ԅⱰQ���'v}b��h��St�����?� lu/�ٵ�P��!���6�� �

Data Encryption Response Key: 846E267CB822197406DA2B161191C6E4
Decrypted Output: ��,�B^FZ�� ςs�c���*E�4��0��ǂ}����6`-P�b�ʞ̳aصĬ�&���+��

【讨论】:

    猜你喜欢
    • 2015-11-02
    • 2014-03-03
    • 1970-01-01
    • 2012-07-29
    • 1970-01-01
    • 1970-01-01
    • 2015-05-24
    • 2016-12-22
    • 1970-01-01
    相关资源
    最近更新 更多