How I Built an Ethical TCP Port Scanner on iPhone for SOC Detection | Lab03
How I Built an Ethical TCP Port Scanner on iPhone to Think Like an Attacker (and Defend Better) — Lab03
As a SOC Analyst learner, I made a mistake. I was only learning defense — logs, alerts, IOCs. But I couldn't understand WHY the SIEM was firing "Port Scan Detected" alerts.
So I decided: To be a better defender, I must think like an attacker.
This week, I built Lab03 of my SOC Toolkit — a TCP Port Scanner — entirely on my iPhone using iSH. And it taught me more about SOC detection than any course.
What is a Port Scanner and Why Should SOC Analysts Care?
A port scanner is the first tool hackers use. Before they exploit anything, they check which doors are open.
Common ports they look for:
• Port 22 = SSH (to brute-force login)
• Port 3389 = RDP (to take over Windows)
• Port 80 / 443 = Web servers
• Port 445 = SMB (for ransomware)
In MITRE ATT&CK framework, this is TA0043 - Reconnaissance. If you see it in your SIEM, you are in Stage 1 of an attack.
My Lab Setup: Building on iPhone
I don't have a laptop. I use iSH app on iPhone.
• Tool: Python 3
• Target: 127.0.0.1 (localhost ONLY)
• Goal: Learn, not attack
Safety First: Ethical Lock
Many scanners on GitHub can scan the internet. That's dangerous and illegal.
My scanner has a safety lock:
ALLOWED_TARGET = "127.0.0.1"
My Real Result (Screenshot)
I ran python3 port_scanner.py on my iPhone.
Result: All 20 common ports showed CLOSED.
At first I thought I failed. Then I understood the defensive lesson:
My iPhone iSH environment runs NO services on those ports. That means it is secure by default. No open doors.
The SOC Lesson That Changed How I Triage Alerts
This lab taught me what a Port Scan looks like from the defender side.
If I am in SOC and my SIEM shows:
One IP -> Tried 20 ports in 2 seconds -> All closed
That's NOT a failed connection. That's Reconnaissance. The attacker is mapping my network. My playbook is:
1. Detect: Rule fires for "Multiple closed ports from single source"
2. Triage: Check if source is internal or external
3. Respond: Block IP, hunt for follow-up exploitation attempts
I would never have understood this without building the offensive tool myself.
Conclusion: Learn Offense to Master Defense
Lab03 is not about hacking. It's about awareness. Now when I see a port scan alert, I don't just close it. I understand the attacker's intent.
This is Lab03 of my SOC Toolkit. 5 more labs coming.
Links:
GitHub Code: [Paste your Lab03 link here]
LinkedIn: [Your LinkedIn profile]
Ethical Disclaimer: This tool is for educational use in your own lab only (127.0.0.1). Scanning systems you do not own is illegal and unethical.
Question for my fellow SOC Analysts: In your SIEM, which port do you see probed the most? For me in labs it's 22 and 3389. Let me know in comments.

Comments
Post a Comment