博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
python 判断Dll是32位还是64位
阅读量:6690 次
发布时间:2019-06-25

本文共 4974 字,大约阅读时间需要 16 分钟。

hot3.png

#_*_coding:gb2312_*_#########################Writer:Write by lhsbqb##Date:2012-07-16       #########################import sysclass GetDllBit:    def __init__(self, dll_name=""):        if len(sys.argv) == 2: #获取DLL软件名            #print sys.argv[1].decode('gb2312')            self.dll_name = sys.argv[1]            self.Oper()        elif dll_name:            self.dll_name = dll_name            self.Oper()        else:            print "Error, Please input only one dll file name."                            def Oper(self): #总操作 获取pe标志 找到pe入口         f = open(self.dll_name, "rb").read(80)        s1 = f[60:61] #低位        s2 = f[61:62] #高位                self.CheckDll(self.Convert(hex(ord(s1))),self.Convert_H(hex(ord(s2))))    def CheckDll(self, one, two): #判断DLL是多少位        res_num = int(one) + int(two) + 6        f = open(self.dll_name, "rb").read(res_num)        for c in f[res_num-2:res_num-1]:            #print("f[res_num-2:res_num-1]",hex(ord(c)))            s_1 = hex(ord(c))                    for c in f[res_num-1:res_num]:            #print("f[res_num-1:res_num]",hex(ord(c)))            s_2 = hex(ord(c))        if s_1 == "0x4c" and s_2 == "0x1":            print("This program run in 32bit system!")        elif s_1 == "0x64" and s_2 == "0x86":            print("This program run in 64bit system!")        else:            print("Error!"+s_1+s_2)                                #print("res_num",res_num)                                def Convert(self, ss): #低位 进行编码转换        if len(ss) == 3:            if ss[-1] == "a" or ss[-1] == "A":                ss = 10            elif ss[-1] == "b" or ss[-1] == "B":                ss = 11            elif ss[-1] == "c" or ss[-1] == "C":                ss = 12            elif ss[-1] == "d" or ss[-1] == "D":                ss = 13            elif ss[-1] == "e" or ss[-1] == "E":                ss = 14            elif ss[-1] == "f" or ss[-1] == "F":                ss = 15            else:                ss = int(ss[-1])        elif len(ss) == 4:            if ss[-1] == "a" or ss[-1] == "A":                ss1 = 10            elif ss[-1] == "b" or ss[-1] == "B":                ss1 = 11            elif ss[-1] == "c" or ss[-1] == "C":                ss1 = 12            elif ss[-1] == "d" or ss[-1] == "D":                ss1 = 13            elif ss[-1] == "e" or ss[-1] == "E":                ss1 = 14            elif ss[-1] == "f" or ss[-1] == "F":                ss1 = 15            else:                ss1 = int(ss[-1])            if ss[-2:-1] == "a" or ss[-2:-1] == "A":                ss2 = 10*16            elif ss[-2:-1] == "b" or ss[-2:-1] == "B":                ss2 = 11*16            elif ss[-2:-1] == "c" or ss[-2:-1] == "C":                ss2 = 12*16            elif ss[-2:-1] == "d" or ss[-2:-1] == "D":                ss2 = 13*16            elif ss[-2:-1] == "e" or ss[-2:-1] == "E":                ss2 = 14*16            elif ss[-2:-1] == "f" or ss[-2:-1] == "F":                ss2 = 15*16            else:                ss2 = int(ss[-2:-1])*16            ss = ss1 + ss2                            return ss    def Convert_H(self, ss): #高位 进行编码转换        if len(ss) == 3:            if ss[-1] == "a" or ss[-1] == "A":                ss = 10*16*16            elif ss[-1] == "b" or ss[-1] == "B":                ss = 11*16*16            elif ss[-1] == "c" or ss[-1] == "C":                ss = 12*16*16            elif ss[-1] == "d" or ss[-1] == "D":                ss = 13*16*16            elif ss[-1] == "e" or ss[-1] == "E":                ss = 14*16*16            elif ss[-1] == "f" or ss[-1] == "F":                ss = 15*16*16            else:                ss = int(ss[-1])*16*16        elif len(ss) == 4:            if ss[-1] == "a" or ss[-1] == "A":                ss1 = 10*16*16            elif ss[-1] == "b" or ss[-1] == "B":                ss1 = 11*16*16            elif ss[-1] == "c" or ss[-1] == "C":                ss1 = 12*16*16            elif ss[-1] == "d" or ss[-1] == "D":                ss1 = 13*16*16            elif ss[-1] == "e" or ss[-1] == "E":                ss1 = 14*16*16            elif ss[-1] == "f" or ss[-1] == "F":                ss1 = 15*16*16            else:                ss1 = int(ss[-1])*16*16            if ss[-2:-1] == "a" or ss[-2:-1] == "A":                ss2 = 10*16*16*16            elif ss[-2:-1] == "b" or ss[-2:-1] == "B":                ss2 = 11*16*16*16            elif ss[-2:-1] == "c" or ss[-2:-1] == "C":                ss2 = 12*16*16*16            elif ss[-2:-1] == "d" or ss[-2:-1] == "D":                ss2 = 13*16*16*16            elif ss[-2:-1] == "e" or ss[-2:-1] == "E":                ss2 = 14*16*16*16            elif ss[-2:-1] == "f" or ss[-2:-1] == "F":                ss2 = 15*16*16*16            else:                ss2 = int(ss[-2:-1])*16*16*16            ss = ss1 + ss2                            return ss    if __name__ == "__main__":    gdb = GetDllBit("32.dll")

 

转载于:https://my.oschina.net/mickelfeng/blog/827691

你可能感兴趣的文章
我的友情链接
查看>>
svn 实践
查看>>
在 PowerShell 中使用 SQL Server (3)
查看>>
我的友情链接
查看>>
CSS元素定位
查看>>
质量时代——“Jolt大奖精选丛书”有奖征文
查看>>
DNS服务器维护命令
查看>>
六、用户与权限
查看>>
面向机器学习数据平台的设计与搭建
查看>>
centos6.7 编译安装mysql-5.6.27
查看>>
spring cloud 整合zpkin问题
查看>>
Maven下载慢的解决方案
查看>>
我的友情链接
查看>>
Android 核心分析 之七------Service深入分析
查看>>
Regsvr32使用方法
查看>>
柱形图Demo
查看>>
编辑器
查看>>
关闭windows的默认共享
查看>>
react开发环境搭建
查看>>
数据库读写分离
查看>>