Skip to content

Pandry/Granti

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Granti

Granti Gohper

What is that

Granti is a tool I've written to check the logs of an application, and, indicating via RegEx the fields of the IP and the timestamp, it analyzes the logs and takes an action when a user exceed with some requests.

But Fail2ban does the same thing!

Well, yes, but actually no

As I saw from my tests, fail2ban looks at the rate of the requests;
Eg. I want to ban any user that does more than 100 requests in a 150 seconds time window.
For Fail2Ban (from my tests), there is no difference between 100 requests in 150 seconds and 10 requests in 15 seconds.
This is why I made Granti.

How it works

The way Granti works is by abstracting a ring chain structure:
Every element in the chain rapresents a request made from a certain IP (there is a chain for each IP). Each element has a number and "contains" the timestamp of a request.
Given a certain number of chain elements (the maximum request we want to allow an user to do), when the chain "closes" up it overwrite the timestamp of the chain element it's writing to.
But, before doing so, it check the timestamp of the request.
If the delta timestamp (between the request that's being overwritten and the request that's going to overwrite) is too low, the IP gets banned (an action gets exectued).

UML (Needs to be translated to English):

Compilation

Set CGO_ENABLED=1 for sqlite
Command to compile statically and export to a VM:
CGO_ENABLED=1 GOOS=linux go build -a -ldflags '-extldflags "-static"' .

TODO

  • Check for given inputs (eg. makes sure that the numbers are not negative)
  • Create a log file per each jail
  • Create a systemd installer and integration
  • Change toml schema to allow jail not to be defined under jails but with [[jailname]]
  • When log gets rotated, the line number should be resetted
  • Reference in the database the jails with the id instead of with the name
  • Add whitelist
  • Abb blackist (eg. banned user agents)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published