Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
MD5 Checksum Perl Script
#1


Here is a little perl script that I coded for simplicity in checking the MD5 sum for a specific file using the checksum method. MD5 is a good way to look for any file modifications if you have the MD5 of the original version of the file, and you see a different string in the file after checking it again.

I use this for checking the MD5 hash of a file that is available for download on a forum. Lots of people submit entries from virustotal or someplace else, which includes an MD5 hash string. If you notice a change in that MD5 you could assume that the original file they have scanned with virustotal has been replaced or modified which should raise some awareness to the downloader, since it may be an attempt to give you a virus of some sort Smile

MD5 is a 128 bit value as well, just for some extra information.

Code:
#!/usr/bin/env perl

# This perl script generates MD5 Checksums

use strict;
use IO::File;
use Getopt::Long;
use Digest::MD5;

print "\n";
print "##########################################################\n";
print "#                                                        #\n";
print "#             Coded by Infinity ~ MD5 Checker              #\n";
print "#                     [MD5 Checksum]                     #\n";
print "#--------------------------------------------------------#\n";
print "##########################################################\n";
print "#                                                        #\n";
print "#         Usage: md5_check.pl filename.extention         #\n";
print "#             Example: md5_check.pl image.jpg            #\n";
print "#                                                        #\n";
print "#       Note - Use in same directory of the file         #\n";
print "#                    You want to check                   #\n";
print "#                                                        #\n";
print "##########################################################\n";
print "\n";

my $File = $ARGV[0];
my $md5 = Digest::MD5->new;
my $check = 1;

open(FILE, $File) or die "Error: Could not open $File for MD5 checksum, please refer to the usage...";
binmode(FILE);
my $md5sum = $md5->addfile(*FILE)->hexdigest;
close FILE;

print "\n";
print "Finished MD5 Checksum for $File:\n";
print "$md5sum\n";
print "\n";

save as whatever you want, I named mine md5_check.pl just so that I have an idea what the script does just by looking at the filename. I have lots of perl scripts that i've coded overtime so I would suggest you name them with appropriate titles as well so you know which is which Smile

if you name it as something say md5.pl then ignore the usage that i've put in the "print" that gets displayed that says you have to use md5_check.pl. Should be common sense.

Put the perl file in the same directory as the file you want to find the MD5 hash of, and run in cmd prompt.

Enjoy Blackhat
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Compile Error in Perl liveproject101 0 1,303 04-12-2013, 03:08 AM
Last Post: liveproject101
  [Perl] IRC Bot wchar_t 26 14,577 08-20-2012, 01:40 PM
Last Post: Trump
  Perl Ebook ven0m 2 1,826 05-04-2012, 08:14 AM
Last Post: ven0m
  Help with a program written in perl Rodman42866 1 1,686 03-09-2012, 03:16 AM
Last Post: AceInfinity
  HTML perl script AceInfinity 5 2,725 12-03-2011, 11:35 PM
Last Post: Closed Account

Forum Jump:


Users browsing this thread: 1 Guest(s)