python 模拟硬盘id_python3在windows下获取cpu、硬盘、bios、主板序列号

import time

import wmi, zlib

def get_cpu_info():

tmpdict = {}

tmpdict["CpuCores"] = 0

c = wmi.WMI()

# print c.Win32_Processor().['ProcessorId']

# print c.Win32_DiskDrive()

for cpu in c.Win32_Processor():

# print cpu

#print("cpu id:", cpu.ProcessorId.strip())

tmpdict["CpuId"] = cpu.ProcessorId.strip()

tmpdict["CpuType"] = cpu.Name

try:

tmpdict["CpuCores"] = cpu.NumberOfCores

except:

tmpdict["CpuCores"] += 1

tmpdict["CpuClock"] = cpu.MaxClockSpeed

return tmpdict

def _read_cpu_usage():

c = wmi.WMI()

for cpu in c.Win32_Processor():

return cpu.LoadPercentage

def get_cpu_usage():

cpustr1 = _read_cpu_usage()

if not cpustr1:

return 0

time.sleep(2)

cpustr2 = _read_cpu_usage()

if not cpustr2:

return 0

cpuper = int(cpustr1) + int(cpustr2) / 2

return cpuper

def get_disk_info():

tmplist = []

encrypt_str = ""

c = wmi.WMI()

for cpu in c.Win32_Processor():

# cpu 序列号

encrypt_str = encrypt_str + cpu.ProcessorId.strip()

print("cpu id:", cpu.ProcessorId.strip())

for physical_disk in c.Win32_DiskDrive():

encrypt_str = encrypt_str + physical_disk.SerialNumber.strip()

# 硬盘序列号

print('disk id:', physical_disk.SerialNumber.strip())

tmpdict = {}

tmpdict["Caption"] = physical_disk.Caption

tmpdict["Size"] = int(physical_disk.Size) / 1000 / 1000 / 1000

tmplist.append(tmpdict)

for board_id in c.Win32_BaseBoard():

# 主板序列号

encrypt_str = encrypt_str + board_id.SerialNumber.strip()

print("main board id:", board_id.SerialNumber.strip())

# for mac in c.Win32_NetworkAdapter():

# mac 地址(包括虚拟机的)

# print "mac addr:", mac.MACAddress:

for bios_id in c.Win32_BIOS():

# bios 序列号

encrypt_str = encrypt_str #+ bios_id.SerialNumber.strip()

print("bios number:", bios_id.SerialNumber.strip())

print("encrypt_str:", encrypt_str)

# 加密算法

print("加密算法:%d" % zlib.adler32(encrypt_str.encode()))

return encrypt_str

if __name__ == "__main__":

# a = get_cpu_info()

# print("cpu: %s" % a)

get_disk_info()

如果本文对您有所帮助,请支持下本站哦!!!^_^

模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘物理序列号模拟硬盘
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值