{"id":13681149,"url":"https://github.com/JPCERTCC/DetectLM","last_synced_at":"2025-04-30T03:30:41.354Z","repository":{"id":97103427,"uuid":"108970520","full_name":"JPCERTCC/DetectLM","owner":"JPCERTCC","description":"Detecting Lateral Movement with Machine Learning","archived":true,"fork":false,"pushed_at":"2017-10-31T09:24:55.000Z","size":398,"stargazers_count":137,"open_issues_count":2,"forks_count":38,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-11-12T00:36:27.594Z","etag":null,"topics":["deep-learning","elasticsearch","kibana","machine-learning","powershell","python","security"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JPCERTCC.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-10-31T09:02:30.000Z","updated_at":"2024-08-10T07:48:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"3293b53f-ce2b-4e61-9515-c9be375ad4cd","html_url":"https://github.com/JPCERTCC/DetectLM","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JPCERTCC%2FDetectLM","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JPCERTCC%2FDetectLM/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JPCERTCC%2FDetectLM/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JPCERTCC%2FDetectLM/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JPCERTCC","download_url":"https://codeload.github.com/JPCERTCC/DetectLM/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251635020,"owners_count":21619126,"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":["deep-learning","elasticsearch","kibana","machine-learning","powershell","python","security"],"created_at":"2024-08-02T13:01:27.103Z","updated_at":"2025-04-30T03:30:40.653Z","avatar_url":"https://github.com/JPCERTCC.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# DetectLM\n  Detecting Lateral Movement with Machine Learning.  \n  DetectLM is a proof of concept code to analyze and detect malicious commands executed via cmd.exe with machine learning.    \n\n  ![DetectLM Architecture](images/system.png)\n\n* **DetectLM.py**: Runs on server. Detect malicious Windows command execution using machine learning and blacklist.\n* **Invoke-DetectLM.ps1**: Runs on client. Sends the logs to the Elasticsearch. Confirm analysis result and display alert message.\n* **cmdlogs.bat**: Collect commands executed via cmd.exe.\n\n## Requirements\n  Each tools require the following modules:\n\n### for Server\n\n* Python3\n* NumPy http://www.numpy.org/\n* Pandas http://pandas.pydata.org/\n\n### for Client\n\n* PowerShell v3 or later\n\n## Supported Client OS\n\n* Windows 8.1\n* Windows 10\n\n## Usage\n\n### for Server\n1. Download and install [Elasticsearch](https://www.elastic.co/downloads/elasticsearch).  \n2. Download and install [Kibana](https://www.elastic.co/downloads/kibana).  \n3. Start Elasticsearch and Kibana.  \n4. Download and save the DetectLM from Github.\n  ```\n  git clone https://github.com/JPCERTCC/DetectLM.git\n  ```\n5. And your Elasticsearch IP Address to **DetectLM/server/config/config.ini**.  \n  ```\n  els_server      = localhost\n  ```\n6. And mapping in Elasticsearch.\n  ```\n  $ python DetectLM.py -m\n  ```\n7. Create cron jobs for **DetectLM.py**.  \n  For example  \n  ```\n  */15 * * * * python3.6 [Folder Name]/DetectLM.py\n  ```\n\n### for Client\n1. Download **client/cmdlogs.bat** and **client/Invoke-DetectLM.ps1**.  \n2. Register **cmdlogs.bat** in the registry entry that starts automatically when the cmd.exe is executed.  \n  ```\n  \u003e reg add \"HKEY_CURRENT_USER\\Software\\Microsoft\\Command Processor\" /v AutoRun /d [Downloaded Folder Name]\\cmdlogs.bat\n  ```\n  or\n  ```\n  \u003e reg add \"HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Command Processor\" /v AutoRun /d [Downloaded Folder Name]\\cmdlogs.bat\n  ```\n3. Create a scheduled task for **Invoke-DetectLM.ps1**.\n  ```\n  \u003e powershell -exec bypass .\\Invoke-DetectLM.ps1 -ehost [Elasticsearch Server]\n  ```\n\n## How to Check Log\n  Executed command logs can be checked from Kibana.  \n  AlertLevel 2 is the malicious commands.\n\n  ![Kibana GUI](images/kibana.png)\n\n### AlertLevel\n  The log has three levels of detection level  \n* **2** : Error log reported by user\n* **1** : Logs detected as malicious by machine learning\n* **0** : No Alert (Default)\n\n### Ignore Flag\n  Ignore flag is automatically added to any command executed by the user.    \n  When malicious Windows command execution is detected by machine learning, a notification will be sent to the client.  \n  A user also can set a ignore flag to specific command execution when asked by client tool.  \n\n  ![Alert example](images/alert.png)\n\n### Dashboard\n  Using Kibana dashboard, logs are visualized.  \n  Example of dashboard is in **kibana_objects**. Import is [Management -\u003e Saved Objects -\u003e Import]\n\n  ![Kibana dashbord](images/kibana_dashboard.png)\n\n## Known Issues\n* This tool supports Windows commands executed via cmd.exe. Any command via PowerShell are not logged nor monitored.\n* Client tool has an issue when handling command line includes \"/c\" or \"/k\".\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJPCERTCC%2FDetectLM","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FJPCERTCC%2FDetectLM","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJPCERTCC%2FDetectLM/lists"}