如何从 perlcc -B 反编译 perl 字节码? [英] how to decompile perl bytecode from perlcc -B?

查看:59
本文介绍了如何从 perlcc -B 反编译 perl 字节码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用deparse反编译字节码,然后失败了.我做了以下测试:(perl 5.8.9)

I want to decompile the bytecode with deparse, then I failed. I do the following test:(perl 5.8.9)

1) 用单行创建一个名为 t.pl 的文件

1) make a file named t.pl with single line

    print 1;

2) 编译得到plc文件

2) compile to get plc file

    $ perl -MO=Bytecode,-H,-ot.plc t.pl

3) 尝试反编译

    $ perl -MO=Deparse t.plc
    use ByteLoader 0.06;
    t.plc syntax OK

4) 使用 Concise 模块$ perl -MO=简明,-exec t.plc

4) use Concise module $ perl -MO=Concise,-exec t.plc

1  <0> enter 
2  <;> nextstate(main 174 y.pl:1) v
3  <0> pushmark s
4  <$> const(IV 1) s
5  <@> print vK
6  <@> leave[1 ref] vKP/REFC
y.plc syntax OK

with this method, we can got some valuable info, but it is hard to read.

我无法获得源代码.我在网上搜索过,它 似乎 解析模块可以解析 perlcc -B 生成的文件.

I can not get the source code. I have searched the web, it seems that Deparse module can deparse the perlcc -B produced file.

有什么想法吗?谢谢

指:

http://ask.slashdot.org/story/05/11/11/0129250/protecting-perl-code

推荐答案

这显然不起作用的原因是字节码的存储方式.Deparse 需要有一棵 OP 树,但 B::Bytecode 只是按 exec 顺序存储操作,而无需构造树.可以在 Bytecode.pm 构建 op 树之后线程化它,方法是处理 PL_main_rootPL_main_start 指针,然后在它们上调用 newPROG.

The reason this doesn't work the obvious way is because of how Bytecode is stored. Deparse needs there to be a tree of OPs, but B::Bytecode just stores the ops in exec order without constructing the tree. It's possible to thread the op tree after Bytecode.pm constructs it, by messing about with the PL_main_root and PL_main_start pointers and then calling newPROG on them.

简而言之,它可以完成,但不能使用标准工具.您必须编写一些东西才能做到这一点,而这需要对 Perl 胆量有所了解.

In short, it can be done, but not with the standard tools. You'd have to write a something to do it, and that would require a bit of a knowledge of the Perl guts.

这篇关于如何从 perlcc -B 反编译 perl 字节码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆