把Matlab的p代码还原为可读的m代码的可能性

来源:互联网 发布:软件测试 阶段 编辑:程序博客网 时间:2024/06/11 18:54

背景

即使一向喜欢开源的mathworks在某些代码上也采取了加密方式。所以商业化软件产品的“开源”主要还是为了商业目的,不能指望像GNU、MIT之类license一样。有了生意才有动力写更好的代码、并为潜在的bug负责。这也是矛盾。

为了查看某个特殊的算法,我从比较顶层的m文件看起,一步步抽丝剥茧,终于找到的关键的被调用的代码文件!不错,它是p-code方式加密的。对算法的探索也就到此卡住了。

于是明知不太现实而为之,想了解下p-code到底是怎么回事,以及,逆向或者解密界目前对于p-code的还原,到底有什么进展。

加密方式

如下链接里有一个描述:

作者和时间:

Subject: convert .p files to .m files
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Date: 10 Mar, 2008 17:04:04

Hrishikesh Kamthe hdkam...@mathworks.com wrote:

How can i convert pcode into mcode
Is there any way to do so.

pcode is encrypted using AES encryption, using a key only known to Mathworks, so only Mathworks could convert it back.

Possibly you could hire them to convert the code for you, but I would not expect it to be inexpensive, and they would probably want hard proofs that you had the legal right to the source code.

加密方式AES,密钥保密。

破解可能

从另外一个链接里可以看到,破解是可能的,所以p-code加密还是比二进制方式要稍微差一点点。

It seems like .p files are AES encrypted, with an unknown key, and have been since 2008 from the date of these posts.

However, as matlab itself can read those files, it needs to include the decryption algorithm and key, from where it can be reverse engineered. And it seems likesomeone has done this and produced an online .p code decryptor. Unfortunately they won’t share the code, and you need to email them to get a password to use thatonline decryptor.

So, to answer your question: Yes, it is possible, but I wasn’t able to find a decryptor that works right out of the box.
shareeditflag

answered Nov 14 ‘2016 at 7:05
Guntram Blohm

有人已经发现了破解或者逆向p-code的方法,并告诫不要用p-code加密,还制作了一个在线的破解器。当然,如果公开这么做,简直是跟mathworks过不去,所以,作者这个在线破解器的使用是需要email向其申请authorization code的。

De-PCode Online Utility
这里写图片描述

联系方式在这里:

For authorization code, please contact email: sippey#gmail.com (replace # with @)

这里写图片描述

——不过,在线的认证码之类的破解,这似乎比p-code还要容易。加密和破解是相互依存的。只有给加密以足够重要或者高的地位,破解才显得更有价值。我的哲学学得还是不错的。