Shadow-Here


Server : Apache/2.4.41 (Ubuntu)
System : Linux cls 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User : iscuser ( 1001)
PHP Version : 7.4.12
Disable Function : shell_exec,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Directory :  /proc/742/task/988/cwd/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :
Current File : //proc/742/task/988/cwd/file_watch_discord_bk.py
import time
from datetime import datetime
import requests
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler

class DiscordNotifierHandler(FileSystemEventHandler):
    def __init__(self, webhook_url):
        self.webhook_url = webhook_url

    def notify_discord(self, message):
        data = {"content": message}
        try:
            response = requests.post(self.webhook_url, json=data)
            if response.status_code == 204:
                print("Discord notification sent.")
            else:
                print(f"Failed Discord notification: {response.status_code}")
        except Exception as e:
            print(f"Error sending Discord notification: {e}")

    def on_modified(self, event):
        if not event.is_directory:
            msg = f":warning: File modified: `{event.src_path}` at {datetime.now()}"
            print(msg)
            self.notify_discord(msg)

    def on_created(self, event):
        if not event.is_directory:
            msg = f":new: File created: `{event.src_path}` at {datetime.now()}"
            print(msg)
            self.notify_discord(msg)

    def on_deleted(self, event):
        if not event.is_directory:
            msg = f":x: File deleted: `{event.src_path}` at {datetime.now()}"
            print(msg)
            self.notify_discord(msg)

def watch_directory(path_to_watch, webhook_url):
    event_handler = DiscordNotifierHandler(webhook_url)
    observer = Observer()
    observer.schedule(event_handler, path=path_to_watch, recursive=True)
    observer.start()
    print(f"Started watching directory: {path_to_watch}")

    try:
        while True:
            time.sleep(1)
    except KeyboardInterrupt:
        observer.stop()
        print("Stopped watching directory.")

    observer.join()

if __name__ == "__main__":
    # Set your directory to watch here:
#    path_to_watch = "/var/www/html/jecrcedu.in/www"

    path_to_watch = "/var/www/html/isc-domains/isc.edu.in/www"

    # Your Discord webhook URL here:
    discord_webhook = "https://discord.com/api/webhooks/1403364001399701605/e2Ul7aGMStHVQ-MCozwenH4hHM4IFdztSUABpzF3MviFcg0dL0cvizUZOV3lx6fsUtxZ"

    watch_directory(path_to_watch, discord_webhook)

Samx