4

I am developing a key-logger on Python (only for curiosity sake). And the script will be an executable. The process will not need a UI or user interaction.

Is there any way, even in another executable to make the key-logger start at start-up?

Josiah Yoder
  • 3,321
  • 4
  • 40
  • 58
Richard Paul Astley
  • 323
  • 3
  • 7
  • 18

5 Answers5

4

I don't use Windows, but you can try making a batch script that runs your python file and make that script Run a program automatically when Windows starts:

  1. Click the Start button Picture of the Start button , click All Programs, right-click the Startup folder, and then click Open.

  2. Open the location that contains the item you want to create a shortcut to.

  3. Right-click the item, and then click Create Shortcut. The new shortcut appears in the same location as the original item.

  4. Drag the shortcut into the Startup folder.

As I said, I don't use Windows, so it might be totally wrong.

You can refer here for making the BAT file, which basically says:

@echo off
python c:\somescript.py %*
pause
Community
  • 1
  • 1
Sait
  • 19,045
  • 18
  • 72
  • 99
  • 2
    It's not mandatory to keep script anywhere else and make shortcuts. just put the file in start folder. – Andersson Jun 30 '15 at 06:29
  • It's not really a scritpt, it will be an executable and I'd like to suppose that i don't have access to the computer – Richard Paul Astley Jun 30 '15 at 13:33
  • 1
    I assume a keylogger is a detached or GUI application, so the OP won't want a console popping up from a batch file. Just create a shortcut in the Startup folder that has the desired command line, using the fully-qualified path to `pythonw.exe`, or whatever the OP's packaged executable is named. Better still would be to make this a scheduled task that runs with highest privileges (i.e. elevated, if the user is an administrator) when the user logs on. – Eryk Sun Jun 30 '15 at 14:29
2

I think that the above answers are too complex. What I did was just drag and drop or copy and paste my file in the startup folder by clicking the quick access toolbar, typing "startup", and the job is done.

screenshot of file manager

I am using Windows 10 operating system, so it might be different in your case.

I hope this is useful.

Edit: The key to this solution is to have the .py extension files open by default by the python console (not a text editor), otherwise it will just open the file instead of executing it. In order to select the default program a type of file is opened with, right click on the .py file -> Open with -> Choose default program. See this example:
screenshot of open with prompt

Bram
  • 2,515
  • 6
  • 36
  • 58
Om Parab
  • 70
  • 7
1

Use VBScript:

1-> create anyname.vbs with this data:

Set wvbs=CreateObject("Wscript.Shell") wvbs.run "full location of your File",0

2-> copy anyname.vbs file in C:\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup this folder

Now when windows start it will run your file in hidden mode

1

Open run with "Start + R", then open "shell:startup". it opens you a folder(the folder that was mentioned before at start menu), and every file that is on this folder, well run at startup.

The folder path is: "C:\Users\USERNAME\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup" (you can copy it on windows explorer, or copy this path and put your account name on USERNAME)

this is the trick i used in my script:

from os import getcwd
from shutil import copy
copy(getcwd()+'/FILE_NAME.exe','C:/Users/USERNAME/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Startup')

They are some ways for file name as well, but im not familiar with it. this code copies it self to startup folder and starts each time windows boots

Jean-François Fabre
  • 137,073
  • 23
  • 153
  • 219
0

Create a shortcut in the shell:startup folder with an absolute path to your pythonw.exe executable. The w version of Python is needed so that it starts up without a shell in the background.

Detailed instructions

Open the startup folder

Type the Windows and R keys at the same time. In the Run dialog, type shell:startup and it enter. This takes you to the Startup folder. Shorcuts in this folder are launched when the computer starts. (For me, the startup folder is at C:\Users\username\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup.)

Create new shortcut

Right-click in this folder and say "New shortcut." Browse to "This PC," "Windows (C:)," "Program Files,", "Python39", and select pythonw.exe. Your Python install is likely in a different location. More recently, Python is found somewhere within %appdata%. (You can paste %appdata% into the run dialog to open this folder and look for Python. It opens in Roaming by default, but be sure to look in Local, too.)

As mentioned at the start of this answer, it is important that you select pythonw.exe rather than python.exe as pythonw.exe will run without opening a command prompt.

On the next "Create Shortcut" screen, titled, "What would you like to name the shortcut," you can name it whatever you want. For the OP, I recommend "Self penetration test."

Click "Finish."

Edit the shortcut to launch your script

In the Startup folder, right click on the app you just created and select "Properties."

In the Properties dialog's Shortcut tab, edit the "Target" to look something like "C:\Program Files\Python310\pythonw.exe" pentest_keylogger.py and the "Start in" to be the folder in which pentest_keylogger.py is found. (As above, you will need to use your Python distribution's path.)

Test your script

Hit OK. Then double-click on the icon to see if it works silently as you desire.

Finally, reboot your machine and use resmon (from the run dialog) or Ctl-Alt-Delete and the task manager to see if your app is running in the background.

Acknowledgements

Thanks to Eryk Sun and Behfar baghery for the core ideas presented here.

Josiah Yoder
  • 3,321
  • 4
  • 40
  • 58