CAPL 主动化脚本 - UDS 安全解锁 Lv1

打印 上一主题 下一主题

主题 875|帖子 875|积分 2625

一种浅显的UDS$27解锁方式,使用capl脚本去实行主动化。
利用CANoe自己的Diagnostic去诊断,返回。
首先:声明2701 2702
拿到种子后,使用diagGenerateKeyFromSeed函数去调用工程里面的DLL文件去计算。
再将计算好的密钥发送到ECU。
  1. void SecurityAccess_Lv1()
  2. {
  3.   diagRequest DCM.request Seed_1; // 27 01
  4.   diagRequest DCM.request Key_2; // 27 02
  5.   const dword Response_time = 50; // diagnostic response time
  6.   byte SeedArray[4]; // Actual Seed length
  7.   byte KeyArray[4]; // Actual key length
  8.   dword KeyActualSize; // Actual key length
  9.   int i;
  10.   
  11.   diagSendRequest(Seed_1);// send 27 01 request
  12.   if(testWaitForDiagResponse(Seed_1,Response_time)) // Waiting for 2701 response, Waiting for 2701 response, place the seed in array
  13.   {
  14.     for(i=0;i<elcount(SeedArray);i++)
  15.       {
  16.         SeedArray[i]=diagGetRespPrimitiveByte(Seed_1,i+2);
  17.         // write("%d",SeedArray[i]);
  18.       }
  19.   }
  20. /* if there is no response within the defined time, consider adding testfail function */
  21. //  else
  22. //  {
  23. //    testStepFail("");
  24. //  }
  25.   if(0==diagGenerateKeyFromSeed("ecuQualifier",SeedArray,elcount(SeedArray),1,"","",KeyArray,elcount(KeyArray),KeyActualSize))
  26.   {
  27.     // write("%d, %d, %d, %d",KeyArray[0],KeyArray[1],KeyArray[2],KeyArray[3]);
  28.     diagSetParameterRaw(Key_2,"SecurityKey",KeyArray,elcount(KeyArray)); // set 27 02 raw
  29.     diagSendRequest(Key_2); // send key to ECU
  30.   }
  31. }
复制代码
这种方式简单,可以快速的去操作。
如果想要做一个通用库,不肯定实用。

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
回复

使用道具 举报

0 个回复

正序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

九天猎人

金牌会员
这个人很懒什么都没写!
快速回复 返回顶部 返回列表