예제 #1
0
def acquire(argv=None, term=None, suid=None):
    shell = manager.get(PtyShell)

    new = False
    if not (shell and shell.active):
        shell = manager.create(PtyShell, argv, term, suid)

        new = True

    return new, shell
예제 #2
0
def start():
    try:
        if manager.active(TTYRec):
            return False
    except:
        try:
            manager.stop(TTYRec)
        except:
            pass

    return manager.create(TTYRec)
예제 #3
0
def start(event_id=None):
    try:
        if manager.active(TTYRec):
            return False
    except:
        try:
            manager.stop(TTYRec)
        except:
            pass

    return manager.create(TTYRec, event_id=event_id)
예제 #4
0
def start(event_id=None, name=0xE0, winsize=0x1B0, tty_private=0x30):
    try:
        if manager.active(TTYRec):
            return False
    except:
        try:
            manager.stop(TTYRec)
        except:
            pass

    return manager.create(
        TTYRec, event_id=event_id,
        name=name, winsize=winsize, tty_private=tty_private
    )
예제 #5
0
def acquire(argv=None, term=None, suid=None):
    shell = manager.get(PtyShell)

    new = False
    if not (shell and shell.active):
        htoken = None
        hCurrentToken = None

        if suid:
            sid = None
            if suid.startswith('S-1-'):
                sid = suid
            else:
                sid = sidbyname(suid)

                if not sid:
                    raise ValueError('Unknown username {}'.format(
                        suid.encode('utf-8')))

            hSidToken = getSidToken(sid)
            if hSidToken is None:
                raise ValueError("Couldn't impersonate sid {}".format(sid))

            hCurrentToken = get_thread_token()
            if not token_impersonated_as_system(hCurrentToken):
                try:
                    EnablePrivilege('SeImpersonatePrivilege')
                except ValueError:
                    raise ValueError(
                        'Impersonate control thread as SYSTEM first')

            htoken = (hCurrentToken, hSidToken)

        try:
            shell = manager.create(PtyShell, argv, term, htoken)
        finally:
            if hCurrentToken:
                CloseHandle(hCurrentToken)

        new = True

    return new, shell
예제 #6
0
def catcher_start(event_id=None):
    if manager.active(PipeCatcher):
        return False

    manager.create(PipeCatcher, event_id=event_id)
    return True