Created
February 21, 2016 07:51
-
-
Save warewolf/b73657c0f24ef16e1801 to your computer and use it in GitHub Desktop.
Because malware.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/perl | |
| use strict; | |
| use warnings; | |
| use Getopt::Long qw(:config pass_through); | |
| use File::Path qw(make_path); | |
| use File::Copy; | |
| use File::Spec; | |
| my $opts = { | |
| dest => "/mnt/malware", | |
| }; | |
| GetOptions($opts,"debug"); | |
| while (my $dir = shift @ARGV) { | |
| opendir(my $dir_fh,$dir) or die "Couldn't open directory $dir for reading! ($!)"; | |
| while (my $file = readdir $dir_fh) { | |
| my ($one,$two) = ($file =~ m/^(..)(..)/); | |
| my $dest = File::Spec->catfile($opts->{dest},$one,$two); | |
| if (! -d $dest) { | |
| make_path($dest, { mode => 0755 }) or die "Couldn't mkdir $dest! ($!)"; | |
| } | |
| move(File::Spec->catfile($dir,$file),$dest); | |
| } | |
| closedir $dir_fh; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/perl | |
| die "Usage: $0 [list of files to rename]" unless scalar @ARGV; | |
| unless(fork) { | |
| pipe R,W; | |
| if (fork) { | |
| open STDOUT, ">&W"; | |
| close R; | |
| exec("sha256sum",@ARGV); | |
| } else { | |
| open STDIN, "<&R"; | |
| close W; | |
| while (<STDIN>) { | |
| my ($sha,$filename) = split(m/\s+/,$_); | |
| link($filename,$sha); | |
| unlink($filename); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment