Painting a Log With Your Own Patterns
A lot of incident response starts with a wall of text. An alert’s raw event, a few thousand lines of a proxy log, a command line someone pasted into chat, the output of a script you ran on a box you don’t trust. Before you can do anything clever with it, you have to read it, and reading it means finding the five things that matter in five hundred lines that don’t.
Most of us do that with whatever is open. Ctrl+F in a text editor finds one thing at a time. grep --color finds several, in one color, and throws away the lines around them unless you remember -C. Notepad++ and Sublime can highlight, but setting it up is a chore and the setup lives on one machine. And none of them tell you anything about what they found.
So I built Prism: paste any text, and a list of regex rules on the side colors every match, each rule in its own color. Hover a hit and it tells you which rule found it, what the capture groups were, and what’s around it. You can try it right now at jon.glass/prism.
Goals
- Paste and see. No import step, no column mapping. Paste, drop a file, or open one, and the rules run.
- Rules you own. Every rule has a name, a color, a style and a note. They’re yours to write, reorder and keep.
- Context on hover. A highlighted word is only half an answer. The other half is the line it’s on and the lines around it.
- Survive big pastes and bad patterns. A few hundred thousand lines should be fine, and one bad regex shouldn’t freeze the page.
- Keep it local. Like the rest of the suite, it’s one static page. Nothing you paste leaves your browser, and Download saves it as a single file for machines that can’t reach the site.
- Work with the other tools. Indicators go to Tessera, timed hits to Recap, and the hits table to Shifu.
Paste Something
Prism starts with a set of DFIR rules: suspicious tooling and PowerShell flags, URLs, IPv4 and email addresses, domains, SHA-256, SHA-1 and MD5 hashes, Windows paths, registry keys and timestamps. The address and domain rules read the defanged forms too, so hxxp://files-update[.]example lights up the same as the live one.
The sample log: a Word document spawns PowerShell with -nop -w hidden -enc, and the rest of the morning follows. Clicking -enc pins its details: the rule, where it is, which of the rule’s 11 hits it is, and the text around it.
Each rule shows its hit count, and the arrows beside it step through its hits. N and Shift+N step through every hit in order, whichever rule it belongs to. Only lines with hits hides everything else, which turns a long proxy log into just the lines your rules care about. How much context the hover shows is up to you, from 40 characters either side to eight lines.
Where two rules match the same text, the one higher in the list wins the color, and a dotted line over the text says something else matched there too. The hover lists all of them. Drag the rules to change the order.
Write Your Own
The starter rules are a beginning. The useful ones are the ones you write for the log in front of you.
A rule with named groups splits each process start into its image, executable and command line, and the hover shows each part. A second rule underlines the host name on every line.
Patterns are JavaScript regular expressions, with checkboxes for ignoring case, multiline ^ and $, and letting . match newlines. Named groups ((?<exe>...)) show up by name in the hover, which is the quickest way I know to check that a pattern pulls out what you meant. Select some text in the viewer and From selection turns it into a rule, escaped and ready to edit.
Bad patterns are the other half of writing regex. Prism runs the matching in a background worker, so an expression like ^(a+)+$ that backtracks forever on the wrong input doesn’t lock up the page. After a few seconds Prism stops it, pauses that rule, and tells you which one it was. Edit the pattern and it tries again.
Markdown, Rendered
A lot of what lands in an incident is markdown: tickets, handoff notes, a README in a suspicious repo, the report a vendor sent over. Render markdown shows it formatted, with every rule still highlighting and every hover still working, because each word on the screen is still a slice of the text you pasted.
The sample incident note. The quoted phishing email’s “review the invoice” link shows its real destination beside it, and hovering it shows the markdown source around it.
It renders the way an analyst should want it to. Links aren’t clickable, and each one shows where it really goes right next to its text, so [review the invoice](hxxp://...) can’t hide its destination. Images are never loaded, which keeps tracking pixels from phoning home; you see the alt text and the address instead. Raw HTML is shown as text, never run. Opening a .md file turns it on for you, and Sample markdown in the Text menu has an incident note to try it on.
Keep Your Rules
A good rule set takes a while to build, and you’ll want it again on the next case.
Rule sets saved in this browser, plus files and links for taking them somewhere else.
Sets saves the current rules under a name, so you can keep one set for Windows event logs and another for proxy logs and switch between them. The panel shows which set you’re in and whether you’ve changed it since you saved. To move rules to another machine or hand them to someone else, save them to a .prism.json file, or copy a link. The link carries the whole rule set in the part of the URL after the #, which browsers never send to a server, and it holds only the rules, never your text. Opening one loads its rules, and if that would replace rules you hadn’t saved, Prism keeps them as a set first.
Send It On
Prism finds things. The other tools do something with them.
The sample log’s indicators in Tessera. Each one carries the rule that found it and its line, and Tessera works out the type. Internal addresses stay out.
Indicators → Tessera sends the unique matches of every rule marked as an indicator. That’s on by default, except for the tooling, timestamp and Base64 rules, which aren’t things you’d hunt for. Defanged values are refanged on the way, and private addresses (10.x, 192.168.x and the like) are left out. Hits with times → Recap sends every hit on a line with a readable timestamp as a timeline event, so you can see when each thing first and last showed up. Hits table → Shifu sends the whole table of hits to filter and group.
You can also export the hits as CSV (with formula characters escaped, so it’s safe to open in Excel) or the highlighted text as a standalone HTML page, which is handy for a report appendix.
What It Doesn’t Do
Prism reads text. It won’t parse an EVTX or a PCAP; export those to text or CSV first (Shifu is good at cleaning up EZTools output). It isn’t a log search engine: it holds what you paste in the browser’s memory, which is fine for hundreds of thousands of lines and not for a week of firewall logs. And it stops counting at 200,000 hits per rule, because a rule that matches that often is highlighting the log rather than anything in it.
Try It
Click Sample on the Tools page for the log in the screenshots, or open the sample markdown. Then try it on Case 01’s proxy log: question 3 asks what WKS-01 talks to every minute or so. A rule for the host, a rule or two for what you suspect, and Only lines with hits will get you most of the way.
The source is on GitHub. If you build a rule set you’re proud of, send me the link.