""" Guardian AI – Thailand Security Automation ผู้พัฒนา: สุธิดล แซ่กั้ว เวอร์ชัน: 2.0 (Full Automation + Daily Dashboard + LINE Notify) """
import os, json, datetime, time, random, socket, platform, requests
def send_line_notify(message, token): url = 'https://notify-api.line.me/api/notify' headers = {'Authorization': f'Bearer {token}'} data = {'message': message} response = requests.post(url, headers=headers, data=data) return response.status_code
# ------------------------
# Zero-Day Sentinel AI
# ------------------------
ZERO_DAY_SIGNATURES = ["exploit_attempt","unusual_payload","obfuscation_detected","zero-day-pattern"]
THREAT_LOG = []
def detect_zero_day(data):
return [sig for sig in ZERO_DAY_SIGNATURES if sig in data]
def log_threat(raw_data, matched):
threat = {
"time": datetime.datetime.now().isoformat(),
"hostname": socket.gethostname(),
"system": platform.system(),
"signature": matched,
"raw_data": raw_data
}
THREAT_LOG.append(threat)
print("[ALERT] Zero-Day Detected:", threat)
def save_daily_log():
filename = f"guardian_log_{datetime.datetime.now().date()}.json"
with open(filename, "w", encoding="utf-8") as f:
""" Guardian AI – Thailand Security Automation ผู้พัฒนา: สุธิดล แซ่กั้ว เวอร์ชัน: 2.0 (Full Automation + Daily Dashboard + LINE Notify) """
import os, json, datetime, time, random, socket, platform, requests
def send_line_notify(message, token): url = 'https://notify-api.line.me/api/notify' headers = {'Authorization': f'Bearer {token}'} data = {'message': message} response = requests.post(url, headers=headers, data=data) return response.status_code
ZERO_DAY_SIGNATURES = ["exploit_attempt","unusual_payload","obfuscation_detected","zero-day-pattern"] THREAT_LOG = []
def detect_zero_day(data): return [sig for sig in ZERO_DAY_SIGNATURES if sig in data]
def log_threat(raw_data, matched): threat = { "time": datetime.datetime.now().isoformat(), "hostname": socket.gethostname(), "system": platform.system(), "signature": matched, "raw_data": raw_data } THREAT_LOG.append(threat) print("[ALERT] Zero-Day Detected:", threat)
def save_daily_log(): filename = f"guardian_log_{datetime.datetime.now().date()}.json" with open(filename, "w", encoding="utf-8") as f: json.dump(THREAT_LOG, f, ensure_ascii=False, indent=2)
def analyze_news(news_items): threats = [] for news in news_items: if any(word in news.lower() for word in ["attack", "breach", "malware"]): threats.append(news) return threats
def threat_assessment(threat_list): assessments = [] for threat in threat_list: probability = random.uniform(0.5, 1.0) severity = random.randint(1, 10) response_level = "High" if severity > 7 else "Medium" assessments.append({ "threat": threat, "probability": round(probability,2), "severity": severity, "response_level": response_level }) return assessments
def detect_drone(drone_data): return [d for d in drone_data if "intruder_drone" in d]
def drone_response(detected_list): for drone in detected_list: print("[DRONE ALERT] Detected:", drone) print(">>> Activating countermeasure...")
def psychological_deterrence(threat_assessments): for threat in threat_assessments: if threat["response_level"]=="High": print(f"[PSYCH ALERT] Warning issued for threat: {threat['threat']}") print(">>> Influence: Encourage alliance/tech exchange")
def feedback_update(): print("[FEEDBACK] Updating AI models and improving prediction...")
def main_loop(line_token): # Sensor Example cyber_logs = ["login_success", "exploit_attempt", "heartbeat_normal", "obfuscation_detected"] news_feed = [ "New malware attack detected in Asia", "Tech conference announced", "Data breach reported in company X" ] drone_feed = ["intruder_drone_alpha", "normal_drone_beta"]
# Zero-Day Detection
for log in cyber_logs:
matched = detect_zero_day(log)
if matched:
log_threat(log, matched)
send_line_notify(f"🚨 Zero-Day Threat Detected: {matched}", line_token)
# Info Guardian
news_threats = analyze_news(news_feed)
# Command AI
assessments = threat_assessment(news_threats)
# Drone Shield
detected_drones = detect_drone(drone_feed)
drone_response(detected_drones)
# Psychological Deterrence
psychological_deterrence(assessments)
# Feedback
feedback_update()
# Save daily log
save_daily_log()
print("\n[Guardian AI Status] Loop completed.")
if name == "main": LINE_TOKEN = "ใส่โทเคนของคุณที่นี่" while True: main_loop(LINE_TOKEN) time.sleep(60) # ปรับเวลาตามต้องการ json.dump(THREAT_LOG, f, ensure_ascii=False, indent=2)
# ------------------------
# Info Guardian AI
# ------------------------
def analyze_news(news_items):
threats = []
for news in news_items:
if any(word in news.lower() for word in ["attack", "breach", "malware"]):
threats.append(news)
return threats
# ------------------------
# Command & Coordination AI
# ------------------------
def threat_assessment(threat_list):
assessments = []
for threat in threat_list:
probability = random.uniform(0.5, 1.0)
severity = random.randint(1, 10)
response_level = "High" if severity > 7 else "Medium"
assessments.append({
"threat": threat,
"probability": round(probability,2),
"severity": severity,
"response_level": response_level
})
return assessments
# ------------------------
# Drone Shield AI
# ------------------------
def detect_drone(drone_data):
return [d for d in drone_data if "intruder_drone" in d]
def drone_response(detected_list):
for drone in detected_list:
print("[DRONE ALERT] Detected:", drone)
print(">>> Activating countermeasure...")
# ------------------------
# Psychological Deterrence
# ------------------------
def psychological_deterrence(threat_assessments):
for threat in threat_assessments:
if threat["response_level"]=="High":
print(f"[PSYCH ALERT] Warning issued for threat: {threat['threat']}")
print(">>> Influence: Encourage alliance/tech exchange")
# ------------------------
# Feedback Loop
# ------------------------
def feedback_update():
print("[FEEDBACK] Updating AI models and improving prediction...")
# ------------------------
# Main Guardian AI Loop
# ------------------------
def main_loop(line_token):
# Sensor Example
cyber_logs = ["login_success", "exploit_attempt", "heartbeat_normal", "obfuscation_detected"]
news_feed = [
"New malware attack detected in Asia",
"Tech conference announced",
"Data breach reported in company X"
]
drone_feed = ["intruder_drone_alpha", "normal_drone_beta"]
# Zero-Day Detection
for log in cyber_logs:
matched = detect_zero_day(log)
if matched:
log_threat(log, matched)
send_line_notify(f"🚨 Zero-Day Threat Detected: {matched}", line_token)
# Info Guardian
news_threats = analyze_news(news_feed)
# Command AI
assessments = threat_assessment(news_threats)
# Drone Shield
detected_drones = detect_drone(drone_feed)
drone_response(detected_drones)
# Psychological Deterrence
psychological_deterrence(assessments)
# Feedback
feedback_update()
# Save daily log
save_daily_log()
print("\n[Guardian AI Status] Loop completed.")
# ------------------------
# Run System
# ------------------------
if __name__ == "__main__":
LINE_TOKEN = "ใส่โทเคนของคุณที่นี่"
while True:
main_loop(LINE_TOKEN)
time.sleep(60) # ปรับเวลาตามต้องการ