判断是否是 pe 文件
#!/usr/bin/perl#$filename='D:\cs\counter-strike\hl.exe' ;
print "please insert a file name,and i will tell you it is a pe file?\n",":";
chomp ($filename=<STDIN>);
open CDFD , '<' ,$filename or die $!;
read CDFD,$dir,400;
$mzdos=substr $dir,0,2;
if($mzdos ge 'MZ')
{
#print $dir,"\n";
$elname=substr $dir,60,4;
$elname=unpack "l",$elname;
#print $elname,"\n";
$peHEAD=substr $dir,$elname-1,4;
if($peHEAD ge "PE"){
print "this is a pe file\n";
}
else{
print "NO";
exit 0;
}
}
else{
print "NO";
exit 1;
}