Dockpylog can be used to automate the process of creating reports and graphs from your auth.log logfiles. It runs in a docker container and comes with an dockerfile to describe all dependencies. This project is mainly written in python, only the installation and the crontab scripts are in bash.
Dockpylog is triggered by a cronjob and does the following steps one time per day at 3am.
-
Grep all the IPs from failed ssh access attempts and store them in
/input/$(date +%d-%m-%y)_ips.txt
, also sort them by uniq. -
Start python programm in non interactive docker container with all its dependencies and mount volume.
-
Read IPs from
/input
folder. -
Query the IP geolocation API for information about every IP and store responses in
data/
. -
Create Barcharts and Report in
/output
. -
Cleanup data
Just check the /output
folder for generated images and reports :)
The installation is tested on a few debian derivates including Debain 9, Ubuntu 18, Kali Linux 2018.3. Dockpylog requires Docker to be installed.
git clone https://github.com/AvasDream/dockpylog.git
cd dockpylog/scripts/ && sudo bash install.sh
What does the install script do?
-
Check if it is running as root and check if docker is installed on host.
-
Create necessary directorys and change some file permissions.
-
Build the docker file.
-
Add cronjob to crontab.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Write me on twitter :)
-
Add Worldmap with one dot per IP
-
Add basemap in Dockerfile
m = Basemap(projection='robin',lon_0=0,resolution='c')
m.fillcontinents(color='white',lake_color='white')
m.drawcoastlines()
# Map (long, lat) to (x, y) for plotting
for i in lonlat:
x, y = m(i[0], i[1])
plt.plot(x, y, 'ro', markersize=3)
plt.title("Source of login attempts")
plt.show()
- Add Timestamp parsing
docker build . -t pyauthlog
# Developement
docker run --rm -it --volume="$(pwd):/home/src" pyauthlog /bin/bash
# Production
docker run -it --rm -e DATE="19-04-19" -v "$(pwd):/home/pyauthlog" pyauthlog
# Delete all images
docker rm $(docker ps -a -q)
docker rmi $(docker images -q)