Programming languages/scripting

1.3 Given a scenario, use appropriate tools or techniques to determine malicious activity.

📘CompTIA CySA+ (CS0-003)


In cybersecurity, especially for detecting malicious activity, understanding programming and scripting helps you:

  • Analyze suspicious files, logs, and network traffic.
  • Automate repetitive tasks (like scanning logs or extracting alerts).
  • Write small scripts to check for anomalies or indicators of compromise.

The main tools and languages you need to know for the exam are JSON, XML, Python, PowerShell, Shell scripts, and Regular Expressions (RegEx).


1. JSON (JavaScript Object Notation)

What it is:

  • JSON is a lightweight data format used to store and exchange data.
  • Easy for humans to read and machines to parse.
  • Often used in APIs, log files, and configuration files.

Why it matters in cybersecurity:

  • Many security tools output data in JSON format.
  • Analysts read JSON to understand alerts, system logs, or threat intelligence feeds.
  • Tools like SIEMs (Security Information and Event Management) often ingest JSON data.

Key Points for Exam:

  • JSON uses key-value pairs: { "username": "alice", "login_status": "failed", "ip_address": "192.168.1.5" }
  • Knowing JSON allows you to filter data and extract indicators of compromise (IoCs).

2. XML (Extensible Markup Language)

What it is:

  • XML is a markup language for storing and transporting data.
  • More verbose than JSON, but widely used in legacy systems.

Why it matters in cybersecurity:

  • Some security tools, vulnerability scanners, and web services output XML logs.
  • Analysts may need to parse XML to find malicious activity, such as unusual login attempts or configuration changes.

Key Points for Exam:

  • XML has tags that define data: <alert> <type>malware</type> <source_ip>10.0.0.5</source_ip> <timestamp>2026-02-05T10:00:00Z</timestamp> </alert>
  • You should know how to navigate XML structures to find relevant information.

3. Python

What it is:

  • Python is a general-purpose programming language.
  • Widely used in cybersecurity for automation, data analysis, and malware analysis.

Why it matters in cybersecurity:

  • Python scripts can read logs, parse JSON/XML, and automate repetitive tasks.
  • Analysts use Python for detecting anomalies, scanning files, or even creating small threat-hunting tools.

Key Points for Exam:

  • Example: reading a log file and detecting failed logins: with open("login.log") as f: for line in f: if "failed" in line: print(line)
  • Understanding Python basics helps in writing scripts or modifying existing tools to detect threats.

4. PowerShell

What it is:

  • A scripting language and shell for Windows systems.
  • Used to automate system administration tasks.

Why it matters in cybersecurity:

  • PowerShell is heavily used by both system admins and attackers.
  • Security analysts use PowerShell to:
    • Check system logs
    • Search for suspicious processes
    • Query system configurations
  • Knowing PowerShell helps detect malware that uses scripts to spread.

Key Points for Exam:

  • Example: list all running processes: Get-Process
  • Example: search for files created in last 24 hours: Get-ChildItem -Path C:\ -Recurse | Where-Object {$_.CreationTime -gt (Get-Date).AddDays(-1)}
  • Analysts must understand PowerShell output to spot unusual activity.

5. Shell Script (Bash)

What it is:

  • Scripting language for Linux/Unix systems.
  • Automates tasks like scanning logs, monitoring system activity, or performing network checks.

Why it matters in cybersecurity:

  • Many servers run Linux.
  • Security analysts use shell scripts to:
    • Monitor log files
    • Identify suspicious network connections
    • Automate incident response

Key Points for Exam:

  • Example: find failed login attempts in Linux: grep "Failed password" /var/log/auth.log
  • Example: check open ports: netstat -tuln
  • Shell scripts make it faster to analyze large datasets or repeat checks.

6. Regular Expressions (RegEx)

What it is:

  • RegEx is a pattern-matching language used to search and extract data from text.

Why it matters in cybersecurity:

  • Analysts use RegEx to find patterns in logs or filter alerts.
  • It’s essential for parsing JSON, XML, or plain text logs efficiently.

Key Points for Exam:

  • Example: find all IP addresses in a log: \b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b
  • RegEx helps detect:
    • Malicious URLs
    • Suspicious file names
    • Unauthorized access attempts

Summary Table for Quick Exam Review

Language / ToolUse in CybersecurityKey Notes
JSONParse logs, SIEM feedsKey-value format
XMLParse legacy system dataTag-based format
PythonAutomation, data analysisScripts to detect anomalies
PowerShellWindows monitoring & automationDetect malware, query logs
Shell ScriptLinux/Unix automationLog analysis, network checks
RegExPattern searching in logsExtract IPs, URLs, filenames

Key Takeaways for Exam:

  1. Understand how each language/script helps detect malicious activity.
  2. Know the basic syntax for extracting data (examples in JSON, XML, Python, PowerShell, Bash, and RegEx).
  3. Be able to read output from these tools and recognize suspicious indicators like failed logins, unusual processes, or abnormal network activity.
  4. You don’t need to be a master programmer, but familiarity with syntax and use cases is expected.
Buy Me a Coffee