[转载]DumpHex(Dumps a binary file to hex)工具源代码
文章作者:reedarvin[at]gmail[dot]com[code]#
# DumpHex v1.0 | Reed Arvin reedarvin[at]gmail[dot]com
#
# Usage:
# DumpHex.pl <file name>
# DumpHex.pl MyBin.exe
#
#######################################################
use strict;
my($strInputFile) = $ARGV[0];
my($intByteCount) = "";
my($binBytes) = "";
my($intReadLength) = "";
if ($#ARGV ne "0")
{
print "DumpHex v1.0 | Reed Arvin reedarvin[at]gmail[dot]com\n";
print "\n";
print "Usage:\n";
print "DumpHex.pl <file name>\n";
print "DumpHex.pl MyBin.exe\n";
exit;
}
$intReadLength = 16;
if (open(INPUTFILE, "< $strInputFile"))
{
open(OUTPUTFILE, "> $strInputFile.txt");
binmode(INPUTFILE);
$intByteCount = 0;
while (read(INPUTFILE, $binBytes, $intReadLength))
{
print (OUTPUTFILE uc(unpack("H" . ($intReadLength * 2), $binBytes)), "\n");
}
close(INPUTFILE);
close(OUTPUTFILE);
}
else
{
print "ERROR! Cannot open file $strInputFile";
}
# Written by Reed Arvin reedarvin[at]gmail[dot]com[/code]
页:
[1]