1. 程式人生 > >把Matlab的p程式碼還原為可讀的m程式碼的可能性

把Matlab的p程式碼還原為可讀的m程式碼的可能性

背景

即使一向喜歡開源的mathworks在某些程式碼上也採取了加密方式。所以商業化軟體產品的“開源”主要還是為了商業目的,不能指望像GNU、MIT之類license一樣。有了生意才有動力寫更好的程式碼、併為潛在的bug負責。這也是矛盾。

為了檢視某個特殊的演算法,我從比較頂層的m檔案看起,一步步抽絲剝繭,終於找到的關鍵的被呼叫的程式碼檔案!不錯,它是p-code方式加密的。對演算法的探索也就到此卡住了。

於是明知不太現實而為之,想了解下p-code到底是怎麼回事,以及,逆向或者解密界目前對於p-code的還原,到底有什麼進展。

加密方式

如下連結裡有一個描述:

作者和時間:

Subject: convert .p files to .m files
From:

[email protected] (Walter Roberson)
Date: 10 Mar, 2008 17:04:04

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 like someone 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 that online 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的。

聯絡方式在這裡:

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

這裡寫圖片描述

——不過,線上的認證碼之類的破解,這似乎比p-code還要容易。加密和破解是相互依存的。只有給加密以足夠重要或者高的地位,破解才顯得更有價值。我的哲學學得還是不錯的。