El-Gayar Inc.
Engineer network-log features, identify anomalous traffic, and reconstruct the hidden message.
As a senior Analyst, help Mr. Tamer El-Gayar in identifying the hidden message left by the attackers before the operation happens.
Overview
You’re given a network activity dataset (logs.csv) from El-Gayar Inc. The company suspects a stealthy APT attacker has embedded hidden communications in the traffic. Your job is to detect the anomalies, extract the embedded signal, and reconstruct the attacker’s hidden message — the flag.
Phase 1 — Explore the Data & Look for Inconsistencies
What to do (explanation only)
- Load the CSV (
logs.csv) and parse timestamps. - Inspect the columns:
bytes_up,bytes_down,req_rate,latency_ms,error_rate,packets, etc.
- Engineer new features to reveal correlations:
bytes_ratio = bytes_up / bytes_downbytes_per_packet = (bytes_up + bytes_down) / packetslatency_per_req = latency_ms / req_rate
Key Insight: Normal enterprise traffic follows statistical relationships (e.g., more packets → more bytes, higher request rate → lower latency). The anomalies break these patterns.
Code snippet — load & engineer features
import pandas as pd
# Load and sort by time
df = pd.read_csv("logs.csv", parse_dates=["ts"])
df = df.sort_values("ts").reset_index(drop=True)
# Derived metrics
total_bytes = df["bytes_up"] + df["bytes_down"]
bytes_ratio = df["bytes_up"] / (df["bytes_down"] + 1e-9)
bytes_per_packet = total_bytes / (df["packets"] + 1e-9)
latency_per_req = df["latency_ms"] / (df["req_rate"] + 1e-9)
Phase 2 — Detect Anomalies with Machine Learning
What to do (explanation only)
- Use Isolation Forest (unsupervised anomaly detection).
- Standardize features before training.
- Rank rows by anomaly score.
This step surfaces ~60 most suspicious records out of 5,000. The attacker’s activity is hidden among them.
Code snippet — anomaly detection
from sklearn.ensemble import IsolationForest
from sklearn.preprocessing import StandardScaler
# Build feature matrix
X = pd.DataFrame({
"login_hour": df["login_hour"],
"bytes_up": df["bytes_up"],
"bytes_down": df["bytes_down"],
"req_rate": df["req_rate"],
"latency_ms": df["latency_ms"],
"error_rate": df["error_rate"],
"packets": df["packets"],
"total_bytes": total_bytes,
"bytes_ratio": bytes_ratio,
"bytes_per_packet": bytes_per_packet,
"latency_per_req": latency_per_req
})
# Standardize & run Isolation Forest
scaler = StandardScaler()
X_scaled = scaler.fit_transform(X)
iforest = IsolationForest(n_estimators=300, contamination=0.01, random_state=1337)
scores = iforest.fit(X_scaled).decision_function(X_scaled)
df["anomaly_score"] = scores
top = df.nsmallest(60, "anomaly_score")
Phase 3 — Identify the Signal
What to do (explanation only)
- Among anomalies, look at the
req_ratecolumn. - Normally,
req_rateis fractional. - Signal rows have exact integer values → these integers are ASCII codes.
Code snippet — extract integer rows
def is_integer_like(x, tol=1e-6):
return abs(x - round(x)) < tol
signal_rows = top[top["req_rate"].apply(is_integer_like)]
Phase 4 — Reconstruct the Hidden Message
What to do (explanation only)
- Sort anomalous rows by timestamp.
- Convert each
req_rateinteger to its ASCII character. - Concatenate to form the flag.
Code snippet — decode ASCII
signal_rows = signal_rows.sort_values("ts")
flag = "".join(chr(int(round(v))) for v in signal_rows["req_rate"])
print("Flag:", flag)
- Final Flag:
IEEE{twenty_low_chr}