Introduction

It's All About Defang

Difficulty:
Find Ed Skoudis upstairs in City Hall and help him troubleshoot a clever phishing tool in his cozy office.

I’ll find Ed inside his office on the second floor of City Hall:

image-20251106073029492
Ed Skoudis

Ed Skoudis

I’m the Founder of Counter Hack Innovations, the team that brings you the SANS Holiday Hack Challenge for the last 22 years.

I’m also the President of the SANS Technology Institute College, which has over 2,300 students studying for their Bachelor’s Degrees, Master’s Degrees, and various certificates.

I was the original author of the SANS SEC504 (Incident Handling and Hacker Attacks) and SANS SEC560 (Enterprise Penetration Testing) courses.

I love Capture the Flag games and puzzles.

I’ve got a steampunk office filled with secret rooms, and I collect antique crypto systems and communication technologies.

I’ve got an original Enigma machine (A726, from the early war years), a leaf of the Gutenberg Bible (1 John 2:3 to 4:16) from 1455, and a Kryha Liliput from the 1920s.

Oh gosh, I could talk for hours about this stuff but I really need your help!

The team has been working on this new SOC tool that helps triage phishing emails…and there are some…issues.

We have had some pretty sketchy emails coming through and we need to make sure we block ALL of the indicators of compromise. Can you help me? No pressure…

Chat with Ed Skoudis

Congratulations! You spoke with Ed Skoudis!

The terminal opens up an interactive dashboard to handle a phishing email incident:

image-20251106073723137 expand

Solution

Email

Headers

The email viewer has an email with full headers. Taking a look, it’s from a domain icicleinnovations.mail:

From: "Icicle Innovations" <sales@icicleinnovations.mail>
To: "Neighborhood Watch" <residents@dosisneighborhood.corp>
Subject: 🎄 URGENT: Holiday Kitchen Makeover - Smart Home Integration! 🎄
Date: Wed, 25 Dec 2025 09:15:33 -0500
Message-ID: <holiday2025-kitchen@dosisneighborhood.corp>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Mailer: KitchenAlert v2.025
Received: from mail.icicleinnovations.mail (172.16.254.1) by dosisneighborhood.corp (10.0.0.5) with SMTP;
         Wed, 25 Dec 2025 09:15:28 -0500
Received: from core.icicleinnovations.mail (192.168.1.1) by mail.icicleinnovations.mail (172.16.254.1);
         Wed, 25 Dec 2025 09:15:22 -0500

It’s sent to holiday2025-kitchen@dosisneighborhood.corp. I’m going to assume that that domain, as well as the 10.0.0.5 IP for the SMTP server are friendly infrastructure.

Body

The email body is offering kitchen renovations:

This has several signs of a phishing email:

  • Urgency, creating pressure to act now before the target has a chance to think.
  • Link to .exe file. It’s never wise to run a executable from an untrusted source.
  • Use of the .mail domain. While these “newer” top level domains are becoming more common, they are still less trustworthy than .com.

Step 1

Overview

The Threat Intelligence Analysis panel has three tabs. The “Extract IOCS (Step 1)” tab has instructions:

image-20251106084047999

Below that are four tabs for different indicators of compromise (IOCs):

image-20251106084116320

For each, I have to give a regex pattern to pull out those indicators from the email. The “Reference” tab has some example regex to pull out these indicators, but most of these have errors or are incomplete:

image-20251106084300939

Domains

Domains are strings connected by “.”. The last item is the top level domain (TLD), like “.com” or “.net”. Originally there were only a handful of these, but starting in 2008 many more have been added. The given regex isn’t actually incorrect, as it defines a character set of lower, upper, and digits ([a-zA-Z0-9-]) and say there will be one or more of those (+), followed by a group that appears one or more times. That group is an escaped “.” (because without the escape it would mean any character) followed by one or more of that that same class of characters. This is going to capture all valid domains, but it also captures other things:

image-20251106090237705

Version numbers, filenames, and IP addresses also match this pattern. For something like this, I like to target specific TLDs at the end. For this example, I’ll look for “com”, “net”, “mail”, and “corp”. Were I doing this in a real environment, I’d come up with a much longer list. I’ll replace the + on the last group with a * to mean 0 or more rather than 1 or more, and add the TLD to the end:

[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.(com|net|mail|corp)

This works:

image-20251106090541272

I’ll remove dosisneighborhood.corp using the “X” button since it’s not associated with the malicious actor to get the final answer:

image-20251106090615518

IPv4

IPv4 addresses are made up of four octets, each represented as an integer from 0 - 255. The above regex uses \d to represent a digit, and then {1,3} to match between one and three digits. Then there’s a . character, escaped by \ because otherwise . represents any character. Then one to three digits, dot, and then one to three digits.

This only matches three octets. If I throw it in to the tool and submit, this is clear:

image-20251106085433274

A simple fix is to just add \.\d{1,3}:

image-20251106085451076

Most of the time, this is a good enough regex to get IPs. Still, there are issues with it. For one, 300.10.10.10 is not a valid IPv4, but it would match here.

I can ask Claude for a regex for IPv4, and it gives basically the one above (adding \b to match on word boundaries), as well as a stricter one that validates the true integer range:

image-20251106084952946

This one matches the same stuff.

I’ll remove the 10.0.0.5 friendly SMTP server IP from the list using the “X” button for a final result:

image-20251106085513366

URL

A uniform resource locator, or URL, is a web address, referring to a location on a network for retrieving some resource. It has a fancy diagram to describe the parts:

URI syntax diagram

The only required parts are the scheme and path, though typically the //host is included as well at a minimum.

The reference URL regex breaks down as follows:

http://[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+(:[0-9]+)?(/[^\s]*)?
  • http:// - the scheme hardcoded as “http” and then the separator “://”.
  • [a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+ - The same domain regex as above.
  • (:[0-9]+)? - The : and then one or more digits specifying the port. The ? means that everything in the ( ) shows up zero or one time.
  • (/[^\s]*)? - a “/” followed by zero or more characters that are not whitespace. If the first character in [ ] is ^, that means everything not in the characters that follow. \s is shorthand for whitespace characters.

This doesn’t extract anything:

image-20251106090925869

That’s because it’s hardcoded the scheme to be “http”. There’s a lot I could do to make this apply to all different kinds of URLs, but for most simple cases, just having that scheme be more flexible will do the trick. I’ll replace http with https? to capture both HTTP and HTTPS (because ? makes the “s” zero or one), or better is just \w+ to make it be any one or more word characters:

image-20251106091435667

Emails

Email addresses can actually have a lot of complex information in them, but they are typically letters and numbers, and “@” symbol, and then a domain.

\b[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}\b

This is actually a good simple regex for a quick scan, and works nicely here:

image-20251106091615891

I’ll remove residents@dosisneighborhood.corp and holiday2025-kitchen@dosisneighborhood.corp, as they are the targets of the phish, not related to the actors:

image-20251106091650166

Step 2

Overview

The “Defang & Report (Step 2)” tab has instructions for “defanging” the IOCs:

image-20251106095555015

Below that, the stats for the IOCs I have from Step 1 are displayed:

image-20251106095624491

Then there’s a place to apply sed commands:

image-20251106095650617

The reference page has a section on using sed:

image-20251106095758120

Defang

The reference commands here are all good, they just need to be chained together (using “;” per the instructions):

image-20251106095928939

Submit

On clicking the button to submit this to the security team, there’s a pop-up showing the final report and that it’s complete!

image-20251106100312019

Outro

Its All About Defang

Congratulations! You have completed the Its All About Defang challenge!

Ed is pleased:

Ed Skoudis

Ed Skoudis

Well you just made that look like a piece of cake! Though I prefer cookies…I know where to find the best in town!

Thanks again! See ya ‘round!