AboutExperienceBlogResourcesLabsMerchContact

inquiries@ctijen.com

☠
← Back to blog
November 15, 2026 · 14 min read

CTI Portfolio Part 3: Script It

Turn the Part 2 lab into a little Python script: RDAP, crt.sh, and VirusTotal passive DNS, all passive. Then run it on a real infostealer domain, walk into three traps on purpose, and find the one lead that actually matters.

This is Part 3 of the CTI portfolio series. It builds on the Part 2 lab, so grab that list of queries from last time, but don't worry if you don't have any! I got ya covered!

The first time I got a tiny little Codecademy Python for loop to print what I wanted, no matter how small, it WORKED, I finally fucking got it. I feel like I unlocked every programming meme and understood why it can be frustrating when I would ask a dev "idk what language it's in, can't you just read it?" lol Coding is infuriating and head-smashingly frustrating, but when you get even just a DIFFERENT error message, it gives you hope. :)

In Part 2, you did every lookup by hand, which is awesome and allows you to understand what's happening and when. But by the third domain, copying IPs out of VirusTotal into a spreadsheet gets v, v OLD. That's the boring half, and the boring half is exactly what scripts are for. You keep the thinking, the script does the clicking (so to speak).

Python shows up in a LOT of CTI job posts, and "can you automate a lookup?" is a really common ask. The good news: you don't need to be a full stack dev. You need to be able to read a little script, change it, and explain what it does. That's what we're building today, together.

The finished script lives on GitHub: CTIJen/cti-portfolio-tools. It's free, MIT licensed, and needs nothing installed except Python.

Your Query List Is Your Spec

Remember the "WRITE DOWN YOUR QUERIES" note in Part 2? Here's why. A spec is just a list of what a program is supposed to do, and your query list is one already. Each step you did by hand can be mapped to a function in the script:

Part 2 steps mapped to Part 3 functions Each step you did by hand in the Part 2 lab, and the function that does it in the script. Step 2, registration, becomes lookup_registration, which asks RDAP. Step 3, certificates, becomes lookup_certs plus the SAN loop. Step 4, passive DNS, becomes lookup_resolutions, which asks the VirusTotal API. Step 4, what else lived on that IP, becomes lookup_ip_neighbors, VirusTotal again. Step 7, write it up, becomes save, right on your laptop. Steps 5 and 6, the servers and fingerprints, are still done by hand. BY HAND (PART 2) THE SCRIPT (PART 3) 2 3 4 4 7 5, 6 Registration Certificates Passive DNS What else lived here? Write it up Servers, fingerprints ICANN Lookup %.domain on crt.sh VirusTotal Relations tab other domains on that IP defang, sources, dates Shodan, Censys, JARM lookup_registration() lookup_certs() lookup_resolutions() lookup_ip_neighbors() save() still by hand asks RDAP plus the SAN loop asks the VirusTotal API VirusTotal again right on your laptop free tiers are tiny

Steps 5 and 6 from part 2 (Shodan, Censys, the fingerprints) are NOT in the script on purpose. Free accounts get very few searches there, so those stay manual for now, and they're a great "add your own feature" project for later.

Some Background and Definitions

Quick vocab, because these words get thrown around:

  • API (Application Programming Interface): a way for a program to ask a website for data. Same data you'd see in the browser, minus the buttons, so your script can read it.
  • JSON: the format most APIs answer in. It looks like {"ip": "203.0.113.7", "date": "2026-09-28"}, nested lists and labels. Python reads it in one line.
  • API key: a long password that tells the API who's asking, so it can count your requests. It's YOURS. Never paste it into code, never commit it to GitHub.
  • Environment variable: a value that lives in your terminal session instead of in your code, like VT_API_KEY. The script reads the key from there, so the key never ends up in the code. Also INCREDIBLY useful when you need to change something that's in multiple places. Instead of finding each instance one-by-one, it's WAY easier to change the variable definition one time in the beginning!
  • Rate limit: how many requests an API lets you make in a window. VirusTotal's free tier is 4 a minute and 500 a day. Go over and you get told to wait (an HTTP 429 error).
  • RDAP (Registration Data Access Protocol): the modern version of WHOIS. Same registration info, but in JSON, so scripts can read it.
  • Defang / refang: defanging turns evil.com into evil[.]com so nobody clicks it by accident. It takes away the danger of the link, or its "fangs". Refanging undoes it so a script can use it.

Walking Through the Script

The full script is about 440 lines, and a LOT of that is comments explaining what each part does and why. Here are the parts that matter, trimmed down a little. Open the real file next to this if you want to follow along!

1. Ask with Midwest politeness... multiple times

Free services flake. crt.sh in particular times out a LOT (while I was testing, it threw a 502 error at half my lookups, then answered fine on the second try). So every request goes through one function that retries with a growing wait:

def get_json(url, headers=None, tries=3):
    all_headers = {"User-Agent": USER_AGENT, "Accept": "application/json"}
    all_headers.update(headers or {})
    for attempt in range(1, tries + 1):
        try:
            request = urllib.request.Request(url, headers=all_headers)
            with urllib.request.urlopen(request, timeout=60) as response:
                return json.loads(response.read().decode("utf-8"))
        except urllib.error.HTTPError as err:
            if err.code == 404:
                return None  # nothing found, so there's no point retrying
            if err.code == 429:
                if attempt < tries:
                    time.sleep(60)  # rate limited, take a breather
                continue
        except (OSError, json.JSONDecodeError):
            pass  # timeouts, connection errors, garbage responses
        if attempt < tries:
            time.sleep(5 * attempt)  # wait 5s, then 10s, then stop
    return None

Notice it uses urllib, which comes with Python. A lot of tutorials use the requests library instead, and it's great, but then everyone has to install it first. I wanted ZERO setup so anyone with Python can run it.

2. The SAN Loop

This is step 3 from Lab 05: search crt.sh, collect the SANs, then search each NEW SAN too. The important parts are the brakes, the checks that tell the loop when to STOP following new domains:

seen = {start}            # every domain we've already queued
to_check = [start]
for round_number in range(rounds + 1):
    next_round = []
    for domain in to_check:
        for cert in lookup_certs(domain):
            big = len(cert["sans"]) > BIG_CERT     # more than 50 SANs? probably a CDN
            for san in cert["sans"]:
                if san not in seen and not big and len(seen) < max_domains:
                    seen.add(san)
                    next_round.append(san)
    to_check = next_round

Three brakes, and every one of them is a lesson from Part 2:

  • seen stops it from looking up the same domain twice (or looping forever when two certs point at each other).
  • BIG_CERT stops it from following a giant shared cert. A cert with 60 SANs is usually a hosting company, and following it means pivoting into half the internet.
  • max_domains and rounds are the "knowing when to stop" lesson, written as code. The script literally prints "Knowing when to stop is a skill!" when it hits the limit. hehehe 😏

3. Passive DNS, Minus the Trap

VirusTotal tells us every IP a domain resolved to, with dates. But remember the Part 2 pitfall: two domains on the same IP only means something if the IP isn't shared by a million other sites. Cloudflare publishes its IP ranges, so the script checks every IP against them:

for res in lookup_resolutions(domain, vt_key):
    provider = shared_network(res["ip"])   # is this a Cloudflare IP?
    if provider:
        note = f"{provider} IP, shared by tons of unrelated sites, not pivoting on it"

It still RECORDS the Cloudflare IP (it's true, and it goes in your write-up), it just doesn't pivot on it.

4. What Else Lived Here?

For every IP that ISN'T shared, the script asks VirusTotal what other domains pointed there, and how close in time:

gap = days_apart(neighbor["date"], res["date"])
if gap <= window:
    note = f"SAME WEEK as {defang(domain)}"
else:
    note = f"{gap} days apart from {defang(domain)}"

Two choices worth pointing out:

  • If 30 or more domains live on the IP, it's flagged as busy (probably shared hosting) and the neighbors aren't listed at all.
  • Neighbors are LEADS, so the script writes them down but never loops through them. If it did, one shared server could turn a ten-minute run into an all-day one, and you'd end up with a pile of unrelated domains.

5. Never Trust the Attacker's Data

This one's easy to miss, so it gets its own callout:

SANs and hostnames come from the ATTACKER. Whoever requests a cert picks the names on it, and whoever owns a domain picks where it points. So the script treats them like any other untrusted input: anything that isn't shaped like a real domain gets skipped before it goes anywhere near a URL, and every CSV cell is checked for spreadsheet formulas (a cell starting with = can actually RUN in Excel).

def csv_safe(value):
    text = "" if value is None else str(value)
    return "'" + text if text[:1] in ("=", "+", "-", "@", "\t", "\r") else text

Is an attacker going to put a booby-trapped formula in a cert just for you? Probably not! But it's two lines, and it's the kind of thing that makes an interviewer go "oh, nice."

6. Writing It Down

Every finding gets saved as one row with where it came from, the date of the evidence, the exact query, and when the script pulled it. Everything is defanged before it hits the disk. That's the "every connection has a source and a date" rule from the Part 2 grading list, just automatic now.

Everything Is Still PASSIVE

Same ground rule as always. The script never resolves the domain, never visits it, never scans it. Every single request goes to a third party that already collected the data: the domain registry (RDAP), crt.sh, or VirusTotal. If you change the script, please keep it that way!

Let's Run It on Something Real

I went to ThreatFox (same as the Part 2 "skipped Part 1?" option) and picked a domain tagged as WARDEN Stealer. Gen Digital's analysis (Vojtěch Krejsa and Jan Rubín, October 8, 2026) describes it as a Rust infostealer sold as a subscription on Russian-language forums since August 2026. It goes after browser data, crypto wallets, and password managers, and it's one of the first stealers they've seen grabbing data from AI assistants and coding agents (Claude, Codex, Grok, and Cursor). We'lllll talk about AI in Part 5! 👀

The starting domain: start-hub[.]beer. Here's what the script found, all eleven rows (I left out the query and timestamp columns so it fits on your phone):

From RDAP (registration, created 2026-09-11):

  • Registrar: Spaceship, Inc.
  • Nameservers: carmelo[.]ns[.]cloudflare[.]com and dolly[.]ns[.]cloudflare[.]com

From crt.sh:

  • One certificate (crt.sh ID 29513023952), Let's Encrypt, issued 2026-09-11

From VirusTotal, where start-hub[.]beer resolved:

  • 172.67.140[.]14 on 2026-09-11, Cloudflare, not pivoting
  • 104.21.94[.]209 on 2026-09-11, Cloudflare, not pivoting
  • 31.59.41[.]155 on 2026-09-29

From VirusTotal, what else lived on 31.59.41[.]155:

  • gradex[.]beer on 2026-09-26, SAME WEEK
  • dgqweg[.]com on 2026-09-26, SAME WEEK
  • orkaleroorkalalelo[.]com on 2026-09-29, SAME WEEK
  • wosback[.]cc on 2026-09-29, SAME WEEK

However, there are three kinds of potential traps to be aware of:

Trap 1: The Registration

Spaceship is a popular, low-cost registrar, and Cloudflare nameservers are what millions of normal sites use. Part 2 called this exact combo out: "A giant registrar and Cloudflare nameservers? Not so much." While it is true, so it should go in the write-up, but it tells you basically nothing about who's behind it.

Trap 2: The Certificates

One Let's Encrypt cert, issued the same day the domain was registered (somebody was in a hurry), and its only SAN is the domain itself. No shared cert, no batch of twelve domains, nothing to loop through. The SAN pivot just... didn't hit.

And that's NORMAL. If every pivot hit, our job would be SO easy and none of us would be needed lol. A dead end is still a result: write down that you checked and what you found (nothing), so the next person doesn't redo it.

Trap 3: The Cloudflare IPs

On September 11, start-hub[.]beer was sitting behind Cloudflare. If the script had pivoted on those IPs, it would have handed us thousands of random websites. Instead it noted them and moved on.

The Real Lead: 31.59.41[.]155

By September 29, the domain had moved OFF Cloudflare to 31.59.41[.]155. That IP isn't in any big shared network, only a handful of domains ever pointed at it, and they all showed up within a few days of each other. Hmmm now THIS is the "same IP, same week" overlap from Part 2.

The Twist: Read the Reference

Here's where it gets fun. ThreatFox tags start-hub[.]beer and gradex[.]beer as WARDEN Stealer at 75% confidence, submitted by a community reporter, with the Gen Digital report as the reference. So I opened the report to check... and neither domain is in it. The IOC list has 50 domains and those two aren't there.

That doesn't mean the tag is wrong! The reporter may have pulled them from their own samples. But so far, the WARDEN label on those two domains rests on one person's submission. Then look at the last row of our output: wosback[.]cc. That one IS in Gen's IOC list. And our script found it sitting on the same IP as start-hub[.]beer, in the same week.

That's two separate sources pointing at the same thing: a community tag on the start domain, plus infrastructure overlap with a domain a research team published. Neither one is proof by itself, but together they make the WARDEN connection a lot more believable. (How you SAY "a lot more believable" in a report is exactly what Part 4 is about. Confidence language! Stay tuned.)

So what about dgqweg[.]com and orkaleroorkalalelo[.]com? They're not in the Gen report, and neither one is on ThreatFox at all (wosback[.]cc is, tagged WARDEN Stealer since October 14). They're LEADS: same IP, same week, worth watching, not proven. They go in the "what we don't know" section, and that's a perfectly good place for them.

Always open the reference. A link next to an indicator means someone THOUGHT it was related. It doesn't mean the report says what you assume it says. Five minutes of reading turned "the database says so" into "here's the evidence, and here's how much I trust it."

THIS is the exciting part! The "wait... I think I found something..." moment.

Scene from the movie Hook: Robin Williams as Peter, surrounded by the Lost Boys, with the caption "You're doing it Peter!"

That feeling is literally how you create intel, and it's what you present at conferences. You dig, you make sure you can always see daylight, and you show everyone what you found so they can find treasure too. :)

The BE CAREFULS

  • Your API key in git. A super common way keys leak is pasting them into code "just to test" and then committing. Keys go in an environment variable, .env goes in .gitignore, and if one ever DOES get pushed, regenerate it immediately. Deleting the commit isn't enough, bots scan GitHub for keys within minutes.
  • Time zones. VirusTotal gives dates as timestamps. Convert them in your local time and some dates come out a day early. The script uses UTC everywhere so everyone gets the same answer, and you should too in reports.
  • crt.sh being crt.sh. It times out. It throws 502s. It's a free community service doing a LOT of work. Be kind to our friend crt[.]sh hahaha
  • Burning your quota. Each IP-neighbor lookup costs a VT request. If you're on the free tier and running a lot of domains, use --skip-neighbors until you know which domains are worth it.
  • Believing the output. The script prints "these are LEADS" at the end for a reason. It found four neighbors. It did NOT find four malicious domains. That part is still your job, and honestly it's the fun part.

Lab 06: Script Your Pivot in an Hour

Same intelligence requirement as Part 2, now with a robot helper:

Your intelligence requirement

"Starting from one domain, how much of this group's current infrastructure can we identify, and what should we watch or block?"

Set your timer! Goal: a working script, a run on a real domain, and one change that's YOURS.

1. Set Up (10 min)

Check you have Python 3.9 or newer (python3 --version). Fork cti-portfolio-tools on GitHub (the Fork button makes your own copy under your account), then clone YOUR fork. Optional: get a free VirusTotal key (your profile, then API Key) and set it as an environment variable by adding export VT_API_KEY=your-key to your shell config file (~/.zshrc on a Mac) in a text editor. Then open a NEW terminal window (or run source ~/.zshrc) so the key actually loads. Run python3 -m unittest and make sure the tests pass.

2. Run It (10 min)

python3 pivot_out.py 'yourdomain[.]com' (defanged input works). Use your domain from Part 2, or borrow one of mine: wosback[.]cc, the one from Gen's IOC list. No VT key? It still runs RDAP and crt.sh and tells you what it skipped. Open the CSV in output/ and make sure you can explain every column.

3. Sort Your Rows (20 min)

Go through every row and sort it into three piles: meaningful, true but meaningless (big registrar, Cloudflare, a giant cert), and lead to check. Did the script skip something you'd have pivoted on? Did it list something you'd have skipped? Then open the reference for your starting indicator and check whether it actually says what the database implies.

Did Part 2 by hand? Compare the two. What did the script find that you missed? What did YOU find that it can't (hint: steps 5 and 6)?

4. Make It Yours (20 min)

Pick ONE small change and make it. Some ideas, easiest first:

  • Add another big shared network to SHARED_NETWORKS (Fastly and Akamai publish their ranges too)
  • Print the LIST of SAME WEEK neighbors at the end (right now you only get a count)
  • Add a --days option that ignores resolutions older than X days
  • Look up each lead in urlscan.io's search API (free key, still passive)

Commit your change with a message that says what you did and why. Check that your key isn't hiding in the history (git log -p | grep -i "your-key-start" should find nothing), then push it to your fork. If it breaks, commit the fix too! A real history beats a perfect one.

Be Ready to Talk About It

Practice these out loud, they're the follow-ups people ask when they see a script in a portfolio. Every answer is somewhere in this post, so say it in YOUR words:

  • Walk me through what your script does, start to finish.
  • Why doesn't it scan or visit the domains?
  • Why does it skip Cloudflare IPs?
  • Why doesn't it loop through the IP neighbors like it does with SANs?
  • Where does your API key live?
  • What does the script NOT do, and how would you add it? (Hint: look at how the VirusTotal step only runs when a key is set.)
  • Why does it check SANs before using them?

Resources


Next up is Part 4, the exec brief, where we take everything from Parts 1 through 3 and turn it into one page a busy leader will actually read. And yes, that's where "a lot more believable" turns into real confidence language. Back to the series hub.

Changelog

  • November 15, 2026: Published.