بتل کد Battle Codeدارد باز می‌شود…

Full Detector چالش 6 از جلسه‌ی 34، سخت

تابع detect(tries) بنویس که برای هر آدرس (به ترتیب الفبایی) یک خط چاپ کند: <ip> tries=<total> max_per_minute=<m> <status> که total کل تلاش‌ها، m بیشترین تلاش در یک سطل یک‌دقیقه‌ای و status برابر ATTACK است اگر m > 4 وگرنه ok. خروجی سه خط است: 10.0.0.5 tries=7 max_per_minute=5 ATTACK، 10.0.0.7 tries=1 max_per_minute=1 ok، 10.0.0.9 tries=2 max_per_minute=2 ok.

from collections import Counter

TRIES = [
    (1700000000, "10.0.0.5"), (1700000005, "10.0.0.5"), (1700000009, "10.0.0.5"),
    (1700000014, "10.0.0.5"), (1700000020, "10.0.0.7"), (1700000031, "10.0.0.5"),
    (1700000045, "10.0.0.5"), (1700000075, "10.0.0.9"), (1700000080, "10.0.0.9"),
    (1700000099, "10.0.0.5"),
]


def detect(tries):
    total = Counter()
    per_minute = Counter()
    # fill both counters, then print one line per ip (sorted)
    pass


detect(TRIES)

راهنما و جواب این چالش · برگشت به درس جلسه‌ی 34: نشانه‌های حمله · چالش بعدی: Ransomware Signs

بیشتر بخوان: تابع در پایتون: آموزش def، پارامتر و return با مثال