From 0b446792b92c231f6c7e9a6237c7f1a84e3cb123 Mon Sep 17 00:00:00 2001 From: zcrt <115991818+zcrt@users.noreply.github.com> Date: Wed, 28 Aug 2024 10:17:15 +0200 Subject: [PATCH] :pushpin: add subfinder settings (#3385) Co-authored-by: Jan Klopper --- .../plugins/pdio_subfinder/boefje.json | 4 ++++ .../boefjes/plugins/pdio_subfinder/main.py | 14 ++++++++++--- .../plugins/pdio_subfinder/schema.json | 20 +++++++++++++++++++ 3 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 boefjes/boefjes/plugins/pdio_subfinder/schema.json diff --git a/boefjes/boefjes/plugins/pdio_subfinder/boefje.json b/boefjes/boefjes/plugins/pdio_subfinder/boefje.json index dfccab421a6..fd69ae598c1 100644 --- a/boefjes/boefjes/plugins/pdio_subfinder/boefje.json +++ b/boefjes/boefjes/plugins/pdio_subfinder/boefje.json @@ -5,5 +5,9 @@ "consumes": [ "Hostname" ], + "environment_keys": [ + "SUBFINDER_RATE_LIMIT", + "SUBFINDER_VERSION" + ], "scan_level": 2 } diff --git a/boefjes/boefjes/plugins/pdio_subfinder/main.py b/boefjes/boefjes/plugins/pdio_subfinder/main.py index be8c5de36b8..be54d15312d 100644 --- a/boefjes/boefjes/plugins/pdio_subfinder/main.py +++ b/boefjes/boefjes/plugins/pdio_subfinder/main.py @@ -1,15 +1,23 @@ +import logging +import os + import docker from boefjes.job_models import BoefjeMeta -SUBFINDER_IMAGE = "projectdiscovery/subfinder:v2.6.6" - def run(boefje_meta: BoefjeMeta) -> list[tuple[set, bytes | str]]: + """Create image from docker and run subfinder with only active domains output.""" + subfinder_image = f"projectdiscovery/subfinder:{os.getenv('SUBFINDER_VERSION', 'v2.6.6')}" + rate_limit = int(os.getenv("SUBFINDER_RATE_LIMIT", "0")) + client = docker.from_env() input_ = boefje_meta.arguments["input"] hostname = input_["name"] - output = client.containers.run(SUBFINDER_IMAGE, ["-silent", "-active", "-d", hostname], remove=True) + logging.info("Using %s with rate limit %s", subfinder_image, rate_limit) + output = client.containers.run( + subfinder_image, ["-silent", "-active", "-rate-limit", str(rate_limit), "-d", hostname], remove=True + ) return [(set(), output)] diff --git a/boefjes/boefjes/plugins/pdio_subfinder/schema.json b/boefjes/boefjes/plugins/pdio_subfinder/schema.json new file mode 100644 index 00000000000..bbb409e75a6 --- /dev/null +++ b/boefjes/boefjes/plugins/pdio_subfinder/schema.json @@ -0,0 +1,20 @@ +{ + "title": "Arguments", + "type": "object", + "properties": { + "SUBFINDER_RATE_LIMIT": { + "title": "SUBFINDER_RATE_LIMIT", + "type": "integer", + "minimum": 1, + "maximum": 65535, + "description": "Maximum number of http requests to send per second." + }, + "SUBFINDER_VERSION": { + "title": "SUBFINDER_VERSION", + "type": "string", + "maxLength": 10, + "description": "Version string including 'v', e.g. 'v2.6.6'." + } + }, + "required": [] +}