Skip to content

Instantly share code, notes, and snippets.

@juanje
Created July 10, 2012 08:21
Show Gist options
  • Save juanje/3081998 to your computer and use it in GitHub Desktop.
Save juanje/3081998 to your computer and use it in GitHub Desktop.
A simple Logstash conffile with a custom grok filter
input {
tcp {
type => "linux-syslog"
port => 3333
}
file {
type => "linux-syslog"
path => [ "/var/log/auth.log" ]
}
}
filter {
grok {
type => "linux-syslog"
pattern => "%{SYSLOGTIMESTAMP:timestamp} %{HOSTNAME:host_target} sshd\[%{BASE10NUM}\]: Failed password for (invalid user |)%{USERNAME:username} from %{IP:src_ip} port %{BASE10NUM:port} ssh2"
add_tag => "ssh_brute_force_attack"
}
}
output {
stdout { }
elasticsearch { embedded => true }
}
@ssstonebraker
Copy link

Thanks dude I used your example to create some more:

grok {
  type => "linux-syslog"
  pattern => "%{SYSLOGTIMESTAMP:timestamp} %{HOSTNAME:host_target} sshd\[%{BASE10NUM}\]: Failed password for invalid user %{USERNAME:username} from %{IP:src_ip} port %{BASE10NUM:port} ssh2"
  add_tag => "ssh_brute_force_attack"
}
grok {
  type => "linux-syslog"
  pattern => "%{SYSLOGTIMESTAMP:timestamp} %{HOSTNAME:host_target} sudo: pam_unix\(sudo:auth\): authentication failure; logname=%{USERNAME:logname} uid=%{BASE10NUM:uid} euid=%{BASE10NUM:euid} tty=%{TTY:tty} ruser=%{USERNAME:ruser} rhost=(?:%{HOSTNAME:remote_host}|\s*) user=%{USERNAME:user}"
  add_tag => "sudo_auth_failure"
}
grok {
  type => "linux-syslog"
  pattern => "%{SYSLOGTIMESTAMP:timestamp} %{HOSTNAME:host_target} sshd\[%{BASE10NUM}\]: Failed password for %{USERNAME:username} from %{IP:src_ip} port %{BASE10NUM:port} ssh2"
  add_tag => "ssh_failed_login"
}

grok {
  type => "linux-syslog"
  pattern => "%{SYSLOGTIMESTAMP:timestamp} %{HOSTNAME:host_target} sshd\[%{BASE10NUM}\]: Accepted password for %{USERNAME:username} from %{IP:src_ip} port %{BASE10NUM:port} ssh2"
  add_tag => "ssh_sucessful_login"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment