poc: psutil for process watcher

This commit is contained in:
Zamitto 2024-07-01 20:23:39 -03:00
parent 9870213fff
commit 0c1a75eedd
2 changed files with 12 additions and 0 deletions

View File

@ -3,3 +3,4 @@ cx_Freeze
cx_Logging; sys_platform == 'win32'
lief; sys_platform == 'win32'
pywin32; sys_platform == 'win32'
psutil

View File

@ -2,7 +2,9 @@ import sys
from http.server import HTTPServer, BaseHTTPRequestHandler
import json
import urllib.parse
import psutil
from downloader import Downloader
from time import time
torrent_port = sys.argv[1]
http_port = sys.argv[2]
@ -33,6 +35,15 @@ class Handler(BaseHTTPRequestHandler):
if self.path == "/healthcheck":
self.send_response(200)
self.end_headers()
if self.path == "/process":
start_time = time()
process_path = set([proc.info["exe"] for proc in psutil.process_iter(['exe'])])
self.send_response(200)
self.send_header("Content-type", "application/json")
self.end_headers()
self.wfile.write(json.dumps(list(process_path)).encode('utf-8'))
print(time() - start_time)
def do_POST(self):
if self.path == "/action":