*********************
abuseipdb-wrapper
*********************
Info
###########################
- python wrapper for abuseipdb API (https://docs.abuseipdb.com/#introduction)
- gives you informations about abuse level of specified IP addresses
- focuses on caching results in local db
Install
###########################
stable version from pypi
.. code-block:: bash
pip install abuseipdb-wrapper
or newest version from github
.. code-block:: bash
pip install git+https://github.com/streanger/abuseipdb-wrapper.git
Command-line usage
###########################
.. code-block:: bash
abuse
or as module
.. code-block:: bash
python -m abuseipdb_wrapper
Python usage
###########################
- **init `AbuseIPDB` object**
Init ``AbuseIPDB`` object using API KEY created on https://www.abuseipdb.com/. Optionally you can provide `db_file` for your local database. It is recommended because this project focuses on storing data for further quick access without need of another requests.
.. code-block:: python
from abuseipdb_wrapper import AbuseIPDB
API_KEY = 'YOUR_API_KEY'
abuse = AbuseIPDB(api_key=API_KEY, db_file='abuseipdb.json')
abuse.colors_legend()
- **check list of IPs**
Specify list of IPs to be checked using ``add_ip_list`` method. Then call ``check`` method and wait for results.
.. code-block:: python
ips = ['1.2.3.4', '5.6.7.8', '9.10.11.12', '13.14.15.16']
abuse.add_ip_list(ips)
abuse.check()
- **no db caching approach**
If you are not interested in caching data in local database and only want to request for IP addresses one by one use the following code.
Have in mind that `.check_ip` method enriches results and removes `reports` section.
If using wrapper is like overkill in your project, go to: https://docs.abuseipdb.com/?python#check-endpoint
.. code-block:: python
from abuseipdb_wrapper import AbuseIPDB
API_KEY = 'YOUR_API_KEY'
abuse = AbuseIPDB(api_key=API_KEY)
ips = ['1.2.3.4', '2.3.4.5', '3.4.5.6']
for IP in ips:
result = abuse.check_ip() # enriched with url and request time
result = abuse.check_ip_orig() # results in original form
print(result)
- **show local db**
To display collected informations use ``show`` method. Alternatively call ``print`` on your ``AbuseIPDB`` object. You can specify columns to be displayed using ``apply_columns_order`` method. It affects both vertical and table view.
.. code-block:: python
columns = ['ipAddress', 'abuseConfidenceScore', 'totalReports', 'countryCode', 'domain', 'isp']
abuse.apply_columns_order(columns)
# show db by print or using .show method
print(abuse)
abuse.show(matched_only=False, table_view=True)
- **viewer**
For interactive IP check use ``.viewer`` method. It let you to provide multiple IPs at once. Use help for more information.
.. code-block:: python
abuse.viewer()
~< abuse >~: columns [columns list] # shows or apply columns order
~< abuse >~: export [csv, html, xlsx, md] # export to file
~< abuse >~: all # check/show all database
- **exports**
.. code-block:: python
abuse.export_csv('out.csv', matched_only=False)
abuse.export_html_styled('out.html', matched_only=False)
abuse.export_xlsx_styled('out.xlsx', matched_only=False)
abuse.export_md('out.md', matched_only=False)
- **convert to dataframe object**
.. code-block:: python
import pandas as pd
matched = abuse.get_db(matched_only=False)
df = pd.DataFrame(matched.values())
- **json columns**
- :code:`abuseConfidenceScore`
- :code:`countryCode`
- :code:`date` # additional
- :code:`domain`
- :code:`hostnames`
- :code:`ipAddress`
- :code:`ipVersion`
- :code:`isPublic`
- :code:`isWhitelisted`
- :code:`isp`
- :code:`lastReportedAt`
- :code:`numDistinctUsers`
- :code:`totalReports`
- :code:`url` # additional
- :code:`usageType`
- :code:`isTor`
Screenshots
###########################
- banner
.. image:: https://raw.githubusercontent.com/streanger/abuseipdb-wrapper/main/screenshots/banner.png
- colors legend
.. image:: https://raw.githubusercontent.com/streanger/abuseipdb-wrapper/main/screenshots/legend.png
- help
.. image:: https://raw.githubusercontent.com/streanger/abuseipdb-wrapper/main/screenshots/help.png
- vertical view
.. image:: https://raw.githubusercontent.com/streanger/abuseipdb-wrapper/main/screenshots/abuse-vertical-view.png
- table view
.. image:: https://raw.githubusercontent.com/streanger/abuseipdb-wrapper/main/screenshots/abuse-table-view.png
Changelog
###########################
- `v.0.2.0`:
- removed pandas and Jinja2 dependencies
- custom export functions
- :code:`date` as isoformat with timezone
- `v.0.1.9`:
- additional :code:`isTorNode` field replaced with :code:`isTor` supported by api
- `v.0.1.8`:
- more flexible exports
- passing :code:`api_key` to :code:`AbuseIPDB` is now optional
- keep order for passing IPs
- viewer:
- skip private IPs flag
- sumup flag
- force new check flag
- more verbose logs
- asterisks for api key using pwinput
- colors support for: windows-cmd, windows-terminal, windows-powershell, vscode, linux-terminal
- tests coverage for most features
- export to markdown
- and few smaller changes
- `v.0.1.7`:
- `abuse` entrypoint
- `columns` command in interactive view
- `export` command in interactive view (to .csv, .html, .xlsx)
- tor exit nodes enrichment
- storing db file in user home directory
- original API request using `.check_ip_orig`
- getpass and keyring for API_KEY read & store
- `v.0.1.6` and before:
- black background for better view in powershell
- export to csv, html, xlsx (from pandas df)
- wrap text in table cells - made using rich table
- return dataframe object
- enrich results with date of last check
Raw data
{
"_id": null,
"home_page": "https://github.com/streanger/abuseipdb-wrapper",
"name": "abuseipdb-wrapper",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "abuseipdb abuse",
"author": "streanger",
"author_email": "divisionexe@gmail.com",
"download_url": null,
"platform": null,
"description": "*********************\nabuseipdb-wrapper\n*********************\n\nInfo\n###########################\n\n- python wrapper for abuseipdb API (https://docs.abuseipdb.com/#introduction)\n\n- gives you informations about abuse level of specified IP addresses\n\n- focuses on caching results in local db\n\nInstall\n###########################\n\nstable version from pypi\n\n.. code-block:: bash\n\n pip install abuseipdb-wrapper\n\nor newest version from github\n\n.. code-block:: bash\n\n pip install git+https://github.com/streanger/abuseipdb-wrapper.git\n\nCommand-line usage\n###########################\n\n.. code-block:: bash\n\n abuse\n\nor as module\n\n.. code-block:: bash\n\n python -m abuseipdb_wrapper\n\nPython usage\n###########################\n\n- **init `AbuseIPDB` object**\n\n Init ``AbuseIPDB`` object using API KEY created on https://www.abuseipdb.com/. Optionally you can provide `db_file` for your local database. It is recommended because this project focuses on storing data for further quick access without need of another requests.\n\n .. code-block:: python\n\n from abuseipdb_wrapper import AbuseIPDB\n API_KEY = 'YOUR_API_KEY'\n abuse = AbuseIPDB(api_key=API_KEY, db_file='abuseipdb.json')\n abuse.colors_legend()\n\n- **check list of IPs**\n\n Specify list of IPs to be checked using ``add_ip_list`` method. Then call ``check`` method and wait for results.\n\n .. code-block:: python\n\n ips = ['1.2.3.4', '5.6.7.8', '9.10.11.12', '13.14.15.16']\n abuse.add_ip_list(ips)\n abuse.check()\n\n- **no db caching approach**\n\n If you are not interested in caching data in local database and only want to request for IP addresses one by one use the following code.\n Have in mind that `.check_ip` method enriches results and removes `reports` section.\n If using wrapper is like overkill in your project, go to: https://docs.abuseipdb.com/?python#check-endpoint\n\n .. code-block:: python\n\n from abuseipdb_wrapper import AbuseIPDB\n API_KEY = 'YOUR_API_KEY'\n abuse = AbuseIPDB(api_key=API_KEY)\n ips = ['1.2.3.4', '2.3.4.5', '3.4.5.6']\n for IP in ips:\n result = abuse.check_ip() # enriched with url and request time\n result = abuse.check_ip_orig() # results in original form\n print(result)\n\n- **show local db**\n\n To display collected informations use ``show`` method. Alternatively call ``print`` on your ``AbuseIPDB`` object. You can specify columns to be displayed using ``apply_columns_order`` method. It affects both vertical and table view.\n\n .. code-block:: python\n\n columns = ['ipAddress', 'abuseConfidenceScore', 'totalReports', 'countryCode', 'domain', 'isp']\n abuse.apply_columns_order(columns)\n # show db by print or using .show method\n print(abuse)\n abuse.show(matched_only=False, table_view=True)\n\n- **viewer**\n\n For interactive IP check use ``.viewer`` method. It let you to provide multiple IPs at once. Use help for more information.\n\n .. code-block:: python\n\n abuse.viewer()\n ~< abuse >~: columns [columns list] # shows or apply columns order\n ~< abuse >~: export [csv, html, xlsx, md] # export to file\n ~< abuse >~: all # check/show all database\n\n- **exports**\n\n .. code-block:: python\n\n abuse.export_csv('out.csv', matched_only=False)\n abuse.export_html_styled('out.html', matched_only=False)\n abuse.export_xlsx_styled('out.xlsx', matched_only=False)\n abuse.export_md('out.md', matched_only=False)\n\n- **convert to dataframe object**\n\n .. code-block:: python\n\n import pandas as pd\n matched = abuse.get_db(matched_only=False)\n df = pd.DataFrame(matched.values())\n\n- **json columns**\n\n - :code:`abuseConfidenceScore`\n - :code:`countryCode`\n - :code:`date` # additional\n - :code:`domain`\n - :code:`hostnames`\n - :code:`ipAddress`\n - :code:`ipVersion`\n - :code:`isPublic`\n - :code:`isWhitelisted`\n - :code:`isp`\n - :code:`lastReportedAt`\n - :code:`numDistinctUsers`\n - :code:`totalReports`\n - :code:`url` # additional\n - :code:`usageType`\n - :code:`isTor`\n\nScreenshots\n###########################\n\n- banner\n\n.. image:: https://raw.githubusercontent.com/streanger/abuseipdb-wrapper/main/screenshots/banner.png\n\n- colors legend\n\n.. image:: https://raw.githubusercontent.com/streanger/abuseipdb-wrapper/main/screenshots/legend.png\n\n- help\n\n.. image:: https://raw.githubusercontent.com/streanger/abuseipdb-wrapper/main/screenshots/help.png\n\n- vertical view\n\n.. image:: https://raw.githubusercontent.com/streanger/abuseipdb-wrapper/main/screenshots/abuse-vertical-view.png\n\n- table view\n\n.. image:: https://raw.githubusercontent.com/streanger/abuseipdb-wrapper/main/screenshots/abuse-table-view.png\n\nChangelog\n###########################\n- `v.0.2.0`:\n\n - removed pandas and Jinja2 dependencies\n - custom export functions\n - :code:`date` as isoformat with timezone\n\n- `v.0.1.9`:\n\n - additional :code:`isTorNode` field replaced with :code:`isTor` supported by api\n\n- `v.0.1.8`:\n\n - more flexible exports\n - passing :code:`api_key` to :code:`AbuseIPDB` is now optional\n - keep order for passing IPs\n - viewer:\n - skip private IPs flag\n - sumup flag\n - force new check flag\n - more verbose logs\n - asterisks for api key using pwinput\n - colors support for: windows-cmd, windows-terminal, windows-powershell, vscode, linux-terminal\n - tests coverage for most features\n - export to markdown\n - and few smaller changes\n\n- `v.0.1.7`:\n\n - `abuse` entrypoint\n - `columns` command in interactive view\n - `export` command in interactive view (to .csv, .html, .xlsx)\n - tor exit nodes enrichment\n - storing db file in user home directory\n - original API request using `.check_ip_orig`\n - getpass and keyring for API_KEY read & store\n\n- `v.0.1.6` and before:\n\n - black background for better view in powershell\n - export to csv, html, xlsx (from pandas df)\n - wrap text in table cells - made using rich table\n - return dataframe object\n - enrich results with date of last check\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "python wrapper for abuseipdb API",
"version": "0.2.0",
"project_urls": {
"Homepage": "https://github.com/streanger/abuseipdb-wrapper"
},
"split_keywords": [
"abuseipdb",
"abuse"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "f9ba692313318a1fc2e81d8a612b158657beb80b1c5ac4b9201d4b5ac50703af",
"md5": "fb56e518cab2e7e7874bf30a0f5da635",
"sha256": "74f6aa905275c453916c7a63a01d0d814c7de5ea959dd6a2072f44e00f741338"
},
"downloads": -1,
"filename": "abuseipdb_wrapper-0.2.0-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "fb56e518cab2e7e7874bf30a0f5da635",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": ">=3.8",
"size": 20957,
"upload_time": "2024-03-25T00:02:18",
"upload_time_iso_8601": "2024-03-25T00:02:18.094528Z",
"url": "https://files.pythonhosted.org/packages/f9/ba/692313318a1fc2e81d8a612b158657beb80b1c5ac4b9201d4b5ac50703af/abuseipdb_wrapper-0.2.0-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-25 00:02:18",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "streanger",
"github_project": "abuseipdb-wrapper",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "certifi",
"specs": [
[
"==",
"2024.2.2"
]
]
},
{
"name": "cffi",
"specs": [
[
"==",
"1.16.0"
]
]
},
{
"name": "charset-normalizer",
"specs": [
[
"==",
"3.3.2"
]
]
},
{
"name": "cryptography",
"specs": [
[
"==",
"42.0.5"
]
]
},
{
"name": "et-xmlfile",
"specs": [
[
"==",
"1.1.0"
]
]
},
{
"name": "idna",
"specs": [
[
"==",
"3.6"
]
]
},
{
"name": "importlib-metadata",
"specs": [
[
"==",
"7.0.1"
]
]
},
{
"name": "jaraco-classes",
"specs": [
[
"==",
"3.3.1"
]
]
},
{
"name": "jeepney",
"specs": [
[
"==",
"0.8.0"
]
]
},
{
"name": "keyring",
"specs": [
[
"==",
"24.3.1"
]
]
},
{
"name": "markdown-it-py",
"specs": [
[
"==",
"3.0.0"
]
]
},
{
"name": "mdurl",
"specs": [
[
"==",
"0.1.2"
]
]
},
{
"name": "more-itertools",
"specs": [
[
"==",
"10.2.0"
]
]
},
{
"name": "openpyxl",
"specs": [
[
"==",
"3.1.2"
]
]
},
{
"name": "pwinput",
"specs": [
[
"==",
"1.0.3"
]
]
},
{
"name": "pycparser",
"specs": [
[
"==",
"2.21"
]
]
},
{
"name": "pygments",
"specs": [
[
"==",
"2.17.2"
]
]
},
{
"name": "requests",
"specs": [
[
"==",
"2.31.0"
]
]
},
{
"name": "rich",
"specs": [
[
"==",
"13.7.1"
]
]
},
{
"name": "secretstorage",
"specs": [
[
"==",
"3.3.3"
]
]
},
{
"name": "tabulate",
"specs": [
[
"==",
"0.9.0"
]
]
},
{
"name": "urllib3",
"specs": [
[
"==",
"2.2.1"
]
]
},
{
"name": "zipp",
"specs": [
[
"==",
"3.17.0"
]
]
}
],
"lcname": "abuseipdb-wrapper"
}