minvws / nl-kat-coordination

OpenKAT scans networks, finds vulnerabilities and creates accessible reports. It integrates the most widely used network tools and scanning software into a modular framework, accesses external databases such as shodan, and combines the information from all these sources into clear reports. It also includes lots of cat hair.
https://openkat.nl
European Union Public License 1.2
127 stars 58 forks source link

Add s3 functionality in Bytes #3505

Closed Souf149 closed 1 month ago

Souf149 commented 2 months ago

Changes

Made it so that if the user adds S3_BUCKET_PREFIX or S3_BUCKET to their environment variables when building OpenKAT, that OpenKAT will use S3-buckets for saving the data from boefje's raw files instead of saving them on the local disk.

Issue link

Closes #3191

Demo

Example files made inside s3 image

Example of one of the files image

QA notes

To test this feature you will need access to an existing s3 server. And inside of you .env file you will need to provide the following variables which are required for boto3:

Outside of these you also have to specify either of the following variables to let OpenKAT know you want to use s3 for the storage of bytes:

Make sure that these are compliant with the bucket naming rules of AWS.

These are the variables I used for testing:

S3_BUCKET_PREFIX=souf-prefix
S3_BUCKET=souf-bucket

# Required env variables for `boto3`
AWS_ACCESS_KEY_ID=GKbf4e89d08d6c5250e7f1de60
AWS_SECRET_ACCESS_KEY=406fef311a69f02fa1c3b58d73a6299651c7890dc0ef5448104f1762e29887b7
AWS_ENDPOINT_URL=http://garage:3900

I made use of the s3 service garage How to setup garage How to work with garage in a container

I built a container for garage with the following docker compose file on the same host machine as bytes

services:
  garage:
    image: dxflrs/garage:v1.0.0
    restart: unless-stopped
    ports:
      - "127.0.0.1:3900:3900"
    volumes:
      - /etc/garage.toml:/etc/garage.toml
      - /var/lib/garage/meta:/var/lib/garage/meta
      - /var/lib/garage/data:/var/lib/garage/data
    networks:
      - network1

networks:
  network1:
    name: nl-kat-coordination_default
    external: true

Code Checklist


Checklist for code reviewers:


Checklist for QA:

What works:

What doesn't work:

Bug or feature?:

stephanie0x00 commented 1 month ago

Checklist for QA:

What works:

We did a live demo of the functionality to check if it works. The code stores data to a local (Garage) S3 bucket and we are also able to retrieve the data stored in bytes. It doesn't seem to break anything on main.

What doesn't work:

n/a

Bug or feature?:

Requires a small change on the logging format to prevent INFO messages from flooding the Bytes logs. This is picked up in this PR.

We identified a few improvements and things that could probably be solved nicer. There are picked up in different tickets and will be created by @Souf149. These include documentation and whether or not both the PREXIX and Bucket env vars are both mandatory (by aws) or whether these can be also used separately.