How can I validate the non-encrypted files from my CTF-archive when using the MATLAB Compiler 4.0 (R14)?
2 次查看(过去 30 天)
显示 更早的评论
I am using the MATLAB Compiler 4.0 (R14) to build a standalone application, and I have included a JPG-file in my project using the following command:
mcc -m myfile.m -a flag.jpg
After deployment, when the files are extracted from the CTF archive during run-time, I would like my MATLAB file to verify that the non-encrypted files are indeed the original files and have not been tampered with.
采纳的回答
MathWorks Support Team
2011-11-18
The MATLAB Compiler encrypts MATLAB files that are contained in the CTF-archive. Other file types that are added to the CTF-archive using the MCC command's “-a” option are not encrypted.
While the MATLAB Compiler does not provide any specific functions for validating non-MATLAB files added to the CTF archive, one approach to this validation would be to compare the file size and timestamp of CTF files to corresponding values known at development time. For example:
attr = dir('flag.jpg');
if(( strcmp(attr.date,expectedDate)==0) || attr.bytes ~= expectedBytes)
error('CTF archive has been tampered with!')
end
where "expectedDate" and "expectedBytes" are values that are determined from inspecting the corresponding file at development time.
This approach should be sufficient to prevent against accidental CTF corruption, as well as simple attacks. If additional security is required, an advanced option would be to examine Java security mechanisms and use the MATLAB Java API to use this functionality from MATLAB code.
For information refer to the documentation on the MATLAB Java API. This can be accessed by navigating as follows in the 'Contents' tab of the documentation browser:
Contents -> MATLAB -> User's Guide -> External Interfaces -> Using JAVA libraries from MATLAB
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Java Package Integration 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!