Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Deobfuscate code from vim

by nferraz (Monk)
on Aug 28, 2008 at 09:53 UTC ( #707431=note: print w/ replies, xml ) Need Help??


in reply to .vimrc for perl programmers

Here's a small trick to deobfuscate code directly from vim, using B::Deparse. All you have to do is to put this in your vimrc:

" Deparse obfuscated code nnoremap <silent> _d :.!perl -MO=Deparse 2>/dev/null<cr> vnoremap <silent> _d :!perl -MO=Deparse 2>/dev/null<cr>
Now, whenever you want to deparse a portion of the code, just press _d. For example, this line:
--$|&&s|\n|-|;
Magically becomes:
s/\n/-/ if --$|;
I find this particularly useful when I have to work with code that abuses Perl's TIMTOWTDIness:
$foo and $bar or $baz = 1;
(Now imagine a three-lines long statement where the attribution comes at the end.) Using B::Deparse, the code becomes more legible:
$baz = 1 unless $foo and $bar;
Unfortunatelly, B::Deparse has it own limitations; but I think this technique can be really useful in some situations.


Comment on Deobfuscate code from vim
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://707431]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (7)
As of 2014-08-21 22:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (144 votes), past polls