Search code examples
python-2.7bufferread-writekeylogger

Logic of Keylogger Code


I am trying to understand keylogger code (for ethical hacking) on YouTUBE

But I cannot understand the purpose of

  1. Opening outputfile for reading
  2. Saving to buffer
  3. Closing the outputfile
  4. Opening the outputfile for writing
  5. Save all log information as a variable

Why not simply open writable file and then close when the program terminates?

What is the logic to the above approach? Is there some sort of best practice? Please clarify

enter image description here


Solution

  • This is because if your file already has any data, then the keylogger will first combine all the old data and new data together and then finally write it into your output file. If it directly writes it then the old data will be vanished...

    Yeaa! you can try using f=open('c:\output.txt', 'a')
    the 'a' here will then append data and the old data will be automatically saved.... try this out! may be this helps solve your problem