当以艺术眼光看程序,寻找程序后面的原理,做到化而不忘
全部博文(57)
分类: Windows平台
2013-05-16 18:49:17
#!/usr/bin/perl
use strict;
my $FILEHANDLE;
open($FILEHANDLE,"a.dll");
binmode($FILEHANDLE);#编码转换,然后就可以当成字符串来读了,
my @array=<$FILEHANDLE>;#转化成数组,比如4550就战胜两个字节,45一个字节,50一个字节
my $FirstLine=$array[0];#这里有个问题:二进制下如何区分行呢?
if($FirstLine=~m/MZ?/)
{
print "Valid DlL file\n";
}
else
{
print "Invalid DLL File\n";
exit(1);
}
print "***************************************************\n";
my $AllInfo = join("",@array);
my $Another=$AllInfo;
$Another=~m/[A-Za-z\s]/g;
print $Another,"\n";
print "***************************************************\n";
$Another=~s/\W[\s{2,}]//g;
print $Another,"\n";
print "***************************************************\n";
#查找导出函数,导出函数前面肯定有相应的DLL的名字
if($AllInfo=~m/(sMILEDownload.dll.[A-Za-z\W]*\W\W)/ig)
{
my $tmp = $1;
print $1,"\n";
print "***************************************************\n";
$tmp=~s/\W{2,}/ /g; #连续进行两次正则表达式操作,也就是将正则表达式分开来
$tmp=~s/\W{1}/,/g; #这样在实现上更加简单
print $tmp,"\n";
print "***************************************************\n";
print "Find the Dll Name\n";
}