Re: Code hiding in Perl
by Anonymous Monk on Jun 26, 2015 at 07:27 UTC
|
..hide code...Now I need your thoughts/suggestions/criticism for the below mentioned approach....I will be very happy to receive your valuable feedback/suggestions on this approach. Thanks in advance.
Comment on Co.. See all the previous discussions, they all apply , your scheme is old :) if a user can run it he can decode it See ?node_id=3989;HIT=hide, ?node_id=3989;HIT=hide+code...
| [reply] |
|
I have gone through many such threads but didn't find any solution/approach which talks about modification of default interpreter to execute (in-memory, hence can't be seen) a password protected encrypted code .. I would like to know how will they decode it?
| [reply] |
|
| [reply] [d/l] [select] |
|
|
|
Re: Code hiding in Perl
by Anonymous Monk on Jun 26, 2015 at 08:35 UTC
|
You haven't shown any code or explained the details of your obfuscation scheme, and you say your code works, so what kind of feedback are you looking for? On the general approach you've already said a central point yourself:
it's almost impossible to completely secure the code from "too curious" eyes
Yes, knowledgeable people will still be able to get the source of the program, all obfuscation does is make it a little bit more difficult.
| [reply] |
|
perl_run(my_perl);
eval_pv(buffer, TRUE);
| [reply] [d/l] |
|
The encryption is done through custom C executable and the execution of encrypted binary code can only be done through another C executable (dummy Perl interpreter) and it does in-memory execution like this.
perl_run(my_perl);
eval_pv(buffer, TRUE);
Easily broken:
- start a debugger
- load the "encrypted" program from the debugger
- set a breakpoint at the call to eval_pv(), or at the first instruction of eval_pv()
- start the program
- instruct the debugger to show the contents of buffer
- copy contents of buffer to a text file
- kill the program
- exit the debugger
It was explained a thousand times or more, but once more for you:
Perl is designed to evaluate unencrypted source code, so at some point, you have to decrypt the encrypted code. Alternatively, you can feed perl a prepared parse tree, in unencrypted form. Again, you have to decrypt the encrypted tree before passing it to perl. B::Deparse can reconstruct perl source code from the tree, so you gain exactly nothing from using a tree.
Both ways, you have to decrypt the encrypted data, so your executable must contain the decryption algorithm and the required decryption key. Both can be exctracted from the executable to create an independant decryption tool. Or, as I explained above, one can simply stop the execution of the program at the point where the decrypted data is passed to perl API functions. That's usually much less work.
And there is NO WAY to prevent that.
See also:
Alexander
--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
| [reply] [d/l] [select] |
|
|
|
|
See overload::eval. It replaces the ENTEREVAL opcode with its own. eval_pv parses the code and then executes the ENTEREVAL opcode before running the code within the eval.
Also, if the program string exists as one large buffer in RAM, its easy to freeze the program as soon as it opens a file (for example) and then dump the memory.
| [reply] [d/l] |
Re: Code hiding in Perl
by RonW (Parson) on Jun 26, 2015 at 21:29 UTC
|
The most you can do is make it inconvenient enough to "keep honest people honest".
Your scheme might accomplish this. Your employer's legal department might be able to craft a suitable license agreement to help with this.
| [reply] |
|
| [reply] |
|
| [reply] |
|
|
Re: Code hiding in Perl
by sundialsvc4 (Abbot) on Jun 26, 2015 at 10:51 UTC
|
Echoing more-or-less the sentiments already expressed here ... it would be far better for you to find a way to trust the customer’s network, and, by extension, the customer himself. Or, at least, hire a lawyer to write you a decently bullet-resistant contract. Your alternative strategy appears to have been to install a custom modified Perl interpreter (!!) on that same customer’s “untrusted” (sic ...) corporate network, and I doubt that you can show me (or the Honorable Court) that you had written authorization from a VP-or-higher to do such a thing.
The only reason why I’d allow a third-party contractor to do such a thing is if I didn’t (yet) know he was doing it. Why is this third-party “hiding [my?] business logic” from me? “Is he setting me up for future extortion?” (I’m quite serious.)
You have concocted an elaborate technical ploy and ... like so many others who kit-bashed a pseudo-cryptographic something-or-other ... you can’t see through it nor see (or acknowledge) its faults even though, or because, others have quickly pointed them out to you. But you also don’t seem to have considered that this sort of thing could land you in a courtroom, having lost your contract, your former-client’s case, and your goodwill.
In saying this, I intend neither to be personal, nor crucifying. Merely to be coldly blunt and candid. You have, in more ways than one, stepped on ice where you should not be. Reverse your steps, carefully but quickly.
| |
Re: Code hiding in Perl
by Anonymous Monk on Jun 26, 2015 at 16:31 UTC
|
| [reply] |