NOTE: This project is still in development. The CLI may change.
PenTestDB parses the output of various pentesting commands and then stores that data in an SQL database for later reference. The advantage of this is when working in large networks, or with many hosts, it can be easy to lose information. With this tool, the pentester can use SQL queries to sort through all the information they have found about the targets. For Example, which known and scanned hosts have port 80/TCP (HTTP) open? The pentester can use an SQL query like this: SELECT host FROM ports WHERE port = '80' AND protocol = 'TCP';
to answer that question. PenTestDB supports plug-ins so you can write your own parser for custom commands or scripts, or if there just isn't a parser for a program you use.
- GNU script
- PostgreSQL
- python3 (if using the built-in parsers)
on the first run, the container needs to be built so run docker-compose build; docker-compose up --exit-code-from ptdb-test
. on subsequent runs, you only need to run the command, docker-compose up --exit-code-from ptdb-test
. see here for more.
from source:
- Install and configure PostgreSQL.
- clone this repo.
- run the install script from this repo's root.
- source the
shell/start.sh
script from your shellsrc
file. (NOTE: This is not currently compatible withfish
.) - start the PostgreSQL
- hack
To see more installation options and instructions go to the installtion section of the wiki
To see a full and indepth look at configurations, go to the configuration section of the wiki.
but the TL;DR is:
- copy
/etc/ptdb/.config/ptdb/
(or/etc/skel/.config/ptdb/
) to~/.config/ptdb
. - copy
/etc/ptdb/ptdb_start.sh
(or/etc/skel/.ptdb_start.sh
) to~/.ptdb_start.sh
. - run
ptdb engagement --new <engagement name> --server default --active
to create a new engagement. - edit the default database acourding to your needs. the default database is located at
.config/ptdb/db-servers/default.toml
.
run queries examples:
ptdb query --get port state service version --from hosts --where "ip = '192.168.1.42'" "state = 'open'"
: Requests the ports along with the corresponding states, services, and versions for all open ports on the machine with the IP address192.168.1.42
. The equivalent SQL query would beSELECT port state service version FROM machines JOIN dns_names ON machines.id = dns_names.machine_uid JOIN ports ON machines.id = ports.machine_uid WHERE ip = '192.168.1.42' AND state = 'open';
.ptdb query --query "SELECT port state service version FROM machines JOIN dns_names ON machines.id = dns_names.machine_uid JOIN ports ON machines.id = ports.machine_uid WHERE ip = '192.168.1.42' AND state = 'open';"
: Makes the SQL query specified by--query
.ptdb pause
to pause locally (or add--global
to the command to pause all sessions.)ptdb resume
to resume locally (or add--global
to the command to resume all sessions.)ptdb info
will print basic info about the current state of the program.