GithubHelp home page GithubHelp logo

midoelhawy / ripe-and-apnic-db-ip-parser Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 27 KB

generate your IP-geolocator directly from ripe DB and other DB'S

Shell 23.03% Python 51.72% Go 25.25%
ip ipgeolocation ripe free-ip-geolocation ripe-ip-parser apnic

ripe-and-apnic-db-ip-parser's Introduction

ripe-and-apnic-db-ip-parser

Introduction

ripe-db-ip-parser is a tool designed to parse the RIPE database of IP address assignments (ripe.db.inetnum) and import the data into a SQLite database for easy querying and analysis. This tool also provides flexibility for users to create their custom parsers to generate JSON or any other schema/database format.

Releases:

You will find all db(sql,mmdb) in the repository release section , do you need to use the repo only if you need to coastumize something

Download latest DB's

To download latest SQLITE_DB:
    wget -O "./ripe_data.db.zip" "https://github.com/midoelhawy/ripe-db-ip-parser/releases/latest/download/db.sqlite.zip"
    unzip -o ".ripe_data.db.zip" -d "./"
    rm "./ripe_data.db.zip"
To download latest MMDB:
    wget -O "./ripe_data.db.zip" "https://github.com/midoelhawy/ripe-db-ip-parser/releases/latest/download/ASN_COUNTRY_AND_CITY.mmdb
"
    unzip -o ".ripe_data.db.zip" -d "./"
    rm "./ripe_data.db.zip"

see Releases

How to Use

Prerequisites

Before using the tool, ensure that you have the following prerequisites installed:

  • Python 3.x
  • pip (Python package manager)

Setup

  1. Clone the repository to your local machine:

    git clone https://github.com/midoelhawy/ripe-and-apnic-db-ip-parser.git
  2. Navigate to the project directory:

    cd ripe-db-ip-parser
  3. Install the required Python packages:

    pip install -r requirements.txt

Parsing the RIPE Database

NOTE: you can run all process's in one step directly by running this command ./scripts/parse_all_ripe_db_and_generate_mmdb.sh

  1. download Ripe and apnic DB by running the following script:

    ./scripts/download-ripe-data.sh
  2. Run the SQL generator to import the parsed data into a SQLite database:

    python3 sqllite_importer.py

Custom Parser

You can also write your custom parser to generate JSON or another type of schema/database format. Follow these steps:

  1. Create a file named myCustomParser.py.

  2. Paste the following code into myCustomParser.py:

    from pathlib import Path
    from lib.db import SQLiteHandler
    from lib.ripe_parser import RIPE_PARSER
    
    if __name__ == "__main__":
        default_ripe_data = str(Path.joinpath(Path(__file__).parents[0],'db/ripe.db.inetnum')) # PUT HERE YOUR FILE PATH
        def on_single_block_process(block):
            pass
            # THIS FUNCTION WILL BE EXECUTED WITH EVERY BLOCK OF IPS 
            # YOU CAN PUT IT TO A JSON FILE FOR EXAMPLE 
    
        RIPE_PARSER.parse_file(default_ripe_data, on_single_block_process)
        print("Done")
  3. Customize the on_single_block_process function to handle each IP block as per your requirements.

  4. Run the myCustomParser.py script to execute your custom parsing logic.

How to generate MMDB database

NOTE: YOU NEED SQLITE DB TO GENERATE MMDB

  1. install and configure go-lang
  2. Run cd ./scripts && go run generate_mmdb.go

ripe-and-apnic-db-ip-parser's People

Contributors

midoelhawy avatar

Watchers

 avatar

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.