All Apps and Add-ons

Scripting, Search, Passing Vars

username9000
New Member

Greetings,

I am trying to setup up Splunk to count the failed login attempts on our firewall and then run a script that will login to the firewall and block said IP address.

Currently, I have it setup to capture failed login attempts and run the default script (echo.sh) for testing purposes.

My questions is, how do I count and pass the IP address after “from” in the log below?

Dec 27 15:37:36 192.168.4.1 seclogin: [2012 Dec 27 15:37:36] UTM5 Login failed: invalid user sdhsdh from 192.168.4.3

Do I have to create a field type or use the field extractor? How does either, affect Splunks outputs listed here: http://docs.splunk.com/Documentation/Splunk/5.0.1/Alert/Configuringscriptedalerts

0 Karma

BobM
Builder

Assuming you already have the src_ip field being extracted, you need a stats command to build a count. Try the following search over a relevant time period:-

seclogin: "Login failed" "invalid user" | stats count by src_ip | where count>20
0 Karma

username9000
New Member

I found this in another thread, seems to have done the trick.

\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3})"

thx for ur help

0 Karma

BobM
Builder

The regex should be generic and accept any numbers.

0 Karma

username9000
New Member

The logs only have one IP address in them (192.168.4.3), by using the GUI will it account for IP addresses that vary in the individual octet? For example, 17.45.252.1? etc? Or do i need to edit the rex syntax? I receive an error message for entering IP addresses that are not found within the log.

0 Karma

BobM
Builder

The interactive field extractor can do this for you.
There is a quick 3min video here http://www.splunk.com/view/SP-CAAADUY
and the docs are here http://docs.splunk.com/Documentation/Splunk/5.0.1/Knowledge/ExtractfieldsinteractivelywithIFX

0 Karma

username9000
New Member

Hi Bob,

No I have not extracted the src_ip field. Am I to define a regular expression to extract the IP or is there a more friendly GUI approach?

0 Karma
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

  🚀 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 ...