Guest User

Untitled

a guest
May 25th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. use FileHandle;
  4. use strict;
  5. my $file = shift @ARGV;
  6. my $fh = new FileHandle;
  7.  
  8. my $is_infected = 0;
  9.  
  10. my $source;
  11. if ($fh->open("< $file")) {
  12. $source = join('', <$fh>);
  13. $is_infected =
  14. $source =~ s{ <html> <body><script>var source.*</body>}{}sm;
  15. $fh->close;
  16. }
  17.  
  18.  
  19. if ($is_infected) {
  20. print "$file: Infected. Now cleaning...";
  21. if ($fh->open("> $file")) {
  22. print $fh $source;
  23. $fh->close;
  24. print "OK\n";
  25. }
  26. else {
  27. print "ERROR: Could not open file for writing\n";
  28. }
  29. }
Add Comment
Please, Sign In to add comment