Activity Log: كل حاجة بالوقت

جارٍ التحميل…

01 / ملخص الدرس

Activity Log: كل حاجة بالوقت

ليه كل خطوة لازم يبقى عليها وقت بالـ UTC، وإزاي تعمل Activity Log بسيط بـ Python وتحفَظه في ملف.

02 / شرح الدرس مكتوبًا

نص شرح المعلم والكود الذي كتبه ونتيجة تشغيله، بنفس ترتيب الدرس.

أهلاً بيك. تخيّل إن الـ server بتاع العميل وقع الساعة اتنين الضهر، وفي نفس اليوم إنت كنت بتعمل Pentest. أول سؤال هيتسأل: إنت السبب؟

هنا الـ Activity Log بيحميك. كل command عملته، بالوقت بالزبط. لو العميل سأل، تقوله: الساعة دي أنا كنت بعمل كدا بالزبط. وكمان فريق الأمن عند العميل بيقارن الـ Log بتاعك باللي شافوه عندهم.

وخد بالك من الوقت نفسه: استخدم UTC، علشان العميل ممكن يكون في بلد تاني. واكتب التاريخ كامل، مش الساعة بس. نعمل function اسمها note، بتاخد العملية والنتيجة، وتضيف الوقت لوحدها. نشغّل… كل سطر عليه الوقت، والـ command، والنتيجة.

main.py
from datetime import datetime, timezone

log = []

def note(action, result):
    t = datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M:%S UTC")
    log.append((t, action, result))

note("nmap -sV 10.10.10.5", "22 ssh, 80 http open")
note("gobuster dir on port 80", "found /admin")

for t, action, result in log:
    print(f"[{t}] {action} -> {result}")

المخرجات

[2026-10-12 10:00:34 UTC] nmap -sV 10.10.10.5 -> 22 ssh, 80 http open
[2026-10-12 10:00:34 UTC] gobuster dir on port 80 -> found /admin

بس الـ log ده هيضيع لو قفلنا البرنامج. خلّينا نحفَظه في ملف اسمه activity dot log. نشغّل… كده اتحَفَظ في ملف، وتقدر ترجعله في أي وقت.

main.py
from datetime import datetime, timezone

log = []

def note(action, result):
    t = datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M:%S UTC")
    log.append((t, action, result))

note("nmap -sV 10.10.10.5", "22 ssh, 80 http open")
note("gobuster dir on port 80", "found /admin")

with open("activity.log", "w") as f:
    for t, action, result in log:
        f.write(f"[{t}] {action} -> {result}\n")

print(open("activity.log").read())

المخرجات

[2026-10-12 10:00:34 UTC] nmap -sV 10.10.10.5 -> 22 ssh, 80 http open
[2026-10-12 10:00:34 UTC] gobuster dir on port 80 -> found /admin

دورك: ضيف note تالتة: إنك جرّبت login على admin بباسورد admin، والنتيجة success.

تمرين

ضيف note("login admin:admin on /admin", "success") قبل الحفظ.

الحل: نشغّل…

main.py
from datetime import datetime, timezone

log = []

def note(action, result):
    t = datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M:%S UTC")
    log.append((t, action, result))

note("nmap -sV 10.10.10.5", "22 ssh, 80 http open")
note("gobuster dir on port 80", "found /admin")
note("login admin:admin on /admin", "success")

with open("activity.log", "w") as f:
    for t, action, result in log:
        f.write(f"[{t}] {action} -> {result}\n")

print(open("activity.log").read())

المخرجات

[2026-10-12 10:00:34 UTC] nmap -sV 10.10.10.5 -> 22 ssh, 80 http open
[2026-10-12 10:00:34 UTC] gobuster dir on port 80 -> found /admin
[2026-10-12 10:00:34 UTC] login admin:admin on /admin -> success

الدرس الجاي: بدل ما تكتب كل command بإيدك… نخلّي الـ terminal يسجّل كل حاجة لوحده. يلا بينا.

03 / دروس المسار (21)
  1. 01ليه التقرير أهم حاجة في الـ Pentest
  2. 02مين بيقرا التقرير؟
  3. 03نظام Notes من أول دقيقة
  4. 04Activity Log: كل حاجة بالوقتانت هنا
  5. 05خلّي الـ Terminal يسجّل لوحده
  6. 06الأدلة: إيه اللي يعتبر دليل؟
  7. 07سلامة الأدلة: Hash و Chain of Custody
  8. 08إخفاء البيانات الحساسة (Redaction)
  9. 09خطوات إعادة التنفيد (Steps to Reproduce)
  10. 10الـ Impact: الخطر الحقيقي على البيزنس
  11. 11CVSS: الخطورة برقم
  12. 12الـ Risk Matrix: الاحتمال في الـ Impact
  13. 13ترتيب الأولويات والـ Quick Wins
  14. 14هيكل تقرير اختبار الاختراق
  15. 15الـ Executive Summary: صفحة للإدارة
  16. 16كتابة الـ Finding التقني
  17. 17توصيات الإصلاح اللي تتنفّد فعلاً
  18. 18خلّي Python يكتب التقرير
  19. 19المراجعة قبل التسليم والـ Retest
  20. 20تقرير امتحان OSCP
  21. 21المراجعة النهائية: من الـ Note للتقرير