Splunk Search

Regex question

sphc
Explorer

Hi!

if I can make groups from <VULN number ... to ... </VULN> with regex?

<VULN number="MP-412750" severity="5" cveid="CVE-2011-1276">
  <TITLE>   Excel</TITLE>
  <PCI_FLAG>1</PCI_FLAG>
  <CVSS_BASE>9.3</CVSS_BASE>
  <CVSS_TEMPORAL>6.9</CVSS_TEMPORAL>
  <CONSEQUENCE><![CDATA[Уязвимость, позволяющая удаленно выполнить код, существует в Microsoft Excel при обработке специально сформированных файлов Excel. В случае успешной эксплуатации данной уязвимости злоумышленник может получить полный контроль над системой и права на установку программ; просмотр, изменение или удаление данных или создание новых учетных записей с полными правами.]]></CONSEQUENCE>
  <DIAGNOSIS><![CDATA[Уязвимость позволяет атакующему выполнить произвольный код.]]></DIAGNOSIS>
  <RESULT>N/A</RESULT>
  <SOLUTION><![CDATA[Используйте рекомендации производителя:
  http://www.microsoft.com/technet/security/Bulletin/MS11-045.mspx]]></SOLUTION></VULN>
<VULN number="MP-412750" severity="5" cveid="CVE-2011-1276">
  <TITLE>   Excel</TITLE>
  <PCI_FLAG>1</PCI_FLAG>
  <CVSS_BASE>9.3</CVSS_BASE>
  <CVSS_TEMPORAL>6.9</CVSS_TEMPORAL>
  <CONSEQUENCE><![CDATA[Уязвимость, позволяющая удаленно выполнить код, существует в Microsoft Excel при обработке специально сформированных файлов Excel. В случае успешной эксплуатации данной уязвимости злоумышленник может получить полный контроль над системой и права на установку программ; просмотр, изменение или удаление данных или создание новых учетных записей с полными правами.]]></CONSEQUENCE>
  <DIAGNOSIS><![CDATA[Уязвимость позволяет атакующему выполнить произвольный код.]]></DIAGNOSIS>
  <RESULT>N/A</RESULT>
  <SOLUTION><![CDATA[Используйте рекомендации производителя:
  http://www.microsoft.com/technet/security/Bulletin/MS11-045.mspx]]></SOLUTION></VULN>
<VULN number="MP-412750" severity="5" cveid="CVE-2011-1276">
  <TITLE>   Excel</TITLE>
  <PCI_FLAG>1</PCI_FLAG>
  <CVSS_BASE>9.3</CVSS_BASE>
  <CVSS_TEMPORAL>6.9</CVSS_TEMPORAL>
  <CONSEQUENCE><![CDATA[Уязвимость, позволяющая удаленно выполнить код, существует в Microsoft Excel при обработке специально сформированных файлов Excel. В случае успешной эксплуатации данной уязвимости злоумышленник может получить полный контроль над системой и права на установку программ; просмотр, изменение или удаление данных или создание новых учетных записей с полными правами.]]></CONSEQUENCE>
  <DIAGNOSIS><![CDATA[Уязвимость позволяет атакующему выполнить произвольный код.]]></DIAGNOSIS>
  <RESULT>N/A</RESULT>
  <SOLUTION><![CDATA[Используйте рекомендации производителя:
  http://www.microsoft.com/technet/security/Bulletin/MS11-045.mspx]]></SOLUTION></VULN>

I want to separate them as events. Thank you!

Tags (2)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

For search-time extraction, try this. The exact regex string will depend on precisely what you want to extract. The mvexpand command splits the extracted fields into separate events.

<your base search> | rex max_match=0 "(?<vuln><VULN.*<\/VULN>)" | mvexpand vuln | ...
---
If this reply helps you, Karma would be appreciated.

View solution in original post

lfedak_splunk
Splunk Employee
Splunk Employee

Hey @sphc, if they solved your problem, remember to "√Accept" an answer to award karma points 🙂

0 Karma

sbbadri
Motivator

@sphc

try this in props.conf,

[yoursourcetype]
LINE_BREAKER = &lt;VULN
DATETIME_CONFIG =
KV_MODE = xml
NO_BINARY_CHECK = true
category = Custom
pulldown_type = true
SHOULD_LINEMERGE = false

0 Karma

richgalloway
SplunkTrust
SplunkTrust

The LINE_BREAKER attribute needs a capture group. Try LINE_BREAKER = ()\<VULN.

---
If this reply helps you, Karma would be appreciated.
0 Karma

sbbadri
Motivator

i guess capture group is not necessary .. whenever it finds &lt;VULN it will break the event from there

0 Karma

richgalloway
SplunkTrust
SplunkTrust

The docs say a capture group is necessary. Also, the contents of the capture group are discarded so be careful how you create your regex.

---
If this reply helps you, Karma would be appreciated.
0 Karma

jodyfsu
Path Finder

Here is what I came up with:

"| rex (VULN\s\w*="(?<number>\w*-\d*)"\s\w*="(?<severity>\d)"\s\w*="(?<cveid>\w*-\d*-\d*))"
0 Karma

richgalloway
SplunkTrust
SplunkTrust

For search-time extraction, try this. The exact regex string will depend on precisely what you want to extract. The mvexpand command splits the extracted fields into separate events.

<your base search> | rex max_match=0 "(?<vuln><VULN.*<\/VULN>)" | mvexpand vuln | ...
---
If this reply helps you, Karma would be appreciated.
Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Dynamic formatting from XML events

This challenge was first posted on Slack #puzzles channelFor a previous puzzle, I needed a set of fixed-length ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  &#x1f680; Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Stronger Security with Federated Search for S3, GCP SQL & Australian Threat ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...