I want to decompile the bytecode with deparse, then I failed. I do the following test:(perl 5.8.9)
1) make a file named t.pl with single line
print 1;
2) compile to get plc file
$ perl -MO=Bytecode,-H,-ot.plc t.pl
3) try to decompile
$ perl -MO=Deparse t.plc
use ByteLoader 0.06;
t.plc syntax OK
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.
I can not get the source code. I have searched the web, it seems that Deparse module can deparse the perlcc -B
produced file.
Any idea? Thanks
refers:
http://ask.slashdot.org/story/05/11/11/0129250/protecting-perl-code
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With