Problem opening and closing file to send over email python

4 replies
I've been dabbling in cyber security and doing some research on parenting monitoring tools and thought a key-logger/email sender would be a good project to learn how to build.

So the code I have sends an email correctly, and also sends the generated text file as an attachment.

The problems I'm having and need help with are: 1. As the key logger continues to log keystrokes, the email attachment does not update the file, it just sends the original file in the original path.
#closing #email #file #opening #problem #python #send
Avatar of Unregistered
  • Profile picture of the author Jeff Polaski
    Try to resolve it by implementing a mechanism to update the file and attach the most recent version to the email.
    {{ DiscussionBoard.errors[11758355].message }}
  • Hello,

    I am new here. I am sorry, but I cannot make a thread. So I will ask here.


    Lately, we update the main menu on our website. But request to contact are now 1 per day(before was 10-20 requests per day). We have organic traffic around 20K per month. So there are always some requests even if most of them are fake.

    I saw a bug that main menu was not shown, but I cannot reproduce it again.(even if I clean cookies)

    So, I am here to ask you to go to website and see if the main Manu in top works properly(Products, Solutions, Customers, Pricing, Resources and Free Trial Button).

    I would really appreciate your help.

    Thank you in advance
    {{ DiscussionBoard.errors[11761044].message }}
  • Profile picture of the author guinemojo23
    Hi!
    It's great that you're exploring cybersecurity! To address your issue, ensure the keylogger program appends keystrokes to the text file and consistently reads the latest version just before attaching it to the email. Incorporate periodic updates or event triggers to send emails with current data. Remember to use these skills responsibly and ethically
    {{ DiscussionBoard.errors[11764816].message }}
  • Profile picture of the author Brenda Gray
    The issue you're encountering with the keylogger not updating the email attachment is likely due to the fact that you're attaching the original file at the start of your program, and it doesn't dynamically update. To achieve this, you can follow these steps:

    Open the file in "append" mode when logging keystrokes, so new data gets appended to the end of the file instead of overwriting it.

    Periodically (e.g., every few minutes), read the contents of the file and send them as an email attachment.

    After sending the email, you can truncate or clear the file to remove the logged keystrokes you've already sent.
    {{ DiscussionBoard.errors[11769017].message }}
  • Profile picture of the author kevin francis
    Banned
    Ensure you've replaced 'your_file.txt' with the actual path to the file you want to attach, and replace 'your_email@gmail.com', 'recipient_email@example.com', 'your_email_password', and 'smtp.gmail.com' with your actual email and SMTP server details.

    This script creates an email message, attaches the specified file, connects to your email server securely, and sends the email with the attached file. Make sure you have the necessary permissions and correct file paths to access and attach the file.

    Python programming services are preferred due to their adaptability, readability, productivity, and robust community backing. Python is a solid option that can help you accomplish your development goals successfully, whether you're creating a web application, data analysis tool, AI solution, or anything in between.
    {{ DiscussionBoard.errors[11770392].message }}
Avatar of Unregistered

Trending Topics