Project

ronin-db

0.01
The project is in a healthy, maintained state
ronin-db is a database library for managing and querying security data. ronin-db provides common ORM models for interacting with the database's SQL tables and querying/storing security data, such as URLs, email addresses, host names, IPs, ports, etc. ronin-db also provides CLI commands for managing the database(s).
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 2.0

Runtime

 Project Readme

ronin-db

CI Code Climate Gem Version

Description

ronin-db is a common database library for managing and querying security data. ronin-db provides common ORM models for interacting with the database's SQL tables and inserting/querying security data, such as URLs, email addresses, host names, IPs, ports, etc. ronin-db also provides CLI commands for managing the database(s).

ronin-db is part of the ronin-rb project, a Ruby toolkit for security research and development.

Features

  • Uses a sqlite database by default.
  • Provides common ActiveRecord models for interacting with the database tables.
  • Provides a ronin-db command for easy management of the database(s).
  • Provides additional commands for querying, inserting, deleting entries from various database tables.

Synopsis

Usage: ronin-db [options] [COMMAND [ARGS...]]

Options:
    -h, --help                       Print help information

Arguments:
    [COMMAND]                        The command name to run
    [ARGS ...]                       Additional arguments for the command

Commands:
    add
    asn
    certs
    completion
    creds
    edit
    emails
    help
    hosts
    ips
    irb, console
    list
    migrate
    open-ports
    oses
    passwords
    people
    phone-numbers
    ports
    remove
    services
    software
    street-addresses
    urls
    web-vulns

List available Databases:

$ ronin-db list

Add a new Database:

$ ronin-db add team-db --uri postgres://user:pass@vpn.example.com/db

Remove a Database:

$ ronin-db remove team-db

Add a host name to the database:

$ ronin-db hosts --add example.com
$ ronin-db hosts --add www.example.com

List host names in the database:

$ ronin-db hosts
example.com
www.example.com
...

Queries only certain host names:

$ ronin-db hosts --domain example.com
example.com
www.example.com
...

Imports a file of host names:

$ ronin-db hosts --import targets.txt

Examples

Manually creating the database:

require 'ronin/db'

Ronin::DB.connect(migrate: true)

Connecting to the default database:

require 'ronin/db'

Ronin::DB.connect

Creating a custom database:

require 'ronin/db'

Ronin::DB.connect('sqlite3:path/to/db.sqlite3', migrate: true)

Connecting to a custom database:

require 'ronin/db'

Ronin::DB.connect('sqlite3:path/to/db.sqlite3')

Interacting with the Ronin::DB models:

require 'ronin/db'

Ronin::DB.connect

Ronin::DB::HostName.create(name: 'www.example.com')
# =>
# #<Ronin::DB::HostName:0x00007f3275cc93f0
#  id: 1,
#  name: "www.example.com",
#  last_scanned_at: nil,
#  created_at: 2022-09-30 05:06:25.633087551 UTC>
Ronin::DB::HostName.create(name: 'www.example.org')
# =>
# #<Ronin::DB::HostName:0x00007f32768b60a0
#  id: 2,
#  name: "www.example.org",
#  last_scanned_at: nil,
#  created_at: 2022-09-30 05:07:00.996736126 UTC>

host_name = Ronin::DB::HostName.find(2)
# =>
# #<Ronin::DB::HostName:0x00007f32758072e0
#  id: 2,
#  name: "www.example.org",
#  last_scanned_at: nil,
#  created_at: 2000-01-01 05:07:00.996736 UTC>

host_name = Ronin::DB::HostName.first
# =>
# #<Ronin::DB::HostName:0x00007f3275cc93f0
#  id: 1,
#  name: "www.example.com",
#  last_scanned_at: nil,
#  created_at: 2022-09-30 05:06:25.633087551 UTC>

host_names = Ronin::DB::HostName.where(name: 'www.example.com')
# =>
# [#<Ronin::DB::HostName:0x00007f327597b4c8
#   id: 1,
#   name: "www.example.com",
#   last_scanned_at: nil,
#   created_at: 2000-01-01 05:06:25.633087 UTC>]

host_names = Ronin::DB::HostName.where(name: 'www.example.com')
# =>
# [#<Ronin::DB::HostName:0x00007f327597b4c8
#   id: 1,
#   name: "www.example.com",
#   last_scanned_at: nil,
#   created_at: 2000-01-01 05:06:25.633087 UTC>]

For more information on how to query the database models, see Active Record Query Interface and ronin-db-activerecord.

Requirements

Install

$ gem install ronin-db

Gemfile

gem 'ronin-db', '~> 0.1'

gemspec

gem.add_dependency 'ronin-db', '~> 0.1'

Development

  1. Fork It!
  2. Clone It!
  3. cd ronin-db
  4. ./scripts/setup
  5. git checkout -b my_feature
  6. Code It!
  7. bundle exec rake spec
  8. git push origin my_feature

If you want to test your changes locally, run rake db:console to start a local database console.

License

Copyright (c) 2006-2024 Hal Brodigan (postmodern.mod3 at gmail.com)

ronin-db is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

ronin-db 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. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with ronin-db. If not, see https://www.gnu.org/licenses/.