python判断是否为“PE文件”
来源:互联网 发布:线切割手动编程割直线 编辑:程序博客网 时间:2024/06/06 09:27
什么是PE文件?
PE文件被称为可移植的执行体是Portable Execute的全称,常见的EXE、DLL、OCX、SYS、COM都是PE文件,PE文件是微软Windows操作系统上的程序文件(可能是间接被执行,如DLL)。
怎么识别PE文件?
1、首先,PE文件一定是MZ(0x4D5A)起头的。
2、其次,3C位置的值(即如图所示E8)指向的值是PE(0x5045)
代码如下:
#coding: UTF-8import linecache,os,struct,sys#get all PE files of a directorydef readFileChar(path): try: fileHandle=open(path,"rb") data_id = struct.unpack("h",fileHandle.read(2)) return data_id[0] fileHandle.close() except Exception ,e: print e return "kkk" def getShifting(path): try: #获得0x3c地址的值,pe文件应为0x45 50 fileHandle=open(path,"rb") fileHandle.seek(60,0) data_id = struct.unpack("h",fileHandle.read(2))[0] fileHandle.close() #print data_id fileHandle=open(path,"rb") fileHandle.seek(data_id,0) pe = struct.unpack("h",fileHandle.read(2))[0] fileHandle.close() return pe except: return "kkk"if __name__=="__main__": paths=[] pePath=[] #paths:all files' paths insPath=sys.argv[1] savefile=insPath.split("\\")[-1] #cur_path=os.path.abspath(os.path.join(os.path.dirname(__file__), "%s_PEfile.txt"%savefile)) cur_path=os.path.abspath(os.path.join("c:\\", "%s_PEfile.txt"%savefile)) #print "cur_path",cur_path savefileHandle=open(cur_path,'w') #print insPath for root,dirs,files in os.walk(insPath): for file in files: paths.append(root+file) path=root+"\\"+file shifting = getShifting(path) # print "readFileChar",readFileChar(path) # print "shifting",shifting if readFileChar(path)==23117 and shifting==17744: pePath.append(file) print path,"is ----------------->pe file " savefileHandle.write(file+'\n') savefileHandle.close()
- python判断是否为“PE文件”
- 判断是否为PE文件改进版
- 判断是否为PE文件改进版
- 通过DOS头判断一个文件是否为PE文件
- 判断文件是否PE格式
- 判断文件是否非pe文件
- 判断你的文件是否为合法的PE文件和应用类型
- 判断文件是否为合法的PE文件和应用类型
- 判断你的文件是否为合法的PE文件和应用类型
- python判断文件是否存在,是否为空,然后写入
- 判断文件是否PE文件,是否GUI程序
- python判断对象是否为文件对象(file object)
- python 判断是否为函数
- 判断文件是否为图片
- 判断文件是否为Unicode
- 判断文件是否为图片
- 判断文件是否为图片
- 判断文件是否为二进制
- Windows下命令行修改IP地址DNS地址
- 关于eas bos 列表界面的忽略CU过滤
- Objective-C语法之KVO的使用
- 非递归的算法检索目录及子文件
- Windows7 64位,JDK 1.7 环境变量的设置
- python判断是否为“PE文件”
- 好代码的特点
- 我的Android进阶之旅------>Android安全退出应用程序的几种方式
- Linux下系统调用的实现
- 野指针
- 你真的搞懂Javascript了吗?(5道测试题)
- Adapter的继承结构
- Objective-C语法之KVC的使用
- 记录资源表