I've just developed a new regex to detect #log4Shell attack attempts in #log4j. It supports obfuscated payloads using recently discovered bypass words.

If you find new bypasses, please let me know. I'll do my best to keep it up-to-date!

Regex and details in this thread (1/8) Image
🔍 Regex:
\${(?i)((\${|}+)?(j|(([^-]*?:)+?'?-?(?1)'?))'?}*)((\${|}+)?(n|(([^-]*?:)+?'?-?(?6)'?))'?}*)((\${|}+)?(d|(([^-]*?:)+?'?-?(?11)'?))'?}*)((\${|}+)?(i|ı|(([^-]*?:)+?'?-?(?16)'?))'?}*)

(2/8)
💡 Supported obfuscation methods:
- generic lookup functions (lower, upper, date, ...)
- :- syntax (${X:Y:Z:-VAL})
- random characters in lookup blocks
- random case in lookup blocks
- abrupt termination of lookup block (${lower:})
- ...

(3/8)
💡 Supported obfuscation methods:
- ...
- nesting (${lower:${upper:j}})
- Unicode conversion confusion
- any combination of the techniques above

Tested payloads available here: pastebin.com/tASDyHb1

(4/8)
⛔ Limitations:
- URL encoding is not directly supported: better to pipe a decoder before running the regex
- finds the "jndi:" pattern only; this ensures to catch any protocol, keeping performances good, and false positive rate low due to the parser pedantism

(5/8)
⛔ Limitations:
- deliberately verbose to maximize compatibility, as non-PCRE engines may not support advanced features (e.g., DEFINE groups, and relative subpattern recursion)
- if you use Python, use the "regex" module, instead or "re"

(6/8)
🛠 How to use it:
- for detecting past malicious activity, analyze your logs with egrep. Note that analyzing logs from the webserver is useless, as you'd get only the computed values. You should use logs of anything before the webserver, or a copy of your traffic.
- ...

(7/8)
🛠 How to use it:
- ...
- for detecting/blocking live attack attempts, implement a new rule on your IDS/IPS using this regex

(8/8)

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with egglessness

egglessness Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(