DenyHosts is a python program that automatically blocks ssh attacks by adding entries to /etc/hosts.deny.
DenyHosts will also inform Linux administrators about offending hosts, attacked users and suspicious logins.
This project is being actively developed on GitHub (https://github.com/denyhosts)
Main point is parsing documents with regular expression to the tree and edit them or replace some of the data, powered by your own python code. Python is very easy to understand, don`t be worried about this and try it! ;-)