One thing that would be helpful in automating the ban of bad IPs might be either to have support for IPBAN directly (https://github.com/DigitalRuby/IPBan/wiki) or possibly to write a custom log .txt that could use IPBAN's existing utility.
I've used the built-in AMS antispam tools from the get-go, many of which have been critical to help control and eliminate spam, but of course it only goes so far. I haven't yet written any scripts to do so (though that's a future project), but I'm basically taking IPs from the SMTP logs that fail due to anti-hammering (or one of the other filters) and manually put them in a ban.txt file that IPBAN looks at and automatically adds to its blacklist. All it needs is basically a plaintext file in a specific directory to either ban or unban IPs, and if there was an option in AMS / AFS to choose to write IPs to a file when they trigger specific filtering rulesets (ban), and then write them to a different file if enough time expires (unban).
I already use anti-hammering to block IPs for a day on unsuccessful logins, etc; what I'm looking for is more of a '2nd tier' ban, where, say, if an IP triggers an anti-hammer block, then that block gets released and that same IP gets blocked again over some period, to write that IP to a file to have IPBAN permanently block it until I manually unblock. It would be helpful for AMS to have a separate log file showing which IPs were blocked in this way with a timestamp.
I'm thinking I could get pretty close to the above using content filtering rules alone, but there doesn't seem to be a trigger rule variable for when an IP triggers a block from Anti-hammering (or similarly, when an IP block 'falls off' after enough time). I can certainly put in an action to write the IP to a file though.
For example, I have anti-hammering set so upon 5 fails w/i a 6 hour period, an IP gets blocked for 24 hours. in the SMTP log, for a repeated attempt after an IP is blocked, looks something like this:
Mon, 22 Jun 2020 00:20:14 -> 1.2.3.4 -> Failed: Action=[Accept Connection], Details=[Port 587: IP Blocked (Anti-Hammering).]
If there was a custom event for this, something like ####IP BLOCKED AH#### that could trigger writing that IP to a file to ban it, that's all I need. if an IP later falls off the hammering threshold, something like ####IP UNBLOCKED AH####, write that IP to a different file. Even better, if there was a file that could keep statistics of how many times an IP triggered a block rule that I could then use, say like 5 blocks w/i the past week/month or something, to perma-block that IP until I manually released it. Putting that IP right in AMS manual blacklist would be fine, as well as writing to a file, with a trigger like ####IP REPEAT OFFENDER####.
If I can achieve the above with existing content rules, I wouldn't mind doing that too - my goal here is ultimately to take advantage of AMS' IP block info to put into IPBAN so other machines can block those worst offending IPs that have no traffic other than malicious...