Code Monkey home page Code Monkey logo

ip-map's Introduction

IP-Map

Creates out of failed SSH Logins with Python. Heavily inspired by /u/Ultradad

Example of Failed SSH Login Attempts Graphics

Requirements

It relies on matplotlib and cartopy, so its quite a hassle to install properly - Sorry!

Furthermore, you need a CSV file which maps IPv4 subnetworks to geolocations, like they come from maxmind ("GeoLite2 City"). The only important thing is, that it has the fields network,latitude,longitude. The default filename is geolocation.csv, but that can be changed with the --geolocation-csv parameter.

Usage

On your Server, you need to read the auth.log files:

grep "Failed" /var/log/auth.log | grep -Po "[\d]+\.[\d]+\.[\d]+\.[\d]+" | sort | uniq -c > failed_logins.txt

As most of the computing time is used for the matching of IPs to a subnetwork, this result can be cached with the --cache-locations locations.csv parameter. So if the dataset did not change, it can be run with the --read-cache locations.csv parameter to directly start with drawing the map.

usage: ip-map.py [-h] [--input INPUT_FILE]
                 [--geolocation-csv GEOLOCATION_FILENAME]
                 [--cache-locations WRITE_LOCATIONS_FILE]
                 [--read-cache READ_LOCATIONS_FILE]
                 [--result-filename RESULT_FILENAME]

Create a Worldmap out of Numbers and IPv4 addresses

optional arguments:
  -h, --help            show this help message and exit
  --input INPUT_FILE    File with number of failed logins followed by IPv4
                        address, one per line, defaults to failed_logins.txt
  --geolocation-csv GEOLOCATION_FILENAME
                        CSV file with subnet / location mapping, defaults to
                        geolocation.csv
  --cache-locations WRITE_LOCATIONS_FILE
                        Cache predicted locations in a file
  --read-cache READ_LOCATIONS_FILE
                        Read location data from cache rather then computing it
  --result-filename RESULT_FILENAME
                        Filename of the resulting map, defaults to result.png

ip-map's People

Contributors

eknoes avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.