Instiq
Chapter 4 · Network Intrusion Analysis·v1.0.0·Updated 7/20/2026·~16 min

What's changed: Initial version

4.5Protocol headers, artifacts, and regular expressions

Key points

Covers what each header element of Ethernet/IPv4/IPv6/TCP/UDP/ICMP/DNS/SMTP, POP3, IMAP/HTTP, HTTPS/ARP reveals, the artifacts (IOCs—hashes, URLs, domains, IPs, filenames, etc.) that are the products of analysis, and basic regular expressions as the tool for searching logs/payloads, as the skill of surfacing threats and feeding the next stage of investigation.

Packet headers are a trove of clues for decoding an attack. Knowing what each field means lets you spot a scan type (TCP flags), a suspected C2 (abnormal DNS queries), or spoofing (duplicate ARP) without reading all the content. And extracting the solid traces obtained from analysis—artifacts (IOCs)—and sharing them lets other systems search for and block the same threat. To pick target strings out of massive logs and payloads, regular expressions are indispensable. This section ties together reading major protocol headers, the elements of IOCs, and basic regex as tools for SOC search and surfacing.

4.5.1Major protocol headers and their reading

  • L2/L3: Ethernet carries source/destination MAC and EtherType (the first 3 bytes of a MAC, the OUI, hint at the NIC vendor; local segment only). IPv4 has src/dst IP, TTL, protocol number, and flags/fragment (TTL as remaining hops hints at OS/path length). IPv6 has 128-bit addresses, a Next Header, and a Hop Limit. ARP resolves IP<->MAC; multiple MACs for one IP or suspicious gratuitous ARP signals ARP spoofing.
  • L4: TCP has src/dst ports, seq/ack, flags (SYN/ACK/FIN/RST/PSH/URG), and a window. The flag pattern indicates a scan type (many SYN-only = SYN scan; frequent RST = closed-port responses). UDP has only src/dst ports and length and is connectionless. ICMP has type/code (echo request/reply, unreachable) and is material for a ping sweep or ICMP tunneling.
  • L7: DNS shows domain names in queries/responses; abnormally long random subdomains or many TXT records suggest DNS tunneling/DGA. HTTP (80) exposes Host/URI/User-Agent/method, while HTTPS (443) encrypts the body with TLS, exposing about the SNI only. Email is SMTP (25/587) to send, POP3 (110), IMAP (143) to receive, where From/To/Subject and attachments are key to phishing analysis.

4.5.2Elements of an artifact (IOC)

  • An artifact is a solid trace obtained from analysis that uniquely points to a threat. From the network: IPs, domains, URLs, User-Agent; from files: hashes (md5/sha256), filenames, paths; from hosts: registry keys, mutexes, creating users. These are registered and shared as IOCs (indicators of compromise), usable to search or block across other assets.
  • A good artifact is specific and reproducible (e.g., a particular sha256, a particular C2 domain); a vague phrase like "a suspicious EXE" is not an IOC. Header/payload analysis -> artifact extraction -> IOC sharing—propagating one analysis result into organization-wide detection—is where a SOC adds value.

4.5.3Basic regular expressions

  • A regular expression describes string patterns and is used in SIEM search, grep, and IPS signatures (pcre). Basics: anchors ^ (line start) / $ (line end); character classes [0-9] or \d (digit) / \w (word char); quantifiers * (zero+) / + (one+) / ? (zero or one) / {n} (n times); any single char .; alternation a|b; groups (...).
  • Practical examples: to grab IPv4, \b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b (the . must be a literal, escaped as \.); to grab a sha256-like 64-hex string, \b[a-f0-9]{64}\b; a rough email extraction, [\w.-]+@[\w.-]+. The key is to escape a metacharacter when searching for it literally (. -> \.); neglecting it turns it into "any single char" and mismatches.
Exam point

Most-tested: ports HTTP 80, HTTPS 443, DNS 53, SMTP 25/587, POP3 110, IMAP 143; header reading—TCP flags (SYN/ACK/FIN/RST) for scan type, long random DNS queries for tunneling/DGA, one IP with multiple MACs in ARP for spoofing, HTTPS encrypts the body leaving about the SNI; IOC = a specific trace such as a hash/domain/URL/IP; regex = ^ $ [] \d + * ? {n} . | () and escaping a metacharacter as \..

Investigating a suspected phishing case, you are handed a pcap of one email delivery and the proxy logs. The email arrived over SMTP (25), and while its From header spoofs a legitimate domain, the actual delivering IP and Received path are an unrelated overseas host—yielding the clue of a sender-authentication mismatch. A link in the body is http://secure-login.bad.example/verify, which, when a user clicks it, traverses the proxy over HTTP (80), leaving the User-Agent and URL in the log. To pick that URL and similar variants out of massive proxy logs, you search with a regular expression like https?://[\w.-]*bad\.example/\S* (escaping . as \., and s? to cover both http/https). From the hits you extract solid artifacts—the malicious domain bad.example, the full URL, the affected user, and, if there is an attachment, its sha256. Registering these as IOCs lets you sweep proxy/DNS logs for traces of other users reaching the same domain, and if DNS shows abnormally long random subdomains, you can suspect additional tunneling. The key is that knowing which protocol each header field belongs to and what it means determines how fast you extract clues. Misreading the mail protocol—"this is IMAP (143) receiving, so the sender is irrelevant"—would make you miss the core evidence of a forged delivery path. And the extracted traces feed organization-wide detection only once they are distilled into reproducible, specific IOCs (domain, URL, hash) rather than a vague "suspicious email."

ProtocolKey fields/portsClue it revealsAnomaly to suspect
TCPPorts, flags (SYN/ACK/RST)Connection direction/stateMany SYN = scanning
DNS53, query/response domainsResolution targets, C2 domainLong random = tunneling/DGA
HTTP/HTTPS80/443, Host/URI/UAWeb access (HTTPS encrypts body)Odd UA, malicious URL
SMTP/POP3/IMAP25,587/110/143, From/To/attachMail path and contentSpoofed sender = phishing
ARPIP<->MAC resolutionLocal-segment mappingOne IP, many MACs = spoofing
Warning

Trap: Writing a . literally for an IP address or domain in a regex is wrong—. is a metacharacter meaning "any single character," so to find a literal dot you escape it as \. (neglecting it mismatches unrelated strings like 1x2y3z4). Also wrong: "capturing HTTPS lets you read the URL path and POST body"—HTTPS (443) encrypts the body with TLS, and roughly only the SNI (destination hostname) is visible in plaintext.

What each protocol header reveals, IOCs, and regex.
Surfacing threats and feeding the next step

4.5.4Section summary

  • Headers are a trove of clues: TCP flags for scanning, long random DNS for tunneling/DGA, one IP with many MACs in ARP for spoofing, HTTPS encrypts the body leaving about the SNI; also memorize ports (80/443/53/25/110/143)
  • An artifact (IOC) is a specific, reproducible trace (hash, domain, URL, IP); a vague phrase is not an IOC, and extraction -> sharing propagates it into organization-wide detection
  • A regex rests on ^ $ [] \d + * ? {n} . | (); escape the metacharacter . as \. when literal (neglecting it turns it into any-single-char and mismatches)

Sign in to track progress — Log in.

Quick check

(just a quick review)

Q1. A DNS log shows many queries to very long, random, each-time-different subdomains under the same non-legitimate parent domain. What event should be suspected most from this observation?

Q2. An analyst tried `\b\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}\b` in `grep` to extract only valid IPv4 addresses from bulk logs, but strings like `1a2b3c4d` also match in droves. Which is the most appropriate cause and fix?

Q3. On the same LAN segment, one IP address is repeatedly mapped to different MAC addresses in the ARP table within a short time, and traffic is suspected of passing through a third party. Which attack does this observation most strongly indicate?

Check your understandingPractice questions for Chapter 4: Network Intrusion Analysis

Keep track of your progress

The full study guide is free to read. Sign up free to practice with the question bank, track what you have read, review your mistakes, and highlight passages.