Pylabview的使用: 还原labview exe内的VI文件
pylabview 就是个帮你搞定 LabVIEW 文件的万能小助手!
它能干啥?
不用安装 LabVIEW,直接批量改文件(比如自动替换参数、修代码)。
把 LabVIEW 的奇怪二进制文件(比如 VI、CTL)变成普通人能看懂的 XML(就像把密码翻译成中文)。
救活损坏的 LabVIEW 文件(比如文件打不开时,帮你捞出有用部分)。
还能从 LabVIEW 打包好的程序(EXE)里反推出原本的代码。
为啥用它?
省时间! 不用一个个手动点鼠标,写个脚本就能自动改几千个文件。
没 LabVIEW 也能干活! 比如你公司没买 LabVIEW 的授权,照样能改文件。
兼容老古董! 支持 20 年前的 LabVIEW 6.0 到 2014 版本(对付老旧项目神器)。
谁需要它?
天天被 LabVIEW 文件折磨的程序员。
想批量改文件但懒得开 LabVIEW 的懒人(比如你)。
需要从打包的程序里扒源码的工程师。
总之,想偷懒、想批量干活、想抢救文件,就找它!
工程地址:
https://github.com/mefistotelis/pylabview/
通过网盘分享的文件:pylabview-master.zip
链接: https://pan.baidu.com/s/1GURNuTQi6v3_YTrtoap85g?pwd=cxyz 提取码: cxyz
首先电脑上安装python 3.8 以上版本, 比如我的安装的3.11版本
下载pylabview工程后, 执行 setup.py 安装和编译pylabview
我用的是电脑自带的CMD命令窗口, 所以窗口中执行 python setup.py
操作:
打开pylabview 目录, 按住 shift键的同时, 鼠标右键菜单里选择[ 打开 powershell 窗口]
python setup.py build
注意, 如果build 改为 -h , 那么可以查看对setup的帮助内容

此时, pylabview就已经编译好等待使用了.
开始破解exe
用7zip 来打开exe , 查看里面的资源


提取里面的 "2" 这个资源块到 pylabview 的 build文件夹内,

使用readRSRC.py 读取"2" 中的labview文件, 解压出bin和xml文件.
python readrsrc.py -x -i "2"

可以在文件夹中看到得到了. 2_lvzp.bin 和 2_strsh25000.bin

我们用7zip解压这个2_lvzp.bin文件, 得到demo.vi文件了.

此时用labveiw打开这个vi文件, 可以发现 程序框图 是灰色的, 不能查看程序

当然了, 编译后的exe, 会自动剔除程序框图, 需要修复后才能查看程序框图.
如果你编译工程的时候 选择了[ 启用调试 ] 功能, 那么恭喜你, 你的vi代码被别人轻易拿到了. 到这一步是可以看到源码了.
从这里开始就出问题了, 我估计是解压"2"的时候那两个 Warining 引起的.
后续需要再确认下.
本文的操作来自这里的讨论:
https://lavag.org/topic/21233-exe-back-to-buildable-project/page/3/
As you can see, the VI is in runnable state and behaves without any errors. My steps to reproduce:
1. Unpacked lvlibp with 7-Zip unarchiver (as I'm on Windows currently) and pulled out "2" file (LIBPLBVW resource).
2. Extracted the inner resource blocks with readRSRC.py -x -i "2" command, got 2.xml, 2_DATA0.bin to 2_DATA4.bin and 2_LVzp.bin files.
3. Unpacked 2_LVzp.bin with an unarchiver, got NI_Embedded_Library.xml and Untitled 1.vi files.
4. Extracted the inner resource blocks from Untitled 1.vi with readRSRC.py -x -i "Untitled 1.vi" command, got Untitled 1.xml and a bunch of various resource sections.
5. Renamed 2_DATA0.bin (from step 2) as Untitled 1_VCTP.bin and placed it near Untitled 1.xml.
6. Added the following text to the end of Untitled 1.xml (before the last </RSRC> tag):
<VCTP> <!-- VI Consolidated Types --> <Section Index="0" Format="bin" File="Untitled 1_VCTP.bin" /> </VCTP>7. Packed the .xml and all the resources into a single VI with readRSRC.py -c -m "Untitled 1.xml" command, got Untitled 1.vi.
8. Extracted the inner resource blocks from Untitled 1.vi (again!) with readRSRC.py -x -i "Untitled 1.vi" command, got Untitled 1.xml and a bunch of various resource sections (is done to get VCTP processed correctly).
9. Opened Untitled 1.xml and removed everything from <LIBN> to </LIBN> (including the tags as well) changed the library name extension from .lvlibp to .lvlib (between <LIBN></LIBN> tags). To wit, this line
<Library>Untitled Library 1.lvlibp</Library>should be turned into this
<Library>Untitled Library 1.lvlib</Library>10. Packed the .xml and all the resources into a single VI with readRSRC.py -c -m "Untitled 1.xml" command, got Untitled 1.vi.
11. Renamed NI_Embedded_Library.xml (from step 3) to Untitled Library 1.lvlib.
12. Opened Untitled Library 1.lvlib in a text editor and altered the lib URL to point to the new location. To wit, this line
<Item Name="Untitled 1.vi" Type="VI" URL="Untitled 1.vi"/>should be turned into this
<Item Name="Untitled 1.vi" Type="VI" URL="../Untitled 1.vi"/>13. Opened the VI (LabVIEW did the library reload from the new path and reported), opened .lvlib.
14. In Project Explorer untied the VI from the library w/ RMB -> Remove from Library menu option, saved the both files w/ File -> Save option.
Now the VI runs fine, so it might be a time to simplify this tutorial a little
登录后方可回帖


测试前, 我们首先自己创建个labveiw工程, 并打包生成exe. 我这里用labview2018,
注意, 高级[生成] 那里的[启用调试] 不要勾上. 默认也是不勾的.
exe准备好后, 所有的准备工作就完成了.