Skip to content

apiban/apiban-client-bash

Repository files navigation

Apiban Clients

APIBAN is made possible by the generosity of our sponsors.

Sample clients have been provided in a simple bash script or golang (go). The basic concept would be to create a chain in IPTABLES called APIBAN and have the clients executed via crontab.

The GO client has been tested more than the bash script. It is recommended that the bash only be used as a template.

The GO client is provided as both source code to build and an executable suitable for most nix environments. It assumes that it will be run in /usr/local/bin/apiban/.

UPDATES 2020-09-01

  • added nftables client for bash (tested on debian 9/10)

Client - bash

Use the GO client if you can... the bash script is suitable for a template. Not recommended for production.

Bash script to check apiban API and block returned IP addresses with iptables.

How to use

  1. Download apiban.sh and apibanconfig.sys
  2. Make sure jq is installed on your system (apt install jq)
  3. Replace MYAPIKEY in apibanconfig.sys with your apiban api key
  4. Run chmod +x apiban.sh
  5. Run ./apiban.sh as needed (cron recommended)

How it works

The client pulls the API key and last known ID from the apibanconfig.sys file.

When the script is executed, it first checks to see if the APIBAN chain exists in iptables. If the chain does not exist, it is recreated and the LKID is reset (allowing a full dump).

IP addresses are added to APIBAN chain and actions are logged in apiban-client.log.

Warranty

This code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

Bash client for APIBAN

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published

Languages