How to decompile perl bytecode from perlcc -B?

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

1) create a file called t.pl with one line

print 1; 

2) compile to get the plc file

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

3) try decompiling

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

4) use the compressed 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 searched the Internet, it seems that the Deparse module can filter out the created perlcc -B file.

Any idea? Thanks

means:

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

+5
source share
1 answer

The reason this doesn't work is obviously due to how Bytecode is stored. Deparse requires an OP tree, but B::Bytecode simply stores ops in exec order without building a tree. You can swap the op tree after Bytecode.pm creates it by starting with the pointers PL_main_root and PL_main_start , and then calling newPROG on them.

In short, this can be done, but not with standard tools. You will need to write something to do this, and this will require a little knowledge of Perl whales.

+1
source

Source: https://habr.com/ru/post/980098/


All Articles