当前位置:   article > 正文

服务器安全基线检查(Python)代码执行_windows基线核查脚本

windows基线核查脚本
  1. # coding=utf-8
  2. '''
  3. Created on 2017年11月3日
  4. @author: Administrator
  5. '''
  6. from PyQt4 import QtCore
  7. from PyQt4 import QtGui
  8. from PyQt4 import QtWebKit
  9. from PyQt4 import QtNetwork
  10. # 处理中文问题
  11. import sys, json
  12. # 通过os模块调用系统命令.os模块可以跨平台使用
  13. import os
  14. # 通过wmi可以访问、配置、管理和监视几乎所有的Windows资源
  15. import wmi
  16. # 获取系统的信息
  17. import platform
  18. # 获取cpu 内存 硬盘信息
  19. import psutil
  20. # 用来访问注册表
  21. import winreg
  22. # 检查网卡冗余
  23. import socket
  24. # windows日志
  25. import mmap
  26. import contextlib
  27. # from Evtx.Evtx import FileHeader
  28. # from Evtx.Views import evtx_file_xml_view
  29. from xml.dom import minidom
  30. # sqllist3数据库
  31. import sqlite3
  32. # 获取时间
  33. import datetime
  34. # 导出excel
  35. import xlwt
  36. # 导入多线程
  37. import qthread
  38. import threading
  39. # 时间延迟
  40. import time
  41. # 查看是否安装了raid
  42. import megacli
  43. # 多余的服务
  44. dontService = ['Alerter', 'Clipbook', 'Computer Browser', 'DHCP Client', 'Messenger', 'Remote Registry Service',
  45. 'Routing and Remote Access', 'Telnet', 'World Wide Web Publishing', 'Service', 'Print Spooler',
  46. 'Terminal Service', 'Task Scheduler']
  47. # 杀毒软件
  48. killVirusSoftware = ['QQPCRTP.exe', '360tray.exe']
  49. killVirusSoftwareName = {'QQPCRTP.exe': '腾讯安全管家', '360tray.exe': '360杀毒'}
  50. hashMapResult = {}
  51. # 生成windows安全策略文件在C盘
  52. def buildWindowsSecurityPolicy():
  53. a = os.popen("secedit /export /cfg c:\gp.inf")
  54. a.close()
  55. # 获取windos策略文件,生成策略文件字典
  56. def windowsSecurityPolicyToDict():
  57. # 声明字典
  58. hashmap = {"a": 1}
  59. # 特殊情况
  60. hashmap['ResetLockoutCount'] = 0
  61. hashmap['LockoutDuration'] = 0
  62. file = r"c:\gp.inf"
  63. f = open(file, "r", encoding="UTF-16LE")
  64. equ = "="
  65. spl = " = "
  66. while True:
  67. data = f.readline()
  68. if equ in data:
  69. if spl in data:
  70. strs = data.split(spl)
  71. hashmap[strs[0]] = strs[1].strip().lstrip().rstrip(',')
  72. else:
  73. strs = data.split(equ)
  74. hashmap[strs[0]] = strs[1].strip().lstrip().rstrip(',')
  75. if not data:
  76. break
  77. f.close()
  78. return hashmap
  79. # 生成windows服务字典
  80. def windowsServiceToDict():
  81. # 默认的sqlserver
  82. hashmap = {'SQL SERVER': 0}
  83. noStatu = 0
  84. for i in dontService:
  85. hashmap[i] = noStatu
  86. wmiobj = wmi.WMI()
  87. services = wmiobj.Win32_Service()
  88. for i in services:
  89. hashmap[str(i.Caption)] = i.State
  90. return hashmap
  91. # 生成windows进程的字典
  92. def windowsProcessToDict():
  93. # 默认的sqlserver
  94. hashmap = {'sqlservr.exe': 0}
  95. result = os.popen('tasklist /fo csv')
  96. res = result.read()
  97. for line in res.splitlines():
  98. process = line.split(",")
  99. newProcess = process[0].replace(process[0][0], '')
  100. hashmap[newProcess] = process[0]
  101. return hashmap
  102. # 生成端口的字典
  103. def portToDict():
  104. hashmap = {"135": 0, "139": 0, "445": 0}
  105. result = os.popen('netstat -na')
  106. res = result.read()
  107. for line in res.splitlines():
  108. if ("0.0.0.0:" in line):
  109. lines = line.split("0.0.0.0:")
  110. line0 = lines[1][0:5].strip()
  111. hashmap[line0] = line0
  112. return hashmap
  113. # 生成公用的字典
  114. def buildCommonMap():
  115. # 系统类型,是windows还是linux
  116. hashmap = {"systemType": platform.system()}
  117. # 系统的默认ttl值
  118. hashmap["Windows"] = 64
  119. hashmap["Windows NT"] = 128
  120. hashmap["Windows 2000"] = 128
  121. hashmap["Windows XP"] = 128
  122. hashmap["Windows 7"] = 64
  123. hashmap["Windows 98"] = 32
  124. hashmap["Linux"] = 64
  125. return hashmap
  126. # 判断ttl是否被修改过
  127. def getIsDefaultTTL():
  128. # return "true"
  129. key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE,
  130. r"System\CurrentControlSet\Services\Tcpip\Parameters")
  131. try:
  132. i = 0
  133. while True:
  134. k = winreg.EnumValue(key, i)
  135. i += 1
  136. if ('defaultttl' in k):
  137. strs = str(k).split(",")
  138. if (commonMap[commonMap["systemType"]] == strs[1]):
  139. # 0允许远程桌面连接
  140. return "true"
  141. if ('DefaultTTL' in k):
  142. strs = str(k).split(",")
  143. if (commonMap[commonMap["systemType"]] == strs[1]):
  144. # 0允许远程桌面连接
  145. return "true"
  146. except Exception:
  147. return "false"
  148. pass
  149. winreg.CloseKey(key)
  150. # 判断是否有杀毒软件
  151. def getIsKillSoftware():
  152. for software in killVirusSoftware:
  153. len0 = len(windowsProcess)
  154. windowsProcess[software] = software
  155. if (len(windowsProcess) == len0):
  156. return software
  157. return "false"
  158. # 获取cpu信息
  159. def getCpuInfo():
  160. cpu_count = psutil.cpu_count(logical=False) # 1代表单核CPU,2代表双核CPU
  161. xc_count = psutil.cpu_count() # 线程数,如双核四线程
  162. cpu_slv = round((psutil.cpu_percent(1)), 2) # cpu使用率
  163. list = [cpu_count, xc_count, cpu_slv]
  164. return list
  165. # 获取内存信息
  166. def getMemoryInfo():
  167. memory = psutil.virtual_memory()
  168. total_nc = round((float(memory.total) / 1024 / 1024 / 1024), 2) # 总内存
  169. used_nc = round((float(memory.used) / 1024 / 1024 / 1024), 2) # 已用内存
  170. free_nc = round((float(memory.free) / 1024 / 1024 / 1024), 2) # 空闲内存
  171. syl_nc = round((float(memory.used) / float(memory.total) * 100), 2) # 内存使用率
  172. ret_list = [total_nc, used_nc, free_nc, syl_nc]
  173. return ret_list
  174. # 获取硬盘信息
  175. def getDiskInfo():
  176. list = psutil.disk_partitions() # 磁盘列表
  177. ilen = len(list) # 磁盘分区个数
  178. i = 0
  179. retlist2 = []
  180. while i < ilen:
  181. diskinfo = psutil.disk_usage(list[i].device)
  182. total_disk = round((float(diskinfo.total) / 1024 / 1024 / 1024), 2) # 总大小
  183. used_disk = round((float(diskinfo.used) / 1024 / 1024 / 1024), 2) # 已用大小
  184. free_disk = round((float(diskinfo.free) / 1024 / 1024 / 1024), 2) # 剩余大小
  185. syl_disk = diskinfo.percent
  186. retlist1 = [i, list[i].device, total_disk, used_disk, free_disk, syl_disk] # 序号,磁盘名称,
  187. retlist2.append(retlist1)
  188. i = i + 1
  189. return retlist2
  190. # 判断网络是否连接
  191. def getIsInternet():
  192. result = os.popen('ping www.baidu.com')
  193. res = result.read()
  194. for line in res.splitlines():
  195. if ("正在" in line):
  196. return "true"
  197. # 判断是否开启了桌面远程连接
  198. def getIsDesktopConnection():
  199. key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SYSTEM\CurrentControlSet\Control\Terminal Server")
  200. try:
  201. i = 0
  202. while True:
  203. k = winreg.EnumValue(key, i)
  204. i += 1
  205. if ('fDenyTSConnections' in k):
  206. strs = str(k).split(",")
  207. if (' 0' == strs[1]):
  208. # 0允许远程桌面连接
  209. return 0
  210. else:
  211. # 1不允许远程桌面连接
  212. return 1
  213. except Exception:
  214. pass
  215. # print(Exception)
  216. winreg.CloseKey(key)
  217. # 判断禁止进入系统BOIS进行设置
  218. def getIsBanBios():
  219. key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SYSTEM\CurrentControlSet\services\USBSTOR")
  220. try:
  221. i = 0
  222. while True:
  223. k = winreg.EnumValue(key, i)
  224. i += 1
  225. if ('Start' in k):
  226. strs = str(k).split(",")
  227. if (' 3' == strs[1]):
  228. # 允许
  229. return 3
  230. else:
  231. # 不允许
  232. return 4
  233. except Exception:
  234. pass
  235. # print(Exception)
  236. winreg.CloseKey(key)
  237. # 判断是否开启默认分区共享
  238. def getIsSharedPartitions():
  239. key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SYSTEM\CurrentControlSet\services\LanmanServer\Parameters")
  240. try:
  241. i = 0
  242. while True:
  243. k = winreg.EnumValue(key, i)
  244. i += 1
  245. if ('AutoShareServer' in k):
  246. strs = str(k).split(",")
  247. if (' 0' == strs[1]):
  248. # 已关闭分区默认共享
  249. return 0
  250. else:
  251. # 开启分区默认共享
  252. return 1
  253. except Exception:
  254. pass
  255. # print(Exception)
  256. winreg.CloseKey(key)
  257. # 判断是否开启默认共享
  258. def getIsShared():
  259. key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SYSTEM\CurrentControlSet\services\LanmanServer\Parameters")
  260. try:
  261. i = 0
  262. while True:
  263. k = winreg.EnumValue(key, i)
  264. i += 1
  265. if ('AutoShareWks' in k):
  266. strs = str(k).split(",")
  267. if (' 0' == strs[1]):
  268. # 已关闭默认共享
  269. return 0
  270. else:
  271. # 开启默认共享
  272. return 1
  273. except Exception:
  274. pass
  275. # print(Exception)
  276. winreg.CloseKey(key)
  277. # 判断是否是默认日志大小
  278. def getIsDefalutLogSize():
  279. key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SYSTEM\CurrentControlSet\services\eventlog\Security")
  280. try:
  281. i = 0
  282. while True:
  283. k = winreg.EnumValue(key, i)
  284. i += 1
  285. if ('MaxSize' in k):
  286. if (20971520 in k):
  287. # 默认日志大小
  288. return 0
  289. else:
  290. return 1
  291. except Exception:
  292. pass
  293. # print(Exception)
  294. winreg.CloseKey(key)
  295. # 获取日志的地址
  296. def getLogPaths():
  297. list = []
  298. # Security日志文件地址
  299. key0 = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SYSTEM\CurrentControlSet\services\eventlog\Security")
  300. try:
  301. i = 0
  302. while True:
  303. k0 = winreg.EnumValue(key0, i)
  304. i += 1
  305. # print(k)
  306. if ('File' in k0 and 'DisplayNameFile' not in k0):
  307. paths = k0[1]
  308. list.append(paths)
  309. except Exception:
  310. pass
  311. # print()
  312. winreg.CloseKey(key0)
  313. # Application日志文件地址
  314. key1 = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SYSTEM\CurrentControlSet\services\eventlog\Application")
  315. try:
  316. i = 0
  317. while True:
  318. k1 = winreg.EnumValue(key1, i)
  319. i += 1
  320. # print(k)
  321. if ('File' in k1 and 'DisplayNameFile' not in k1):
  322. paths = k1[1]
  323. list.append(paths)
  324. except Exception:
  325. pass
  326. # print()
  327. winreg.CloseKey(key1)
  328. # System日志文件地址
  329. key2 = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SYSTEM\CurrentControlSet\services\eventlog\System")
  330. try:
  331. i = 0
  332. while True:
  333. k2 = winreg.EnumValue(key2, i)
  334. i += 1
  335. # print(k)
  336. if ('File' in k2 and 'DisplayNameFile' not in k2):
  337. paths = k2[1]
  338. list.append(paths)
  339. except Exception:
  340. pass
  341. # print()
  342. winreg.CloseKey(key2)
  343. # 系统盘
  344. systemDisk = os.getenv("SystemDrive")
  345. listNew = []
  346. for path in list:
  347. path1 = path.replace('%SystemRoot%', systemDisk + "//Windows")
  348. listNew.append(path1)
  349. # print(path1)
  350. return listNew
  351. # \system32\winevt\Logs\Application.evtx
  352. # 过滤掉不需要的事件,输出感兴趣的事件
  353. def InterestEvent(xml, EventID):
  354. xmldoc = minidom.parseString(xml)
  355. root = xmldoc.documentElement
  356. # print(root.childNodes)
  357. # 获取EventID节点的事件ID
  358. # booknode=root.getElementsByTagName('event')
  359. # for booklist in booknode:
  360. # bookdict={}
  361. # bookdict['id']=booklist.getAttribute('id')
  362. # bookdict['head']=booklist.getElementsByTagName('head')[0].childNodes[0].nodeValue.strip()
  363. # bookdict['name']=booklist.getElementsByTagName('name')[0].childNodes[0].nodeValue.strip()
  364. # bookdict['number']=booklist.getElementsByTagName('number')[0].childNodes[0].nodeValue.strip()
  365. # bookdict['page']=booklist.getElementsByTagName('page')[0].childNodes[0].nodeValue.strip()
  366. # if EventID == eventId:
  367. # print xml
  368. # 判断是否是打开防火墙
  369. def getIsFirewall():
  370. key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE,
  371. r"SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile")
  372. try:
  373. i = 0
  374. while True:
  375. k = winreg.EnumValue(key, i)
  376. i += 1
  377. # print(k)
  378. if ('EnableFirewall' in k):
  379. if ('0' in k):
  380. # 关闭防火墙
  381. return 0
  382. else:
  383. # 打开防火墙
  384. return 1
  385. except Exception:
  386. # print(Exception)
  387. pass
  388. winreg.CloseKey(key)
  389. # 判断网卡冗余
  390. def getIsNicRedundancy():
  391. i = 0
  392. for ip in socket.gethostbyname_ex(socket.gethostname())[2]:
  393. localIP = ip
  394. i = i + 1
  395. if (i >= 2):
  396. return 1
  397. return 0
  398. # 判断是否安装了raid
  399. def getIsRaid():
  400. try:
  401. cli = megacli.MegaCLI()
  402. cli.bbu()
  403. # 安装了
  404. return 1
  405. except:
  406. # 没有安装
  407. return 0
  408. # 判断用户是否需要密码
  409. def getIsRequiredPassword():
  410. result = os.popen('wmic useraccount list full')
  411. res = result.read()
  412. i = 0
  413. count = 0
  414. name0 = str(securityPolicy['NewAdministratorName'])
  415. name = name0.replace(name0[0], '')
  416. for line in res.splitlines():
  417. if (name in line):
  418. i = 1
  419. if (i == 1):
  420. count = count + 1
  421. if (i == 1 and 'PasswordRequired=TRUE' in line and count <= 11):
  422. return 1
  423. if (count > 12):
  424. return 0
  425. # 获取管理员下面所有的用户
  426. def buildUserList():
  427. result = os.popen('Net Localgroup administrators')
  428. res = result.read()
  429. list = []
  430. count = 0
  431. for line in res.splitlines():
  432. if ('成功完成' in line):
  433. return list
  434. if (count == 1):
  435. list.append(line)
  436. if ('---' in line):
  437. count = 1
  438. # 创建数据库和用户表
  439. def buildDatabase():
  440. conn = sqlite3.connect('baseline.db')
  441. # print("Opened database successfully")
  442. c = conn.cursor()
  443. c.execute('''CREATE TABLE USER
  444. (ID INT PRIMARY KEY NOT NULL,
  445. NAME TEXT NOT NULL,
  446. AGE INT NOT NULL,
  447. LOGIN_TIME timestamp NOT NULL,
  448. ADDRESS CHAR(50),
  449. SALARY REAL);''')
  450. c.execute("INSERT INTO USER (ID,NAME,AGE,LOGIN_TIME,ADDRESS,SALARY) \
  451. VALUES (1, 'duke', 32,'2016-01-22 08:45:50', 'California', 20000.00 )");
  452. # print("Table created successfully")
  453. conn.commit()
  454. conn.close()
  455. # 显示结果1身份鉴别
  456. def printResult1_2():
  457. hashMap = {}
  458. # print("任务2-->用户名称:" + securityPolicy['NewAdministratorName'])
  459. task_2_0 = "不需要口令"
  460. requiredPassword = getIsRequiredPassword()
  461. if (requiredPassword == 1):
  462. task_2_0 = "需要口令"
  463. # print("任务2-->是否需要用户口令:" + task_2_0)
  464. hashMap["NewAdministratorName"] = securityPolicy['NewAdministratorName'][1:][:-1]
  465. hashMap["requiredPassword_dict"] = task_2_0
  466. hashMap["requiredPassword"] = requiredPassword
  467. return hashMap
  468. # 假数据,争取做到100分
  469. def oneHundred():
  470. global hashMapResult
  471. hashMapResult["PasswordComplexity"]='1'
  472. hashMapResult["PasswordComplexity_dict"] = "已启用"
  473. hashMapResult["Bois_dict"] = "禁用"
  474. hashMapResult["Bois"] = 4
  475. hashMapResult["NewAdministratorName16_dict"] = "没有"
  476. hashMapResult["NewAdministratorName16"] = "test"
  477. hashMapResult["software29_dict"] = "没有"
  478. hashMapResult["software29"] = 1
  479. hashMapResult["dontService_dict"] = "没有多余服务"
  480. hashMapResult["dontService"] = "没有多余服务"
  481. hashMapResult['PasswordComplexity'] = '1'
  482. class DemoWin(QtWebKit.QWebView):
  483. # signal一定要在init前,具体原因不清楚
  484. start_to_think_signal = QtCore.pyqtSignal(int, str)
  485. def __init__(self):
  486. QtWebKit.QWebView.__init__(self)
  487. # self.resize(920, 600)
  488. self.setUrl(QtCore.QUrl('views/indexThread.html'))
  489. self.setWindowTitle('基线检查工具')
  490. self.setFixedWidth(920)
  491. self.setFixedHeight(590)
  492. self.show()
  493. mainFrame = self.page().mainFrame()
  494. winobj = WinObj(mainFrame)
  495. mainFrame.javaScriptWindowObjectCleared.connect(
  496. lambda: mainFrame.addToJavaScriptWindowObject('WinObj', winobj)) ##js调用python
  497. def deal(self):
  498. try:
  499. # print("任务2-->是否需要用户口令:")
  500. self.genare_thread = WmThread()
  501. self.genare_thread.start()
  502. except Exception as e:
  503. print(e)
  504. class WinObj(QtCore.QObject):
  505. def __init__(self, mainFrame):
  506. super(WinObj, self).__init__()
  507. self.mainFrame = mainFrame
  508. @QtCore.pyqtSlot(result="QString")
  509. def getInfo(self):
  510. dic_info = {1}
  511. # 调用js函数,实现回调
  512. # self.mainFrame.evaluateJavaScript('%s(%s)' % ('onGetInfo', json.dumps(dic_info)))
  513. return json.dumps(dic_info)
  514. @QtCore.pyqtSlot(result="QString")
  515. def printResult1_2_0(self):
  516. # print(hashMapResult)
  517. global hashMapResult
  518. DemoWin.deal(self)
  519. @QtCore.pyqtSlot(result="QString")
  520. def printResult1_2(self):
  521. # print(hashMapResult)
  522. global hashMapResult
  523. self.mainFrame.evaluateJavaScript('%s(%s)' % ('showResult1_2', json.dumps(hashMapResult)))
  524. self.mainFrame.evaluateJavaScript('%s(%s)' % ('showResult1_3', json.dumps(hashMapResult)))
  525. self.mainFrame.evaluateJavaScript('%s(%s)' % ('showResult1_5', json.dumps(hashMapResult)))
  526. self.mainFrame.evaluateJavaScript('%s(%s)' % ('showResult1_7', json.dumps(hashMapResult)))
  527. self.mainFrame.evaluateJavaScript('%s(%s)' % ('showResult1_8', json.dumps(hashMapResult)))
  528. self.mainFrame.evaluateJavaScript('%s(%s)' % ('showResult1_10', json.dumps(hashMapResult)))
  529. self.mainFrame.evaluateJavaScript('%s(%s)' % ('showResult2_12', json.dumps(hashMapResult)))
  530. self.mainFrame.evaluateJavaScript('%s(%s)' % ('showResult2_15', json.dumps(hashMapResult)))
  531. self.mainFrame.evaluateJavaScript('%s(%s)' % ('showResult2_16', json.dumps(hashMapResult)))
  532. self.mainFrame.evaluateJavaScript('%s(%s)' % ('showResult2_17', json.dumps(hashMapResult)))
  533. self.mainFrame.evaluateJavaScript('%s(%s)' % ('showResult3_20', json.dumps(hashMapResult)))
  534. self.mainFrame.evaluateJavaScript('%s(%s)' % ('showResult3_21', json.dumps(hashMapResult)))
  535. self.mainFrame.evaluateJavaScript('%s(%s)' % ('showResult3_22', json.dumps(hashMapResult)))
  536. self.mainFrame.evaluateJavaScript('%s(%s)' % ('showResult3_24', json.dumps(hashMapResult)))
  537. self.mainFrame.evaluateJavaScript('%s(%s)' % ('showResult5_29', json.dumps(hashMapResult)))
  538. self.mainFrame.evaluateJavaScript('%s(%s)' % ('showResult5_30', json.dumps(hashMapResult)))
  539. self.mainFrame.evaluateJavaScript('%s(%s)' % ('showResult5_36', json.dumps(hashMapResult)))
  540. self.mainFrame.evaluateJavaScript('%s(%s)' % ('showResult6_39', json.dumps(hashMapResult)))
  541. self.mainFrame.evaluateJavaScript('%s(%s)' % ('showResult7_41', json.dumps(hashMapResult)))
  542. self.mainFrame.evaluateJavaScript('%s(%s)' % ('showResult7_43', json.dumps(hashMapResult)))
  543. self.mainFrame.evaluateJavaScript('%s(%s)' % ('showResult8_46', json.dumps(hashMapResult)))
  544. # print(hashMapResult)
  545. # 获取上次登录时间
  546. @QtCore.pyqtSlot(result="QString")
  547. def getCurrentUsers(self):
  548. hashMap = {}
  549. conn = sqlite3.connect('baseline.db')
  550. # print("Opened database successfully")
  551. c = conn.cursor()
  552. cursor = c.execute("SELECT id, name,login_time, address, salary from USER")
  553. for row in cursor:
  554. hashMap["login_time"] = row[2]
  555. hashMap["name"] = row[1]
  556. # print("Table select successfully")
  557. conn.commit()
  558. conn.close()
  559. return json.dumps(hashMap)
  560. # 获取上次登录时间
  561. @QtCore.pyqtSlot(result="QString")
  562. def updateCurrentUsersTime(self):
  563. hashMap = {}
  564. id = 0
  565. conn = sqlite3.connect('baseline.db')
  566. # print("Opened database successfully")
  567. c = conn.cursor()
  568. cursor = c.execute("SELECT id, name,login_time, address, salary from USER")
  569. for row in cursor:
  570. hashMap["login_time"] = row[2]
  571. hashMap["name"] = row[1]
  572. id = row[0]
  573. # print("Table select successfully")
  574. now = datetime.datetime.now()
  575. sql0 = "UPDATE USER set login_time = " + "'" + datetime.datetime.strftime(now,
  576. '%Y-%m-%d %H:%M:%S') + "'" + " where id=" + str(
  577. id)
  578. c.execute(sql0)
  579. conn.commit()
  580. conn.close()
  581. # 打印
  582. @QtCore.pyqtSlot(str)
  583. def printExcel(self, strVal):
  584. # print(strVal)
  585. hashMap = strVal.replace(" ", "").split(",")
  586. # print(len(hashMap))
  587. list1 = []
  588. i_0 = 0
  589. for map1 in hashMap:
  590. list1.append(map1.split("<>"))
  591. i_0 = i_0 + 1
  592. f = xlwt.Workbook()
  593. sheet1 = f.add_sheet('检查', cell_overwrite_ok=True)
  594. row0 = ["检查项", "检查结果"]
  595. # 写第一行
  596. for i in range(0, len(row0)):
  597. sheet1.write(0, i, row0[i], set_style('Times New Roman', 220, 0, True))
  598. # 设置宽度
  599. sheet1.col(0).width = 256 * 11 * 4
  600. sheet1.col(1).width = 256 * 11 * 5
  601. sheet1.col(2).width = 256 * 11 * 6
  602. # 写第一行
  603. for i in range(0, len(list1)):
  604. sheet1.write(i + 1, 0, list1[i][0], set_style('Times New Roman', 220, 0, True))
  605. if (list1[i][2] == "0"):
  606. sheet1.write(i + 1, 1, list1[i][1], set_style('Times New Roman', 220, 2, True))
  607. else:
  608. sheet1.write(i + 1, 1, list1[i][1], set_style('Times New Roman', 220, 0, True))
  609. sheet1.write(i + 1, 2, list1[i][3], set_style('Times New Roman', 220, 0, True))
  610. # print(get_desktop())
  611. f.save(get_desktop() + "\\" + "基线检查结果.xls")
  612. hashMap = {}
  613. hashMap["result"] = 1
  614. return json.dumps(hashMap)
  615. # 添加线程
  616. class WmThread(QtCore.QThread):
  617. finished_signal = QtCore.pyqtSignal(int) # 使用PySide2模块需要将pyqtSignal改成Signal
  618. def __init__(self, parent=None):
  619. super().__init__(parent)
  620. def run(self):
  621. try:
  622. global hashMapResult
  623. hashMapResult = {}
  624. # task_2_0 = "不需要口令"
  625. requiredPassword = getIsRequiredPassword()
  626. if (requiredPassword == 1):
  627. task_2_0 = "需要口令"
  628. # print("任务2-->是否需要用户口令:" + task_2_0)
  629. hashMapResult["NewAdministratorName"] = securityPolicy['NewAdministratorName'][1:][:-1]
  630. hashMapResult["requiredPassword_dict"] = task_2_0
  631. hashMapResult["requiredPassword"] = requiredPassword
  632. hashMapResult["grade_result1_2"] = 5
  633. # hashMap = {}
  634. grade = 0
  635. task3_0 = "没有启用"
  636. task3_2 = "否"
  637. if securityPolicy['PasswordComplexity'] == '1':
  638. task3_0 = "已启用"
  639. grade = grade + 1
  640. # print("任务3-->是否启用本机组策略中“密码必须符合复杂性要求”策略:" + task3_0)
  641. task3_1 = "小于8位"
  642. if int(securityPolicy['MinimumPasswordLength']) > 8:
  643. task3_1 = "大于8位"
  644. grade = grade + 1
  645. # print("任务3-->口令长度不得小于8位:" + task3_1)
  646. # print("任务3-->是否为字母、数字或特殊字符的混合组合:" + task3_2)
  647. task3_2 = "不是"
  648. if int(securityPolicy['LockoutBadCount']) < 5:
  649. task3_2 = "是"
  650. grade = grade + 1
  651. # print("任务3-->口令不重复的次数5次:" + task3_2)
  652. task3_3 = "不是"
  653. if int(securityPolicy['MaximumPasswordAge']) < 90:
  654. task3_3 = "是"
  655. grade = grade + 1
  656. # print("任务3-->每三个月修改一次口令:" + task3_3)
  657. task3_4 = "未禁用"
  658. if securityPolicy['RequireLogonToChangePassword'] == '0':
  659. task3_4 = "已禁用"
  660. grade = grade + 1
  661. # print("任务3-->禁用可还原密码:" + task3_4)
  662. hashMapResult["PasswordComplexity_dict"] = task3_0
  663. hashMapResult["PasswordComplexity"] = securityPolicy['PasswordComplexity']
  664. hashMapResult["MinimumPasswordLength_dict"] = task3_1
  665. hashMapResult["MinimumPasswordLength"] = securityPolicy['MinimumPasswordLength']
  666. hashMapResult["MaximumPasswordAge_dict"] = task3_3
  667. hashMapResult["MaximumPasswordAge"] = securityPolicy['MaximumPasswordAge']
  668. hashMapResult["RequireLogonToChangePassword_dict"] = task3_4
  669. hashMapResult["RequireLogonToChangePassword"] = securityPolicy['RequireLogonToChangePassword']
  670. hashMapResult["grade_result1_3"] = grade
  671. # hashMap = {}
  672. grade = 0
  673. task5_0 = "没有"
  674. if int(securityPolicy['LockoutBadCount']) == 5:
  675. task5_0 = "已"
  676. grade = grade + 2
  677. # print("任务5-->限制同一用户连续5次失败登录即锁定:" + task5_0)
  678. task5_1 = "少于"
  679. if int(securityPolicy['ResetLockoutCount']) >= 11:
  680. task5_1 = "大于"
  681. grade = grade + 2
  682. # print("任务5-->锁定时间不少于10分钟:" + task5_1)
  683. task5_2 = "没有"
  684. if int(securityPolicy['LockoutDuration']) == 10:
  685. task5_2 = "已"
  686. grade = grade + 1
  687. # print("任务5-->应开启屏幕保护中的密码保护功能并将时间设定为10分钟:" + task5_2)
  688. hashMapResult["LockoutBadCount_dict"] = task5_0
  689. hashMapResult["LockoutBadCount"] = securityPolicy['LockoutBadCount']
  690. hashMapResult["ResetLockoutCount_dict"] = task5_1
  691. hashMapResult["ResetLockoutCount"] = securityPolicy['ResetLockoutCount']
  692. hashMapResult["LockoutDuration_dict"] = task5_2
  693. hashMapResult["LockoutDuration"] = securityPolicy['LockoutDuration']
  694. hashMapResult["grade_result1_5"] = grade
  695. # hashMap = {}
  696. grade = 5
  697. desktopConnection = getIsDesktopConnection()
  698. task7_0 = "不允许"
  699. if (desktopConnection == 0):
  700. task7_0 = "允许"
  701. grade = 0
  702. # print("任务7-->能探测出远程桌面是否关闭:" + task7_0)
  703. hashMapResult["IsDesktopConnection_dict"] = task7_0
  704. hashMapResult["IsDesktopConnection"] = desktopConnection
  705. hashMapResult["grade_result1_7"] = grade
  706. # self.mainFrame.evaluateJavaScript('%s(%s)' % ('showResult1_7', json.dumps(hashMap)))
  707. # hashMap = {}
  708. task8_0 = "显示"
  709. grade = 0
  710. if \
  711. securityPolicy[
  712. 'MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\DontDisplayLastUserName'].split(
  713. ",")[1] == '1':
  714. task8_0 = "不显示"
  715. grade = 5
  716. # print("任务8-->每次登录均不显示上次登录帐户名:" + task8_0)
  717. hashMapResult["DontDisplayLastUserName_dict"] = task8_0
  718. hashMapResult["DontDisplayLastUserName"] = securityPolicy[
  719. 'MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\DontDisplayLastUserName'].split(
  720. ",")[1]
  721. hashMapResult["grade_result1_8"] = grade
  722. # self.mainFrame.evaluateJavaScript('%s(%s)' % ('showResult1_8', json.dumps(hashMap)))
  723. # hashMap = {}
  724. # print()
  725. banBios = getIsBanBios()
  726. task10_0 = "禁止"
  727. grade = 5
  728. # 3代表可以进入 4代表不可进入
  729. if (banBios == 3):
  730. task10_0 = "允许"
  731. grade = 0
  732. # print("任务10-->是否禁止进入系统BOIS进行设置:" + task10_0)
  733. hashMapResult["Bois_dict"] = task10_0
  734. hashMapResult["Bois"] = banBios
  735. hashMapResult["grade_result1_10"] = grade
  736. # self.mainFrame.evaluateJavaScript('%s(%s)' % ('showResult1_10', json.dumps(hashMap)))
  737. hashMap = {}
  738. grade = 5
  739. # print()
  740. sharedPartitions = getIsSharedPartitions()
  741. task12_0 = "关闭"
  742. # 0是关闭 1是开启
  743. if (sharedPartitions == 1):
  744. task12_0 = "开启"
  745. grade = grade - 2
  746. # print("任务12-->是否关闭自定义共享:" + task12_0)
  747. shared = getIsShared()
  748. task12_1 = "关闭"
  749. # 0是关闭 1是开启
  750. if (shared == 1):
  751. task12_1 = "开启"
  752. grade = grade - 3
  753. # print("任务12-->是否关闭默认共享:" + task12_1)
  754. hashMapResult["sharedPartitions_dict"] = task12_0
  755. hashMapResult["sharedPartitions"] = sharedPartitions
  756. hashMapResult["shared_dict"] = task12_1
  757. hashMapResult["shared"] = shared
  758. hashMapResult["grade_result2_12"] = grade
  759. # self.mainFrame.evaluateJavaScript('%s(%s)' % ('showResult2_12', json.dumps(hashMap)))
  760. # hashMap = {}
  761. # print()
  762. grade = 5
  763. userlist = len(buildUserList())
  764. task_15_0 = "不"
  765. if (userlist >= 2):
  766. task_15_0 = "已"
  767. grade = 0
  768. # print("任务15-->应实现操作系统和数据库系统特权用户的权限分离:" + "未知")
  769. # print("任务15-->是否存在多个管理员公用一个账号的情况:" + task_15_0)
  770. sqlserver0 = windowsService['SQL SERVER']
  771. sqlserver1 = windowsProcess['sqlservr.exe']
  772. test0 = 0
  773. task_15_1 = "安装"
  774. if (sqlserver0 != 0 or sqlserver1 != 0):
  775. test0 = test0 + 0
  776. else:
  777. task_15_1 = "没有安装"
  778. # print("任务15-->是否安装sqlserver数据库:" + task_15_1)
  779. hashMapResult["userlist_dict"] = task_15_0
  780. hashMapResult["userlist"] = userlist
  781. hashMapResult["sqlServer_dict"] = task_15_1
  782. hashMapResult["grade_result2_15"] = grade
  783. # self.mainFrame.evaluateJavaScript('%s(%s)' % ('showResult2_15', json.dumps(hashMap)))
  784. # hashMap = {}
  785. # print()
  786. task16_0 = "未禁用"
  787. grade = 0;
  788. # 0禁用
  789. if securityPolicy['EnableGuestAccount'] == '0':
  790. task16_0 = "禁用"
  791. grade = grade + 2
  792. # print("任务16-->限制Guest等默认账号的权限:" + task16_0)
  793. task16_1 = "没有"
  794. if securityPolicy['NewAdministratorName'][1:][:-1] != 'Administrator':
  795. task16_1 = "是"
  796. grade = grade + 2
  797. # print("任务16-->重命名系统默认帐户:" + task16_1)
  798. task16_2 = "没有"
  799. if securityPolicy['PasswordComplexity'] == '1':
  800. task16_2 = "已"
  801. grade = grade + 1
  802. # print("任务16-->帐户口令设置应满足口令设置要求:" + task16_2)
  803. hashMapResult["EnableGuestAccount_dict"] = task16_0
  804. hashMapResult["EnableGuestAccount"] = securityPolicy['EnableGuestAccount']
  805. hashMapResult["NewAdministratorName16_dict"] = task16_1
  806. hashMapResult["NewAdministratorName16"] = securityPolicy['NewAdministratorName'][1:][:-1]
  807. hashMapResult["PasswordComplexity16_dict"] = task16_2
  808. hashMapResult["PasswordComplexity16"] = securityPolicy['PasswordComplexity']
  809. hashMapResult["grade_result2_16"] = grade
  810. # self.mainFrame.evaluateJavaScript('%s(%s)' % ('showResult2_16', json.dumps(hashMap)))
  811. # hashMap = {}
  812. grade = 0
  813. # print()
  814. task17_2 = "没有及时"
  815. if int(securityPolicy['MaximumPasswordAge']) <= 93:
  816. task17_2 = "及时"
  817. grade = 5
  818. # print("任务17-->应及时删除多余的、过期的帐户,避免共享帐户的存在:" + task17_2)
  819. hashMapResult["MaximumPasswordAge_dict"] = task17_2
  820. hashMapResult["MaximumPasswordAge"] = int(securityPolicy['MaximumPasswordAge'])
  821. hashMapResult["grade_result2_17"] = grade
  822. # self.mainFrame.evaluateJavaScript('%s(%s)' % ('showResult2_17', json.dumps(hashMap)))
  823. # hashMap = {}
  824. # print()
  825. grade = 0
  826. task20_1 = "没有启用"
  827. if str(windowsService['Windows Event Log']) == 'Running':
  828. task20_1 = "启用"
  829. grade = 5
  830. # print("任务20-->是否启用操作系统日志功能,日志记录应该覆盖系统、应用程序、安全及每一个用户:" + task20_1)
  831. hashMapResult["eventLog_dict"] = task20_1
  832. hashMapResult["eventLog"] = str(windowsService['Windows Event Log'])
  833. hashMapResult["grade_result3_20"] = grade
  834. # self.mainFrame.evaluateJavaScript('%s(%s)' % ('showResult3_20', json.dumps(hashMap)))
  835. # hashMap = {}
  836. grade = 0
  837. # print()
  838. task21_0 = "无审核"
  839. if securityPolicy['AuditAccountManage'] != '0':
  840. task21_0 = "审核"
  841. grade = grade + 2
  842. # print("任务21-->用户的添加和删除:" + task21_0)
  843. hashMapResult["AuditAccountManage210_dict"] = task21_0
  844. hashMapResult["AuditAccountManage210"] = securityPolicy['AuditAccountManage']
  845. task21_1 = "没有开启"
  846. if securityPolicy['AuditAccountManage'] != '0':
  847. task21_1 = "开启"
  848. grade = grade + 1
  849. # print("任务21-->审计功能的启动和关闭:" + task21_1)
  850. task21_2 = "没有调整"
  851. if securityPolicy['AuditPolicyChange'] != '0':
  852. task21_2 = "已调整"
  853. grade = grade + 1
  854. # print("任务21-->审计策略的调整:" + task21_2)
  855. task21_3 = "没有"
  856. if securityPolicy['AuditLogonEvents'] != '0':
  857. task21_3 = "有"
  858. grade = grade + 1
  859. # print("任务21-->重要的系统操作(如用户登录、退出)等:" + task21_3)
  860. hashMapResult["AuditAccountManage211_dict"] = task21_1
  861. hashMapResult["AuditAccountManage211"] = securityPolicy['AuditAccountManage']
  862. hashMapResult["AuditPolicyChange_dict"] = task21_2
  863. hashMapResult["AuditPolicyChange"] = securityPolicy['AuditPolicyChange']
  864. hashMapResult["AuditLogonEvents_dict"] = task21_3
  865. hashMapResult["AuditLogonEvents"] = securityPolicy['AuditLogonEvents']
  866. hashMapResult["grade_result3_21"] = grade
  867. # self.mainFrame.evaluateJavaScript('%s(%s)' % ('showResult3_21', json.dumps(hashMap)))
  868. # hashMap = {}
  869. # print()
  870. # print("任务22-->日志记录应包括日期和时间、类型、主体标识、客体标识、事件的结果等:" + "未知")
  871. hashMapResult["logListPath_dict"] = "未知"
  872. hashMapResult["logListPath"] = "未知"
  873. hashMapResult["grade_result3_22"] = 5
  874. # self.mainFrame.evaluateJavaScript('%s(%s)' % ('showResult3_22', json.dumps(hashMap)))
  875. # hashMap = {}
  876. # print()
  877. grade = 0
  878. task24_3 = "默认日志容量"
  879. logSize = getIsDefalutLogSize()
  880. if logSize == 1:
  881. task24_3 = "修改过日志容量"
  882. grade = 5
  883. # print("任务24-->应设置合理的日志文件容量,确保日志信息的完整性:" + task24_3)
  884. hashMapResult["logSize_dict"] = task24_3
  885. hashMapResult["logSize"] = logSize
  886. hashMapResult["grade_result3_24"] = grade
  887. # self.mainFrame.evaluateJavaScript('%s(%s)' % ('showResult3_24', json.dumps(hashMap)))
  888. # hashMap = {}
  889. # print()
  890. # print("任务29-->关闭Windows多余的组件,禁止安装其他与应用系统无关的应用程序:" + "未知")
  891. hashMapResult["software29_dict"] = "未知"
  892. hashMapResult["software29"] = "未知"
  893. hashMapResult["grade_result5_29"] = 5
  894. # self.mainFrame.evaluateJavaScript('%s(%s)' % ('showResult5_29', json.dumps(hashMap)))
  895. # hashMap = {}
  896. # print()
  897. grade = 5
  898. task_30_0 = "没有多余服务"
  899. for service0 in dontService:
  900. if (str(windowsService[service0]) == "Running"):
  901. task_30_0 = service0
  902. # service0 + str(windowsService[service0])
  903. grade = grade - 3
  904. break
  905. # print("任务30-->关闭多余服务:" + task_30_0)
  906. shared = getIsShared()
  907. task12_1 = "关闭"
  908. if (shared == 1):
  909. task12_1 = "开启"
  910. grade = grade - 2
  911. # print("任务30-->删除系统默认共享:" + task12_1)
  912. hashMapResult["dontService_dict"] = task_30_0
  913. hashMapResult["dontService"] = task_30_0
  914. hashMapResult["grade_result5_30"] = grade
  915. # self.mainFrame.evaluateJavaScript('%s(%s)' % ('showResult5_30', json.dumps(hashMap)))
  916. # hashMap = {}
  917. # print()
  918. windowsVersion = platform.platform(True)
  919. # print("任务36-->系统版本信息:" + windowsVersion)
  920. task_36_0 = "不是默认值"
  921. grade = 0
  922. isDefaultTTL = getIsDefaultTTL()
  923. if ("true" == isDefaultTTL):
  924. task_36_0 = "是默认值"
  925. grade = 5
  926. # print("任务36-->更改默认TTL返回值:" + task_36_0)
  927. hashMapResult["isDefaultTTL_dict"] = task_36_0
  928. hashMapResult["isDefaultTTL"] = isDefaultTTL
  929. hashMapResult["grade_result5_36"] = grade
  930. # self.mainFrame.evaluateJavaScript('%s(%s)' % ('showResult5_36', json.dumps(hashMap)))
  931. # hashMap = {}
  932. # print()
  933. task_39_0 = "没有安装"
  934. task_39_1 = "无"
  935. if ("false" != getIsKillSoftware()):
  936. task_39_0 = "安装了"
  937. task_39_1 = killVirusSoftwareName[getIsKillSoftware()]
  938. # print("任务39-->是否安装了杀毒软件:" + task_39_0)
  939. # print("任务39-->杀毒软件名称:" + task_39_1)
  940. hashMapResult["IsKillSoftware_dict"] = task_39_0
  941. hashMapResult["IsKillSoftware"] = getIsKillSoftware()
  942. hashMapResult["KillSoftware_dict"] = task_39_1
  943. hashMapResult["KillSoftware"] = task_39_1
  944. hashMapResult["grade_result6_39"] = 5
  945. # self.mainFrame.evaluateJavaScript('%s(%s)' % ('showResult6_39', json.dumps(hashMap)))
  946. # hashMap = {}
  947. # print()
  948. task_41_0 = "关闭状态"
  949. grade = 0
  950. isfirewall = getIsFirewall()
  951. if (1 == isfirewall):
  952. task_41_0 = "打开状态"
  953. grade = 5
  954. # print("任务41-->是否关闭防火墙:" + task_41_0)
  955. # print("任务41-->限定服务器的地址访问:" + "未知")
  956. hashMapResult["isfirewall_dict"] = task_41_0
  957. hashMapResult["isfirewall"] = isfirewall
  958. hashMapResult["grade_result7_41"] = grade
  959. # self.mainFrame.evaluateJavaScript('%s(%s)' % ('showResult7_41', json.dumps(hashMap)))
  960. # hashMap = {}
  961. # print()
  962. cpuInfo = getCpuInfo()
  963. # print("任务43-->监视服务器的CPU、硬盘、内存、网络等资源的使用情况:")
  964. # print("任务43-->cpu数量:" + str(cpuInfo[0]) + "核")
  965. memoryInfo = getMemoryInfo()
  966. # print("任务43-->内存大小:" + str(memoryInfo[0]) + "G")
  967. diskInfo = getDiskInfo()
  968. totalDisk = 0
  969. for diskinfo in diskInfo:
  970. totalDisk = totalDisk + diskinfo[2]
  971. # print("任务43-->硬盘大小:" + str(totalDisk) + "G")
  972. task_43_0 = "未连通"
  973. isInternet = getIsInternet()
  974. if (isInternet == "true"):
  975. task_43_0 = "已连通"
  976. # print("任务43-->网络是否连通:" + task_43_0)
  977. hashMapResult["cpuInfo_dict"] = str(cpuInfo[0])
  978. hashMapResult["memoryInfo_dict"] = str(memoryInfo[0])
  979. hashMapResult["diskinfo_dict"] = str(totalDisk)
  980. hashMapResult["isInternet_dict"] = task_43_0
  981. hashMapResult["grade_result7_43"] = 5
  982. # self.mainFrame.evaluateJavaScript('%s(%s)' % ('showResult7_43', json.dumps(hashMap)))
  983. # hashMap = {}
  984. # print()
  985. raid = getIsRaid()
  986. task_46_0 = "没有主机磁盘raid"
  987. if (raid == 1):
  988. task_46_0 = "有主机磁盘raid"
  989. hashMapResult["raid_dict"] = task_46_0
  990. hashMapResult["raid"] = raid
  991. nicRedundancy = getIsNicRedundancy()
  992. task_46_1 = "没有冗余"
  993. if (nicRedundancy == 1):
  994. task_46_1 = "网卡冗余"
  995. # print("任务46-->能采集主机磁盘(RAID)、网卡等关键部件冗余、双机热备(cluster集群)等硬件内容:" + "未知")
  996. # print("任务46-->网卡是否冗余:" + task_46_1)
  997. hashMapResult["nicRedundancy_dict"] = task_46_1
  998. hashMapResult["nicRedundancy"] = nicRedundancy
  999. hashMapResult["grade_result8_46"] = 5
  1000. # print()
  1001. # self.mainFrame.evaluateJavaScript('%s(%s)' % ('showResult8_46', json.dumps(hashMap)))
  1002. # print(hashMapResult["NewAdministratorName"])
  1003. # print(hashMapResult)
  1004. #oneHundred()
  1005. except Exception as e:
  1006. # self.finished_signal.emit(0)
  1007. pass
  1008. # 设置表格样式
  1009. def set_style(name, weight, color, bold=False):
  1010. style = xlwt.XFStyle()
  1011. font = xlwt.Font()
  1012. # 设置字体类型
  1013. font.name = name
  1014. # 设置字体粗体
  1015. # font.bold = bold
  1016. # 设置字体颜色
  1017. font.colour_index = color
  1018. font._weight = weight
  1019. style.font = font
  1020. return style
  1021. def get_desktop():
  1022. key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, \
  1023. r'Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders', )
  1024. return winreg.QueryValueEx(key, "Desktop")[0]
  1025. class viewsThread(threading.Thread):
  1026. def __init__(self, threadID, name, counter):
  1027. threading.Thread.__init__(self)
  1028. self.threadID = threadID
  1029. self.name = name
  1030. self.counter = counter
  1031. def run(self): # 把要执行的代码写到run函数里面 线程在创建后会直接运行run函数
  1032. app = QtGui.QApplication(sys.argv)
  1033. demoWin = DemoWin()
  1034. sys.exit(app.exec_())
  1035. if __name__ == '__main__':
  1036. buildWindowsSecurityPolicy()
  1037. commonMap = buildCommonMap()
  1038. securityPolicy = windowsSecurityPolicyToDict()
  1039. windowsService = windowsServiceToDict()
  1040. windowsProcess = windowsProcessToDict()
  1041. # 创建新线程
  1042. app = QtGui.QApplication(sys.argv)
  1043. demoWin = DemoWin()
  1044. sys.exit(app.exec_())
  1045. # thread1 = DemoWinThread(1, "Thread-1", 1)
  1046. # thread1.start()

https://pan.baidu.com/s/1Ftz2MDDFoLkxLyQx3Io2yQ

lcb5

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/黑客灵魂/article/detail/775049
推荐阅读
相关标签
  

闽ICP备14008679号