GithubHelp home page GithubHelp logo

ihrishikesh0896 / service_watchdog Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 24 KB

Python script designed to monitor and log any new services that start listening on localhost (127.0.0.1) on any port. The script is cross-platform compatible, running seamlessly on Windows, Linux, and macOS.

License: MIT License

Python 100.00%

service_watchdog's Introduction

Local Service Monitor

local_service_monitor.py is a Python script designed to monitor and log any new services that start listening on localhost (127.0.0.1) on any port. The script is cross-platform compatible, running seamlessly on Windows, Linux, and macOS.

Features

  • Local IP Detection: Identifies the local IP address of the machine.
  • Service Monitoring: Continuously monitors for new services that are listening on localhost.
  • Background Process: Runs as a background process to ensure continuous monitoring without interrupting other tasks.
  • Cross-Platform Compatibility: Compatible with major operating systems including Windows, Linux, and macOS.
  • Logging: Logs the details of new services, including the port, process ID (PID), and process name, to a log file (service_monitor.log).

Use Case: Integration with EDR Systems

This script can be used as part of a custom EDR (Endpoint Detection and Response) solution to enhance security monitoring capabilities. It helps in detecting temporary ports that are opened and used to send/receive data from other devices or hosts, which can be indicative of suspicious activity or potential security threats.

By integrating this script with your EDR system, you can:

  • Monitor for Temporary Services: Detect new services that open ports temporarily, which might be used for unauthorized data transfer.
  • Log Suspicious Activity: Keep a detailed log of all new services, making it easier to investigate suspicious activities.
  • Automate Responses: Combine this script with other security tools to automate responses to potential threats, such as alerting administrators or shutting down suspicious services.

Requirements

  • Python 3.x
  • psutil library

Installation

  1. Clone the Repository:

    git clone https://github.com/ihrishikesh0896/service_watchdog.git
    cd local_service_monitor
  2. Install Dependencies: Ensure psutil is installed:

    pip install -r requirements.txt

Usage

  1. Run the Script: Execute the script with Python:
    python local_service_monitor.py

How It Works

  1. Initialization: The script configures logging to store logs in service_monitor.log.
  2. IP Address Retrieval: Uses the socket library to determine the local IP address.
  3. Service Detection: Utilizes the psutil library to fetch current services listening on localhost.
  4. Monitoring Process: Runs monitor_services as a background process using the multiprocessing module, checking for new services at specified intervals (default is every 60 seconds).
  5. Logging: Logs any new services detected with their port, PID, and process name.

Example Log Entry

2024-07-26 12:34:56 - New service detected on port 8080 with PID 12345, Name: python

OS Detection

The script detects the operating system and handles OS-specific operations if necessary. If an unsupported OS is detected, it logs a warning and terminates.

Contributing

Contributions are welcome! Please open an issue or submit a pull request if you have any improvements or new features to add.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contact

For questions or suggestions, please contact [[email protected]] or open an issue on GitHub.


service_watchdog's People

Contributors

ihrishikesh0896 avatar

Stargazers

Ashutosh avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.