发新话题
打印

[转载]DumpHex(Dumps a binary file to hex)工具源代码

[转载]DumpHex(Dumps a binary file to hex)工具源代码

文章作者:reedarvin[at]gmail[dot]com
复制内容到剪贴板
代码:
#
# 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
曾几何时,有人对我说:装B遭雷劈。我说:去你妈的。于是,这个人又对我说:如果再说脏话,上帝会惩罚你的。我说:我操上帝。结论:彪悍的人生不需要上帝。

TOP

发新话题