|
| 1 | +import os,psutil,time,hashlib,win32con,win32api |
| 2 | + |
| 3 | +def search_files(path,tagfile): |
| 4 | + number=0 |
| 5 | + fulldir_result=[] |
| 6 | + for ipath in os.listdir(path): |
| 7 | + fulldir = os.path.join(path,ipath) |
| 8 | + if(os.path.isfile(fulldir)): |
| 9 | + if(tagfile in os.path.split(fulldir)[1]): |
| 10 | + fulldir_result.append(fulldir) |
| 11 | + number=number+1 |
| 12 | + return fulldir_result |
| 13 | +def sha256(filname): |
| 14 | + with open(filname, "rb") as f: |
| 15 | + sha256obj = hashlib.sha256() |
| 16 | + sha256obj.update(f.read()) |
| 17 | + hash_value = sha256obj.hexdigest() |
| 18 | + return hash_value |
| 19 | + |
| 20 | +disks_list=psutil.disk_partitions() |
| 21 | +print(disks_list) |
| 22 | +checked=[] |
| 23 | + |
| 24 | +while(True): |
| 25 | + for pid in psutil.pids(): |
| 26 | + try: |
| 27 | + p=psutil.Process(pid) |
| 28 | + if os.path.basename(p.exe())=='dxFastRun.exe': |
| 29 | + p.kill() |
| 30 | + print("kill") |
| 31 | + os.remove(p.exe()) |
| 32 | + print("delete") |
| 33 | + except: |
| 34 | + pass |
| 35 | + |
| 36 | + |
| 37 | + disk_list=psutil.disk_partitions() |
| 38 | + for i in range(0,len(disks_list)): |
| 39 | + try: |
| 40 | + disk_list.remove(disks_list[i]) |
| 41 | + except: |
| 42 | + pass |
| 43 | + print(disk_list) |
| 44 | + for i in range(0,len(disk_list)): |
| 45 | + if(disk_list[i].device in checked): |
| 46 | + pass |
| 47 | + else: |
| 48 | + exe_list=search_files(disk_list[i].device,'.exe') |
| 49 | + print(exe_list) |
| 50 | + for i in range(0,len(exe_list)): |
| 51 | + sha=sha256(exe_list[i]) |
| 52 | + print(sha) |
| 53 | + if(sha256(exe_list[i])=="767ac83224a31b257ed755871b06bf7d4afae2ca65015be69c7691df355d7c2e"): |
| 54 | + print("found virus in disk") |
| 55 | + os.remove(exe_list[i]) |
| 56 | + print("delete") |
| 57 | + win32api.SetFileAttributes(exe_list[i].replace(".exe",""), win32con.FILE_ATTRIBUTE_NORMAL) |
| 58 | + print("set dirs") |
| 59 | + checked.append(disk_list[i].device) |
| 60 | + |
| 61 | + for i in range(0,len(checked)): |
| 62 | + try: |
| 63 | + if(checked[i] in str(psutil.disk_partitions())): |
| 64 | + pass |
| 65 | + else: |
| 66 | + checked.remove(checked[i]) |
| 67 | + except: |
| 68 | + checked=[] |
| 69 | + |
| 70 | + time.sleep(1) |
0 commit comments