I am using python 3. On windows 7.
I recently made a python keylogger. It saves the keylogs in a text file as i type and upon pressing WIDOWS Key it sends the text from the textfile to my gmail account using smtplib.
I have to manually start the python file and it gets quite boring!
What my question is that is there any way to run that keylogger script on startup (without manually putting it in the startup folder -- because i want the script to do everything itself), and then to quickly close the script as soon as the user presses the shutdown button (and delay the shutdown time somehow).
The reason i want this is because i belive that a keylogger must be hidden from the user not to include that it must be hidden from the antivirus ;)
i have tested this with python task scheduler but it only takes time parameters (i.e. from 5:00 to 7:00) not the startup and shutdown time.
If i am to include more information on this topic that you need to solve this question i will gladly help you!
Thanks in advance
Related
I wrote a python script to automate content recordings in AdobePremiere Pro. It is supposed to be triggered by tasks created on Windows' Task Scheduler. But it is not working as intended.
It seems like the commands expected are not being sent for some reason.
This is the link to the repository containing all the logic tried to achieve the automation task:
https://github.com/rfabreu/AdobePremiere-Recording-Automation-Python
After writing the python scripts, the batch scripts were created to execute those python files.
Then on the Task Scheduler, tasks were created to run the required batch scripts.
Python script to start a recording:
import schedule
import time
from pynput import keyboard
def start_recording():
with keyboard.Press(keyboard.Key.g):
keyboard.press(keyboard.Key.g)
keyboard.release(keyboard.Key.g)
schedule.every().day.at("18:50").do(start_recording)
while True:
schedule.run_pending()
time.sleep(1)
Batch script to run the python scripts when triggered:
#echo off
cd [enter_dir_name]
set PYTHON_EXE=python
set SCRIPT_DIRECTORY=.
for %%f in (%SCRIPT_DIRECTORY%\*.py) do (
start /B /MIN %PYTHON_EXE% "%%f"
)
The expected result is that the script sends keyboard commands at a certain time:
So, considering that AdobePremiere Pro is open, the first script should send a key press command of the "g" key to start recording when triggered by the bat file.
Then, when triggered at a certain time another script should send the key press command of the "esc" key to stop recording.
The final step if for the third script to send a key press command of the "enter" key to save the recorded content.
After trying different things, including updating python on the pc, nothing happens.
When checking the Task Scheduler logs it seems like the task to run the bat file was executed successfully, but then the desired outcome did not reflect any effects on AdobePremiere Pro.
I am not sure how to phrase this question (does a tree falling in the forest make a sound if there's no one there to hear it?) but I have a simple program that visits several websites through a selenium loop, opening each url in a new tab.
I know the program works fine when I execute it and watch it work. When that happens, the program opens the tabs as instructed, then leaves them open for me to check that everything worked fine, then it sends me an email to let me know that the program has run.
Now my problem is that I have scheduled this task in Windows, and I receive the email when the program executes, but when this happens and I check my browser I don't see any tabs left open, as I usually see after the program has run.
So my question is/are: does Selenium have some code-only mode that executes the programs in the background and goes to the places I indicated it to go, without opening the tabs if I am not using the browser at the time? Could it be possible that the program is running and reaching the end -thus sending me the email- but did not open the tabs and thus it is not working when I schedule it to work and I am not at the computer or the computer is on standby (I have scheduled it to wake the computer to execute the program)
Is there anything I am missing? Thanks!
We're running a Python script (which uses multithreading) to do some work on an Amazon-EC2 based Windows Server 2008 machine. When the machine starts, I can see that it starts executing the Python script, and then I start seeing messages like the following in the event log:
Windows detected your registry file is still in use by other applications or services. The file will be unloaded now. The applications or services that hold your registry file may not function properly afterwards.
DETAIL -
19 user registry handles leaked from \Registry\User\S-1-5-21-2812493808-1934077838-3320662659-500_Classes:
Process 2872 (\Device\HarddiskVolume1\Python27\python.exe) has opened key \REGISTRY\USER\S-1-5-21-2812493808-1934077838-3320662659-500_CLASSES
Process 2844 (\Device\HarddiskVolume1\Python27\python.exe) has opened key \REGISTRY\USER\S-1-5-21-2812493808-1934077838-3320662659-500_CLASSES
Process 2408 (\Device\HarddiskVolume1\Python27\python.exe) has opened key \REGISTRY\USER\S-1-5-21-2812493808-1934077838-3320662659-500_CLASSES
What exactly does this mean, and how do I stop Windows from killing some of the threads?
When a scheduled task is configured to run as a particular user, that user's account is logged on non-interactively in order to run the task. When the task is finished, the user's registry hive is unloaded. For some reason, this is happening prematurely.
From your description, you have a single scheduled task, which launches various subprocesses. It seems likely that the parent process is exiting before the subprocesses are finished, and that this is causing the user's registry hive to be unloaded. You can verify this theory by turning on auditing for process creation and termination (in Group Policy under Advanced Audit Policy Configuration) or by using a tool such as Process Monitor (available from the MS website).
Assuming this is the cause, the fix is for the parent process to wait for the subprocesses to exit before itself exiting; alternatively, depending on your circumstances, it may be sensible for the parent task to simply never exit.
If you don't have direct control over the relationship between the parent process and the subprocesses then you'll need to create a new parent process to launch the script for you, and then either wait for all subprocesses to complete or sleep forever, as appropriate.
It may be that some your files are corrupted. Try the following:
Perform SFC(System file Checker) scan and see if it helps.
Press Windows key + X.
Select Command Prompt(Admin).
Type sfc /scannow and hit enter.
Also perform a chkdsk:
Press Windows Logo + C to open the Charms bar.
Now click Settings and then More PC Settings.
Now click General and then click Restart Now under Advanced Startup.
Now Click Troubleshoot.
Now click Advanced options and select Command prompt.
Type chkdsk /r and hit enter.
Last but not least, if the above doesn't work, you can perform a startup repair:
Press Windows logo + W to open the search box.
Type Advanced Startup options, hit enter.
Then Click Restart Now under Advanced Startup.
Now Click Troubleshoot.
Then click Advanced options and then Automatic Repair.
Hope it helps.
I have written a simple python script that runs as soon as a certain user on my linux system logs in. It ask's for a password... however the problem is they just exit out of the terminal or minimize it and continue using the computer. So basically it is a password authentication script. So what I am curious about is how to make the python script stay up and not let them exit or do anything else until they entered the correct password. Is there some module I need to import or some command that can pause the system functions until my python script is done?
Thanks
I am doing it just out of interest and I know a lot could go wrong but I think it would be a fun thing to do. It can even protect 1 specific system process. I am just curious how to pause the system and make the user do the python script before anything else.
There will always be a way for the user to get past your script.
Let's assume for a moment that you actually manage to block the X-server, without blocking input to your program (so the user can still enter the password). The user could just alt-f1 out of the X-server to a console and kill "your weird app". If you manage to block that too he could ssh to the box and kill your app.
There is most certainly no generic way to do something like this; this is what the login commands for the console and the session managers (like gdm) for the graphical display are for: they require a user to enter his password before giving him some form of interactive session. After that, why would you want yet another password to do the same thing? the system is designed to not let users use it without a password (or another form of authentication), but there is no API to let programs block the system whenever they feel like it.
You want the equivalent of a "modal" window, but this is not (directly) possible in a multiuser, multitasking environment.
The next best thing is to prevent the user from accessing the system. For example, if you create an invisible window as large as the display, that will intercept any mouse events, and whatever is "behind" will be unaccessible.
At that point you have the problem of preventing the user from using the keyboard to terminate the application, or to switch to another application, or to another virtual console (this last is maybe the most difficult). So you need to access and lock the keyboard, not only the "standard" keyboard but the low-level keys as well.
And to do this, your application needs to have administrative rights, and yet run in the user environment. Which starts to look like a recipe for disaster, unless you really know what you are doing.
What you want to do should be done through a Pluggable Authentication Module (PAM) that will integrate with your display manager. Maybe, you can find some PAM module that will "outsource" or "callback" some external program, i.e., your Python script.
Since this thing is just for fun, here's a work arond: make the script log the user out if he ignores the prompt for some time, or closes the terminal/kills the process. Here's how it might look like for gnome:
import os
def set_exit_handler(func):
import signal
signal.signal(signal.SIGHUP, func) # on closing the terminal
signal.signal(signal.SIGTERM, func) # on killing the process
import atexit
atexit.register(func) # on Ctrl-C, Ctrl-D and other proper exits
if __name__ == "__main__":
def on_exit(a=None, b=None):
print "exit handler triggered"
os.system("gnome-session-quit --logout --no-prompt")
set_exit_handler(on_exit)
print "Enter password:"
raw_input()
# ... some verification/timeout code ...
If the user will now close the terminal or kill the process, he'll be logged out instantaneously :)
I'm working on a project for school where e-mails will be pulled from an inbox and downloaded to different locations depending on how things are parsed. The language I'm writing in is Python, and the environment it will be run on is Windows XP. The idea is that the program will run in the background with no interaction from the user until they basically shutdown their computer. A concern I had is what this will mean if they shut it down while a file is in the process of being saved, and what I can do to handle it.
Will it just be a file.part thing? Will the shutdown throw the "Waiting to close X application" message and finish saving before terminating on its own?
use atexit module
You should really check this out: Link (How Windows Shuts Down)
easy crossplatform/crosslanguage way of handling partial file saving:
save to a temporary filename like "file.ext.part"
after you're done saving, rename to "file.ext"