in cortado/rtas/persistent_scripts.py [0:0]
def main():
log.info("Persistent Scripts")
if _common.is_system():
log.info("Must be run as a non-SYSTEM user")
raise _common.ExecutionError("RTA must be run as a non-SYSTEM user")
# Remove any existing profiles
user_profile = os.environ["USERPROFILE"]
log_file = Path(user_profile) / NAME / ".log"
# Remove log file if exists
_common.remove_file(log_file)
log.info("Running VBS")
_ = _common.execute_command(["cscript.exe", VBS])
# Let the script establish persistence, then read the log file back
time.sleep(5)
_common.print_file(log_file)
_common.remove_file(log_file)
# Now trigger a 'logon' event which causes persistence to run
log.info("Simulating user logon and loading of profile")
# _common.execute(["taskkill.exe", "/f", "/im", "explorer.exe"])
# time.sleep(2)
_ = _common.execute_command("C:\\Windows\\System32\\userinit.exe", shell=True)
_ = _common.execute_command(["schtasks.exe", "/run", "/tn", NAME])
# Wait for the "logon" to finish
time.sleep(30)
_common.print_file(log_file)
# Now delete the user profile
log.info("Cleanup")
_common.remove_file(log_file)
_ = _common.execute_command(["schtasks.exe", "/delete", "/tn", NAME, "/f"])