Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python3 compatibility, Pep8 formatting, Environment variable options. #20

Merged
merged 1 commit into from
Dec 30, 2016
Merged

Conversation

cjwelborn
Copy link
Contributor

This PR allows the linux version of KeyLogger to run on Python 2 or 3.
The code was reformatted in Pep8 style to help with readability.
Three environment variables are checked so options can be set:

  • pylogger_file: Sets the file path for the logger. Defaults to: ~/Desktop/file.log
  • pylogger_cancel: Sets the cancel key for the logger. Defaults to: `
  • pylogger_clean: Determines whether the log file should be cleared at the start. Defaults to: No (not set)

Example usage of environment variables:

# Tells the keylogger to clear the log file, by simply setting pylogger_clean to anything.
# Tells the keylogger to use ! as the cancel key, by setting pylogger_cancel to "!"
# Tells the keylogger to use /home/cj/myfile.txt as the log file by setting pylogger_file.
pylogger_clean=1 pylogger_cancel='!' pylogger_file="/home/cj/myfile.txt" python3 ./keylogger.py

If keylogger.py is made executable (chmod +x keylogger.py), you can drop the python3 part:

pylogger_file="/home/cj/myfile.txt" ./keylogger.py

By prepending the environment variables to the command, it sets the variable for that command's subshell only. They can be set permanently by putting them in .bashrc.

These options could just as well be implemented using command-line options, but I thought the argument parsing might add too much code (even though docopt only takes one line after you define the usage string).

@cjwelborn cjwelborn mentioned this pull request Dec 29, 2016
@cjwelborn
Copy link
Contributor Author

The owner of pyxhook accepted my changes for pyxhook.py, so if you don't like the keylogger.py changes you could just update from there.

Copy link
Owner

@GiacomoLaw GiacomoLaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks awesome, thanks for your Help!

Please update the readme.md to support your changes, and then you are all good to go!

@GiacomoLaw
Copy link
Owner

Also, please squash your commits into one. 😉

Thanks!

@GiacomoLaw GiacomoLaw added this to the V2.2 milestone Dec 30, 2016
This is a collection of 5 squashed commits:

Allow environment variable log file setting,
use env python.

Pep8 formatted, Python 3+ compatibility.

Further Python 3 fixes, allow cancel key setting.

Allow clearing the file through an env var. A couple of cleanups.

Allow clearing the file through an env var.

A couple of cleanups, doc changes.
@cjwelborn
Copy link
Contributor Author

@GiacomoLaw, readme updated, commits squashed. 😄

Copy link
Owner

@GiacomoLaw GiacomoLaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work, thanks so much!

@GiacomoLaw GiacomoLaw merged commit d670a1f into GiacomoLaw:master Dec 30, 2016
@cjwelborn cjwelborn deleted the python3 branch December 30, 2016 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants