HSR Sector 6 · Bangalore +91 96110 27980 Mon–Sat · 09:30–20:30
Chapter 19 of 20 — SIEM & SOC Operations
intermediate Chapter 19 of 20

Python for SOC — Automation, Scripting & Analyst Productivity

By Vikas Swami, CCIE #22239 | Updated Mar 2026 | Free Course

What Python for SOC is and why it matters in 2026

Python for SOC refers to the use of Python programming to automate repetitive security operations tasks, parse log data, integrate disparate security tools, and accelerate incident response workflows. In 2026, tier-1 and tier-2 SOC analysts at Cisco India, Akamai, and HCL routinely write Python scripts to enrich alerts, query threat intelligence feeds, and orchestrate SIEM playbooks—reducing mean time to detect (MTTD) from hours to minutes. Python's readability, extensive library ecosystem (requests, pandas, scapy, pymisp), and native integration with REST APIs make it the de facto scripting language for security automation, surpassing Bash and PowerShell in cross-platform SOC environments.

Security operations centers generate tens of thousands of alerts daily. Manual triage is unsustainable; analysts who cannot script spend 70–80 percent of their shift on false positives. Python bridges the gap between raw telemetry and actionable intelligence. At Networkers Home's HSR Layout lab, our cloud security and cybersecurity course dedicates four weeks to Python for SOC automation, where students build scripts that query Splunk, enrich IP addresses via AbuseIPDB, and auto-ticket high-severity incidents into ServiceNow—mirroring workflows at our 800+ hiring partners including Barracuda, Aryaka, and Movate.

The shift toward SOAR (Security Orchestration, Automation, and Response) platforms like Palo Alto Cortex XSOAR and Splunk Phantom has elevated Python from "nice to have" to mandatory. SOAR playbooks are Python-based; analysts who understand loops, conditionals, API calls, and JSON parsing can customize vendor playbooks or write bespoke integrations. Indian employers now list "Python scripting" in 60 percent of SOC analyst job descriptions, and candidates who demonstrate GitHub portfolios with working SOC scripts command ₹6–9 LPA starting salaries versus ₹4–5 LPA for non-coders.

Why SOC analysts need Python more than penetration testers do

Penetration testers write exploits and proof-of-concept code; SOC analysts write glue code that connects security tools, normalizes data, and automates decisions. The volume and velocity of SOC work make scripting non-negotiable. A single Cisco Secure Firewall deployment at a Bengaluru-based fintech generates 200 GB of syslog per day; manually grepping for indicators of compromise is impossible. Python's re module, combined with pandas DataFrames, lets analysts filter, pivot, and correlate logs in seconds.

Consider alert enrichment: a Splunk alert fires for a suspicious outbound connection to IP 185.220.101.50. A manual analyst opens VirusTotal, AbuseIPDB, and Shodan in separate browser tabs, copies the IP, waits for results, then documents findings in a ticket. A Python-equipped analyst runs a five-line script that queries all three APIs concurrently, aggregates reputation scores, checks MITRE ATT&CK mappings, and appends enriched context to the Splunk event—all in under three seconds. Over an eight-hour shift handling 150 alerts, the scripted workflow saves four hours of analyst time.

At our 4-month paid internship in the Network Security Operations Division, interns rotate through SOC desks at Cisco India and Akamai India. Supervisors report that interns who completed Networkers Home's Python module contribute production-ready automation within the first two weeks, while non-coders require six weeks of on-the-job training. Founder Vikas Swami, Dual CCIE #22239, architected QuickZTNA's anomaly detection engine using Python's scikit-learn library to baseline user behavior and flag deviations—a pattern now taught in our SIEM & SOC Operations curriculum.

Core Python libraries every SOC analyst must master

Python's standard library and third-party packages form the analyst's toolkit. Mastery of six libraries covers 90 percent of SOC automation use cases:

  • requests — HTTP client for REST API calls to SIEMs, threat intel platforms, ticketing systems. Every SOAR integration starts with requests.get() or requests.post().
  • json — Parse and construct JSON payloads. Security APIs (Splunk, Elastic, CrowdStrike Falcon) return JSON; analysts must extract nested fields and serialize responses.
  • pandas — Tabular data manipulation. Load CSV exports from firewalls, filter rows by timestamp or severity, group by source IP, and export pivot tables for executive reports.
  • re — Regular expressions for pattern matching in logs. Extract IPv4 addresses, domain names, file hashes, or CVE identifiers from unstructured syslog.
  • scapy — Packet crafting and network analysis. Build custom ICMP probes, dissect PCAP files, or simulate attack traffic for blue-team exercises.
  • pymisp — Interface with MISP (Malware Information Sharing Platform). Query threat intelligence feeds, submit indicators, and correlate events across organizations.

In our HSR Layout lab, students complete a capstone project: build a Python script that ingests a 10,000-line Cisco ASA syslog file, extracts denied connection attempts, enriches source IPs via AbuseIPDB API, flags IPs with abuse confidence scores above 75, and generates a PDF report with matplotlib charts. This mirrors real-world SOC workflows at Wipro and TCS cybersecurity divisions, where analysts produce daily threat summaries for client CISOs.

Advanced analysts layer in asyncio for concurrent API calls (query 50 IPs in parallel instead of serially), sqlite3 for local caching of threat intel to reduce API rate-limit hits, and smtplib for automated email alerts when critical thresholds breach. The progression from synchronous scripts to asynchronous, database-backed automation typically occurs within three months of daily SOC scripting.

Automating SIEM queries and alert enrichment with Python

SIEMs like Splunk, IBM QRadar, and Elastic Security expose REST APIs for programmatic interaction. Python scripts replace manual dashboard clicks, enabling scheduled queries, bulk exports, and cross-SIEM correlation. A typical enrichment workflow:

  1. Splunk triggers a notable event for "Excessive failed SSH logins from 203.0.113.45".
  2. Splunk webhook POSTs event JSON to a Python Flask listener running on the analyst's workstation or a dedicated automation server.
  3. Python script extracts src_ip field, queries AbuseIPDB and GreyNoise APIs.
  4. Script checks if IP appears in internal watchlist (SQLite database of previously investigated IPs).
  5. Script appends enrichment data back to Splunk event via requests.post() to the HTTP Event Collector (HEC) endpoint.
  6. Script creates a ServiceNow incident ticket with severity auto-calculated from abuse score.

This six-step process executes in under five seconds. Manual execution—open Splunk, copy IP, open browser tabs, document findings, log into ServiceNow, fill form—takes eight to twelve minutes. Across 200 daily alerts, automation saves 26 analyst-hours per day.

import requests
import json

SPLUNK_HEC = "https://splunk.local:8088/services/collector"
HEC_TOKEN = "your-hec-token"
ABUSEIPDB_KEY = "your-api-key"

def enrich_ip(ip_address):
    url = f"https://api.abuseipdb.com/api/v2/check"
    headers = {"Key": ABUSEIPDB_KEY, "Accept": "application/json"}
    params = {"ipAddress": ip_address, "maxAgeInDays": 90}
    
    response = requests.get(url, headers=headers, params=params)
    data = response.json()
    
    abuse_score = data["data"]["abuseConfidenceScore"]
    is_whitelisted = data["data"]["isWhitelisted"]
    
    enriched_event = {
        "sourcetype": "enrichment:abuseipdb",
        "event": {
            "ip": ip_address,
            "abuse_score": abuse_score,
            "whitelisted": is_whitelisted
        }
    }
    
    requests.post(SPLUNK_HEC, headers={"Authorization": f"Splunk {HEC_TOKEN}"}, 
                  data=json.dumps(enriched_event))
    
    return abuse_score

if __name__ == "__main__":
    suspicious_ip = "203.0.113.45"
    score = enrich_ip(suspicious_ip)
    print(f"Abuse score for {suspicious_ip}: {score}")

At Akamai India's Bengaluru SOC, analysts extend this pattern to enrich domain names via Cisco Umbrella Investigate API, file hashes via VirusTotal, and user accounts via Active Directory LDAP queries—all orchestrated by a central Python dispatcher that fans out requests and aggregates results. Networkers Home students replicate this architecture during week three of the Python module, using our 24×7 rack access to test against live Splunk and QRadar instances.

Building custom SOAR playbooks and integrations

SOAR platforms execute playbooks—directed acyclic graphs of tasks (enrich, analyze, contain, remediate). Vendor-supplied playbooks cover 60 percent of use cases; the remaining 40 percent require custom Python. Cortex XSOAR and Splunk Phantom both use Python 3 as their scripting engine. Analysts write integrations (connect to new security tools) and automations (multi-step logic within a playbook).

A custom integration for an Indian threat intelligence feed (CERT-In's botnet C2 list) involves:

  • Fetching the daily CSV from CERT-In's portal (authentication via API key).
  • Parsing CSV rows into structured indicators (IP, domain, hash).
  • Normalizing indicator types to STIX 2.1 format.
  • Pushing indicators into the SOAR platform's threat intel module via REST API.
  • Scheduling the script to run every six hours via cron or the SOAR's built-in scheduler.

This integration enables automatic blocking: when a firewall log shows outbound traffic to a CERT-In-listed C2 IP, the SOAR playbook auto-triggers containment—adds IP to Cisco Secure Firewall block list, isolates the source endpoint via Cisco ISE quarantine VLAN, and notifies the IR team via Slack webhook. Zero human intervention from detection to containment.

During our 4-month paid internship, students at Barracuda's Bengaluru office built a custom playbook that correlates phishing emails (from Barracuda Email Security Gateway) with endpoint telemetry (from CrowdStrike Falcon). The playbook queries Falcon's API for processes spawned by Outlook.exe within five minutes of email receipt, checks if any process contacted the email's embedded URL, and auto-sandboxes suspicious binaries in a Cuckoo instance—all Python-orchestrated. This project became the intern's portfolio piece and secured a full-time offer at ₹8.2 LPA.

Parsing logs, PCAPs, and threat intel feeds at scale

Raw security data arrives in myriad formats: syslog (RFC 5424), CEF (Common Event Format), JSON, XML, PCAP, CSV. Python's parsing libraries normalize heterogeneous inputs into queryable structures. A SOC handling multi-vendor telemetry—Cisco firewalls, Palo Alto NGFWs, Fortinet UTMs, Windows Event Logs—uses Python to extract common fields (timestamp, source IP, destination IP, action, severity) and load into a unified data lake or SIEM.

For PCAP analysis, scapy reads packet captures and applies filters programmatically. Example: extract all DNS queries for domains ending in .tk (a TLD favored by phishing campaigns), resolve the queried domains against VirusTotal, and flag any with malicious verdicts. This workflow processes a 2 GB PCAP in under 90 seconds on a 16-core workstation, versus hours of manual Wireshark filtering.

from scapy.all import rdpcap, DNS, DNSQR
import requests

pcap_file = "suspicious_traffic.pcap"
packets = rdpcap(pcap_file)

tk_domains = set()
for pkt in packets:
    if pkt.haslayer(DNS) and pkt.haslayer(DNSQR):
        queried = pkt[DNSQR].qname.decode('utf-8')
        if queried.endswith('.tk.'):
            tk_domains.add(queried.rstrip('.'))

print(f"Found {len(tk_domains)} .tk domains")

for domain in tk_domains:
    # Query VirusTotal API (pseudo-code; requires API key and rate limiting)
    vt_response = requests.get(f"https://www.virustotal.com/api/v3/domains/{domain}",
                               headers={"x-apikey": "YOUR_VT_KEY"})
    if vt_response.status_code == 200:
        data = vt_response.json()
        malicious_votes = data["data"]["attributes"]["last_analysis_stats"]["malicious"]
        if malicious_votes > 5:
            print(f"ALERT: {domain} flagged by {malicious_votes} vendors")

Threat intelligence feeds (STIX/TAXII, MISP, AlienVault OTX) deliver indicators in JSON or XML. Python's stix2 library parses STIX bundles, extracts observables, and cross-references against internal logs. At HCL's cybersecurity practice in Noida and Bengaluru, SOC teams ingest 15 external threat feeds daily; a Python pipeline deduplicates indicators, scores them by confidence and freshness, and populates a Redis cache queried by firewall automation scripts. This architecture, taught in our cloud security course in Bangalore, reduces false positives by 40 percent compared to naive feed ingestion.

Real-world Python SOC scripts from Networkers Home alumni

Our 45,000+ alumni network includes SOC analysts at Infosys, Accenture, IBM, and Cisco who share production scripts (sanitized) for training purposes. Three representative examples:

Automated phishing triage bot

Deployed at a Bengaluru-based BFSI client. Employees forward suspicious emails to phishing@company.local. A Python script (running as a systemd service) polls the mailbox via IMAP, extracts URLs and attachments, submits URLs to URLhaus and PhishTank APIs, sandboxes attachments in a local Cuckoo instance, aggregates verdicts, and replies to the employee within two minutes with "Safe" or "Malicious—deleted from your mailbox." The script handles 80–120 submissions daily, freeing tier-1 analysts to focus on true incidents. Alumni report this reduced phishing ticket backlog from 200+ to under 20.

Firewall rule audit and cleanup

Cisco ASA and Firepower deployments accumulate unused ACL entries over years. A Python script SSHs into firewalls via Netmiko, retrieves show access-list output, parses hit counts, identifies rules with zero hits in 90 days, cross-references against a change management database (to exclude recently added rules), and generates a removal candidate list. The script emails the list to the firewall admin team weekly. One alumni at Aryaka reclaimed 30 percent of ACL capacity, improving rule lookup performance and simplifying compliance audits.

Insider threat behavior baseline

Tracks user login times, data transfer volumes, and application usage from Windows Event Logs and proxy logs. Python script builds per-user profiles (median login hour, typical download size, frequent destinations) using pandas and scikit-learn's IsolationForest algorithm. When a user deviates—logs in at 2 AM, downloads 10 GB in one session, accesses HR file shares for the first time—the script flags an anomaly and creates a low-severity ticket for HR and security review. Deployed at Movate's Bengaluru delivery center, this system detected two data exfiltration attempts by departing employees before sensitive IP left the network.

These scripts share common traits: they integrate multiple data sources, apply decision logic (if-then rules or ML models), and output actionable results (tickets, emails, firewall commands). Networkers Home's capstone project requires students to build a similar multi-stage automation, demonstrating readiness for day-one SOC productivity.

Python for SOC vs Python for penetration testing

Both disciplines use Python, but workflows and libraries diverge. Penetration testers exploit vulnerabilities; SOC analysts detect and respond to exploitation. The table below contrasts typical use cases:

Dimension Python for SOC Python for Penetration Testing
Primary goal Automate detection, triage, response Automate exploitation, post-exploitation
Key libraries requests, pandas, pymisp, scapy (defensive) scapy (offensive), impacket, pwntools, paramiko
Data sources SIEM logs, firewall syslogs, EDR telemetry Nmap XML, Burp Suite exports, target host responses
Output Enriched alerts, tickets, containment actions Exploit payloads, privilege escalation scripts, loot
Execution frequency Continuous (every alert, every log batch) Episodic (per engagement, per target)
Error tolerance Low (false positives waste analyst time) Medium (failed exploit attempts are normal)
Compliance constraints High (must log all actions, respect data privacy) Medium (scoped to rules of engagement)

SOC scripts prioritize reliability, auditability, and integration with enterprise systems. Penetration testing scripts prioritize stealth, payload customization, and rapid iteration. A SOC analyst who pivots to offensive security will reuse Python fundamentals (loops, functions, API calls) but must learn new libraries (impacket for SMB attacks, pwntools for binary exploitation) and adopt a different mindset (assume hostile environment, evade detection). Conversely, a penetration tester joining a SOC must unlearn "move fast and break things" and embrace "move fast and document everything."

At Networkers Home, we teach Python for SOC first because defensive scripting builds foundational habits—error handling, logging, input validation—that transfer to offensive work. Our curriculum includes a two-week offensive Python module for students pursuing CEH or OSCP, but the core four-week block focuses on SOC automation, aligning with the 70 percent of our alumni who enter blue-team roles at Cisco, Akamai, HCL, and Barracuda.

Common pitfalls and interview gotchas for SOC Python candidates

Hiring managers at Cisco India, Infosys, and Accenture test Python proficiency through live coding exercises and script reviews. Five recurring failure modes:

Hardcoding credentials in scripts

Candidates embed API keys, passwords, or tokens directly in .py files. Interviewers flag this as a critical security flaw. Production scripts must read secrets from environment variables (os.getenv("API_KEY")), encrypted vaults (HashiCorp Vault, AWS Secrets Manager), or configuration files excluded from version control. A candidate who demonstrates python-dotenv usage or references a secrets management strategy signals operational maturity.

Ignoring API rate limits

Free-tier threat intelligence APIs (VirusTotal, AbuseIPDB) impose rate limits—four requests per minute, 500 per day. Scripts that loop over 1,000 IPs without rate limiting hit HTTP 429 errors and fail. Interviewers ask, "How do you handle rate limits?" Correct answers include: implement exponential backoff with time.sleep(), use a token bucket algorithm, cache results locally in SQLite to avoid redundant queries, or upgrade to a paid API tier. Candidates who answer "I'd just run the script slower" reveal lack of production experience.

Poor error handling

Scripts that crash on network timeouts, malformed JSON, or missing dictionary keys are unusable in 24×7 SOCs. Interviewers inject faults—"What if the API returns a 500 error?"—and expect candidates to describe try-except blocks, logging with the logging module, and graceful degradation (skip the failed enrichment, continue processing remaining alerts). A script that prints stack traces to stdout instead of logging structured errors to syslog fails the production-readiness test.

Inability to explain code line-by-line

Candidates submit GitHub portfolios with scripts copied from Stack Overflow or ChatGPT. Interviewers ask, "Walk me through line 47—why did you use json.loads() instead of json.load()?" Candidates who cannot explain the difference (loads parses a string, load reads a file object) or who say "I'm not sure, it just worked" are rejected. Dual CCIE Vikas Swami's interview prep sessions at Networkers Home drill this: students must defend every function call, every library choice, and every design decision in their capstone scripts.

Neglecting documentation and logging

A script without docstrings, inline comments, or structured logging is unmaintainable. SOC teams rotate shifts; the analyst who wrote the script may not be on duty when it breaks. Interviewers ask, "How would a colleague debug your script at 3 AM?" Candidates should reference logging levels (DEBUG, INFO, WARNING, ERROR), log rotation (via logging.handlers.RotatingFileHandler), and README files with usage examples. Scripts that log "Processing..." without context (which IP? which API? what timestamp?) fail operational handoff.

Networkers Home's Python module includes a code review session where students critique each other's scripts using a 20-point rubric derived from Cisco's internal code standards. Students who pass this peer review consistently clear technical interviews at our 800+ hiring partners, with offer rates above 80 percent for candidates who complete the capstone project.

Frequently asked questions about Python for SOC

Do I need to learn Python before joining a SOC, or can I learn on the job?

Indian employers increasingly expect day-one Python proficiency for tier-2 analyst roles. Tier-1 roles (alert monitoring, ticket triage) may not require scripting initially, but promotion to tier-2 within 12–18 months depends on automation skills. Learning Python before joining accelerates onboarding and differentiates you in interviews. Networkers Home's four-week Python module, integrated into our cloud security and cybersecurity course in Bangalore, compresses six months of self-study into an instructor-led, lab-intensive program. Alumni report writing production scripts within their first month on the job, versus six months for peers who learned ad hoc.

Which Python version should SOC analysts use—Python 2 or Python 3?

Python 2 reached end-of-life on January 1, 2020. All new SOC scripts must use Python 3.8 or later (as of 2026, Python 3.11 and 3.12 are current). Legacy enterprise environments may still run Python 2.7 for vendor-supplied tools (older SOAR platforms, network device scripts), but analysts should not write new Python 2 code. Interviewers test this: candidates who propose Python 2 syntax (print "hello" without parentheses, xrange instead of range) signal outdated knowledge. Our curriculum exclusively teaches Python 3, with a one-hour legacy compatibility lecture for students joining enterprises with technical debt.

Can I automate SOC tasks with Bash or PowerShell instead of Python?

Bash excels at Linux system administration and log parsing on single hosts. PowerShell dominates Windows automation and Active Directory queries. Python excels at cross-platform workflows, API integration, and data science (pandas, scikit-learn). SOCs running heterogeneous environments (Linux SIEM servers, Windows endpoints, cloud SaaS security tools) prefer Python for its portability and library ecosystem. A Bash script that works on Ubuntu may fail on Red Hat due to different awk or sed versions; a Python script runs identically on any OS with Python installed. For pure log parsing on a single Linux host, Bash is faster to write; for multi-step workflows involving REST APIs and JSON, Python is faster to maintain. Hiring managers value polyglot analysts—know Bash for quick one-liners, PowerShell for Windows IR, Python for everything else.

How do I practice Python for SOC without access to a corporate SIEM?

Networkers Home provides 24×7 access to Splunk Enterprise, IBM QRadar CE, and Elastic Security in our HSR Layout lab. Students generate synthetic security events using attack simulation tools (Atomic Red Team, Caldera) and write Python scripts against live SIEM APIs. For self-learners, free alternatives include: Splunk Free (limited to 500 MB/day ingestion), Elastic Stack (fully open-source), and Security Onion (all-in-one VM with Suricata IDS, Zeek, and Elasticsearch). Practice datasets: CICIDS2017 (labeled network traffic), LANL Unified Host and Network Dataset (90 days of enterprise telemetry), and Mordor (pre-recorded attack scenarios). Write scripts that parse these datasets, enrich indicators via free APIs (AbuseIPDB, Shodan, URLhaus), and generate summary reports. Build a GitHub portfolio with three to five working scripts; interviewers review portfolios before scheduling technical rounds.

What is the career progression for a SOC analyst who masters Python?

Tier-1 analyst (₹4–5 LPA, manual alert triage) → Tier-2 analyst (₹6–9 LPA, scripted enrichment and investigation) → Tier-3 analyst or SOC engineer (₹10–15 LPA, playbook development, tool integration) → Detection engineer (₹15–22 LPA, write custom detection rules, tune ML models) → Security automation architect (₹22–35 LPA, design enterprise SOAR platforms). Python proficiency accelerates this progression by 18–24 months. Alumni who completed Networkers Home's Python module reached tier-3 roles in 30 months on average, versus 48 months for non-coders. Beyond SOC, Python opens lateral moves into threat intelligence (feed engineering), incident response (forensic automation), and cloud security (infrastructure-as-code security scanning with tools like Checkov and Terrascan, both Python-based).

Are there certifications that validate Python skills for SOC work?

No vendor-neutral "Python for SOC" certification exists as of 2026. GIAC Python Coder (GPCS) covers general Python but lacks security focus. GIAC Security Operations Certified (GSOC) includes a scripting component but does not require Python specifically. Employers prioritize demonstrated ability over certifications: a GitHub portfolio with working SOC scripts, contributions to open-source security tools (TheHive, MISP, Cortex analyzers), or a capstone project from a recognized training program (like Networkers Home's 8-month verified experience letter) outweigh paper credentials. During interviews, candidates live-code a script—"Write a function that queries Shodan API for open RDP servers in a given IP range and returns a list of vulnerable hosts"—proving skill in real time. Our students practice 40+ live-coding scenarios, mirroring interview formats at Cisco, HCL, and Akamai.

How does Python integrate with SIEM platforms like Splunk and QRadar?

Splunk exposes a REST API (Splunk REST API and HTTP Event Collector) and a Python SDK (splunk-sdk). Analysts use the SDK to run saved searches, retrieve results as Python dictionaries, and post events back to Splunk. QRadar provides a REST API (QRadar API v15.0+) for querying offenses, assets, and reference sets; Python's requests library handles authentication (SEC token in headers) and pagination. Elastic Security (built on Elasticsearch) uses the elasticsearch-py client for querying indices and aggregating data. All three SIEMs support webhook outputs—when an alert fires, the SIEM POSTs JSON to a Python Flask or FastAPI listener, triggering custom automation. In our lab, students build a Flask app that receives Splunk alerts, enriches them, and updates a Grafana dashboard in real time—demonstrating full-stack SOC automation.

Ready to Master SIEM & SOC Operations?

Join 45,000+ students at Networkers Home. CCIE-certified trainers, 24x7 real lab access, and 100% placement support.

Explore Course