initial commit

This commit is contained in:
Phil Skentelbery
2020-11-09 20:32:20 -06:00
commit 13ffb7b83e
2 changed files with 32 additions and 0 deletions

29
failed_login.py Normal file
View File

@ -0,0 +1,29 @@
from pprint import pprint
import socket
import typer
from splunklib.client import connect
import splunklib.results as results
def display(response):
reader = results.ResultsReader(response)
typer.secho("---- Failed Logins ---", fg=typer.colors.MAGENTA)
for result in reader:
if isinstance(result, dict):
login = ("timestamp={2} user={0} src=:{1}").format(result["user"],result["src"],result["timestamp"])
typer.echo(login)
def main(host: str = typer.Option(..., prompt=True, help="Splunk hostname"),
port: int = typer.Option(8089,help="Splunk REST API port"),
username: str = typer.Option(..., prompt=True, help="Splunk username"),
password: str = typer.Option(..., prompt=True, help="Splunk password")):
search = """search index=_audit action="login attempt" info="failed" earliest=-7d@d | table timestamp user src"""
service = connect(host=host, port=port, username=username, password=password)
socket.setdefaulttimeout(None)
response = service.jobs.oneshot(search)
display(response)
if __name__ == "__main__":
typer.run(main)