Skip to content

Instantly share code, notes, and snippets.

@Bsebring
Last active February 14, 2024 12:37
Show Gist options
  • Save Bsebring/afcd0ab2c42d5fd603582c7ded2e9368 to your computer and use it in GitHub Desktop.
Save Bsebring/afcd0ab2c42d5fd603582c7ded2e9368 to your computer and use it in GitHub Desktop.

Revisions

  1. Bsebring revised this gist Jul 10, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion abuseipdb_block.py
    Original file line number Diff line number Diff line change
    @@ -14,7 +14,7 @@
    comment = message + "; Ports: " + ports + "; Direction: " + inOut + "; Trigger: " + trigger + "; Logs: " + logs
    headers = {
    'Accept': 'application/json',
    'Key': 'f4635bfa5be867bcd3543064934716df3506bf8dbfe9daaedd896331b465851f0e3049daa6add6d2'
    'Key': '$YOUR_API_KEY'
    }
    # String holding parameters to pass in json format
    querystring = {
  2. Bsebring created this gist Jul 9, 2019.
    42 changes: 42 additions & 0 deletions abuseipdb_block.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,42 @@
    #!/usr/bin/env python

    import requests
    import json
    import sys

    # Defining the api-endpoint
    url = 'https://api.abuseipdb.com/api/v2/report'
    ports = sys.argv[2]
    inOut = sys.argv[4]
    message = sys.argv[6]
    logs = sys.argv[7]
    trigger = sys.argv[8]
    comment = message + "; Ports: " + ports + "; Direction: " + inOut + "; Trigger: " + trigger + "; Logs: " + logs
    headers = {
    'Accept': 'application/json',
    'Key': 'f4635bfa5be867bcd3543064934716df3506bf8dbfe9daaedd896331b465851f0e3049daa6add6d2'
    }
    # String holding parameters to pass in json format
    querystring = {
    'ip':sys.argv[1],
    'categories':'14',
    'comment':comment
    }


    response = requests.request(method='POST', url=url, headers=headers, params=querystring)

    decodedResponse = json.loads(response.text)

    if response.status_code == 200:
    print(json.dumps(decodedResponse['data'], sort_keys=True, indent=4))
    elif response.status_code == 429:
    print (json.dumps(decodedResponse['errors'][0], sort_keys=True, indent=4))
    elif response.status_code == 422:
    print (json.dumps(decodedResponse['errors'][0], sort_keys=True, indent=4))
    elif response.status_code == 302:
    print('Unsecure protocol requested. Redirected to HTTPS.')
    elif response.status_code == 401:
    print (json.dumps(decodedResponse['errors'][0], sort_keys=True, indent=4))
    else:
    print('Unexpected server response. Status Code:' + response.status_code)