Giter Site home page Giter Site logo

ipdbrep.sh's Introduction

ipdbrep.sh

ShellCheck

Report IPs to AbuseIPDB directly from the shell

Schermata 2022-09-27 alle 23 25 31

Contents

What is this?

I created this script with the only purpose of submitting an IP address to the AbuseIPDB database directly from the shell but in a "guided" way with a pseudo-graphical interface (provided by Dialog).

How does it work?

It makes a POST request to the AbuseIPDB REPORT Endpoint. As simple as that. You can find the API documentation here.

Prerequisites

  • An AbuseIPDB API key, it's free. If you have an account already, you can create your API key from your dashboard.

  • The graphical interface is provided by Dialog, so you will need to install it to make this script work.

Installation

  1. Make sure Dialog is available on your system by running:
dialog --version

If not, you can install it by following the instructions in the next chapter

  1. Download ipdbrep.sh from the main branch to your local machine:
wget https://raw.githubusercontent.com/EarlyOwl/ipdbrep.sh/main/ipdbrep.sh
  1. Make it executable:
chmod +x ipdbrep.sh
  1. Run the script with:
./ipdbrep.sh

or, if you want every request output to be saved on a txt file and not only displayed on the screen:

./ipdbrep.sh save

That's it. Note that you will be prompted for your API key each time you execute the script. If you want to avoid this behavior, you can save your API key in a file named api.txt in the script's working directory.

If you want to test the script, as per documentation, you can simply report 127.0.0.1. The output should be similar to this:

  {
    "data": {
      "ipAddress": "127.0.0.1",
      "abuseConfidenceScore": 0
    }
  }

How do I install Dialog?

If Dialog is not present on your machine, you can run those commands based on your current OS / distro to install it:

Ubuntu / Debian
sudo apt-get update
sudo apt-get install dialog
RHEL / CentOS
sudo yum install dialog
MacOS

Install it via HomeBrew by running:

brew install dialog

Misc

Can I contribute? Can I reuse all/part of this script for other purposes?

Yes and yes.

Where I can find the report categories?

You can find them here.

This sucks / You could have done X instead of X!

I'm eager to learn, open an issue or a pull request to suggest an improvement / fix.

ipdbrep.sh's People

Contributors

earlyowl avatar

Watchers

 avatar

ipdbrep.sh's Issues

[BUG] mktemp: too few X's in template ‘api_output.txt’

Bug description

After providing the last parameter for the POST request the script throws an exception:

mktemp: too few X's in template ‘api_output.txt’
./ipdbrep.sh: line 14: $api_output: ambiguous redirect

Verified on Ubuntu 20.04.4 LTS. MacOS 12.6 Monterey doesn't seem to be affected.

What did go wrong?

From mktemp man page:

Create a temporary file or directory, safely, and print its name. TEMPLATE must contain at least 3 consecutive 'X's in last component. If TEMPLATE is not specified, use tmp.XXXXXXXXXX, and --tmpdir is implied. Files are created u+rw, and directories u+rwx, minus umask restrictions.

So while this actually works on MacOS 12.6:

#Creating a temporary txt to store cURL results
api_output=$(mktemp api_output.txt)

It should have been (simply) something like:

#Creating a temporary txt to store cURL results
api_output=$(mktemp)

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.