Add timestamped logging, clean up old logs, add .gitignore
This commit is contained in:
1 parent
cc6aae0122
commit
ed0e58af7c
5 files changed
+62
-7257
No files matched your search
@@ -13,9 +13,23 @@ import json
|
||||
import time
|
||||
import uuid
|
||||
import random
|
||||
import logging
|
||||
from datetime import datetime
|
||||
from collections import defaultdict, deque
|
||||
from fastmcp import FastMCP
|
||||
|
||||
# Setup timestamped logging
|
||||
log_filename = f"server_{datetime.now().strftime('%Y-%m-%d_%H-%M-%S')}.log"
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
format='%(asctime)s [%(levelname)s] %(message)s',
|
||||
handlers=[
|
||||
logging.FileHandler(log_filename),
|
||||
logging.StreamHandler()
|
||||
]
|
||||
)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Configuration
|
||||
IMPLANT_URL = os.environ.get("IMPLANT_URL", "http://localhost:9000")
|
||||
BEACON_TIMEOUT = 300 # Seconds before an implant is considered offline (5 min)
|
||||
@@ -337,7 +351,7 @@ class ImplantCheckInHandler(BaseHTTPRequestHandler):
|
||||
self.end_headers()
|
||||
|
||||
def log_message(self, format, *args):
|
||||
print(f"[Implant HTTP] {format % args}")
|
||||
logger.info(f"[Implant HTTP] {format % args}")
|
||||
|
||||
|
||||
def start_implant_http_server(port=8001):
|
||||
@@ -345,7 +359,7 @@ def start_implant_http_server(port=8001):
|
||||
httpd = HTTPServer(("0.0.0.0", port), ImplantCheckInHandler)
|
||||
thread = threading.Thread(target=httpd.serve_forever, daemon=True)
|
||||
thread.start()
|
||||
print(f"Implant check-in server listening on :{port}")
|
||||
logger.info(f"Implant check-in server listening on :{port}")
|
||||
return httpd
|
||||
|
||||
|
||||
@@ -357,8 +371,8 @@ if __name__ == "__main__":
|
||||
|
||||
if len(sys.argv) > 1 and sys.argv[1] == "--http":
|
||||
port = int(sys.argv[2]) if len(sys.argv) > 2 else 8000
|
||||
print(f"Starting agentic-pentest MCP server on http://0.0.0.0:{port}")
|
||||
logger.info(f"Starting agentic-pentest MCP server on http://0.0.0.0:{port}")
|
||||
server.run(transport="http", host="0.0.0.0", port=port)
|
||||
else:
|
||||
print("Starting agentic-pentest MCP server (stdio transport)")
|
||||
logger.info("Starting agentic-pentest MCP server (stdio transport)")
|
||||
server.run()
|
||||
Reference in new issue
Block a user