For a security PoC in java 1.8 (java.util.regex.*) I try to detect in a log file an sql injection attack like "union select from", even if it's encoded to bypass a waf. Example from OWASP:
/*!%55NiOn*/ /*!%53eLEct*/
REVERSE(noinu)+REVERSE(tceles)
un?+un/**/ion+se/**/lect+
A dirty way to detect it thanks to a regex would be to detect 3 consecutive letters in character classes, [unio], [selct] and [from].
So a quite simple regex with few false positive would be like:
([unio])([unio&&[^\\1])[unio&&[^\\1\\2]]
=> does not match uni
[unio][unio&&[^u][unio&&[^un]]
=> does match uni
So I use subtraction, but using capturing group or named capturing group in a subtraction seems impossible but I need it to detect REVERSE(noinu)+REVERSE(tceles)
as well as /*!%55NiOn*/ /*!%53eLEct*/
Does anyone know how I could do it?
Thanks and sorry for the crappy english