reconFTW is a tool designed to perform automated recon on a target domain by running the best set of tools to perform scanning and finding out vulnerabilities
Shell bug-bountybugbountybugbounty-tooldnshackingnucleiosintpenetration-testingpentestpentest-toolpentestingreconreconnaissancescannersecuritysecurity-toolssubdomainsubdomain-enumerationvulnerabilities
fix: critical syntax errors and security improvements
six2dez3d8a1381510c
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.ymlindex abd2dab..a8b9280 100644--- a/.github/workflows/tests.yml+++ b/.github/workflows/tests.yml@@ -29,6 +29,10 @@ jobs:- name: Run ShellCheck on reconftw.shrun: shellcheck -S warning reconftw.sh+ - name: Run ShellCheck on modules+ run: shellcheck -S warning modules/*.sh+ continue-on-error: true+- name: Run ShellCheck on install.shrun: shellcheck -S warning install.shcontinue-on-error: truediff --git a/CHANGELOG.md b/CHANGELOG.mdnew file mode 100644index 0000000..f79a571--- /dev/null+++ b/CHANGELOG.md@@ -0,0 +1,78 @@+# Changelog++All notable changes to this project will be documented in this file.++The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),+and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).++## [Unreleased]++### Added++#### Phase 1 — Input Sanitization & Safety+- `sanitize_domain()`, `sanitize_ip()`, `sanitize_interlace_input()` functions for user-supplied input+- Configurable Axiom resolver paths (`AXIOM_RESOLVERS_PATH`, `AXIOM_RESOLVERS_TRUSTED_PATH`)++#### Phase 2 — Error Handling & Operational Robustness+- Numeric error codes for distinct failure categories+- Log rotation (`MAX_LOG_FILES`, `MAX_LOG_AGE_DAYS`) to prevent unbounded log growth+- Cleanup traps (`trap … EXIT`) for graceful shutdown and temp-file removal+- Structured JSON logging option (`STRUCTURED_LOGGING`)+- Pre-flight disk-space check (`MIN_DISK_SPACE_GB`)+- `validate_config` function to catch configuration errors before scanning starts++#### Phase 3 — Secrets & Configuration Security+- Environment-variable fallback pattern for all API keys (`SHODAN_API_KEY="${SHODAN_API_KEY:-}"`)+- Optional `secrets.cfg` file (gitignored) that is auto-sourced when present+- Docker secrets guidance — pass secrets at runtime via `-e` flags, not baked into the image+- Input validation hardening across configuration loading++#### Phase 4 — Testing Infrastructure+- `tests/` directory with `unit/`, `integration/`, and `fixtures/` sub-directories+- bats-core unit tests (`test_sanitize.bats`, `test_utils.bats`)+- `--source-only` flag in `reconftw.sh` to allow sourcing without execution (enables unit testing)+- `tests/run_tests.sh` runner script (`--all` for integration tests)+- GitHub Actions CI workflow (`tests.yml`) — ShellCheck + unit tests + integration matrix+- Makefile targets: `make test` (unit), `make test-all` (unit + integration)++#### Phase 5 — Modularization+- 8-module architecture under `modules/`:+ - `core.sh` — lifecycle, logging, notifications, cleanup+ - `modes.sh` — scan modes, argument parsing, help+ - `subdomains.sh` — all subdomain enumeration functions+ - `web.sh` — web analysis, fuzzing, JS checks+ - `vulns.sh` — vulnerability scanning functions+ - `osint.sh` — OSINT module functions+ - `axiom.sh` — Axiom/Ax fleet management helpers+ - `utils.sh` — shared utilities, sanitization, validation+- `reconftw.sh` reduced to a ~536-line entry point (sourcing, arg parsing, dispatch)++#### Phase 6 — Health Checks, Performance & Operational Modes+- `--health-check` flag — run system health check and exit (also used by Docker `HEALTHCHECK`)+- `--incremental` flag — only scan new findings since last run (`INCREMENTAL_MODE`)+- `--adaptive-rate` flag — automatically adjust rate limits on 429/503 errors (`ADAPTIVE_RATE_LIMIT`)+- `--dry-run` flag — show what would be executed without running commands+- Performance timing for scan stages+- Docker `HEALTHCHECK` directive in Dockerfile+- Cache configuration (`CACHE_MAX_AGE_DAYS`) for wordlists and resolvers++### Changed+- `reconftw.sh` refactored from monolithic script into modular entry point + 8 modules+- All `eval` usage on user input removed; replaced with safe alternatives+- All API key variables now use env-var fallback pattern (`${VAR:-}`) instead of hardcoded placeholders+- `reconftw.cfg` updated with new sections: incremental mode, adaptive rate limiting, cache, log rotation, structured logging, disk space check+- Makefile `lint` target now covers `modules/*.sh` in addition to `reconftw.sh` and `install.sh`+- Plugin/tool path references updated for modular layout++### Fixed+- Docker image no longer embeds secrets at build time+- Variable quoting issues across the codebase+- Potential command injection through unsanitized domain/path inputs++### Security+- All user-supplied input (domains, IPs, shell metacharacters) is sanitized before use+- `eval` removed from code paths handling user input+- Secrets management via environment variables and `secrets.cfg` (never committed)+- Docker runtime secrets pattern documented and enforced++[Unreleased]: https://github.com/six2dez/reconftw/compare/v3.2...HEADdiff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdnew file mode 100644index 0000000..dc0798b--- /dev/null+++ b/CONTRIBUTING.md@@ -0,0 +1,219 @@+# Contributing to reconFTW++Thank you for your interest in contributing to reconFTW! This guide covers everything you need to get started.++## Code of Conduct++Please read and follow the [Code of Conduct](CODE_OF_CONDUCT.md) in all interactions.++## Security Vulnerabilities++If you discover a security vulnerability, **do not open a public issue**. See [SECURITY.md](SECURITY.md) for responsible disclosure instructions.++## Development Setup++1. **Fork and clone** the repository:++ ```bash+ git clone https://github.com/<your-username>/reconftw+ cd reconftw+ git remote add upstream https://github.com/six2dez/reconftw+ git checkout dev+ ```++2. **Install dependencies**:++ ```bash+ ./install.sh+ ```++3. **Install dev tools** (optional but recommended):++ ```bash+ # Linting+ brew install shellcheck # or: apt install shellcheck+ # Formatting+ brew install shfmt # or: go install mvdan.cc/sh/v3/cmd/shfmt@latest+ # Testing+ brew install bats-core # or: apt install bats+ ```++## Project Structure++```+reconftw/+├── reconftw.sh # Entry point (~536 lines) — arg parsing, module loading, dispatch+├── reconftw.cfg # Default configuration file+├── install.sh # Installer script+├── Makefile # Data management, lint, fmt, test targets+├── modules/+│ ├── core.sh # Lifecycle, logging, notifications, cleanup+│ ├── modes.sh # Scan modes, argument parsing, help+│ ├── subdomains.sh # Subdomain enumeration functions+│ ├── web.sh # Web analysis, fuzzing, JS checks+│ ├── vulns.sh # Vulnerability scanning functions+│ ├── osint.sh # OSINT module functions+│ ├── axiom.sh # Axiom/Ax fleet management helpers+│ └── utils.sh # Shared utilities, sanitization, validation+├── tests/+│ ├── run_tests.sh # Test runner (--all for integration)+│ ├── unit/ # bats-core unit tests+│ ├── integration/ # bats-core integration tests+│ └── fixtures/ # Test data files+├── Docker/+│ └── Dockerfile # Official Docker image definition+└── Terraform/ # AWS deployment via Terraform + Ansible+```++## Code Style++- **Shell**: Bash 4+ required. Use `#!/bin/bash` shebang.+- **Formatter**: `shfmt` with project defaults — `shfmt -w -i 4 -bn -ci`+- **Linter**: `shellcheck -S warning`+- Run both before submitting:++ ```bash+ make lint+ make fmt+ ```++## Input Safety Rules++All user-supplied input **must** be sanitized before use:++- Use `sanitize_domain()` for domain names+- Use `sanitize_ip()` for IP/CIDR input+- Use `sanitize_interlace_input()` for arguments passed to interlace+- **Never** use `eval` on user input+- **Always** quote variables: `"${var}"`, not `$var`++## How to Add a New Function++1. **Choose the right module**: Place your function in the appropriate file under `modules/`:+ - Subdomain work → `subdomains.sh`+ - Web analysis → `web.sh`+ - Vulnerability checks → `vulns.sh`+ - OSINT → `osint.sh`+ - Utilities → `utils.sh`++2. **Follow the lifecycle pattern**:++ ```bash+ function my_new_check() {+ start_func "${FUNCNAME[0]}" "Running my new check"+ # ... your logic ...+ end_func "Results: ${FUNCNAME[0]}" "${FUNCNAME[0]}"+ }+ ```++3. **Add a config toggle** in `reconftw.cfg`:++ ```bash+ MY_NEW_CHECK=true # Enable or disable my new check+ ```++4. **Write tests**: Add a bats test in `tests/unit/`:++ ```bash+ @test "my_new_check validates input" {+ source ./reconftw.sh --source-only+ run my_new_check "valid-input"+ [ "$status" -eq 0 ]+ }+ ```++5. **Call it from a mode**: Wire the function into the appropriate mode in `modules/modes.sh`.++## How to Add a New Tool Integration++1. Add the install logic to `install.sh`+2. Add configuration variables to `reconftw.cfg`+3. Add the function that calls the tool to the appropriate module+4. Wire it into the relevant scan mode in `modes.sh`+5. Add a `--check-tools` entry if the tool is required+6. Write tests covering basic invocation+7. Update the Features section in `README.md`++## Configuration Change Guidelines++When adding new configuration variables:++- Use the environment-variable fallback pattern for secrets:++ ```bash+ MY_API_KEY="${MY_API_KEY:-}"+ ```++- Use descriptive names with comments explaining the purpose+- Group related variables together in `reconftw.cfg`+- Document new variables in the README configuration section++## Testing++### Running Tests++```bash+# Unit tests only+make test++# Unit + integration tests+make test-all++# Via the runner script+./tests/run_tests.sh # unit only+./tests/run_tests.sh --all # unit + integration+```++### Writing Tests++Tests use [bats-core](https://github.com/bats-core/bats-core). Place unit tests in `tests/unit/` with the `.bats` extension.++Use the `--source-only` pattern to load functions without executing the main script:++```bash+#!/usr/bin/env bats++setup() {+ source ./reconftw.sh --source-only+}++@test "sanitize_domain strips invalid chars" {+ result="$(sanitize_domain 'exam;ple.com')"+ [ "$result" = "example.com" ]+}+```++### CI Pipeline++The GitHub Actions workflow (`.github/workflows/tests.yml`) runs on every push and pull request:++1. **ShellCheck** — lints `reconftw.sh`, `modules/*.sh`, and `install.sh`+2. **Unit Tests** — runs `bats tests/unit/*.bats`+3. **Integration Tests** — installs reconFTW and runs tool checks++## Pull Request Process++1. **Target the `dev` branch** — never submit PRs directly to `main`+2. **Keep PRs focused** — one feature or fix per PR+3. **Include tests** for new functionality+4. **Pass linting**: `make lint` must pass+5. **Describe your changes** clearly in the PR description+6. **Reference issues** if applicable (e.g., "Fixes #123")++## Bug Reports++Submit bugs via [GitHub Issues](https://github.com/six2dez/reconftw/issues/new/choose). Include:++- reconFTW version (`git describe --tags`)+- OS and Bash version (`bash --version`)+- Steps to reproduce+- Expected vs. actual behavior+- Relevant log output++## Feature Requests++Open a [GitHub Issue](https://github.com/six2dez/reconftw/issues/new/choose) with:++- A clear description of the feature+- Use case / motivation+- Example configuration or usage if applicablediff --git a/Docker/Dockerfile b/Docker/Dockerfileindex cba480d..c814c71 100644--- a/Docker/Dockerfile+++ b/Docker/Dockerfile@@ -152,5 +152,8 @@ EXPOSE 85-90WORKDIR /reconftw+HEALTHCHECK --interval=60s --timeout=30s --retries=3 \+ CMD ./reconftw.sh --health-check || exit 1+ENTRYPOINT [ "./reconftw.sh" ]CMD [ "--help" ]diff --git a/Makefile b/Makefileindex 1571251..ca331c3 100644--- a/Makefile+++ b/Makefile@@ -32,14 +32,14 @@ upload:lint:@if command -v shellcheck >/dev/null 2>&1; then \- shellcheck -S warning reconftw.sh install.sh; \+ shellcheck -S warning reconftw.sh modules/*.sh install.sh; \else \echo "shellcheck not found. Install: https://www.shellcheck.net/"; \fifmt:@if command -v shfmt >/dev/null 2>&1; then \- shfmt -w -i 4 -bn -ci install.sh reconftw.sh; \+ shfmt -w -i 4 -bn -ci install.sh reconftw.sh modules/*.sh; \else \echo "shfmt not found. Install: https://github.com/mvdan/sh"; \fidiff --git a/README.md b/README.mdindex 3a2ba47..cbdd757 100644--- a/README.md+++ b/README.md@@ -60,6 +60,7 @@ reconFTW leverages a wide range of techniques, including passive and active subd- [Web Analysis](#web-analysis)- [Vulnerability Checks](#vulnerability-checks)- [Extras](#extras)+- [🏗️ Architecture](#️-architecture)- [💿 Installation](#-installation)- [Local Installation (PC/VPS/VM)](#local-installation-pcvpsvm)- [Docker](#docker)@@ -76,12 +77,15 @@ reconFTW leverages a wide range of techniques, including passive and active subd- [🗂️ Data Management](#️-data-management)- [Makefile](#makefile)- [Manual](#manual)+- [🧪 Testing](#-testing)- [Mindmap/Workflow](#mindmapworkflow)- [Sample video](#sample-video)- [🤝 How to Contribute](#-how-to-contribute)+- [🔒 Security](#-security)- [❓ Need Help?](#-need-help)- [💖 Support This Project](#-support-this-project)- [🙏 Thanks](#-thanks)+- [📝 Changelog](#-changelog)- [📜 License](#-license)- [⭐ Star History](#-star-history)@@ -194,6 +198,62 @@ reconFTW is packed with features to make reconnaissance thorough and efficient.- **Command Tracing**: Toggle `SHOW_COMMANDS` to log every executed command into target logs for debugging.- **Asset Store**: Appends findings to `assets.jsonl` for downstream automation when `ASSET_STORE` is enabled.- **ARM Support**: Compatible with Raspberry Pi and ARM architectures (including MacOS MX).+- **Health Check**: Built-in system health check via `--health-check` (also used by Docker `HEALTHCHECK`).+- **Incremental Mode**: Only scan new findings since last run (`--incremental`).+- **Adaptive Rate Limiting**: Automatically back off on 429/503 errors (`--adaptive-rate`).+- **Structured Logging**: Optional JSON log output for advanced analysis (`STRUCTURED_LOGGING`).+- **Input Sanitization**: All user input is sanitized to prevent command injection.+- **Dry-Run Mode**: Preview what would be executed without running commands (`--dry-run`).+- **Modular Architecture**: Codebase split into 8 focused modules for maintainability.+- **Secrets Management**: Environment variables, `secrets.cfg`, and Docker runtime secrets (see [SECURITY.md](SECURITY.md)).++---++## 🏗️ Architecture++reconFTW uses a modular architecture. The main entry point (`reconftw.sh`) handles argument parsing and sources 8 specialized modules from the `modules/` directory.++### Directory Layout++```+reconftw/+├── reconftw.sh # Entry point — arg parsing, module loading, dispatch+├── reconftw.cfg # Default configuration+├── install.sh # Installer+├── Makefile # Data management, lint, fmt, test targets+├── modules/+│ ├── core.sh # Lifecycle, logging, notifications, cleanup (1024 lines)+│ ├── modes.sh # Scan modes, argument parsing, help (902 lines)+│ ├── subdomains.sh # Subdomain enumeration (1938 lines)+│ ├── web.sh # Web analysis, fuzzing, JS checks (1712 lines)+│ ├── vulns.sh # Vulnerability scanning (926 lines)+│ ├── osint.sh # OSINT functions (500 lines)+│ ├── axiom.sh # Axiom/Ax fleet helpers (143 lines)+│ └── utils.sh # Utilities, sanitization, validation (508 lines)+├── tests/+│ ├── run_tests.sh # Test runner+│ ├── unit/ # bats-core unit tests+│ ├── integration/ # Integration tests+│ └── fixtures/ # Test data+├── Docker/+│ └── Dockerfile # Official Docker image+└── Terraform/ # AWS deployment+```++### Module Reference++| Module | Lines | Purpose |+|--------|------:|---------|+| `core.sh` | 1024 | Lifecycle management, logging, notifications, cleanup traps |+| `modes.sh` | 902 | Scan mode definitions, argument parsing, help output |+| `subdomains.sh` | 1938 | All subdomain enumeration functions |+| `web.sh` | 1712 | Web analysis, fuzzing, JS analysis, CMS detection |+| `vulns.sh` | 926 | Vulnerability scanning (XSS, SQLi, SSRF, etc.) |+| `osint.sh` | 500 | OSINT functions (WHOIS, emails, dorks, metadata) |+| `utils.sh` | 508 | Shared utilities, input sanitization, validation |+| `axiom.sh` | 143 | Axiom/Ax distributed fleet management |++The `--source-only` flag allows sourcing `reconftw.sh` without executing the main logic, enabling unit testing of individual functions.---@@ -284,6 +344,29 @@ cd reconftw- To skip Axiom tooling in custom builds, pass `--build-arg INSTALL_AXIOM=false`.- Mount your notify config at `~/.config/notify/providerconfig.yaml` inside the container if you use notifications.+5. **Secrets at Runtime**:++ Pass API keys and secrets via environment variables — never bake them into the image:++ ```bash+ docker run -it --rm \+ -e SHODAN_API_KEY="your-key" \+ -e COLLAB_SERVER="your-server" \+ -e XSS_SERVER="your-server" \+ -v "${PWD}/OutputFolder/:/reconftw/Recon/" \+ six2dez/reconftw:main -d example.com -r+ ```++ See [SECURITY.md](SECURITY.md) for full secrets management guidance.++6. **Health Check**:++ The Docker image includes a built-in `HEALTHCHECK` that runs `./reconftw.sh --health-check` every 60 seconds. You can also run it manually:++ ```bash+ docker exec <container-id> ./reconftw.sh --health-check+ ```+### Terraform + Ansible- Deploy reconFTW on AWS using Terraform and Ansible.@@ -321,14 +404,19 @@ cd reconftwThe `reconftw.cfg` file controls the entire execution of reconFTW. It allows fine-grained customization of:- **Tool Paths**: Set paths for tools, resolvers, and wordlists (`tools`, `resolvers`, `fuzz_wordlist`).-- **API Keys**: Configure keys for Shodan, WHOISXML, etc. (uncomment and set in `reconftw.cfg`).+- **API Keys**: Configure keys for Shodan, WHOISXML, etc. via environment variables or `secrets.cfg` (see [SECURITY.md](SECURITY.md)).- **Scanning Modes**: Enable/disable modules (e.g., `OSINT`, `SUBDOMAINS_GENERAL`, `VULNS_GENERAL`).- **Performance**: Adjust threads, rate limits, and timeouts (e.g., `FFUF_THREADS`, `HTTPX_RATELIMIT`).+- **Adaptive Rate Limiting**: Automatically back off on 429/503 errors (`ADAPTIVE_RATE_LIMIT`, `MIN_RATE_LIMIT`, `MAX_RATE_LIMIT`).+- **Incremental Scanning**: Only scan new findings since last run (`INCREMENTAL_MODE`).- **Notifications**: Set up Slack, Discord, or Telegram notifications (`NOTIFY_CONFIG`).-- **Axiom**: Configure distributed scanning (`AXIOM_FLEET_NAME`, `AXIOM_FLEET_COUNT`).+- **Axiom**: Configure distributed scanning and resolver paths (`AXIOM_FLEET_NAME`, `AXIOM_FLEET_COUNT`, `AXIOM_RESOLVERS_PATH`).- **AI Reporting**: Select AI model and report format (`AI_MODEL`, `AI_REPORT_TYPE`).- **Advanced Web Checks**: Toggle GraphQL introspection, parameter discovery, WebSocket testing, gRPC probing, and IPv6 scanning.- **Automation & Data**: Control quick rescan heuristics, asset logging, chunk sizes, hotlists, and debug tracing (`QUICK_RESCAN`, `ASSET_STORE`, `CHUNK_LIMIT`, `HOTLIST_TOP`, `SHOW_COMMANDS`).+- **Disk & Logging**: Pre-flight disk check (`MIN_DISK_SPACE_GB`), log rotation (`MAX_LOG_FILES`, `MAX_LOG_AGE_DAYS`), structured JSON logging (`STRUCTURED_LOGGING`).+- **Caching**: Configure cache expiry for wordlists and resolvers (`CACHE_MAX_AGE_DAYS`).+- **Secrets**: Use `secrets.cfg` for local overrides or environment variables for CI/Docker (see [SECURITY.md](SECURITY.md)).**Example Configuration**:@@ -351,13 +439,34 @@ generate_resolvers=false # Generate custom resolvers with dnsvalidatorupdate_resolvers=true # Fetch and rewrite resolvers from trickest/resolvers before DNS resolutionresolvers_url="https://raw.githubusercontent.com/trickest/resolvers/main/resolvers.txt"resolvers_trusted_url="https://gist.githubusercontent.com/six2dez/ae9ed7e5c786461868abd3f2344401b6/raw/trusted_resolvers.txt"-fuzzing_remote_list="https://raw.githubusercontent.com/six2dez/OneListForAll/main/onelistforallmicro.txt" # Used to send to axiom(if used) on fuzzing+fuzzing_remote_list="https://raw.githubusercontent.com/six2dez/OneListForAll/main/onelistforallmicro.txt" # Used to send to axiom(if used) on fuzzingproxy_url="http://127.0.0.1:8080/" # Proxy urlinstall_golang=true # Set it to false if you already have Golang configured and readyupgrade_tools=trueupgrade_before_running=false # Upgrade tools before running#dir_output=/custom/output/path-SHOW_COMMANDS=false # Log every executed command to the per-target log (verbose; may include sensitive data)+SHOW_COMMANDS=false # Set true to log every executed command to the per-target log (verbose; may include sensitive data)+MIN_DISK_SPACE_GB=0 # Minimum required disk space in GB before starting reconnaissance (0 to disable check)++# Incremental mode configuration+INCREMENTAL_MODE=false # Only scan new findings since last run (use --incremental flag to enable)++# Adaptive rate limiting configuration+ADAPTIVE_RATE_LIMIT=false # Automatically adjust rate limits when encountering 429/503 errors (use --adaptive-rate flag to enable)+MIN_RATE_LIMIT=10 # Minimum rate limit (requests per second)+MAX_RATE_LIMIT=500 # Maximum rate limit (requests per second)+RATE_LIMIT_BACKOFF_FACTOR=0.5 # Multiply rate by this when errors occur (0.5 = half speed)+RATE_LIMIT_INCREASE_FACTOR=1.2 # Multiply rate by this on success (1.2 = 20% faster)++# Cache configuration+CACHE_MAX_AGE_DAYS=30 # Maximum age in days for cached wordlists/resolvers (30 = 1 month)++# Log rotation+MAX_LOG_FILES=10 # Maximum number of log files to keep per target+MAX_LOG_AGE_DAYS=30 # Delete log files older than this many days++# Structured logging configuration (JSON format)+STRUCTURED_LOGGING=false # Enable JSON structured logging for advanced log analysis# Golang Vars (Comment or change on your own)export GOROOT="${GOROOT:-/usr/local/go}"@@ -385,13 +494,15 @@ GITHUB_TOKENS=${tools}/.github_tokensGITLAB_TOKENS=${tools}/.gitlab_tokens#CUSTOM_CONFIG=custom_config_path.txt # In case you use a custom config file, uncomment this line and set your files path-# APIs/TOKENS - Uncomment the lines you want removing the '#' at the beginning of the line-#SHODAN_API_KEY="XXXXXXXXXXXXX"-#WHOISXML_API="XXXXXXXXXX"-#XSS_SERVER="XXXXXXXXXXXXXXXXX"-#COLLAB_SERVER="XXXXXXXXXXXXXXXXX"-#slack_channel="XXXXXXXX"-#slack_auth="xoXX-XXX-XXX-XXX"+# APIs/TOKENS - Set via environment variables (preferred) or uncomment and edit below.+# Environment variables take precedence if set.+SHODAN_API_KEY="${SHODAN_API_KEY:-}"+WHOISXML_API="${WHOISXML_API:-}"+XSS_SERVER="${XSS_SERVER:-}"+COLLAB_SERVER="${COLLAB_SERVER:-}"+slack_channel="${slack_channel:-}"+slack_auth="${slack_auth:-}"+# For additional secrets, create a secrets.cfg file (gitignored) and it will be auto-sourced# File descriptorsDEBUG_STD="&>/dev/null" # Skips STD output on installer@@ -403,7 +514,7 @@ GOOGLE_DORKS=trueGITHUB_DORKS=trueGITHUB_REPOS=trueMETADATA=true # Fetch metadata from indexed office documents-EMAILS=true # Fetch emails from differents sites+EMAILS=true # Fetch emails from differents sitesDOMAIN_INFO=true # whois infoIP_INFO=true # Reverse IP search, geolocation and whoisAPI_LEAKS=true # Check for API leaks@@ -435,7 +546,7 @@ ZONETRANSFER=true # Check zone transferS3BUCKETS=true # Check S3 buckets misconfigsREVERSE_IP=false # Check reverse IP subdomain search (set True if your target is CIDR/IP)TLS_PORTS="21,22,25,80,110,135,143,261,271,324,443,448,465,563,614,631,636,664,684,695,832,853,854,990,993,989,992,994,995,1129,1131,1184,2083,2087,2089,2096,2221,2252,2376,2381,2478,2479,2482,2484,2679,2762,3077,3078,3183,3191,3220,3269,3306,3410,3424,3471,3496,3509,3529,3539,3535,3660,36611,3713,3747,3766,3864,3885,3995,3896,4031,4036,4062,4064,4081,4083,4116,4335,4336,4536,4590,4740,4843,4849,5443,5007,5061,5321,5349,5671,5783,5868,5986,5989,5990,6209,6251,6443,6513,6514,6619,6697,6771,7202,7443,7673,7674,7677,7775,8243,8443,8991,8989,9089,9295,9318,9443,9444,9614,9802,10161,10162,11751,12013,12109,14143,15002,16995,41230,16993,20003"-INSCOPE=false # Uses inscope tool to filter the scope, requires .scope file in reconftw folder+INSCOPE=false # Uses inscope tool to filter the scope, requires .scope file in reconftw folder# Web detectionWEBPROBESIMPLE=true # Web probing on 80/443@@ -446,7 +557,7 @@ UNCOMMON_PORTS_WEB="81,300,591,593,832,981,1010,1311,1099,2082,2095,2096,2480,30# HostFAVICON=true # Check Favicon domain discovery-PORTSCANNER=true # Enable or disable the whole Port scanner module+PORTSCANNER=true # Enable or disable the whole Port scanner moduleGEO_INFO=true # Fetch Geolocalization infoPORTSCAN_PASSIVE=true # Port scanner with ShodanPORTSCAN_ACTIVE=true # Port scanner with nmap@@ -476,7 +587,7 @@ ROBOTSWORDLIST=true # Check historic disallow entries on waybackMachinePASSWORD_DICT=true # Generate password dictionaryPASSWORD_MIN_LENGTH=5 # Min password lengthPASSWORD_MAX_LENGTH=14 # Max password length-CLOUDHUNTER_PERMUTATION=NORMAL # Options: DEEP (very slow), NORMAL (slow), NONE+CLOUDHUNTER_PERMUTATION=NORMAL # Options: DEEP (very slow), NORMAL (slow), NONE# VulnsVULNS_GENERAL=false # Enable or disable the vulnerability module (very intrusive and slow)@@ -560,6 +671,9 @@ resolvers=${tools}/resolvers.txtresolvers_trusted=${tools}/resolvers_trusted.txt# Axiom Fleet+# Resolver paths on Axiom instances (change if your fleet uses a different home dir)+AXIOM_RESOLVERS_PATH="/home/op/lists/resolvers.txt"+AXIOM_RESOLVERS_TRUSTED_PATH="/home/op/lists/resolvers_trusted.txt"# Will not start a new fleet if one exist w/ same name and size (or larger)# AXIOM=false Uncomment only to overwrite command line flagsAXIOM_FLEET_LAUNCH=true # Enable or disable spin up a new fleet, if false it will use the current fleet with the AXIOM_FLEET_NAME prefix@@ -665,16 +779,20 @@ reconFTW supports multiple modes and options for flexible reconnaissance. Use th### General Options-| Flag | Description |-| --------------- | ---------------------------------------------- |-| `--deep` | Enable deep scanning (slower, VPS recommended) |-| `-f` | Custom configuration file path |-| `-o` | Output directory for results |-| `-v` | Enable Axiom distributed scanning |-| `-q` | Set rate limit (requests per second) |-| `-y` | Enables AI results analysis |-| `--check-tools` | Exit if required tools are missing |-| `--quick-rescan` | Skip heavy modules when no new subs/webs are found |+| Flag | Description |+| ----------------- | -------------------------------------------------------- |+| `--deep` | Enable deep scanning (slower, VPS recommended) |+| `-f` | Custom configuration file path |+| `-o` | Output directory for results |+| `-v` | Enable Axiom distributed scanning |+| `-q` | Set rate limit (requests per second) |+| `-y` | Enables AI results analysis |+| `--check-tools` | Exit if required tools are missing |+| `--quick-rescan` | Skip heavy modules when no new subs/webs are found |+| `--health-check` | Run system health check and exit |+| `--incremental` | Only scan new findings since last run |+| `--adaptive-rate` | Automatically adjust rate limits on errors (429/503) |+| `--dry-run` | Show what would be executed without running commands |### Example Usage@@ -799,10 +917,17 @@ Use the provided `Makefile` for easy repository management (requires [GitHub CLI4. **Lint / Format Scripts**:```bash- make lint # shellcheck for install.sh & reconftw.sh (best effort)+ make lint # shellcheck for reconftw.sh, modules/*.sh & install.shmake fmt # shfmt with project defaults```+5. **Run Tests**:++ ```bash+ make test # unit tests (bats-core)+ make test-all # unit + integration tests+ ```+### Manual1. Create a private repository on GitHub/GitLab.@@ -833,6 +958,77 @@ Use the provided `Makefile` for easy repository management (requires [GitHub CLI---+## 🧪 Testing++reconFTW uses [bats-core](https://github.com/bats-core/bats-core) for automated testing.++### Install bats-core++```bash+# macOS+brew install bats-core++# Debian/Ubuntu+apt install bats++# From source+git clone https://github.com/bats-core/bats-core.git /tmp/bats+sudo /tmp/bats/install.sh /usr/local+```++### Running Tests++```bash+# Unit tests only+make test++# Unit + integration tests+make test-all++# Via the runner script+./tests/run_tests.sh # unit only+./tests/run_tests.sh --all # unit + integration+```++### Test Directory Structure++```+tests/+├── run_tests.sh # Test runner script+├── unit/ # Unit tests (fast, no network)+│ ├── test_sanitize.bats+│ └── test_utils.bats+├── integration/ # Integration tests (require installed tools)+└── fixtures/ # Shared test data files+```++### Writing Tests++Tests use the `--source-only` pattern to load functions without executing the main script:++```bash+#!/usr/bin/env bats++setup() {+ source ./reconftw.sh --source-only+}++@test "sanitize_domain strips invalid chars" {+ result="$(sanitize_domain 'exam;ple.com')"+ [ "$result" = "example.com" ]+}+```++### CI Pipeline++The GitHub Actions workflow (`.github/workflows/tests.yml`) runs on every push and pull request:++1. **ShellCheck** — lints `reconftw.sh`, `modules/*.sh`, and `install.sh`+2. **Unit Tests** — runs all `tests/unit/*.bats` files+3. **Integration Tests** — installs reconFTW and validates tool availability++---+## Mindmap/Workflow@@ -847,12 +1043,19 @@ Use the provided `Makefile` for easy repository management (requires [GitHub CLI## 🤝 How to Contribute-Contributions are welcome! You can help by:+See [CONTRIBUTING.md](CONTRIBUTING.md) for the full contributing guide, including development setup, code style, testing, and PR process.++Quick links:++- [Report a Bug](https://github.com/six2dez/reconftw/issues/new/choose)+- [Submit a Pull Request](https://github.com/six2dez/reconftw/tree/dev) (target the `dev` branch)+- [Code of Conduct](CODE_OF_CONDUCT.md)++----- **Reporting Issues**: Submit bugs or feature requests via [GitHub Issues](https://github.com/six2dez/reconftw/issues/new/choose).-- **Submitting Pull Requests**: Contribute code improvements to the [dev branch](https://github.com/six2dez/reconftw/tree/dev).+## 🔒 Security-**Guidelines**: Follow the [Code of Conduct](CODE_OF_CONDUCT.md).+For security policy, secrets management, and vulnerability reporting, see [SECURITY.md](SECURITY.md).---@@ -896,6 +1099,12 @@ Special thanks to the following services for supporting reconFTW:---+## 📝 Changelog++See [CHANGELOG.md](CHANGELOG.md) for a detailed list of changes in each release.++---+## 📜 LicensereconFTW is licensed under the [MIT License](LICENSE).diff --git a/SECURITY.md b/SECURITY.mdnew file mode 100644index 0000000..846a53b--- /dev/null+++ b/SECURITY.md@@ -0,0 +1,110 @@+# Security Policy++## Supported Versions++| Version | Supported |+| ------- | ------------------ |+| dev | :white_check_mark: |+| 3.x | :white_check_mark: |+| < 3.0 | :x: |++## Reporting a Vulnerability++**Do not open a public GitHub issue for security vulnerabilities.**++Instead, please report them responsibly by emailing **six2dez** directly:++- Email: [[email protected]](mailto:[email protected])+- Subject: `[reconFTW Security] <brief description>`++You should receive a response within 72 hours acknowledging the report. The maintainer will work with you to understand and remediate the issue before any public disclosure.++## Secrets Management++reconFTW handles API keys and credentials in three ways (in order of precedence):++### 1. Environment Variables (recommended)++Set secrets as environment variables before running:++```bash+export SHODAN_API_KEY="your-key"+export WHOISXML_API="your-key"+export XSS_SERVER="your-server"+export COLLAB_SERVER="your-server"+./reconftw.sh -d target.com -r+```++### 2. secrets.cfg File++Create a `secrets.cfg` file in the reconFTW root directory. It is automatically sourced at startup and is listed in `.gitignore`:++```bash+# secrets.cfg — never commit this file+SHODAN_API_KEY="your-key"+WHOISXML_API="your-key"+XSS_SERVER="your-server"+COLLAB_SERVER="your-server"+slack_channel="your-channel"+slack_auth="xoxb-your-token"+```++### 3. Docker Runtime Secrets++When running via Docker, pass secrets with `-e` flags at runtime. Never bake secrets into the image:++```bash+docker run -it --rm \+ -e SHODAN_API_KEY="your-key" \+ -e COLLAB_SERVER="your-server" \+ -v "${PWD}/OutputFolder/:/reconftw/Recon/" \+ six2dez/reconftw:main -d example.com -r+```++## Files to Never Commit++The following files may contain secrets and must **never** be committed to version control:++| File | Purpose |+|------|---------|+| `secrets.cfg` | Local secrets override file |+| `.env` | Environment variable definitions |+| `reconftw.cfg` (with keys) | Configuration with API keys filled in |+| `*.tokens` | GitHub/GitLab token files |++Verify these are covered by `.gitignore` before pushing.++## Input Sanitization++reconFTW sanitizes all user-supplied input to prevent command injection:++| Function | Purpose |+|----------|---------|+| `sanitize_domain()` | Strips characters not valid in domain names |+| `sanitize_ip()` | Validates and cleans IP/CIDR input |+| `sanitize_interlace_input()` | Removes shell metacharacters from interlace arguments |++All `eval` usage on user input has been removed. Variables are quoted throughout the codebase to prevent word-splitting and globbing attacks.++## Security-Related Configuration++These variables in `reconftw.cfg` control security and operational safety:++| Variable | Default | Description |+|----------|---------|-------------|+| `MIN_DISK_SPACE_GB` | `0` | Minimum disk space (GB) required before scanning starts (0 = disabled) |+| `MAX_LOG_FILES` | `10` | Maximum log files kept per target (prevents disk exhaustion) |+| `MAX_LOG_AGE_DAYS` | `30` | Auto-delete logs older than this many days |+| `STRUCTURED_LOGGING` | `false` | Enable JSON structured logging for audit trails |+| `SHOW_COMMANDS` | `false` | Log every executed command (may include sensitive data) |+| `INTRUSIVE` | `false` | Enable intrusive cloud write/CORS tests (dangerous, keep disabled) |+| `CACHE_MAX_AGE_DAYS` | `30` | Maximum cache age for wordlists/resolvers |++## Docker Security++The Dockerfile follows these security practices:++- Secrets are passed at runtime via environment variables, not embedded at build time+- A `HEALTHCHECK` directive ensures the container is monitored+- Non-essential build dependencies are removed in the final image+- The `--build-arg INSTALL_AXIOM=false` flag skips Axiom tooling when not neededdiff --git a/install.sh b/install.shindex d2ec288..2dac705 100755--- a/install.sh+++ b/install.sh@@ -8,15 +8,15 @@ IFS=$'\n\t'# Detect if the script is being run in MacOS with Homebrew Bashif [[ $OSTYPE == "darwin"* && $BASH != "/opt/homebrew/bin/bash" ]]; then- exec /opt/homebrew/bin/bash "$0" "$@"+ exec /opt/homebrew/bin/bash "$0" "$@"fi# Load main configurationCONFIG_FILE="./reconftw.cfg"if [[ ! -f $CONFIG_FILE ]]; then- printf "%b[!] Config file reconftw.cfg not found.%b\n" "$bred" "$reset"- exit 1+ printf "%b[!] Config file reconftw.cfg not found.%b\n" "$bred" "$reset"+ exit 1fisource "$CONFIG_FILE"@@ -33,11 +33,11 @@ IS_MAC=$([[ $OSTYPE == "darwin"* ]] && echo "True" || echo "False")# timeout/gtimeout compatibilityif command -v timeout >/dev/null 2>&1; then- TIMEOUT_CMD="timeout"+ TIMEOUT_CMD="timeout"elif command -v gtimeout >/dev/null 2>&1; then- TIMEOUT_CMD="gtimeout"+ TIMEOUT_CMD="gtimeout"else- TIMEOUT_CMD=""+ TIMEOUT_CMD=""fi# Globals for CLI overrides@@ -49,67 +49,67 @@ TOOLS_ONLY=${TOOLS_ONLY:-false}# If LOGFILE provided via env/flag, tee all outputif [[ -n ${LOGFILE} ]]; then- exec > >(tee -a "${LOGFILE}") 2>&1+ exec > >(tee -a "${LOGFILE}") 2>&1fi# Helper: run with timeout seconds if availablerun_to() {- local secs=$1- shift || true- if [[ -n $TIMEOUT_CMD ]]; then "$TIMEOUT_CMD" "$secs" "$@"; else "$@"; fi+ local secs=$1+ shift || true+ if [[ -n $TIMEOUT_CMD ]]; then "$TIMEOUT_CMD" "$secs" "$@"; else "$@"; fi}# Helper: optionally dry-runrun_cmd() {- if [[ $DRY_RUN == "true" ]]; then- printf "%s\n" "[DRY-RUN] $*"- return 0- fi- "$@"+ if [[ $DRY_RUN == "true" ]]; then+ printf "%s\n" "[DRY-RUN] $*"+ return 0+ fi+ "$@"}# Helper: quiet run (respect VERBOSE)q() {- if [[ $DRY_RUN == "true" ]]; then- printf "%s\n" "[DRY-RUN] $*"- return 0- fi- if [[ $VERBOSE == "true" ]]; then "$@"; else { "$@"; } &>/dev/null; fi+ if [[ $DRY_RUN == "true" ]]; then+ printf "%s\n" "[DRY-RUN] $*"+ return 0+ fi+ if [[ $VERBOSE == "true" ]]; then "$@"; else { "$@"; } &>/dev/null; fi}# Helper: quiet run with timeoutq_to() {- local secs=$1- shift || true- if [[ $DRY_RUN == "true" ]]; then- printf "%s\n" "[DRY-RUN] (to ${secs}) $*"- return 0- fi- if [[ -n $TIMEOUT_CMD ]]; then- if [[ $VERBOSE == "true" ]]; then "$TIMEOUT_CMD" "$secs" "$@"; else { "$TIMEOUT_CMD" "$secs" "$@"; } &>/dev/null; fi- else- if [[ $VERBOSE == "true" ]]; then "$@"; else { "$@"; } &>/dev/null; fi- fi+ local secs=$1+ shift || true+ if [[ $DRY_RUN == "true" ]]; then+ printf "%s\n" "[DRY-RUN] (to ${secs}) $*"+ return 0+ fi+ if [[ -n $TIMEOUT_CMD ]]; then+ if [[ $VERBOSE == "true" ]]; then "$TIMEOUT_CMD" "$secs" "$@"; else { "$TIMEOUT_CMD" "$secs" "$@"; } &>/dev/null; fi+ else+ if [[ $VERBOSE == "true" ]]; then "$@"; else { "$@"; } &>/dev/null; fi+ fi}# Helper: retry with linear backoffretry() {- local attempts=$1- local delay=$2- shift 2- local n=0- until "$@"; do- n=$((n + 1))- if ((n >= attempts)); then return 1; fi- sleep $((delay * n))- done+ local attempts=$1+ local delay=$2+ shift 2+ local n=0+ until "$@"; do+ n=$((n + 1))+ if ((n >= attempts)); then return 1; fi+ sleep $((delay * n))+ done}ensure_git_dir() {- local _path="$1"- if [[ -d "$_path" && ! -d "$_path/.git" ]]; then- rm -rf "$_path" 2>/dev/null || true- fi+ local _path="$1"+ if [[ -d "$_path" && ! -d "$_path/.git" ]]; then+ rm -rf "$_path" 2>/dev/null || true+ fi}# Non-fatal error trap: log and continue@@ -128,37 +128,37 @@ msg_err() { printf "%b%s%b\n" "$red" "$1" "$reset"; }# Progress helper (simple spinner output)progress_update() { :; }with_spinner() {- local _msg="$1"- shift- if [[ $DRY_RUN == "true" ]]; then- printf "%s\n" "[DRY-RUN] ${_msg}"- printf "%s\n" "[DRY-RUN] $*"- return 0- fi- if [[ $VERBOSE == "true" ]]; then- [[ -n $_msg ]] && printf "%s\n" "$_msg"- "$@"- return $?- fi- local spinner="|/-\\"- local spinner_len=4- local i=0- [[ -n $_msg ]] && printf "%s " "$_msg"- "$@" &- local cmd_pid=$!- while kill -0 "$cmd_pid" 2>/dev/null; do- printf "\r%s %s" "$_msg" "${spinner:i:1}"- i=$(((i + 1) % spinner_len))- sleep 0.1- done- wait "$cmd_pid"- local exit_code=$?- if [[ $exit_code -eq 0 ]]; then- printf "\r%s done\n" "$_msg"- else- printf "\r%s failed\n" "$_msg"- fi- return $exit_code+ local _msg="$1"+ shift+ if [[ $DRY_RUN == "true" ]]; then+ printf "%s\n" "[DRY-RUN] ${_msg}"+ printf "%s\n" "[DRY-RUN] $*"+ return 0+ fi+ if [[ $VERBOSE == "true" ]]; then+ [[ -n $_msg ]] && printf "%s\n" "$_msg"+ "$@"+ return $?+ fi+ local spinner="|/-\\"+ local spinner_len=4+ local i=0+ [[ -n $_msg ]] && printf "%s " "$_msg"+ "$@" &+ local cmd_pid=$!+ while kill -0 "$cmd_pid" 2>/dev/null; do+ printf "\r%s %s" "$_msg" "${spinner:i:1}"+ i=$(((i + 1) % spinner_len))+ sleep 0.1+ done+ wait "$cmd_pid"+ local exit_code=$?+ if [[ $exit_code -eq 0 ]]; then+ printf "\r%s done\n" "$_msg"+ else+ printf "\r%s failed\n" "$_msg"+ fi+ return $exit_code}# Keep arrays defined for potential later use, but classic UI prints a short summary only@@ -168,136 +168,136 @@ declare -a REPOS_CLONED REPOS_SKIPPED REPOS_FAIL# Basic network precheckcheck_network() {- printf "%bRunning: Network precheck%b\n" "$bblue" "$reset"- # Silence successful output; show message only on failure. Use q_to to respect --verbose.- if ! q_to 5 bash -lc 'getent hosts github.com >/dev/null 2>&1 || dig +short github.com >/dev/null 2>&1 || nslookup github.com >/dev/null 2>&1'; then- printf "%b[!] DNS resolution for github.com failed. Check your network.%b\n" "$bred" "$reset"- fi- if ! q_to 10 curl -I -s https://github.com >/dev/null 2>&1; then- printf "%b[!] HTTPS connectivity to github.com failed. Installer may fail.%b\n" "$yellow" "$reset"- fi+ printf "%bRunning: Network precheck%b\n" "$bblue" "$reset"+ # Silence successful output; show message only on failure. Use q_to to respect --verbose.+ if ! q_to 5 bash -lc 'getent hosts github.com >/dev/null 2>&1 || dig +short github.com >/dev/null 2>&1 || nslookup github.com >/dev/null 2>&1'; then+ printf "%b[!] DNS resolution for github.com failed. Check your network.%b\n" "$bred" "$reset"+ fi+ if ! q_to 10 curl -I -s https://github.com >/dev/null 2>&1; then+ printf "%b[!] HTTPS connectivity to github.com failed. Installer may fail.%b\n" "$yellow" "$reset"+ fi}# Check Bash versionBASH_VERSION_NUM=$(bash --version | awk 'NR==1{print $4}' | cut -d'.' -f1)if [[ $BASH_VERSION_NUM -lt 4 ]]; then- printf "%bYour Bash version is lower than 4, please update.%b\n" "$bred" "$reset"- if [[ $IS_MAC == "True" ]]; then- printf "%bFor macOS, run 'brew install bash' and rerun the installer in a new terminal.%b\n" "$yellow" "$reset"- fi- exit 1+ printf "%bYour Bash version is lower than 4, please update.%b\n" "$bred" "$reset"+ if [[ $IS_MAC == "True" ]]; then+ printf "%bFor macOS, run 'brew install bash' and rerun the installer in a new terminal.%b\n" "$yellow" "$reset"+ fi+ exit 1fi# Declare Go tools and their installation commandsdeclare -A gotools=(- ["gf"]="go install -v github.com/tomnomnom/gf@latest"- ["brutespray"]="go install -v github.com/x90skysn3k/brutespray@latest"- ["qsreplace"]="go install -v github.com/tomnomnom/qsreplace@latest"- ["ffuf"]="go install -v github.com/ffuf/ffuf/v2@latest"- ["github-subdomains"]="go install -v github.com/gwen001/github-subdomains@latest"- ["gitlab-subdomains"]="go install -v github.com/gwen001/gitlab-subdomains@latest"- ["nuclei"]="go install -v github.com/projectdiscovery/nuclei/v3/cmd/nuclei@latest"- ["anew"]="go install -v github.com/tomnomnom/anew@latest"- ["notify"]="go install -v github.com/projectdiscovery/notify/cmd/notify@latest"- ["unfurl"]="go install -v github.com/tomnomnom/[email protected]"- ["httpx"]="go install -v github.com/projectdiscovery/httpx/cmd/httpx@latest"- ["github-endpoints"]="go install -v github.com/gwen001/github-endpoints@latest"- ["dnsx"]="go install -v github.com/projectdiscovery/dnsx/cmd/dnsx@latest"- ["subjs"]="go install -v github.com/lc/subjs@latest"- ["Gxss"]="go install -v github.com/KathanP19/Gxss@latest"- ["katana"]="go install -v github.com/projectdiscovery/katana/cmd/katana@latest"- ["crlfuzz"]="go install -v github.com/dwisiswant0/crlfuzz/cmd/crlfuzz@latest"- ["dalfox"]="go install -v github.com/hahwul/dalfox/v2@latest"- ["puredns"]="go install -v github.com/d3mondev/puredns/v2@latest"- ["interactsh-client"]="go install -v github.com/projectdiscovery/interactsh/cmd/interactsh-client@latest"- ["analyticsrelationships"]="go install -v github.com/Josue87/analyticsrelationships@latest"- ["gotator"]="go install -v github.com/Josue87/gotator@latest"- ["roboxtractor"]="go install -v github.com/Josue87/roboxtractor@latest"- ["mapcidr"]="go install -v github.com/projectdiscovery/mapcidr/cmd/mapcidr@latest"- ["cdncheck"]="go install -v github.com/projectdiscovery/cdncheck/cmd/cdncheck@latest"- ["dnstake"]="go install -v github.com/pwnesia/dnstake/cmd/dnstake@latest"- ["tlsx"]="go install -v github.com/projectdiscovery/tlsx/cmd/tlsx@latest"- ["gitdorks_go"]="go install -v github.com/damit5/gitdorks_go@latest"- ["smap"]="go install -v github.com/s0md3v/smap/cmd/smap@latest"- ["dsieve"]="go install -v github.com/trickest/dsieve@master"- ["inscope"]="go install -v github.com/tomnomnom/hacks/inscope@latest"- ["enumerepo"]="go install -v github.com/trickest/enumerepo@latest"- ["Web-Cache-Vulnerability-Scanner"]="go install -v github.com/Hackmanit/Web-Cache-Vulnerability-Scanner@latest"- ["subfinder"]="go install -v github.com/projectdiscovery/subfinder/v2/cmd/subfinder@latest"- ["hakip2host"]="go install -v github.com/hakluke/hakip2host@latest"- ["mantra"]="go install -v github.com/Brosck/mantra@latest"- ["crt"]="go install -v github.com/cemulus/crt@latest"- ["s3scanner"]="go install -v github.com/sa7mon/s3scanner@latest"- ["nmapurls"]="go install -v github.com/sdcampbell/nmapurls@latest"- ["shortscan"]="go install -v github.com/bitquark/shortscan/cmd/shortscan@latest"- ["sns"]="go install github.com/sw33tLie/sns@latest"- ["ppmap"]="go install -v github.com/kleiton0x00/ppmap@latest"- ["sourcemapper"]="go install -v github.com/denandz/sourcemapper@latest"- ["jsluice"]="go install -v github.com/BishopFox/jsluice/cmd/jsluice@latest"- ["urlfinder"]="go install -v github.com/projectdiscovery/urlfinder/cmd/urlfinder@latest"- ["cent"]="go install -v github.com/xm1k3/cent@latest"- ["csprecon"]="go install github.com/edoardottt/csprecon/cmd/csprecon@latest"- ["VhostFinder"]="go install -v github.com/wdahlenburg/VhostFinder@latest"- ["misconfig-mapper"]="go install github.com/intigriti/misconfig-mapper/cmd/misconfig-mapper@latest"- ["grpcurl"]="go install -v github.com/fullstorydev/grpcurl/cmd/grpcurl@latest"+ ["gf"]="go install -v github.com/tomnomnom/gf@latest"+ ["brutespray"]="go install -v github.com/x90skysn3k/brutespray@latest"+ ["qsreplace"]="go install -v github.com/tomnomnom/qsreplace@latest"+ ["ffuf"]="go install -v github.com/ffuf/ffuf/v2@latest"+ ["github-subdomains"]="go install -v github.com/gwen001/github-subdomains@latest"+ ["gitlab-subdomains"]="go install -v github.com/gwen001/gitlab-subdomains@latest"+ ["nuclei"]="go install -v github.com/projectdiscovery/nuclei/v3/cmd/nuclei@latest"+ ["anew"]="go install -v github.com/tomnomnom/anew@latest"+ ["notify"]="go install -v github.com/projectdiscovery/notify/cmd/notify@latest"+ ["unfurl"]="go install -v github.com/tomnomnom/[email protected]"+ ["httpx"]="go install -v github.com/projectdiscovery/httpx/cmd/httpx@latest"+ ["github-endpoints"]="go install -v github.com/gwen001/github-endpoints@latest"+ ["dnsx"]="go install -v github.com/projectdiscovery/dnsx/cmd/dnsx@latest"+ ["subjs"]="go install -v github.com/lc/subjs@latest"+ ["Gxss"]="go install -v github.com/KathanP19/Gxss@latest"+ ["katana"]="go install -v github.com/projectdiscovery/katana/cmd/katana@latest"+ ["crlfuzz"]="go install -v github.com/dwisiswant0/crlfuzz/cmd/crlfuzz@latest"+ ["dalfox"]="go install -v github.com/hahwul/dalfox/v2@latest"+ ["puredns"]="go install -v github.com/d3mondev/puredns/v2@latest"+ ["interactsh-client"]="go install -v github.com/projectdiscovery/interactsh/cmd/interactsh-client@latest"+ ["analyticsrelationships"]="go install -v github.com/Josue87/analyticsrelationships@latest"+ ["gotator"]="go install -v github.com/Josue87/gotator@latest"+ ["roboxtractor"]="go install -v github.com/Josue87/roboxtractor@latest"+ ["mapcidr"]="go install -v github.com/projectdiscovery/mapcidr/cmd/mapcidr@latest"+ ["cdncheck"]="go install -v github.com/projectdiscovery/cdncheck/cmd/cdncheck@latest"+ ["dnstake"]="go install -v github.com/pwnesia/dnstake/cmd/dnstake@latest"+ ["tlsx"]="go install -v github.com/projectdiscovery/tlsx/cmd/tlsx@latest"+ ["gitdorks_go"]="go install -v github.com/damit5/gitdorks_go@latest"+ ["smap"]="go install -v github.com/s0md3v/smap/cmd/smap@latest"+ ["dsieve"]="go install -v github.com/trickest/dsieve@master"+ ["inscope"]="go install -v github.com/tomnomnom/hacks/inscope@latest"+ ["enumerepo"]="go install -v github.com/trickest/enumerepo@latest"+ ["Web-Cache-Vulnerability-Scanner"]="go install -v github.com/Hackmanit/Web-Cache-Vulnerability-Scanner@latest"+ ["subfinder"]="go install -v github.com/projectdiscovery/subfinder/v2/cmd/subfinder@latest"+ ["hakip2host"]="go install -v github.com/hakluke/hakip2host@latest"+ ["mantra"]="go install -v github.com/Brosck/mantra@latest"+ ["crt"]="go install -v github.com/cemulus/crt@latest"+ ["s3scanner"]="go install -v github.com/sa7mon/s3scanner@latest"+ ["nmapurls"]="go install -v github.com/sdcampbell/nmapurls@latest"+ ["shortscan"]="go install -v github.com/bitquark/shortscan/cmd/shortscan@latest"+ ["sns"]="go install github.com/sw33tLie/sns@latest"+ ["ppmap"]="go install -v github.com/kleiton0x00/ppmap@latest"+ ["sourcemapper"]="go install -v github.com/denandz/sourcemapper@latest"+ ["jsluice"]="go install -v github.com/BishopFox/jsluice/cmd/jsluice@latest"+ ["urlfinder"]="go install -v github.com/projectdiscovery/urlfinder/cmd/urlfinder@latest"+ ["cent"]="go install -v github.com/xm1k3/cent@latest"+ ["csprecon"]="go install github.com/edoardottt/csprecon/cmd/csprecon@latest"+ ["VhostFinder"]="go install -v github.com/wdahlenburg/VhostFinder@latest"+ ["misconfig-mapper"]="go install github.com/intigriti/misconfig-mapper/cmd/misconfig-mapper@latest"+ ["grpcurl"]="go install -v github.com/fullstorydev/grpcurl/cmd/grpcurl@latest")# Declare pipx tools and their pathsdeclare -A pipxtools=(- ["dnsvalidator"]="vortexau/dnsvalidator"- ["interlace"]="codingo/Interlace"- ["wafw00f"]="EnableSecurity/wafw00f"- ["commix"]="commixproject/commix"- ["urless"]="xnl-h4ck3r/urless"- ["ghauri"]="r0oth3x49/ghauri"- ["xnLinkFinder"]="xnl-h4ck3r/xnLinkFinder"- ["xnldorker"]="xnl-h4ck3r/xnldorker"- ["porch-pirate"]="MandConsultingGroup/porch-pirate"- ["p1radup"]="iambouali/p1radup"- ["subwiz"]="hadriansecurity/subwiz"- ["arjun"]="s0md3v/Arjun"- ["gqlspection"]="doyensec/GQLSpection"- ["cloud_enum"]="initstring/cloud_enum"+ ["dnsvalidator"]="vortexau/dnsvalidator"+ ["interlace"]="codingo/Interlace"+ ["wafw00f"]="EnableSecurity/wafw00f"+ ["commix"]="commixproject/commix"+ ["urless"]="xnl-h4ck3r/urless"+ ["ghauri"]="r0oth3x49/ghauri"+ ["xnLinkFinder"]="xnl-h4ck3r/xnLinkFinder"+ ["xnldorker"]="xnl-h4ck3r/xnldorker"+ ["porch-pirate"]="MandConsultingGroup/porch-pirate"+ ["p1radup"]="iambouali/p1radup"+ ["subwiz"]="hadriansecurity/subwiz"+ ["arjun"]="s0md3v/Arjun"+ ["gqlspection"]="doyensec/GQLSpection"+ ["cloud_enum"]="initstring/cloud_enum")# Declare repositories and their pathsdeclare -A repos=(- ["dorks_hunter"]="six2dez/dorks_hunter"- ["gf"]="tomnomnom/gf"- ["Gf-Patterns"]="1ndianl33t/Gf-Patterns"- ["sus_params"]="g0ldencybersec/sus_params"- ["Corsy"]="s0md3v/Corsy"- ["CMSeeK"]="Tuhinshubhra/CMSeeK"- ["fav-up"]="pielco11/fav-up"- ["massdns"]="blechschmidt/massdns"- ["Oralyzer"]="r0075h3ll/Oralyzer"- ["testssl.sh"]="drwetter/testssl.sh"- ["JSA"]="w9w/JSA"- ["CloudHunter"]="belane/CloudHunter"- ["ultimate-nmap-parser"]="shifty0g/ultimate-nmap-parser"- ["pydictor"]="LandGrey/pydictor"- ["gitdorks_go"]="damit5/gitdorks_go"- ["Web-Cache-Vulnerability-Scanner"]="Hackmanit/Web-Cache-Vulnerability-Scanner"- ["regulator"]="cramppet/regulator"- ["gitleaks"]="gitleaks/gitleaks"- ["trufflehog"]="trufflesecurity/trufflehog"- ["nomore403"]="devploit/nomore403"- ["SwaggerSpy"]="UndeadSec/SwaggerSpy"- ["LeakSearch"]="JoelGMSec/LeakSearch"- ["ffufPostprocessing"]="Damian89/ffufPostprocessing"- ["misconfig-mapper"]="intigriti/misconfig-mapper"- ["Spoofy"]="MattKeeley/Spoofy"- ["msftrecon"]="Arcanum-Sec/msftrecon"- ["Scopify"]="Arcanum-Sec/Scopify"- ["metagoofil"]="opsdisk/metagoofil"- ["EmailHarvester"]="maldevel/EmailHarvester"- ["reconftw_ai"]="six2dez/reconftw_ai"+ ["dorks_hunter"]="six2dez/dorks_hunter"+ ["gf"]="tomnomnom/gf"+ ["Gf-Patterns"]="1ndianl33t/Gf-Patterns"+ ["sus_params"]="g0ldencybersec/sus_params"+ ["Corsy"]="s0md3v/Corsy"+ ["CMSeeK"]="Tuhinshubhra/CMSeeK"+ ["fav-up"]="pielco11/fav-up"+ ["massdns"]="blechschmidt/massdns"+ ["Oralyzer"]="r0075h3ll/Oralyzer"+ ["testssl.sh"]="drwetter/testssl.sh"+ ["JSA"]="w9w/JSA"+ ["CloudHunter"]="belane/CloudHunter"+ ["ultimate-nmap-parser"]="shifty0g/ultimate-nmap-parser"+ ["pydictor"]="LandGrey/pydictor"+ ["gitdorks_go"]="damit5/gitdorks_go"+ ["Web-Cache-Vulnerability-Scanner"]="Hackmanit/Web-Cache-Vulnerability-Scanner"+ ["regulator"]="cramppet/regulator"+ ["gitleaks"]="gitleaks/gitleaks"+ ["trufflehog"]="trufflesecurity/trufflehog"+ ["nomore403"]="devploit/nomore403"+ ["SwaggerSpy"]="UndeadSec/SwaggerSpy"+ ["LeakSearch"]="JoelGMSec/LeakSearch"+ ["ffufPostprocessing"]="Damian89/ffufPostprocessing"+ ["misconfig-mapper"]="intigriti/misconfig-mapper"+ ["Spoofy"]="MattKeeley/Spoofy"+ ["msftrecon"]="Arcanum-Sec/msftrecon"+ ["Scopify"]="Arcanum-Sec/Scopify"+ ["metagoofil"]="opsdisk/metagoofil"+ ["EmailHarvester"]="maldevel/EmailHarvester"+ ["reconftw_ai"]="six2dez/reconftw_ai")# Function to display the bannerfunction banner() {- tput clear- cat <<EOF+ tput clear+ cat <<EOF██▀███ ▓█████ ▄████▄ ▒█████ ███▄ █ █████▒▄▄▄█████▓ █ █░▓██ ▒ ██▒▓█ ▀ ▒██▀ ▀█ ▒██▒ ██▒ ██ ▀█ █ ▓██ ▒ ▓ ██▒ ▓▒▓█░ █ ░█░@@ -316,316 +316,316 @@ EOF# Function to install Go toolsfunction install_tools() {- header "Installing Golang tools (${#gotools[@]})"-- local go_step=0- local failed_tools=()- local total_go=${#gotools[@]}- local go_ok=0 go_skip=0 go_fail=0- for gotool in "${!gotools[@]}"; do- ((++go_step))- if [[ $upgrade_tools == "false" ]]; then- if command -v "$gotool" &>/dev/null; then- INST_GO_SKIP+=("$gotool")- ((++go_skip))- progress_update "Go tools" "$go_step" "$total_go" "$go_ok" "$go_skip" "$go_fail"- [[ $COMPACT != "true" ]] && msg_warn "[$go_step/$total_go] ${gotool} already installed"- continue- fi- fi-- # Install the Go tool- if q bash -lc "${gotools[$gotool]}"; then- INST_GO_OK+=("$gotool")- ((++go_ok))- progress_update "Go tools" "$go_step" "$total_go" "$go_ok" "$go_skip" "$go_fail"- [[ $COMPACT != "true" ]] && msg_ok "[$go_step/$total_go] ${gotool} installed"- else- failed_tools+=("$gotool")- INST_GO_FAIL+=("$gotool")- ((++go_fail))- double_check=true- progress_update "Go tools" "$go_step" "$total_go" "$go_ok" "$go_skip" "$go_fail"- msg_err "[$go_step/$total_go] ${gotool} failed"- fi- done- [[ $COMPACT == "true" && $IS_TTY -eq 1 ]] && printf "\n"-- header "Installing pipx tools (${#pipxtools[@]})"-- local pipx_step=0- local failed_pipx_tools=()- local total_px=${#pipxtools[@]}- local px_ok=0 px_skip=0 px_fail=0-- for pipxtool in "${!pipxtools[@]}"; do- ((++pipx_step))- if [[ $upgrade_tools == "false" ]]; then- if command -v "$pipxtool" &>/dev/null; then- INST_PX_SKIP+=("$pipxtool")- ((++px_skip))- progress_update "pipx tools" "$pipx_step" "$total_px" "$px_ok" "$px_skip" "$px_fail"- [[ $COMPACT != "true" ]] && msg_warn "[$pipx_step/$total_px] ${pipxtool} already installed"- continue- fi- fi-- # Install the pipx tool- q pipx install "git+https://github.com/${pipxtools[$pipxtool]}"- exit_status=$?- if [[ $exit_status -ne 0 ]]; then- failed_pipx_tools+=("$pipxtool")- INST_PX_FAIL+=("$pipxtool")- ((++px_fail))- double_check=true- progress_update "pipx tools" "$pipx_step" "$total_px" "$px_ok" "$px_skip" "$px_fail"- msg_err "[$pipx_step/$total_px] ${pipxtool} install failed"- continue- fi-- # Upgrade the pipx tool- q pipx upgrade "${pipxtool}"- exit_status=$?- if [[ $exit_status -ne 0 ]]; then- failed_pipx_tools+=("$pipxtool")- INST_PX_FAIL+=("$pipxtool")- ((++px_fail))- double_check=true- progress_update "pipx tools" "$pipx_step" "$total_px" "$px_ok" "$px_skip" "$px_fail"- msg_err "[$pipx_step/$total_px] ${pipxtool} upgrade failed"- continue- fi-- INST_PX_OK+=("$pipxtool")- ((++px_ok))- progress_update "pipx tools" "$pipx_step" "$total_px" "$px_ok" "$px_skip" "$px_fail"- [[ $COMPACT != "true" ]] && msg_ok "[$pipx_step/$total_px] ${pipxtool} ready"- done- [[ $COMPACT == "true" && $IS_TTY -eq 1 ]] && printf "\n"-- header "Installing repositories (${#repos[@]})"-- local repos_step=0- local failed_repos=()- local total_repo=${#repos[@]}- local repo_ok=0 repo_skip=0 repo_fail=0-- for repo in "${!repos[@]}"; do- ((++repos_step))- if [[ $upgrade_tools == "false" ]]; then- if [[ -d "${dir}/${repo}" ]]; then- REPOS_SKIPPED+=("$repo")- ((++repo_skip))- progress_update "repos" "$repos_step" "$total_repo" "$repo_ok" "$repo_skip" "$repo_fail"- [[ $COMPACT != "true" ]] && msg_warn "[$repos_step/$total_repo] $repo already present at ${dir}/${repo}"- continue- fi- fi- # Clone the repository- if [[ ! -d "${dir}/${repo}" || -z "$(ls -A "${dir}/${repo}")" ]]; then- msg_run "[$repos_step/${#repos[@]}] $repo (clone)"- if retry 3 3 q_to 180 git clone --filter="blob:none" "https://github.com/${repos[$repo]}" "${dir}/${repo}"; then- exit_status=0- else- exit_status=$?- fi- if [[ $exit_status -ne 0 ]]; then- msg_err "[$repos_step/$total_repo] $repo clone failed"- failed_repos+=("$repo")- REPOS_FAIL+=("$repo")- ((++repo_fail))- double_check=true- continue- fi- REPOS_CLONED+=("$repo")- ((++repo_ok))- progress_update "repos" "$repos_step" "$total_repo" "$repo_ok" "$repo_skip" "$repo_fail"- fi-- # Navigate to the repository directory- cd "${dir}/${repo}" || {- msg_err "[$repos_step/$total_repo] $repo: cannot enter ${dir}/${repo}"- failed_repos+=("$repo")- REPOS_FAIL+=("$repo")- ((++repo_fail))- double_check=true- continue- }-- # Pull the latest changes- msg_run "[$repos_step/${#repos[@]}] $repo (pull)"- if retry 3 3 q_to 60 git pull; then- exit_status=0- else- exit_status=$?- fi- if [[ $exit_status -ne 0 ]]; then- msg_err "[$repos_step/$total_repo] $repo pull failed"- failed_repos+=("$repo")- REPOS_FAIL+=("$repo")- ((++repo_fail))- double_check=true- continue- fi-- # Install requirements inside a virtual environment- if [[ -s "requirements.txt" ]]; then- if [[ ! -f "venv/bin/activate" ]]; then- python3 -m venv venv &>/dev/null- fi- # shellcheck disable=SC1091- source venv/bin/activate- if ! pip3 install --upgrade -r requirements.txt &>/dev/null; then- msg_err "[$repos_step/$total_repo] $repo: pip requirements failed"- failed_repos+=("$repo")- REPOS_FAIL+=("$repo")- ((++repo_fail))- double_check=true- fi- if [ "$repo" = "dorks_hunter" ]; then- source venv/bin/activate- pip install xnldorker &>/dev/null || true- fi- deactivate || true- fi-- # Special handling for certain repositories- case "$repo" in- "massdns")- make &>/dev/null && strip -s bin/massdns && $SUDO cp bin/massdns /usr/local/bin/ &>/dev/null- ;;- "gitleaks")- make build &>/dev/null && $SUDO cp ./gitleaks /usr/local/bin/ &>/dev/null- ;;- "nomore403")- go get &>/dev/null- go build &>/dev/null- chmod +x ./nomore403- ;;- "ffufPostprocessing")- git reset --hard origin/master &>/dev/null- git pull &>/dev/null- go build -o ffufPostprocessing main.go &>/dev/null- chmod +x ./ffufPostprocessing- ;;- "trufflehog")- go install &>/dev/null- ;;- esac-- # Copy gf patterns if applicable- if [[ $repo == "gf" ]]; then- cp -r examples "${HOME}/.gf" &>/dev/null || true- elif [[ $repo == "Gf-Patterns" ]]; then- cp ./*.json "${HOME}/.gf" &>/dev/null || true- elif [[ $repo == "sus_params" ]]; then- for f in ./gf-patterns/*.json; do- base=$(basename "$f")- dest="${HOME}/.gf/$base"- cat "$f" | anew -q "$dest" >/dev/null || true- done- fi-- # Return to the main directory- cd "$dir" || {- msg_err "Failed to navigate back to directory '$dir'"- exit 1- }-- msg_ok "[$repos_step/$total_repo] $repo ready"- done- [[ $COMPACT == "true" && $IS_TTY -eq 1 ]] && printf "\n"-- # Notify and ensure subfinder is installed twice (as per original script)- # Guard with command checks to avoid aborting under set -e- q command -v notify >/dev/null 2>&1 && q notify || true- q command -v subfinder >/dev/null 2>&1 && q subfinder || true- q command -v subfinder >/dev/null 2>&1 && q subfinder || true- mkdir -p ${NUCLEI_TEMPLATES_PATH} &>/dev/null- #cent init -f &>/dev/null- #cent -p ${NUCLEI_TEMPLATES_PATH} &>/dev/null-- # Handle failed installations- if [[ ${#failed_tools[@]} -ne 0 ]]; then- printf "\n%bFailed to install the following Go tools: %s%b\n" "$red" "${failed_tools[*]}" "$reset"- fi-- if [[ ${#failed_pipx_tools[@]} -ne 0 ]]; then- printf "\n%bFailed to install the following pipx tools: %s%b\n" "$red" "${failed_pipx_tools[*]}" "$reset"- fi-- if [[ ${#failed_repos[@]} -ne 0 ]]; then- printf "\n%bFailed to clone or update the following repositories:%b\n%s\n" "$red" "$reset" "${failed_repos[*]}"- fi+ header "Installing Golang tools (${#gotools[@]})"++ local go_step=0+ local failed_tools=()+ local total_go=${#gotools[@]}+ local go_ok=0 go_skip=0 go_fail=0+ for gotool in "${!gotools[@]}"; do+ ((++go_step))+ if [[ $upgrade_tools == "false" ]]; then+ if command -v "$gotool" &>/dev/null; then+ INST_GO_SKIP+=("$gotool")+ ((++go_skip))+ progress_update "Go tools" "$go_step" "$total_go" "$go_ok" "$go_skip" "$go_fail"+ [[ $COMPACT != "true" ]] && msg_warn "[$go_step/$total_go] ${gotool} already installed"+ continue+ fi+ fi++ # Install the Go tool+ if q bash -lc "${gotools[$gotool]}"; then+ INST_GO_OK+=("$gotool")+ ((++go_ok))+ progress_update "Go tools" "$go_step" "$total_go" "$go_ok" "$go_skip" "$go_fail"+ [[ $COMPACT != "true" ]] && msg_ok "[$go_step/$total_go] ${gotool} installed"+ else+ failed_tools+=("$gotool")+ INST_GO_FAIL+=("$gotool")+ ((++go_fail))+ double_check=true+ progress_update "Go tools" "$go_step" "$total_go" "$go_ok" "$go_skip" "$go_fail"+ msg_err "[$go_step/$total_go] ${gotool} failed"+ fi+ done+ [[ $COMPACT == "true" && $IS_TTY -eq 1 ]] && printf "\n"++ header "Installing pipx tools (${#pipxtools[@]})"++ local pipx_step=0+ local failed_pipx_tools=()+ local total_px=${#pipxtools[@]}+ local px_ok=0 px_skip=0 px_fail=0++ for pipxtool in "${!pipxtools[@]}"; do+ ((++pipx_step))+ if [[ $upgrade_tools == "false" ]]; then+ if command -v "$pipxtool" &>/dev/null; then+ INST_PX_SKIP+=("$pipxtool")+ ((++px_skip))+ progress_update "pipx tools" "$pipx_step" "$total_px" "$px_ok" "$px_skip" "$px_fail"+ [[ $COMPACT != "true" ]] && msg_warn "[$pipx_step/$total_px] ${pipxtool} already installed"+ continue+ fi+ fi++ # Install the pipx tool+ q pipx install "git+https://github.com/${pipxtools[$pipxtool]}"+ exit_status=$?+ if [[ $exit_status -ne 0 ]]; then+ failed_pipx_tools+=("$pipxtool")+ INST_PX_FAIL+=("$pipxtool")+ ((++px_fail))+ double_check=true+ progress_update "pipx tools" "$pipx_step" "$total_px" "$px_ok" "$px_skip" "$px_fail"+ msg_err "[$pipx_step/$total_px] ${pipxtool} install failed"+ continue+ fi++ # Upgrade the pipx tool+ q pipx upgrade "${pipxtool}"+ exit_status=$?+ if [[ $exit_status -ne 0 ]]; then+ failed_pipx_tools+=("$pipxtool")+ INST_PX_FAIL+=("$pipxtool")+ ((++px_fail))+ double_check=true+ progress_update "pipx tools" "$pipx_step" "$total_px" "$px_ok" "$px_skip" "$px_fail"+ msg_err "[$pipx_step/$total_px] ${pipxtool} upgrade failed"+ continue+ fi++ INST_PX_OK+=("$pipxtool")+ ((++px_ok))+ progress_update "pipx tools" "$pipx_step" "$total_px" "$px_ok" "$px_skip" "$px_fail"+ [[ $COMPACT != "true" ]] && msg_ok "[$pipx_step/$total_px] ${pipxtool} ready"+ done+ [[ $COMPACT == "true" && $IS_TTY -eq 1 ]] && printf "\n"++ header "Installing repositories (${#repos[@]})"++ local repos_step=0+ local failed_repos=()+ local total_repo=${#repos[@]}+ local repo_ok=0 repo_skip=0 repo_fail=0++ for repo in "${!repos[@]}"; do+ ((++repos_step))+ if [[ $upgrade_tools == "false" ]]; then+ if [[ -d "${dir}/${repo}" ]]; then+ REPOS_SKIPPED+=("$repo")+ ((++repo_skip))+ progress_update "repos" "$repos_step" "$total_repo" "$repo_ok" "$repo_skip" "$repo_fail"+ [[ $COMPACT != "true" ]] && msg_warn "[$repos_step/$total_repo] $repo already present at ${dir}/${repo}"+ continue+ fi+ fi+ # Clone the repository+ if [[ ! -d "${dir}/${repo}" || -z "$(ls -A "${dir}/${repo}")" ]]; then+ msg_run "[$repos_step/${#repos[@]}] $repo (clone)"+ if retry 3 3 q_to 180 git clone --filter="blob:none" "https://github.com/${repos[$repo]}" "${dir}/${repo}"; then+ exit_status=0+ else+ exit_status=$?+ fi+ if [[ $exit_status -ne 0 ]]; then+ msg_err "[$repos_step/$total_repo] $repo clone failed"+ failed_repos+=("$repo")+ REPOS_FAIL+=("$repo")+ ((++repo_fail))+ double_check=true+ continue+ fi+ REPOS_CLONED+=("$repo")+ ((++repo_ok))+ progress_update "repos" "$repos_step" "$total_repo" "$repo_ok" "$repo_skip" "$repo_fail"+ fi++ # Navigate to the repository directory+ cd "${dir}/${repo}" || {+ msg_err "[$repos_step/$total_repo] $repo: cannot enter ${dir}/${repo}"+ failed_repos+=("$repo")+ REPOS_FAIL+=("$repo")+ ((++repo_fail))+ double_check=true+ continue+ }++ # Pull the latest changes+ msg_run "[$repos_step/${#repos[@]}] $repo (pull)"+ if retry 3 3 q_to 60 git pull; then+ exit_status=0+ else+ exit_status=$?+ fi+ if [[ $exit_status -ne 0 ]]; then+ msg_err "[$repos_step/$total_repo] $repo pull failed"+ failed_repos+=("$repo")+ REPOS_FAIL+=("$repo")+ ((++repo_fail))+ double_check=true+ continue+ fi++ # Install requirements inside a virtual environment+ if [[ -s "requirements.txt" ]]; then+ if [[ ! -f "venv/bin/activate" ]]; then+ python3 -m venv venv &>/dev/null+ fi+ # shellcheck disable=SC1091+ source venv/bin/activate+ if ! pip3 install --upgrade -r requirements.txt &>/dev/null; then+ msg_err "[$repos_step/$total_repo] $repo: pip requirements failed"+ failed_repos+=("$repo")+ REPOS_FAIL+=("$repo")+ ((++repo_fail))+ double_check=true+ fi+ if [ "$repo" = "dorks_hunter" ]; then+ source venv/bin/activate+ pip install xnldorker &>/dev/null || true+ fi+ deactivate || true+ fi++ # Special handling for certain repositories+ case "$repo" in+ "massdns")+ make &>/dev/null && strip -s bin/massdns && $SUDO cp bin/massdns /usr/local/bin/ &>/dev/null+ ;;+ "gitleaks")+ make build &>/dev/null && $SUDO cp ./gitleaks /usr/local/bin/ &>/dev/null+ ;;+ "nomore403")+ go get &>/dev/null+ go build &>/dev/null+ chmod +x ./nomore403+ ;;+ "ffufPostprocessing")+ git reset --hard origin/master &>/dev/null+ git pull &>/dev/null+ go build -o ffufPostprocessing main.go &>/dev/null+ chmod +x ./ffufPostprocessing+ ;;+ "trufflehog")+ go install &>/dev/null+ ;;+ esac++ # Copy gf patterns if applicable+ if [[ $repo == "gf" ]]; then+ cp -r examples "${HOME}/.gf" &>/dev/null || true+ elif [[ $repo == "Gf-Patterns" ]]; then+ cp ./*.json "${HOME}/.gf" &>/dev/null || true+ elif [[ $repo == "sus_params" ]]; then+ for f in ./gf-patterns/*.json; do+ base=$(basename "$f")+ dest="${HOME}/.gf/$base"+ cat "$f" | anew -q "$dest" >/dev/null || true+ done+ fi++ # Return to the main directory+ cd "$dir" || {+ msg_err "Failed to navigate back to directory '$dir'"+ exit 1+ }++ msg_ok "[$repos_step/$total_repo] $repo ready"+ done+ [[ $COMPACT == "true" && $IS_TTY -eq 1 ]] && printf "\n"++ # Notify and ensure subfinder is installed twice (as per original script)+ # Guard with command checks to avoid aborting under set -e+ q command -v notify >/dev/null 2>&1 && q notify || true+ q command -v subfinder >/dev/null 2>&1 && q subfinder || true+ q command -v subfinder >/dev/null 2>&1 && q subfinder || true+ mkdir -p ${NUCLEI_TEMPLATES_PATH} &>/dev/null+ #cent init -f &>/dev/null+ #cent -p ${NUCLEI_TEMPLATES_PATH} &>/dev/null++ # Handle failed installations+ if [[ ${#failed_tools[@]} -ne 0 ]]; then+ printf "\n%bFailed to install the following Go tools: %s%b\n" "$red" "${failed_tools[*]}" "$reset"+ fi++ if [[ ${#failed_pipx_tools[@]} -ne 0 ]]; then+ printf "\n%bFailed to install the following pipx tools: %s%b\n" "$red" "${failed_pipx_tools[*]}" "$reset"+ fi++ if [[ ${#failed_repos[@]} -ne 0 ]]; then+ printf "\n%bFailed to clone or update the following repositories:%b\n%s\n" "$red" "$reset" "${failed_repos[*]}"+ fi}# Function to reset git proxy settingsfunction reset_git_proxies() {- git config --global --unset http.proxy || true- git config --global --unset https.proxy || true+ git config --global --unset http.proxy || true+ git config --global --unset https.proxy || true}# Function to check for updatesfunction check_updates() {- printf "%bRunning: Looking for new reconFTW version%b\n" "$bblue" "$reset"-- if { [[ -n $TIMEOUT_CMD ]] && $TIMEOUT_CMD 10 git fetch; } || git fetch; then- BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "HEAD")- HEADHASH=$(git rev-parse HEAD 2>/dev/null || true)- # Skip auto-update if no upstream (detached HEAD or no tracking branch)- if ! git rev-parse --abbrev-ref --symbolic-full-name @{u} >/dev/null 2>&1; then- printf "%bNo upstream configured (detached HEAD). Skipping auto-update.%b\n" "$yellow" "$reset"- return 0- fi- UPSTREAMHASH=$(git rev-parse "@{u}")-- if [[ $HEADHASH != "$UPSTREAMHASH" ]]; then- local cfg_backup="" cfg_backup_ts=""- if git status --porcelain | grep -q .; then- if [[ $FORCE_UPDATE == "true" ]]; then- printf "%bLocal changes detected; forcing update.%b\n" "$yellow" "$reset"- else- printf "%bLocal changes detected. Skipping auto-update. Re-run with --force-update to override.%b\n" "$yellow" "$reset"- return 0- fi- fi- printf "%bA new version is available. Updating...%b\n" "$yellow" "$reset"- if git status --porcelain | grep -q 'reconftw.cfg$'; then- cfg_backup_ts=$(date +%Y%m%d_%H%M%S)- cfg_backup="reconftw.cfg.bak.${cfg_backup_ts}"- cp reconftw.cfg "$cfg_backup"- printf "%breconftw.cfg has been backed up to %s%b\n" "$yellow" "$cfg_backup" "$reset"- fi- git reset --hard &>/dev/null- run_to 60 git pull &>/dev/null- printf "%bUpdated! Running the new installer version...%b\n" "$bgreen" "$reset"-- # Show config diff against new default- if [[ -n $cfg_backup && -f reconftw.cfg ]]; then- mkdir -p .tmp- cfg_diff_file=".tmp/reconftw_cfg_diff_${cfg_backup_ts}.patch"- if diff -u "$cfg_backup" reconftw.cfg >"$cfg_diff_file"; then- printf "%bConfig unchanged between versions (diff: %s).%b\n" "$yellow" "$cfg_diff_file" "$reset"- else- printf "%bConfig differences saved to %s (old -> new).%b\n" "$yellow" "$cfg_diff_file" "$reset"- fi- fi- else- printf "%breconFTW is already up to date!%b\n" "$bgreen" "$reset"- # If config is locally modified, still provide a diff against current default- if ! git diff --quiet -- reconftw.cfg; then- local cfg_diff_ts cfg_diff_file- cfg_diff_ts=$(date +%Y%m%d_%H%M%S)- mkdir -p .tmp- cfg_diff_file=".tmp/reconftw_cfg_diff_${cfg_diff_ts}.patch"- if git diff HEAD --unified -- reconftw.cfg >"$cfg_diff_file"; then- printf "%bLocal reconftw.cfg differs from default; diff saved to %s.%b\n" "$yellow" "$cfg_diff_file" "$reset"- fi- fi- fi- else- printf "\n%b[!] Unable to check for updates.%b\n" "$bred" "$reset"- fi+ printf "%bRunning: Looking for new reconFTW version%b\n" "$bblue" "$reset"++ if { [[ -n $TIMEOUT_CMD ]] && $TIMEOUT_CMD 10 git fetch; } || git fetch; then+ BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "HEAD")+ HEADHASH=$(git rev-parse HEAD 2>/dev/null || true)+ # Skip auto-update if no upstream (detached HEAD or no tracking branch)+ if ! git rev-parse --abbrev-ref --symbolic-full-name @{u} >/dev/null 2>&1; then+ printf "%bNo upstream configured (detached HEAD). Skipping auto-update.%b\n" "$yellow" "$reset"+ return 0+ fi+ UPSTREAMHASH=$(git rev-parse "@{u}")++ if [[ $HEADHASH != "$UPSTREAMHASH" ]]; then+ local cfg_backup="" cfg_backup_ts=""+ if git status --porcelain | grep -q .; then+ if [[ $FORCE_UPDATE == "true" ]]; then+ printf "%bLocal changes detected; forcing update.%b\n" "$yellow" "$reset"+ else+ printf "%bLocal changes detected. Skipping auto-update. Re-run with --force-update to override.%b\n" "$yellow" "$reset"+ return 0+ fi+ fi+ printf "%bA new version is available. Updating...%b\n" "$yellow" "$reset"+ if git status --porcelain | grep -q 'reconftw.cfg$'; then+ cfg_backup_ts=$(date +%Y%m%d_%H%M%S)+ cfg_backup="reconftw.cfg.bak.${cfg_backup_ts}"+ cp reconftw.cfg "$cfg_backup"+ printf "%breconftw.cfg has been backed up to %s%b\n" "$yellow" "$cfg_backup" "$reset"+ fi+ git reset --hard &>/dev/null+ run_to 60 git pull &>/dev/null+ printf "%bUpdated! Running the new installer version...%b\n" "$bgreen" "$reset"++ # Show config diff against new default+ if [[ -n $cfg_backup && -f reconftw.cfg ]]; then+ mkdir -p .tmp+ cfg_diff_file=".tmp/reconftw_cfg_diff_${cfg_backup_ts}.patch"+ if diff -u "$cfg_backup" reconftw.cfg >"$cfg_diff_file"; then+ printf "%bConfig unchanged between versions (diff: %s).%b\n" "$yellow" "$cfg_diff_file" "$reset"+ else+ printf "%bConfig differences saved to %s (old -> new).%b\n" "$yellow" "$cfg_diff_file" "$reset"+ fi+ fi+ else+ printf "%breconFTW is already up to date!%b\n" "$bgreen" "$reset"+ # If config is locally modified, still provide a diff against current default+ if ! git diff --quiet -- reconftw.cfg; then+ local cfg_diff_ts cfg_diff_file+ cfg_diff_ts=$(date +%Y%m%d_%H%M%S)+ mkdir -p .tmp+ cfg_diff_file=".tmp/reconftw_cfg_diff_${cfg_diff_ts}.patch"+ if git diff HEAD --unified -- reconftw.cfg >"$cfg_diff_file"; then+ printf "%bLocal reconftw.cfg differs from default; diff saved to %s.%b\n" "$yellow" "$cfg_diff_file" "$reset"+ fi+ fi+ fi+ else+ printf "\n%b[!] Unable to check for updates.%b\n" "$bred" "$reset"+ fi}# Function to install Golang@@ -651,27 +651,27 @@ function install_golang_version() {local archive_suffix=""case "$ARCH" in- arm64 | aarch64)- if [[ $IS_MAC == "True" ]]; then- archive_suffix="darwin-arm64"- else- archive_suffix="linux-arm64"- fi- ;;- armv6l | armv7l)- archive_suffix="linux-armv6l"- ;;- amd64 | x86_64)- if [[ $IS_MAC == "True" ]]; then- archive_suffix="darwin-amd64"- else- archive_suffix="linux-amd64"- fi- ;;- *)- msg_err "[!] Unsupported architecture. Please install go manually."- return 1- ;;+ arm64 | aarch64)+ if [[ $IS_MAC == "True" ]]; then+ archive_suffix="darwin-arm64"+ else+ archive_suffix="linux-arm64"+ fi+ ;;+ armv6l | armv7l)+ archive_suffix="linux-armv6l"+ ;;+ amd64 | x86_64)+ if [[ $IS_MAC == "True" ]]; then+ archive_suffix="darwin-amd64"+ else+ archive_suffix="linux-amd64"+ fi+ ;;+ *)+ msg_err "[!] Unsupported architecture. Please install go manually."+ return 1+ ;;esaclocal archive_url="https://dl.google.com/go/${version}.${archive_suffix}.tar.gz"@@ -762,314 +762,315 @@ function install_golang_version() {# Function to install system packages based on OSfunction install_system_packages() {- if [[ -f /etc/debian_version ]]; then- install_apt- elif [[ -f /etc/redhat-release ]]; then- install_yum- elif [[ -f /etc/arch-release ]]; then- install_pacman- elif [[ $IS_MAC == "True" ]]; then- install_brew- elif [[ -f /etc/os-release ]]; then- install_yum # Assuming RedHat-based- else- printf "%b[!] Unsupported OS. Please install dependencies manually.%b\n" "$bred" "$reset"- exit 1- fi+ if [[ -f /etc/debian_version ]]; then+ install_apt+ elif [[ -f /etc/redhat-release ]]; then+ install_yum+ elif [[ -f /etc/arch-release ]]; then+ install_pacman+ elif [[ $IS_MAC == "True" ]]; then+ install_brew+ elif [[ -f /etc/os-release ]]; then+ install_yum # Assuming RedHat-based+ else+ printf "%b[!] Unsupported OS. Please install dependencies manually.%b\n" "$bred" "$reset"+ exit 1+ fi}# Function to install required packages for Debian-based systemsfunction install_apt() {- $SUDO apt-get update -y &>/dev/null- $SUDO apt-get install -y python3 python3-pip python3-venv pipx python3-virtualenv build-essential gcc cmake ruby whois git curl libpcap-dev wget zip python3-dev pv dnsutils libssl-dev libffi-dev libxml2-dev libxslt1-dev zlib1g-dev nmap jq apt-transport-https lynx medusa xvfb libxml2-utils procps bsdmainutils libdata-hexdump-perl &>/dev/null- # Move chromium browser dependencies (required by `nuclei -headless -id screenshot`) into a separate apt install command, and add a fallback for Ubuntu 24.04 (where `libasound2` is renamed to `libasound2t64`)- $SUDO apt-get install -y libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libxkbcommon-x11-0 libxcomposite-dev libxdamage1 libxrandr2 libgbm-dev libpangocairo-1.0-0 libasound2 &>/dev/null ||- $SUDO apt-get install -y libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libxkbcommon-x11-0 libxcomposite-dev libxdamage1 libxrandr2 libgbm-dev libpangocairo-1.0-0 libasound2t64 &>/dev/null- curl https://sh.rustup.rs -sSf | sh -s -- -y >/dev/null 2>&1- source "${HOME}/.cargo/env"- cargo install ripgen &>/dev/null- cargo install smugglex &>/dev/null- pipx ensurepath -f &>/dev/null- # Install jsbeautifier and shodan CLI in isolated environments to avoid PEP 668 conflicts- pipx install jsbeautifier &>/dev/null || true- pipx install shodan &>/dev/null || pipx upgrade shodan &>/dev/null || true+ $SUDO apt-get update -y &>/dev/null+ $SUDO apt-get install -y python3 python3-pip python3-venv pipx python3-virtualenv build-essential gcc cmake ruby whois git curl libpcap-dev wget zip python3-dev pv dnsutils libssl-dev libffi-dev libxml2-dev libxslt1-dev zlib1g-dev nmap jq apt-transport-https lynx medusa xvfb libxml2-utils procps bsdmainutils libdata-hexdump-perl &>/dev/null+ # Move chromium browser dependencies (required by `nuclei -headless -id screenshot`) into a separate apt install command, and add a fallback for Ubuntu 24.04 (where `libasound2` is renamed to `libasound2t64`)+ $SUDO apt-get install -y libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libxkbcommon-x11-0 libxcomposite-dev libxdamage1 libxrandr2 libgbm-dev libpangocairo-1.0-0 libasound2 &>/dev/null \+ || $SUDO apt-get install -y libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libxkbcommon-x11-0 libxcomposite-dev libxdamage1 libxrandr2 libgbm-dev libpangocairo-1.0-0 libasound2t64 &>/dev/null+ curl https://sh.rustup.rs -sSf | sh -s -- -y >/dev/null 2>&1+ source "${HOME}/.cargo/env"+ cargo install ripgen &>/dev/null+ cargo install smugglex &>/dev/null+ pipx ensurepath -f &>/dev/null+ # Install jsbeautifier and shodan CLI in isolated environments to avoid PEP 668 conflicts+ pipx install jsbeautifier &>/dev/null || true+ pipx install shodan &>/dev/null || pipx upgrade shodan &>/dev/null || true}# Function to install required packages for macOSfunction install_brew() {- if command -v brew &>/dev/null; then- printf "%bbrew is already installed.%b\n" "$bgreen" "$reset"- else- /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"- fi- brew update &>/dev/null- brew install --formula bash coreutils gnu-getopt gnu-sed python pipx massdns jq gcc cmake ruby git curl wget zip pv bind whois nmap lynx medusa shodan &>/dev/null- brew install rustup &>/dev/null- rustup-init -y &>/dev/null- cargo install ripgen &>/dev/null- cargo install smugglex &>/dev/null+ if command -v brew &>/dev/null; then+ printf "%bbrew is already installed.%b\n" "$bgreen" "$reset"+ else+ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"+ fi+ brew update &>/dev/null+ brew install --formula bash coreutils gnu-getopt gnu-sed python pipx massdns jq gcc cmake ruby git curl wget zip pv bind whois nmap lynx medusa shodan &>/dev/null+ brew install rustup &>/dev/null+ rustup-init -y &>/dev/null+ cargo install ripgen &>/dev/null+ cargo install smugglex &>/dev/null}# Function to install required packages for RedHat-based systemsfunction install_yum() {- $SUDO yum groupinstall "Development Tools" -y &>/dev/null- # Base install first (python3 may be 3.6 on older EL)- $SUDO yum install -y epel-release &>/dev/null || true- $SUDO yum install -y python3 python3-pip gcc cmake ruby git curl libpcap whois wget pipx zip pv bind-utils openssl-devel libffi-devel libxml2-devel libxslt-devel zlib-devel nmap jq lynx medusa xorg-x11-server-xvfb &>/dev/null+ $SUDO yum groupinstall "Development Tools" -y &>/dev/null+ # Base install first (python3 may be 3.6 on older EL)+ $SUDO yum install -y epel-release &>/dev/null || true+ $SUDO yum install -y python3 python3-pip gcc cmake ruby git curl libpcap whois wget pipx zip pv bind-utils openssl-devel libffi-devel libxml2-devel libxslt-devel zlib-devel nmap jq lynx medusa xorg-x11-server-xvfb &>/dev/null- # Ensure Python >= 3.7 on yum-based systems- if ! python3 - <<-'PYCHK' &>/dev/null; then+ # Ensure Python >= 3.7 on yum-based systems+ if ! python3 - <<-'PYCHK' &>/dev/null; thenimport sys; raise SystemExit(0 if sys.version_info >= (3,7) else 1)PYCHK- # Try DNF/YUM module streams (EL8+/EL9+) for newer Python- if command -v dnf &>/dev/null || $SUDO yum -y module list python38 &>/dev/null; then- # Prefer 3.9, then 3.8- if command -v dnf &>/dev/null; then- $SUDO dnf -y module install python39 &>/dev/null || $SUDO dnf -y module install python38 &>/dev/null || true- else- $SUDO yum -y module install python39 &>/dev/null || $SUDO yum -y module install python38 &>/dev/null || true- fi- fi-- # Amazon Linux 2 path- if command -v amazon-linux-extras &>/dev/null; then- $SUDO amazon-linux-extras install -y python3.8 &>/dev/null || true- fi-- # EL7 fallback via IUS (best-effort)- REL_VER=$( (cat /etc/redhat-release 2>/dev/null || cat /etc/centos-release 2>/dev/null) || true)- if [[ $REL_VER == *" 7."* ]]; then- $SUDO yum install -y https://repo.ius.io/ius-release-el7.rpm &>/dev/null || true- $SUDO yum install -y python37u python37u-pip python37u-devel &>/dev/null || true- fi-- # If python3.9/3.8/3.7 binaries exist, prefer the newest by creating a higher-priority symlink- if ! python3 - <<-'PYCHK' &>/dev/null; then+ # Try DNF/YUM module streams (EL8+/EL9+) for newer Python+ if command -v dnf &>/dev/null || $SUDO yum -y module list python38 &>/dev/null; then+ # Prefer 3.9, then 3.8+ if command -v dnf &>/dev/null; then+ $SUDO dnf -y module install python39 &>/dev/null || $SUDO dnf -y module install python38 &>/dev/null || true+ else+ $SUDO yum -y module install python39 &>/dev/null || $SUDO yum -y module install python38 &>/dev/null || true+ fi+ fi++ # Amazon Linux 2 path+ if command -v amazon-linux-extras &>/dev/null; then+ $SUDO amazon-linux-extras install -y python3.8 &>/dev/null || true+ fi++ # EL7 fallback via IUS (best-effort)+ REL_VER=$( (cat /etc/redhat-release 2>/dev/null || cat /etc/centos-release 2>/dev/null) || true)+ if [[ $REL_VER == *" 7."* ]]; then+ $SUDO yum install -y https://repo.ius.io/ius-release-el7.rpm &>/dev/null || true+ $SUDO yum install -y python37u python37u-pip python37u-devel &>/dev/null || true+ fi++ # If python3.9/3.8/3.7 binaries exist, prefer the newest by creating a higher-priority symlink+ if ! python3 - <<-'PYCHK' &>/dev/null; thenimport sys; raise SystemExit(0 if sys.version_info >= (3,7) else 1)PYCHK- NEW_PY=""- for cand in /usr/bin/python3.11 /usr/bin/python3.10 /usr/bin/python3.9 /usr/bin/python3.8 /usr/bin/python3.7; do- [[ -x $cand ]] && NEW_PY="$cand" && break- done- if [[ -n $NEW_PY ]]; then- $SUDO ln -sf "$NEW_PY" /usr/local/bin/python3 2>/dev/null || true- export PATH="/usr/local/bin:$PATH"- fi- fi- fi-- # Ensure pipx uses the selected python3- export PIPX_DEFAULT_PYTHON="$(command -v python3 || echo python3)"-- # Ensure pipx is present even on older EL (install via pip if the rpm doesn't exist)- if ! command -v pipx &>/dev/null; then- python3 -m pip install --user -U pip pipx &>/dev/null || true- export PATH="$HOME/.local/bin:$PATH"- fi- curl https://sh.rustup.rs -sSf | sh -s -- -y >/dev/null 2>&1- source "${HOME}/.cargo/env"- cargo install ripgen &>/dev/null- cargo install smugglex &>/dev/null- # Ensure pipx path and install shodan CLI- pipx ensurepath -f &>/dev/null || true- pipx install shodan &>/dev/null || pipx upgrade shodan &>/dev/null || true+ NEW_PY=""+ for cand in /usr/bin/python3.11 /usr/bin/python3.10 /usr/bin/python3.9 /usr/bin/python3.8 /usr/bin/python3.7; do+ [[ -x $cand ]] && NEW_PY="$cand" && break+ done+ if [[ -n $NEW_PY ]]; then+ $SUDO ln -sf "$NEW_PY" /usr/local/bin/python3 2>/dev/null || true+ export PATH="/usr/local/bin:$PATH"+ fi+ fi+ fi++ # Ensure pipx uses the selected python3+ export PIPX_DEFAULT_PYTHON="$(command -v python3 || echo python3)"++ # Ensure pipx is present even on older EL (install via pip if the rpm doesn't exist)+ if ! command -v pipx &>/dev/null; then+ python3 -m pip install --user -U pip pipx &>/dev/null || true+ export PATH="$HOME/.local/bin:$PATH"+ fi+ curl https://sh.rustup.rs -sSf | sh -s -- -y >/dev/null 2>&1+ source "${HOME}/.cargo/env"+ cargo install ripgen &>/dev/null+ cargo install smugglex &>/dev/null+ # Ensure pipx path and install shodan CLI+ pipx ensurepath -f &>/dev/null || true+ pipx install shodan &>/dev/null || pipx upgrade shodan &>/dev/null || true}# Function to install required packages for Arch-based systemsfunction install_pacman() {- $SUDO pacman -Sy --noconfirm python python-pip base-devel gcc cmake ruby git curl libpcap python-pipx whois wget zip pv bind openssl libffi libxml2 libxslt zlib nmap jq lynx medusa xorg-server-xvfb &>/dev/null- curl https://sh.rustup.rs -sSf | sh -s -- -y >/dev/null 2>&1- source "${HOME}/.cargo/env"- cargo install ripgen &>/dev/null- cargo install smugglex &>/dev/null- # Ensure pipx path and install shodan CLI- pipx ensurepath -f &>/dev/null || true- pipx install shodan &>/dev/null || pipx upgrade shodan &>/dev/null || true+ $SUDO pacman -Sy --noconfirm python python-pip base-devel gcc cmake ruby git curl libpcap python-pipx whois wget zip pv bind openssl libffi libxml2 libxslt zlib nmap jq lynx medusa xorg-server-xvfb &>/dev/null+ curl https://sh.rustup.rs -sSf | sh -s -- -y >/dev/null 2>&1+ source "${HOME}/.cargo/env"+ cargo install ripgen &>/dev/null+ cargo install smugglex &>/dev/null+ # Ensure pipx path and install shodan CLI+ pipx ensurepath -f &>/dev/null || true+ pipx install shodan &>/dev/null || pipx upgrade shodan &>/dev/null || true}# Function to perform initial setupfunction initial_setup() {- banner- reset_git_proxies-- if [[ $TOOLS_ONLY == "true" ]]; then- header "Tools-only mode"- with_spinner "Installing/validating Golang" install_golang_version- mkdir -p ${HOME}/.gf- mkdir -p "$tools"- mkdir -p ${HOME}/.config/notify/- mkdir -p ${HOME}/.config/nuclei/- touch "${dir}/.github_tokens"- touch "${dir}/.gitlab_tokens"-- q pipx ensurepath- export PATH="${HOME}/.local/bin:${PATH}"-- install_tools- return- fi-- header "Install/Update"- with_spinner "Checking for updates" check_updates- with_spinner "Installing system packages" install_system_packages- check_network- with_spinner "Installing/validating Golang" install_golang_version- mkdir -p ${HOME}/.gf- mkdir -p "$tools"- mkdir -p ${HOME}/.config/notify/- mkdir -p ${HOME}/.config/nuclei/- touch "${dir}/.github_tokens"- touch "${dir}/.gitlab_tokens"-- q pipx ensurepath- # Ensure $HOME/.local/bin is available now even if profile isn't sourced- export PATH="${HOME}/.local/bin:${PATH}"- # Do not source user shell profiles here to avoid errors like 'PS1: unbound variable'- # in non-interactive shells with 'set -u'. PATH for this process is already updated.-- install_tools-- # Repositories with special configurations- header "Configuring special repositories"-- # Nuclei Templates (opt-out with MANAGE_NUCLEI_TEMPLATES=false)- MANAGE_NUCLEI_TEMPLATES=${MANAGE_NUCLEI_TEMPLATES:-true}- if [[ $MANAGE_NUCLEI_TEMPLATES == "true" ]]; then- ensure_git_dir "${NUCLEI_TEMPLATES_PATH}"- if [[ ! -d ${NUCLEI_TEMPLATES_PATH} ]]; then- q mkdir -p "${NUCLEI_TEMPLATES_PATH}"- with_spinner "Cloning nuclei-templates" retry 3 3 q_to 300 git clone https://github.com/projectdiscovery/nuclei-templates "${NUCLEI_TEMPLATES_PATH}" || true- else- with_spinner "Updating nuclei-templates" retry 3 3 q_to 120 git -C "${NUCLEI_TEMPLATES_PATH}" pull || true- fi- ensure_git_dir "${NUCLEI_TEMPLATES_PATH}/extra_templates"- fi- with_spinner "Nuclei template update" nuclei -update-templates -update-template-dir "${NUCLEI_TEMPLATES_PATH}" >/dev/null 2>&1 || true-- # sqlmap- ensure_git_dir "${dir}/sqlmap"- if [[ ! -d "${dir}/sqlmap" ]]; then- #printf "${yellow}Cloning sqlmap...\n"- if ! retry 3 3 q_to 120 git clone --depth 1 https://github.com/sqlmapproject/sqlmap.git "${dir}/sqlmap"; then true; fi- else- #printf "${yellow}Updating sqlmap...\n"- if ! retry 3 3 q_to 60 git -C "${dir}/sqlmap" pull; then true; fi- fi-- # massdns- ensure_git_dir "${dir}/massdns"- if [[ ! -d "${dir}/massdns" ]]; then- #printf "${yellow}Cloning and compiling massdns...\n"- if ! retry 3 3 q_to 120 git clone https://github.com/blechschmidt/massdns.git "${dir}/massdns"; then true; fi- q make -C "${dir}/massdns"- strip -s "${dir}/massdns/bin/massdns" 2>/dev/null- $SUDO cp "${dir}/massdns/bin/massdns" /usr/local/bin/ 2>/dev/null- else- #printf "${yellow}Updating massdns...\n"- if ! retry 3 3 q_to 60 git -C "${dir}/massdns" pull; then true; fi- fi-- # gf patterns- if [[ ! -d "$HOME/.gf" ]]; then- #printf "${yellow}Installing gf patterns...\n"- ensure_git_dir "${dir}/gf"- if ! retry 3 3 q_to 120 git clone https://github.com/tomnomnom/gf.git "${dir}/gf"; then true; fi- cp -r "${dir}/gf/examples" ~/.gf 2>/dev/null || true- ensure_git_dir "${dir}/Gf-Patterns"- if ! retry 3 3 q_to 120 git clone https://github.com/1ndianl33t/Gf-Patterns "${dir}/Gf-Patterns"; then true; fi- cp "${dir}/Gf-Patterns"/*.json ~/.gf/ 2>/dev/null || true- else- #printf "${yellow}Updating gf patterns...\n"- ensure_git_dir "${dir}/Gf-Patterns"- if ! retry 3 3 q_to 60 git -C "${dir}/Gf-Patterns" pull; then true; fi- fi-- header "Downloading required files"-- mkdir -p ${HOME}/.config/notify- # Download required files with error handling- declare -A downloads=(- ["notify_provider_config"]="https://gist.githubusercontent.com/six2dez/23a996bca189a11e88251367e6583053/raw ${HOME}/.config/notify/provider-config.yaml"- ["getjswords"]="https://raw.githubusercontent.com/m4ll0k/Bug-Bounty-Toolz/master/getjswords.py ${tools}/getjswords.py"- ["subdomains_huge"]="https://raw.githubusercontent.com/n0kovo/n0kovo_subdomains/main/n0kovo_subdomains_huge.txt ${subs_wordlist_big}"- ["trusted_resolvers"]="https://gist.githubusercontent.com/six2dez/ae9ed7e5c786461868abd3f2344401b6/raw ${resolvers_trusted}"- ["resolvers"]="https://raw.githubusercontent.com/trickest/resolvers/main/resolvers.txt ${resolvers}"- ["subs_wordlist"]="https://gist.github.com/six2dez/a307a04a222fab5a57466c51e1569acf/raw ${subs_wordlist}"- ["permutations_list"]="https://gist.github.com/six2dez/ffc2b14d283e8f8eff6ac83e20a3c4b4/raw ${tools}/permutations_list.txt"- ["fuzz_wordlist"]="https://raw.githubusercontent.com/six2dez/OneListForAll/main/onelistforallmicro.txt ${fuzz_wordlist}"- ["lfi_wordlist"]="https://gist.githubusercontent.com/six2dez/a89a0c7861d49bb61a09822d272d5395/raw ${lfi_wordlist}"- ["ssti_wordlist"]="https://gist.githubusercontent.com/six2dez/ab5277b11da7369bf4e9db72b49ad3c1/raw ${ssti_wordlist}"- ["headers_inject"]="https://gist.github.com/six2dez/d62ab8f8ffd28e1c206d401081d977ae/raw ${tools}/headers_inject.txt"- ["axiom_config"]="https://gist.githubusercontent.com/six2dez/6e2d9f4932fd38d84610eb851014b26e/raw ${tools}/axiom_config.sh"- ["jsluice_patterns"]="https://gist.githubusercontent.com/six2dez/2aafa8dc2b682bb0081684e71900e747/raw ${tools}/jsluice_patterns.json"- )-- for key in "${!downloads[@]}"; do- url="${downloads[$key]% *}"- destination="${downloads[$key]#* }"-- # Skip download if provider-config.yaml already exists- if [[ $key == "notify_provider_config" && -f $destination ]]; then- printf "[%bSKIPPING%b] %s as it already exists at %s.\n" "$yellow" "$reset" "$key" "$destination"- continue- fi-- # Ensure destination directory exists- mkdir -p "$(dirname "$destination")" 2>/dev/null || true-- if with_spinner "Fetching $key" retry 3 3 q_to 120 wget -q -O "$destination" "$url"; then- :- else- msg_err "Failed to download $key from $url"- continue- fi- done-- # (removed) kiterunner routes tarball handling-- # Make axiom_config.sh executable- chmod +x "${tools}/axiom_config.sh" || {- printf "%b[!] Failed to make axiom_config.sh executable.%b\n" "$red" "$reset"- }-- header "Final configuration"-- # Update resolvers if generate_resolvers is true- if [[ $generate_resolvers == true ]]; then- if [[ ! -s $resolvers || $(find "$resolvers" -mtime +1 -print) ]]; then- printf "%bChecking resolvers lists...\nAccurate resolvers are the key to great results.\nThis may take around 10 minutes if it's not updated.%b\n" "$yellow" "$reset"- rm -f "$resolvers" &>/dev/null- dnsvalidator -tL https://public-dns.info/nameservers.txt -threads "$DNSVALIDATOR_THREADS" -o "$resolvers" &>/dev/null- dnsvalidator -tL https://raw.githubusercontent.com/blechschmidt/massdns/master/lists/resolvers.txt -threads "$DNSVALIDATOR_THREADS" -o tmp_resolvers &>/dev/null-- if [[ -s "tmp_resolvers" ]]; then- cat tmp_resolvers | anew -q "$resolvers"- rm -f tmp_resolvers &>/dev/null- fi-- [[ ! -s $resolvers ]] && wget -q -O "$resolvers" https://raw.githubusercontent.com/trickest/resolvers/main/resolvers.txt- [[ ! -s $resolvers_trusted ]] && wget -q -O "$resolvers_trusted" https://gist.githubusercontent.com/six2dez/ae9ed7e5c786461868abd3f2344401b6/raw/trusted_resolvers.txt- printf "%bResolvers updated.%b\n" "$yellow" "$reset"- fi- generate_resolvers=false- else- if [[ -s $resolvers && $(find "$resolvers" -mtime +1 -print) ]]; then- printf "%bChecking resolvers lists...\nAccurate resolvers are the key to great results.\nDownloading new resolvers.%b\n" "$yellow" "$reset"- wget -q -O "$resolvers" https://raw.githubusercontent.com/trickest/resolvers/main/resolvers.txt- wget -q -O "$resolvers_trusted" https://gist.githubusercontent.com/six2dez/ae9ed7e5c786461868abd3f2344401b6/raw/trusted_resolvers.txt- printf "%bResolvers updated.%b\n" "$yellow" "$reset"- fi- fi-- # Strip all Go binaries and copy to /usr/local/bin (files only)- find "${GOPATH}/bin" -type f -perm -u+x -exec strip -s {} \; 2>/dev/null || true- find "${GOPATH}/bin" -type f -perm -u+x -exec $SUDO cp {} /usr/local/bin/ \; 2>/dev/null || true-- # Final reminders (classic output)- local final_reminder- final_reminder="$(cat <<EOF+ banner+ reset_git_proxies++ if [[ $TOOLS_ONLY == "true" ]]; then+ header "Tools-only mode"+ with_spinner "Installing/validating Golang" install_golang_version+ mkdir -p ${HOME}/.gf+ mkdir -p "$tools"+ mkdir -p ${HOME}/.config/notify/+ mkdir -p ${HOME}/.config/nuclei/+ touch "${dir}/.github_tokens"+ touch "${dir}/.gitlab_tokens"++ q pipx ensurepath+ export PATH="${HOME}/.local/bin:${PATH}"++ install_tools+ return+ fi++ header "Install/Update"+ with_spinner "Checking for updates" check_updates+ with_spinner "Installing system packages" install_system_packages+ check_network+ with_spinner "Installing/validating Golang" install_golang_version+ mkdir -p ${HOME}/.gf+ mkdir -p "$tools"+ mkdir -p ${HOME}/.config/notify/+ mkdir -p ${HOME}/.config/nuclei/+ touch "${dir}/.github_tokens"+ touch "${dir}/.gitlab_tokens"++ q pipx ensurepath+ # Ensure $HOME/.local/bin is available now even if profile isn't sourced+ export PATH="${HOME}/.local/bin:${PATH}"+ # Do not source user shell profiles here to avoid errors like 'PS1: unbound variable'+ # in non-interactive shells with 'set -u'. PATH for this process is already updated.++ install_tools++ # Repositories with special configurations+ header "Configuring special repositories"++ # Nuclei Templates (opt-out with MANAGE_NUCLEI_TEMPLATES=false)+ MANAGE_NUCLEI_TEMPLATES=${MANAGE_NUCLEI_TEMPLATES:-true}+ if [[ $MANAGE_NUCLEI_TEMPLATES == "true" ]]; then+ ensure_git_dir "${NUCLEI_TEMPLATES_PATH}"+ if [[ ! -d ${NUCLEI_TEMPLATES_PATH} ]]; then+ q mkdir -p "${NUCLEI_TEMPLATES_PATH}"+ with_spinner "Cloning nuclei-templates" retry 3 3 q_to 300 git clone https://github.com/projectdiscovery/nuclei-templates "${NUCLEI_TEMPLATES_PATH}" || true+ else+ with_spinner "Updating nuclei-templates" retry 3 3 q_to 120 git -C "${NUCLEI_TEMPLATES_PATH}" pull || true+ fi+ ensure_git_dir "${NUCLEI_TEMPLATES_PATH}/extra_templates"+ fi+ with_spinner "Nuclei template update" nuclei -update-templates -update-template-dir "${NUCLEI_TEMPLATES_PATH}" >/dev/null 2>&1 || true++ # sqlmap+ ensure_git_dir "${dir}/sqlmap"+ if [[ ! -d "${dir}/sqlmap" ]]; then+ #printf "${yellow}Cloning sqlmap...\n"+ if ! retry 3 3 q_to 120 git clone --depth 1 https://github.com/sqlmapproject/sqlmap.git "${dir}/sqlmap"; then true; fi+ else+ #printf "${yellow}Updating sqlmap...\n"+ if ! retry 3 3 q_to 60 git -C "${dir}/sqlmap" pull; then true; fi+ fi++ # massdns+ ensure_git_dir "${dir}/massdns"+ if [[ ! -d "${dir}/massdns" ]]; then+ #printf "${yellow}Cloning and compiling massdns...\n"+ if ! retry 3 3 q_to 120 git clone https://github.com/blechschmidt/massdns.git "${dir}/massdns"; then true; fi+ q make -C "${dir}/massdns"+ strip -s "${dir}/massdns/bin/massdns" 2>/dev/null+ $SUDO cp "${dir}/massdns/bin/massdns" /usr/local/bin/ 2>/dev/null+ else+ #printf "${yellow}Updating massdns...\n"+ if ! retry 3 3 q_to 60 git -C "${dir}/massdns" pull; then true; fi+ fi++ # gf patterns+ if [[ ! -d "$HOME/.gf" ]]; then+ #printf "${yellow}Installing gf patterns...\n"+ ensure_git_dir "${dir}/gf"+ if ! retry 3 3 q_to 120 git clone https://github.com/tomnomnom/gf.git "${dir}/gf"; then true; fi+ cp -r "${dir}/gf/examples" ~/.gf 2>/dev/null || true+ ensure_git_dir "${dir}/Gf-Patterns"+ if ! retry 3 3 q_to 120 git clone https://github.com/1ndianl33t/Gf-Patterns "${dir}/Gf-Patterns"; then true; fi+ cp "${dir}/Gf-Patterns"/*.json ~/.gf/ 2>/dev/null || true+ else+ #printf "${yellow}Updating gf patterns...\n"+ ensure_git_dir "${dir}/Gf-Patterns"+ if ! retry 3 3 q_to 60 git -C "${dir}/Gf-Patterns" pull; then true; fi+ fi++ header "Downloading required files"++ mkdir -p ${HOME}/.config/notify+ # Download required files with error handling+ declare -A downloads=(+ ["notify_provider_config"]="https://gist.githubusercontent.com/six2dez/23a996bca189a11e88251367e6583053/raw ${HOME}/.config/notify/provider-config.yaml"+ ["getjswords"]="https://raw.githubusercontent.com/m4ll0k/Bug-Bounty-Toolz/master/getjswords.py ${tools}/getjswords.py"+ ["subdomains_huge"]="https://raw.githubusercontent.com/n0kovo/n0kovo_subdomains/main/n0kovo_subdomains_huge.txt ${subs_wordlist_big}"+ ["trusted_resolvers"]="https://gist.githubusercontent.com/six2dez/ae9ed7e5c786461868abd3f2344401b6/raw ${resolvers_trusted}"+ ["resolvers"]="https://raw.githubusercontent.com/trickest/resolvers/main/resolvers.txt ${resolvers}"+ ["subs_wordlist"]="https://gist.github.com/six2dez/a307a04a222fab5a57466c51e1569acf/raw ${subs_wordlist}"+ ["permutations_list"]="https://gist.github.com/six2dez/ffc2b14d283e8f8eff6ac83e20a3c4b4/raw ${tools}/permutations_list.txt"+ ["fuzz_wordlist"]="https://raw.githubusercontent.com/six2dez/OneListForAll/main/onelistforallmicro.txt ${fuzz_wordlist}"+ ["lfi_wordlist"]="https://gist.githubusercontent.com/six2dez/a89a0c7861d49bb61a09822d272d5395/raw ${lfi_wordlist}"+ ["ssti_wordlist"]="https://gist.githubusercontent.com/six2dez/ab5277b11da7369bf4e9db72b49ad3c1/raw ${ssti_wordlist}"+ ["headers_inject"]="https://gist.github.com/six2dez/d62ab8f8ffd28e1c206d401081d977ae/raw ${tools}/headers_inject.txt"+ ["axiom_config"]="https://gist.githubusercontent.com/six2dez/6e2d9f4932fd38d84610eb851014b26e/raw ${tools}/axiom_config.sh"+ ["jsluice_patterns"]="https://gist.githubusercontent.com/six2dez/2aafa8dc2b682bb0081684e71900e747/raw ${tools}/jsluice_patterns.json"+ )++ for key in "${!downloads[@]}"; do+ url="${downloads[$key]% *}"+ destination="${downloads[$key]#* }"++ # Skip download if provider-config.yaml already exists+ if [[ $key == "notify_provider_config" && -f $destination ]]; then+ printf "[%bSKIPPING%b] %s as it already exists at %s.\n" "$yellow" "$reset" "$key" "$destination"+ continue+ fi++ # Ensure destination directory exists+ mkdir -p "$(dirname "$destination")" 2>/dev/null || true++ if with_spinner "Fetching $key" retry 3 3 q_to 120 wget -q -O "$destination" "$url"; then+ :+ else+ msg_err "Failed to download $key from $url"+ continue+ fi+ done++ # (removed) kiterunner routes tarball handling++ # Make axiom_config.sh executable+ chmod +x "${tools}/axiom_config.sh" || {+ printf "%b[!] Failed to make axiom_config.sh executable.%b\n" "$red" "$reset"+ }++ header "Final configuration"++ # Update resolvers if generate_resolvers is true+ if [[ $generate_resolvers == true ]]; then+ if [[ ! -s $resolvers || $(find "$resolvers" -mtime +1 -print) ]]; then+ printf "%bChecking resolvers lists...\nAccurate resolvers are the key to great results.\nThis may take around 10 minutes if it's not updated.%b\n" "$yellow" "$reset"+ rm -f "$resolvers" &>/dev/null+ dnsvalidator -tL https://public-dns.info/nameservers.txt -threads "$DNSVALIDATOR_THREADS" -o "$resolvers" &>/dev/null+ dnsvalidator -tL https://raw.githubusercontent.com/blechschmidt/massdns/master/lists/resolvers.txt -threads "$DNSVALIDATOR_THREADS" -o tmp_resolvers &>/dev/null++ if [[ -s "tmp_resolvers" ]]; then+ cat tmp_resolvers | anew -q "$resolvers"+ rm -f tmp_resolvers &>/dev/null+ fi++ [[ ! -s $resolvers ]] && wget -q -O "$resolvers" https://raw.githubusercontent.com/trickest/resolvers/main/resolvers.txt+ [[ ! -s $resolvers_trusted ]] && wget -q -O "$resolvers_trusted" https://gist.githubusercontent.com/six2dez/ae9ed7e5c786461868abd3f2344401b6/raw/trusted_resolvers.txt+ printf "%bResolvers updated.%b\n" "$yellow" "$reset"+ fi+ generate_resolvers=false+ else+ if [[ -s $resolvers && $(find "$resolvers" -mtime +1 -print) ]]; then+ printf "%bChecking resolvers lists...\nAccurate resolvers are the key to great results.\nDownloading new resolvers.%b\n" "$yellow" "$reset"+ wget -q -O "$resolvers" https://raw.githubusercontent.com/trickest/resolvers/main/resolvers.txt+ wget -q -O "$resolvers_trusted" https://gist.githubusercontent.com/six2dez/ae9ed7e5c786461868abd3f2344401b6/raw/trusted_resolvers.txt+ printf "%bResolvers updated.%b\n" "$yellow" "$reset"+ fi+ fi++ # Strip all Go binaries and copy to /usr/local/bin (files only)+ find "${GOPATH}/bin" -type f -perm -u+x -exec strip -s {} \; 2>/dev/null || true+ find "${GOPATH}/bin" -type f -perm -u+x -exec $SUDO cp {} /usr/local/bin/ \; 2>/dev/null || true++ # Final reminders (classic output)+ local final_reminder+ final_reminder="$(+ cat <<EOFRemember to set your API keys:- subfinder (${HOME}/.config/subfinder/provider-config.yaml)- GitHub (${HOME}/Tools/.github_tokens)@@ -1079,15 +1080,15 @@ Remember to set your API keys:- notify (${HOME}/.config/notify/provider-config.yaml)- WHOISXML API (WHOISXML_API in reconftw.cfg or env var)EOF-)"- printf "%b%s%b\n" "$yellow" "$final_reminder" "$reset"- printf "%bFinished!%b\n" "$bgreen" "$reset"- printf "%b#######################################################################%b\n" "$bgreen" "$reset"+ )"+ printf "%b%s%b\n" "$yellow" "$final_reminder" "$reset"+ printf "%bFinished!%b\n" "$bgreen" "$reset"+ printf "%b#######################################################################%b\n" "$bgreen" "$reset"}# Function to display additional helpfunction show_additional_help() {- cat <<USAGE+ cat <<USAGEUsage: $0 [OPTIONS]Options:@@ -1100,62 +1101,62 @@ Options:Without options, the script checks for updates and installs all dependencies.USAGE- exit 0+ exit 0}# Function to handle installation argumentsfunction handle_install_arguments() {- printf "\n%breconFTW installer/updater script%b\n" "$bgreen" "$reset"-- while [[ $# -gt 0 ]]; do- case "$1" in- -h | --help)- show_additional_help- ;;- --tools)- TOOLS_ONLY=true- shift- ;;- --verbose)- VERBOSE=true- DEBUG_STD=""- DEBUG_ERROR=""- shift- ;;- --log)- LOGFILE="$2"- shift 2 || true- ;;- --force-update)- FORCE_UPDATE=true- shift- ;;- --dry-run)- DRY_RUN=true- shift- ;;- *)- printf "%bError: Invalid argument '%s'%b\n" "$bred" "$1" "$reset"- echo "Use -h or --help for usage information."- exit 1- ;;- esac- done-- printf "%bThis may take some time. Grab a coffee!%b\n" "$yellow" "$reset"-- # Determine if the script is run as root- if [[ "$(id -u)" -eq 0 ]]; then- SUDO=""- else- if ! sudo -n true 2>/dev/null; then- printf "%bIt is strongly recommended to add your user to sudoers.%b\n" "$bred" "$reset"- printf "%bThis will avoid prompts for sudo password during installation and scans.%b\n" "$bred" "$reset"- printf "%bRun the following command to add your user to sudoers:%b\n" "$bred" "$reset"- printf "%becho \"%s ALL=(ALL:ALL) NOPASSWD: ALL\" | sudo tee /etc/sudoers.d/reconFTW%b\n\n" "$bred" "$USER" "$reset"- fi- SUDO="sudo"- fi+ printf "\n%breconFTW installer/updater script%b\n" "$bgreen" "$reset"++ while [[ $# -gt 0 ]]; do+ case "$1" in+ -h | --help)+ show_additional_help+ ;;+ --tools)+ TOOLS_ONLY=true+ shift+ ;;+ --verbose)+ VERBOSE=true+ DEBUG_STD=""+ DEBUG_ERROR=""+ shift+ ;;+ --log)+ LOGFILE="$2"+ shift 2 || true+ ;;+ --force-update)+ FORCE_UPDATE=true+ shift+ ;;+ --dry-run)+ DRY_RUN=true+ shift+ ;;+ *)+ printf "%bError: Invalid argument '%s'%b\n" "$bred" "$1" "$reset"+ echo "Use -h or --help for usage information."+ exit 1+ ;;+ esac+ done++ printf "%bThis may take some time. Grab a coffee!%b\n" "$yellow" "$reset"++ # Determine if the script is run as root+ if [[ "$(id -u)" -eq 0 ]]; then+ SUDO=""+ else+ if ! sudo -n true 2>/dev/null; then+ printf "%bIt is strongly recommended to add your user to sudoers.%b\n" "$bred" "$reset"+ printf "%bThis will avoid prompts for sudo password during installation and scans.%b\n" "$bred" "$reset"+ printf "%bRun the following command to add your user to sudoers:%b\n" "$bred" "$reset"+ printf "%becho \"%s ALL=(ALL:ALL) NOPASSWD: ALL\" | sudo tee /etc/sudoers.d/reconFTW%b\n\n" "$bred" "$USER" "$reset"+ fi+ SUDO="sudo"+ fi}# Invoke main functionsdiff --git a/lib/config.sh b/lib/config.shnew file mode 100644index 0000000..770310f--- /dev/null+++ b/lib/config.sh@@ -0,0 +1,307 @@+#!/bin/bash+# reconFTW Configuration Loader+# Loads configuration from hierarchical config directory+# Priority (low to high): defaults → config/*.conf → secrets.conf → environment variables+#+# NOTE: This module is NOT currently active. Configuration is loaded from reconftw.cfg.+# This modular config system is preparatory code for future improvements when we want+# to split the monolithic reconftw.cfg into organized sections under config/*.conf.+# To activate: source this file from reconftw.sh instead of directly sourcing reconftw.cfg.++set -o pipefail++# Base configuration directory+RECONFTW_CONFIG_DIR="${RECONFTW_CONFIG_DIR:-${SCRIPTPATH}/config}"++# Error codes+readonly E_CONFIG_NOT_FOUND=10+readonly E_CONFIG_INVALID=11+readonly E_CONFIG_SYNTAX=12++# Configuration sections and their files+# Order matters - loaded in this sequence+declare -a CONFIG_SECTIONS=(+ "00-global.conf" # Global settings, paths, defaults+ "10-osint.conf" # OSINT module configuration+ "20-subdomains.conf" # Subdomain enumeration settings+ "30-web.conf" # Web analysis settings+ "40-vulns.conf" # Vulnerability scanning settings+ "50-performance.conf" # Performance and threading+ "60-notifications.conf" # Notification settings+ "70-advanced.conf" # Advanced features+ "90-secrets.conf" # API keys and secrets (gitignored)+)++# load_config_hierarchical()+# Description: Loads all configuration files in order+# Arguments: None+# Returns: 0 on success, exits on critical error+# Side effects: Sets global configuration variables+function load_config_hierarchical() {+ local config_dir="${1:-$RECONFTW_CONFIG_DIR}"+ local errors=0+ local warnings=0++ # Validate config directory exists+ if [[ ! -d "$config_dir" ]]; then+ printf "[ERROR] Configuration directory not found: %s\n" "$config_dir" >&2+ exit $E_CONFIG_NOT_FOUND+ fi++ # Load each configuration section in order+ for section in "${CONFIG_SECTIONS[@]}"; do+ local conf_file="${config_dir}/${section}"+ if [[ -f "$conf_file" ]]; then+ if ! _load_config_file "$conf_file"; then+ errors=$((errors + 1))+ fi+ fi+ done++ # Apply environment variable overrides+ _apply_env_overrides++ # Validate loaded configuration+ if ! validate_config; then+ printf "[ERROR] Configuration validation failed\n" >&2+ errors=$((errors + 1))+ fi++ if [[ $errors -gt 0 ]]; then+ printf "[WARN] %d configuration errors detected\n" "$errors" >&2+ return 1+ fi++ return 0+}++# _load_config_file()+# Description: Safely loads a single configuration file+# Arguments: $1 - Path to config file+# Returns: 0 on success, 1 on failure+function _load_config_file() {+ local conf_file="$1"++ # Security: Check file permissions+ local perms+ perms=$(stat -c "%a" "$conf_file" 2>/dev/null || stat -f "%Lp" "$conf_file" 2>/dev/null)+ if [[ -n "$perms" && "$perms" -gt 644 ]]; then+ printf "[WARN] Config file has overly permissive permissions (%s): %s\n" "$perms" "$conf_file" >&2+ fi++ # Check for dangerous patterns before sourcing+ if grep -qE '(eval[[:space:]]|\$\(.*\)|`.*`|rm[[:space:]]+-rf)' "$conf_file" 2>/dev/null; then+ printf "[ERROR] Config file contains potentially dangerous commands: %s\n" "$conf_file" >&2+ return $E_CONFIG_INVALID+ fi++ # Source the file with error handling+ if ! source "$conf_file" 2>/dev/null; then+ printf "[ERROR] Failed to load config file: %s\n" "$conf_file" >&2+ return $E_CONFIG_SYNTAX+ fi++ return 0+}++# _apply_env_overrides()+# Description: Overrides config values with environment variables+# Arguments: None+# Returns: 0+function _apply_env_overrides() {+ # List of variables that can be overridden via environment+ local -a override_vars=(+ "tools"+ "dir_output"+ "SHOW_COMMANDS"+ "MIN_DISK_SPACE_GB"+ "SHODAN_API_KEY"+ "WHOISXML_API"+ "XSS_SERVER"+ "COLLAB_SERVER"+ "slack_channel"+ "slack_auth"+ "OSINT"+ "SUBDOMAINS_GENERAL"+ "VULNS_GENERAL"+ "DEEP"+ "AXIOM"+ "NOTIFICATION"+ "FARADAY"+ "FFUF_THREADS"+ "HTTPX_THREADS"+ "HTTPX_RATELIMIT"+ "NUCLEI_RATELIMIT"+ "INCREMENTAL_MODE"+ "ADAPTIVE_RATE_LIMIT"+ "STRUCTURED_LOGGING"+ "ASSET_STORE"+ "QUICK_RESCAN"+ )++ for var in "${override_vars[@]}"; do+ local env_val+ env_val=$(printenv "$var" 2>/dev/null)+ if [[ -n "$env_val" ]]; then+ if _validate_config_var "$var" "$env_val"; then+ declare -g "$var=$env_val"+ fi+ fi+ done+}++# _validate_config_var()+# Description: Validates a configuration variable value+# Arguments: $1 - Variable name, $2 - Value+# Returns: 0 if valid, 1 if invalid+function _validate_config_var() {+ local var="$1"+ local value="$2"++ # Boolean validation+ if [[ "$var" =~ ^(OSINT|SUBDOMAINS_GENERAL|VULNS_GENERAL|DEEP|AXIOM|NOTIFICATION|FARADAY|INCREMENTAL_MODE|ADAPTIVE_RATE_LIMIT|STRUCTURED_LOGGING|ASSET_STORE|QUICK_RESCAN)$ ]]; then+ if [[ ! "$value" =~ ^(true|false)$ ]]; then+ printf "[WARN] Invalid boolean value for %s: %s (expected true/false)\n" "$var" "$value" >&2+ return 1+ fi+ fi++ # Numeric validation+ if [[ "$var" =~ _THREADS$|_RATELIMIT$|_TIMEOUT$ ]]; then+ if [[ ! "$value" =~ ^[0-9]+$ ]]; then+ printf "[WARN] Invalid numeric value for %s: %s\n" "$var" "$value" >&2+ return 1+ fi+ fi++ return 0+}++# validate_config()+# Description: Performs comprehensive configuration validation+# Arguments: None+# Returns: 0 if valid, 1 if errors found+function validate_config() {+ local warnings=0+ local errors=0++ # Check conflicting configurations+ if [[ "${VULNS_GENERAL:-false}" == true && "${SUBDOMAINS_GENERAL:-false}" == false ]]; then+ printf "[WARN] VULNS_GENERAL=true but SUBDOMAINS_GENERAL=false\n" >&2+ warnings=$((warnings + 1))+ fi++ # Validate numeric variables+ local -a numeric_vars=(+ "FFUF_THREADS"+ "HTTPX_THREADS"+ "DALFOX_THREADS"+ "HTTPX_RATELIMIT"+ "NUCLEI_RATELIMIT"+ "MIN_RATE_LIMIT"+ "MAX_RATE_LIMIT"+ )++ for var in "${numeric_vars[@]}"; do+ local var_value+ var_value="${!var:-}"+ if [[ -n "$var_value" && ! "$var_value" =~ ^[0-9]+$ ]]; then+ printf "[ERROR] %s must be numeric, got: %s\n" "$var" "$var_value" >&2+ errors=$((errors + 1))+ fi+ done++ # Check rate limit configuration+ if [[ "${ADAPTIVE_RATE_LIMIT:-false}" == true ]]; then+ if [[ -n "${MIN_RATE_LIMIT:-}" && -n "${MAX_RATE_LIMIT:-}" ]]; then+ if [[ $MIN_RATE_LIMIT -gt $MAX_RATE_LIMIT ]]; then+ printf "[ERROR] MIN_RATE_LIMIT > MAX_RATE_LIMIT\n" >&2+ errors=$((errors + 1))+ fi+ fi+ fi++ # Validate Axiom configuration+ if [[ "${AXIOM:-false}" == true ]]; then+ if ! command -v axiom-scan &>/dev/null; then+ printf "[WARN] AXIOM=true but axiom-scan not found\n" >&2+ warnings=$((warnings + 1))+ fi+ fi++ if [[ $errors -gt 0 ]]; then+ printf "[ERROR] Configuration validation failed\n" >&2+ return 1+ fi++ return 0+}++# config_get()+# Description: Safely retrieves a configuration value+# Arguments: $1 - Variable name, $2 - Default value (optional)+# Returns: Echoes the value+function config_get() {+ local var="$1"+ local default="${2:-}"+ local value++ value="${!var:-$default}"+ printf '%s' "$value"+}++# migrate_legacy_config()+# Description: Migrates old reconftw.cfg to new hierarchical format+# Arguments: $1 - Path to old config file, $2 - New config dir (optional)+# Returns: 0 on success, 1 on failure+function migrate_legacy_config() {+ local old_config="$1"+ local new_config_dir="${2:-$RECONFTW_CONFIG_DIR}"++ if [[ ! -f "$old_config" ]]; then+ printf "[ERROR] Legacy config file not found: %s\n" "$old_config" >&2+ return 1+ fi++ printf "[INFO] Migrating legacy config...\n"+ mkdir -p "$new_config_dir"++ # Create new config files+ # This is a simplified migration - creates basic structure+ cat >"$new_config_dir/00-global.conf" <<'EOF'+#############################################+# reconFTW Global Config #+#############################################++tools="$HOME/Tools"+SCRIPTPATH="$(cd "$(dirname "$0")" >/dev/null 2>&1 && pwd -P)"++# Version info+if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then+ reconftw_version="$(git rev-parse --abbrev-ref HEAD)-$(git describe --tags 2>/dev/null || git rev-parse --short HEAD)"+else+ reconftw_version="standalone"+fi++# Resolvers+generate_resolvers=false+update_resolvers=true+resolvers_url="https://raw.githubusercontent.com/trickest/resolvers/main/resolvers.txt"+resolvers_trusted_url="https://gist.githubusercontent.com/six2dez/ae9ed7e5c786461868abd3f2344401b6/raw/trusted_resolvers.txt"++# General options+proxy_url="http://127.0.0.1:8080/"+install_golang=true+upgrade_tools=true+upgrade_before_running=false+SHOW_COMMANDS=false+MIN_DISK_SPACE_GB=5++# Debug output+DEBUG_STD="&>/dev/null"+DEBUG_ERROR="2>/dev/null"+EOF++ printf "[INFO] Migration complete to: %s\n" "$new_config_dir"+ return 0+}diff --git a/lib/validation.sh b/lib/validation.shnew file mode 100644index 0000000..0782eed--- /dev/null+++ b/lib/validation.sh@@ -0,0 +1,209 @@+#!/bin/bash+# reconFTW Validation Library+# Provides type checking and input validation functions++set -o pipefail++# Error codes+readonly E_INVALID_DOMAIN=20+readonly E_INVALID_IP=21+readonly E_INVALID_PATH=22+readonly E_INVALID_URL=23+readonly E_INVALID_EMAIL=24++# validate_domain()+# Description: Validates a domain name format+# Arguments: $1 - Domain string to validate+# Returns: 0 if valid, 1 if invalid+function validate_domain() {+ local domain="$1"++ # Check if empty+ if [[ -z "$domain" ]]; then+ return $E_INVALID_DOMAIN+ fi++ # Check for command injection characters+ if echo "$domain" | grep -qE '[;|&$`\\(){}]'; then+ return $E_INVALID_DOMAIN+ fi++ # Check if it's an IP address (valid for scanning)+ if [[ "$domain" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then+ # Validate IP octets+ local IFS='.'+ local -a octets+ read -ra octets <<<"$domain"+ for octet in "${octets[@]}"; do+ if [[ "$octet" -lt 0 || "$octet" -gt 255 ]]; then+ return $E_INVALID_DOMAIN+ fi+ done+ return 0+ fi++ # Validate domain name format (simplified RFC check)+ if [[ ! "$domain" =~ ^[a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?)*$ ]]; then+ return $E_INVALID_DOMAIN+ fi++ # Check total length+ if [[ ${#domain} -gt 253 ]]; then+ return $E_INVALID_DOMAIN+ fi++ return 0+}++# NOTE: sanitize_domain() is defined in modules/utils.sh+# This avoids duplication and ensures consistent behavior++# validate_ipv4()+# Description: Validates an IPv4 address+# Arguments: $1 - IP string to validate+# Returns: 0 if valid, 1 if invalid+function validate_ipv4() {+ local ip="$1"++ if [[ ! "$ip" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then+ return $E_INVALID_IP+ fi++ local IFS='.'+ local -a octets+ read -ra octets <<<"$ip"++ if [[ ${#octets[@]} -ne 4 ]]; then+ return $E_INVALID_IP+ fi++ for octet in "${octets[@]}"; do+ if [[ ! "$octet" =~ ^[0-9]+$ ]]; then+ return $E_INVALID_IP+ fi+ if [[ "$octet" -lt 0 || "$octet" -gt 255 ]]; then+ return $E_INVALID_IP+ fi+ done++ return 0+}++# validate_boolean()+# Description: Validates a boolean value+# Arguments: $1 - Value to validate+# Returns: 0 if valid boolean, 1 otherwise+function validate_boolean() {+ local value="$1"++ if [[ "$value" =~ ^(true|false|1|0|yes|no)$ ]]; then+ return 0+ fi++ return 1+}++# validate_integer()+# Description: Validates an integer within optional range+# Arguments: $1 - Value, $2 - Min (optional), $3 - Max (optional)+# Returns: 0 if valid, 1 if invalid+function validate_integer() {+ local value="$1"+ local min="${2:-}"+ local max="${3:-}"++ if [[ ! "$value" =~ ^-?[0-9]+$ ]]; then+ return 1+ fi++ if [[ -n "$min" && "$value" -lt "$min" ]]; then+ return 1+ fi++ if [[ -n "$max" && "$value" -gt "$max" ]]; then+ return 1+ fi++ return 0+}++# validate_port()+# Description: Validates a TCP/UDP port number+# Arguments: $1 - Port number+# Returns: 0 if valid port (1-65535), 1 otherwise+function validate_port() {+ local port="$1"+ validate_integer "$port" 1 65535+}++# sanitize_path()+# Description: Sanitizes a file path+# Arguments: $1 - Path to sanitize+# Returns: Echoes sanitized path+function sanitize_path() {+ local path="$1"++ # Remove control characters+ path=$(printf '%s' "$path" | tr -d '\000-\037')++ # Remove trailing slashes (except root)+ if [[ "$path" != "/" ]]; then+ path=$(printf '%s' "$path" | sed 's:/*$::')+ fi++ # Normalize path+ path=$(printf '%s' "$path" | sed 's://*:/:g')++ printf '%s' "$path"+}++# sanitize_interlace_input()+# Description: Sanitizes input for interlace tool+# Arguments: $1 - Input file, $2 - Output file (optional)+# Returns: 0 on success+function sanitize_interlace_input() {+ local infile="$1"+ local outfile="${2:-$1}"++ # Remove lines containing shell metacharacters+ local pattern='[;|&$`\(){}]'++ if [[ "$infile" == "$outfile" ]]; then+ local tmpfile+ tmpfile=$(mktemp)+ grep -v "$pattern" "$infile" >"$tmpfile" 2>/dev/null || true+ mv "$tmpfile" "$outfile"+ else+ grep -v "$pattern" "$infile" >"$outfile" 2>/dev/null || true+ fi++ return 0+}++# is_empty()+# Description: Checks if a value is empty+# Arguments: $1 - Value to check+# Returns: 0 if empty, 1 if not empty+function is_empty() {+ local value="$1"++ if [[ -z "${value// /}" ]]; then+ return 0+ fi++ return 1+}++# is_numeric()+# Description: Checks if a value is numeric+# Arguments: $1 - Value to check+# Returns: 0 if numeric, 1 if not+function is_numeric() {+ local value="$1"++ if [[ "$value" =~ ^-?[0-9]+(\.[0-9]+)?$ ]]; then+ return 0+ fi++ return 1+}diff --git a/modules/axiom.sh b/modules/axiom.shnew file mode 100644index 0000000..063b9bc--- /dev/null+++ b/modules/axiom.sh@@ -0,0 +1,146 @@+#!/bin/bash+# reconFTW - Axiom/resolver module+# Contains: resolvers_update, resolvers_update_quick_local,+# resolvers_update_quick_axiom, resolvers_optimize_local,+# ipcidr_target, axiom_launch, axiom_shutdown, axiom_selected+# This file is sourced by reconftw.sh - do not execute directly+[[ -z "${SCRIPTPATH:-}" ]] && {+ echo "Error: This module must be sourced by reconftw.sh" >&2+ exit 1+}++function resolvers_update() {++ if [[ $generate_resolvers == true ]]; then+ if [[ $AXIOM != true ]]; then+ if [[ ! -s $resolvers ]] || [[ $(find "$resolvers" -mtime +1 -print) ]]; then+ notification "Resolvers seem older than 1 day\n Generating custom resolvers..." warn+ rm -f -- "$resolvers" 2>>"$LOGFILE"+ dnsvalidator -tL https://public-dns.info/nameservers.txt -threads $DNSVALIDATOR_THREADS -o $resolvers 2>>"$LOGFILE" >/dev/null+ dnsvalidator -tL https://raw.githubusercontent.com/blechschmidt/massdns/master/lists/resolvers.txt -threads $DNSVALIDATOR_THREADS -o tmp_resolvers 2>>"$LOGFILE" >/dev/null+ [ -s "tmp_resolvers" ] && cat tmp_resolvers | anew -q $resolvers+ [ -s "tmp_resolvers" ] && rm -f tmp_resolvers 2>>"$LOGFILE" >/dev/null+ [ ! -s "$resolvers" ] && wget -q -O - ${resolvers_url} >$resolvers+ [ ! -s "$resolvers_trusted" ] && wget -q -O - ${resolvers_trusted_url} >$resolvers_trusted+ notification "Updated\n" good+ fi+ else+ notification "Checking resolvers lists...\n Accurate resolvers are the key to great results\n This may take around 10 minutes if it's not updated" warn+ axiom-exec "([[ \$(find \"${AXIOM_RESOLVERS_PATH}\" -mtime +1 -print) ]] || [[ \$(wc -l < \"${AXIOM_RESOLVERS_PATH}\") -le 40 ]]) && dnsvalidator -tL https://public-dns.info/nameservers.txt -threads 200 -o ${AXIOM_RESOLVERS_PATH}" &>/dev/null+ axiom-exec "wget -q -O - ${resolvers_url} > ${AXIOM_RESOLVERS_PATH}" 2>>"$LOGFILE" >/dev/null+ axiom-exec "wget -q -O - ${resolvers_trusted_url} > ${AXIOM_RESOLVERS_TRUSTED_PATH}" 2>>"$LOGFILE" >/dev/null+ notification "Updated\n" good+ fi+ generate_resolvers=false+ else++ if [[ ! -s $resolvers ]] || [[ $(find "$resolvers" -mtime +1 -print) ]]; then+ notification "Resolvers seem older than 1 day\n Downloading new resolvers..." warn+ cached_download "${resolvers_url}" "$resolvers" "resolvers.txt"+ cached_download "${resolvers_trusted_url}" "$resolvers_trusted" "resolvers_trusted.txt"+ notification "Resolvers updated\n" good+ fi+ fi++}++function resolvers_update_quick_local() {+ if [[ $update_resolvers == true ]]; then+ cached_download "${resolvers_url}" "$resolvers" "resolvers.txt"+ cached_download "${resolvers_trusted_url}" "$resolvers_trusted" "resolvers_trusted.txt"+ fi+}++function resolvers_update_quick_axiom() {+ axiom-exec "wget -q -O - ${resolvers_url} > ${AXIOM_RESOLVERS_PATH}" 2>>"$LOGFILE" >/dev/null+ axiom-exec "wget -q -O - ${resolvers_trusted_url} > ${AXIOM_RESOLVERS_TRUSTED_PATH}" 2>>"$LOGFILE" >/dev/null+}++function resolvers_optimize_local() {+ # Experimental: dedupe resolvers; prefer faster ones if dnsx available+ sort -u "$resolvers" -o "$resolvers" 2>/dev/null || true+ sort -u "$resolvers_trusted" -o "$resolvers_trusted" 2>/dev/null || true+}++function ipcidr_target() {+ IP_CIDR_REGEX='(((25[0-5]|2[0-4][0-9]|1?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|1?[0-9][0-9]?))(\/([8-9]|[1-2][0-9]|3[0-2]))([^0-9.]|$)|(((25[0-5]|2[0-4][0-9]|1?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|1?[0-9][0-9]?)$)'+ if [[ $1 =~ ^$IP_CIDR_REGEX ]]; then+ echo $1 | mapcidr -silent | anew -q target_reconftw_ipcidr.txt+ if [[ -s "./target_reconftw_ipcidr.txt" ]]; then+ [ "$REVERSE_IP" = true ] && cat ./target_reconftw_ipcidr.txt | hakip2host | cut -d' ' -f 3 | unfurl -u domains 2>/dev/null | sed -e 's/*\.//' -e 's/\.$//' -e '/\./!d' | anew -q ./target_reconftw_ipcidr.txt+ if [[ $(cat ./target_reconftw_ipcidr.txt | wc -l) -eq 1 ]]; then+ domain=$(cat ./target_reconftw_ipcidr.txt)+ elif [[ $(cat ./target_reconftw_ipcidr.txt | wc -l) -gt 1 ]]; then+ unset domain+ list=${PWD}/target_reconftw_ipcidr.txt+ fi+ fi+ if [[ -n $2 ]]; then+ cat $list | anew -q $2+ sed_i '/\/[0-9]*$/d' $2+ fi+ fi+}++function axiom_launch() {+ # let's fire up a FLEET!+ if [[ $AXIOM_FLEET_LAUNCH == true ]] && [[ -n $AXIOM_FLEET_NAME ]] && [[ -n $AXIOM_FLEET_COUNT ]]; then+ start_func ${FUNCNAME[0]} "Launching our Axiom fleet"++ # Check to see if we have a fleet already, if so, SKIP THIS!+ NUMOFNODES=$(timeout 30 axiom-ls | grep -c "$AXIOM_FLEET_NAME" || true)+ if [[ $NUMOFNODES -ge $AXIOM_FLEET_COUNT ]]; then+ axiom-select "$AXIOM_FLEET_NAME*"+ end_func "Axiom fleet $AXIOM_FLEET_NAME already has $NUMOFNODES instances" info+ else+ if [[ $NUMOFNODES -eq 0 ]]; then+ startcount=$AXIOM_FLEET_COUNT+ else+ startcount=$((AXIOM_FLEET_COUNT - NUMOFNODES))+ fi+ # Build args safely to avoid word-splitting issues+ local -a AXIOM_FLEET_ARGS=(-i "$startcount")+ # Regions intentionally disabled here per original comment+ # To re-enable: [[ -n ${AXIOM_FLEET_REGIONS-} ]] && AXIOM_FLEET_ARGS+=( --regions="${AXIOM_FLEET_REGIONS}" )++ # Show the exact command with proper quoting+ printf 'axiom-fleet %q' "${AXIOM_FLEET_NAME}"+ printf ' %q' "${AXIOM_FLEET_ARGS[@]}"+ echo+ axiom-fleet "${AXIOM_FLEET_NAME}" "${AXIOM_FLEET_ARGS[@]}"+ axiom-select "$AXIOM_FLEET_NAME*"+ if [[ -n $AXIOM_POST_START ]]; then+ bash -lc "$AXIOM_POST_START" 2>>"$LOGFILE" >/dev/null+ fi++ NUMOFNODES=$(timeout 30 axiom-ls | grep -c "$AXIOM_FLEET_NAME" || true)+ end_func "Axiom fleet $AXIOM_FLEET_NAME launched $NUMOFNODES instances" info+ fi+ fi+}++function axiom_shutdown() {+ if [[ $AXIOM_FLEET_LAUNCH == true ]] && [[ $AXIOM_FLEET_SHUTDOWN == true ]] && [[ -n $AXIOM_FLEET_NAME ]]; then+ #if [[ "$mode" == "subs_menu" ]] || [[ "$mode" == "list_recon" ]] || [[ "$mode" == "passive" ]] || [[ "$mode" == "all" ]]; then+ if [[ $mode == "subs_menu" ]] || [[ $mode == "passive" ]] || [[ $mode == "all" ]]; then+ notification "Automatic Axiom fleet shutdown is not enabled in this mode" info+ return+ fi+ axiom-rm -f "$AXIOM_FLEET_NAME*" || true+ axiom-ls | grep "$AXIOM_FLEET_NAME" || true+ notification "Axiom fleet $AXIOM_FLEET_NAME shutdown" info+ fi+}++function axiom_selected() {++ if [[ ! $(axiom-ls | tail -n +2 | sed '$ d' | wc -l) -gt 0 ]]; then+ notification "No axiom instances running ${reset}\n\n" error+ exit+ fi++ if [[ ! $(cat ~/.axiom/selected.conf | sed '/^\s*$/d' | wc -l) -gt 0 ]]; then+ notification "No axiom instances selected ${reset}\n\n" error+ exit+ fi+}diff --git a/modules/core.sh b/modules/core.shnew file mode 100644index 0000000..b9f5371--- /dev/null+++ b/modules/core.sh@@ -0,0 +1,1025 @@+#!/bin/bash+# reconFTW - Core framework module+# Contains: UI wrappers, banner, version check, tools check, logging,+# output/notification, lifecycle (start_func/end_func), plugins, assets+# This file is sourced by reconftw.sh - do not execute directly+[[ -z "${SCRIPTPATH:-}" ]] && {+ echo "Error: This module must be sourced by reconftw.sh" >&2+ exit 1+}++# --------------------------------------+# Classic UI wrappers (no tput/icons)+# --------------------------------------++pt_header() { :; }+pt_msg_run() { printf "\n%b[%s] %s%b\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "$1" "$reset"; }+pt_msg_ok() { printf "\n%b[%s] %s%b\n" "$bgreen" "$(date +'%Y-%m-%d %H:%M:%S')" "$1" "$reset"; }+pt_msg_warn() { printf "\n%b[%s] %s%b\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "$1" "$reset"; }+pt_msg_err() { printf "\n%b[%s] %s%b\n" "$bred" "$(date +'%Y-%m-%d %H:%M:%S')" "$1" "$reset"; }++# Ensure a safe default for early log redirections+# If LOGFILE is unset or empty, send logs to /dev/null until later initialization+: "${LOGFILE:=/dev/null}"++enable_command_trace() {+ # Enable bash xtrace to the current LOGFILE when SHOW_COMMANDS=true+ if [[ ${SHOW_COMMANDS:-false} != true ]]; then+ return+ fi+ [[ -z ${LOGFILE:-} ]] && return++ # Close any previous trace descriptor (native bash {varname} redirect syntax)+ if [[ -n ${TRACE_FD:-} ]]; then+ exec {TRACE_FD}>&- 2>/dev/null || true+ fi++ # Open a new descriptor against the active log+ if ! exec {TRACE_FD}>>"$LOGFILE"; then+ return+ fi+ export BASH_XTRACEFD=$TRACE_FD+ export PS4='+ ${BASH_SOURCE##*/}:${LINENO}: '+ set -x+}++function banner_grabber() {+ local banner_file="${SCRIPTPATH}/banners.txt"++ # Check if the banner file exists+ if [[ ! -f $banner_file ]]; then+ echo "Banner file not found: $banner_file" >&2+ return 1+ fi++ # Source the banner file+ source "$banner_file"++ # Collect all banner variable names+ mapfile -t banner_vars < <(compgen -A variable | grep '^banner[0-9]\+$')++ # Check if any banners are available+ if [[ ${#banner_vars[@]} -eq 0 ]]; then+ echo "No banners found in $banner_file" >&2+ return 1+ fi++ # Select a random banner+ local rand_index=$((RANDOM % ${#banner_vars[@]}))+ local banner_var="${banner_vars[$rand_index]}"+ local banner_code="${!banner_var}"++ # Output the banner code+ printf "%b\n" "$banner_code"+}++function banner() {+ local banner_code+ if banner_code=$(banner_grabber); then+ printf "\n%b%s" "$bgreen" "$banner_code"+ printf "\n %s by @six2dez%b\n" "$reconftw_version" "$reset"+ else+ printf "\n%bFailed to load banner.%b\n" "$bgreen" "$reset"+ fi+}++###############################################################################################################+################################################### TOOLS #####################################################+###############################################################################################################++function check_version() {++ # Check if git is installed+ if ! command -v git >/dev/null 2>&1; then+ printf "\n%bGit is not installed. Cannot check for updates.%b\n\n" "$bred" "$reset"+ return 1+ fi++ # Check if current directory is a git repository+ if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then+ printf "\n%bCurrent directory is not a git repository. Cannot check for updates.%b\n\n" "$bred" "$reset"+ return 1+ fi++ # Fetch updates with a timeout (supports gtimeout on macOS)+ if ! { [[ -n $TIMEOUT_CMD ]] && $TIMEOUT_CMD 10 git fetch >/dev/null 2>&1; } && ! git fetch >/dev/null 2>&1; then+ printf "\n%bUnable to check updates (git fetch timed out).%b\n\n" "$bred" "$reset"+ return 1+ fi++ # Get current branch name+ local BRANCH+ BRANCH=$(git rev-parse --abbrev-ref HEAD)++ # Get upstream branch+ local UPSTREAM+ UPSTREAM=$(git rev-parse --abbrev-ref --symbolic-full-name "@{u}" 2>/dev/null)+ if [[ -z $UPSTREAM ]]; then+ printf "\n%bNo upstream branch set for '%s'. Cannot check for updates.%b\n\n" "$bred" "$BRANCH" "$reset"+ return 1+ fi++ # Get local and remote commit hashes+ local LOCAL REMOTE+ LOCAL=$(git rev-parse HEAD)+ REMOTE=$(git rev-parse "$UPSTREAM")++ # Compare local and remote hashes+ if [[ $LOCAL != "$REMOTE" ]]; then+ printf "\n%bThere is a new version available. Run ./install.sh to get the latest version.%b\n\n" "$yellow" "$reset"+ fi+}++function tools_installed() {+ # Check if all tools are installed+ printf "\n\n%b#######################################################################%b\n" "$bgreen" "$reset"+ printf "%b[%s] Checking installed tools %b\n\n" "$bblue" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"++ local all_installed=true+ local missing_tools=()++ # Check environment variables+ local env_vars=("GOPATH" "GOROOT" "PATH")+ for var in "${env_vars[@]}"; do+ if [[ -z ${!var} ]]; then+ printf "%b [*] %s variable\t\t[NO]%b\n" "$bred" "$var" "$reset"+ all_installed=false+ missing_tools+=("$var environment variable")+ fi+ done++ # Define tools and their paths/commands+ declare -A tools_files=(+ ["dorks_hunter"]="${tools}/dorks_hunter/dorks_hunter.py"+ ["dorks_hunter_python"]="${tools}/dorks_hunter/venv/bin/python3"+ ["fav-up"]="${tools}/fav-up/favUp.py"+ ["fav-up_python"]="${tools}/fav-up/venv/bin/python3"+ ["Corsy"]="${tools}/Corsy/corsy.py"+ ["Corsy_python"]="${tools}/Corsy/venv/bin/python3"+ ["testssl.sh"]="${tools}/testssl.sh/testssl.sh"+ ["CMSeeK"]="${tools}/CMSeeK/cmseek.py"+ ["CMSeeK_python"]="${tools}/CMSeeK/venv/bin/python3"+ ["OneListForAll"]="$fuzz_wordlist"+ ["lfi_wordlist"]="$lfi_wordlist"+ ["ssti_wordlist"]="$ssti_wordlist"+ ["subs_wordlist"]="$subs_wordlist"+ ["subs_wordlist_big"]="$subs_wordlist_big"+ ["resolvers"]="$resolvers"+ ["resolvers_trusted"]="$resolvers_trusted"+ ["getjswords"]="${tools}/getjswords.py"+ ["JSA"]="${tools}/JSA/jsa.py"+ ["JSA_python"]="${tools}/JSA/venv/bin/python3"+ ["CloudHunter"]="${tools}/CloudHunter/cloudhunter.py"+ ["CloudHunter_python"]="${tools}/CloudHunter/venv/bin/python3"+ ["nmap-parse-output"]="${tools}/ultimate-nmap-parser/ultimate-nmap-parser.sh"+ ["pydictor"]="${tools}/pydictor/pydictor.py"+ ["regulator"]="${tools}/regulator/main.py"+ ["regulator_python"]="${tools}/regulator/venv/bin/python3"+ ["nomore403"]="${tools}/nomore403/nomore403"+ ["ffufPostprocessing"]="${tools}/ffufPostprocessing/ffufPostprocessing"+ ["spoofy"]="${tools}/Spoofy/spoofy.py"+ ["spoofy_python"]="${tools}/Spoofy/venv/bin/python3"+ ["swaggerspy"]="${tools}/SwaggerSpy/swaggerspy.py"+ ["swaggerspy_python"]="${tools}/SwaggerSpy/venv/bin/python3"+ ["LeakSearch"]="${tools}/LeakSearch/LeakSearch.py"+ ["LeakSearch_python"]="${tools}/LeakSearch/venv/bin/python3"+ ["Oralyzer"]="${tools}/Oralyzer/oralyzer.py"+ ["Oralyzer_python"]="${tools}/Oralyzer/venv/bin/python3"+ ["msftrecon"]="${tools}/msftrecon/msftrecon/msftrecon.py"+ ["msftrecon_python"]="${tools}/msftrecon/venv/bin/python3"+ ["Scopify"]="${tools}/Scopify/scopify.py"+ ["Scopify_python"]="${tools}/Scopify/venv/bin/python3"+ ["EmailHarvester"]="${tools}/EmailHarvester/EmailHarvester.py"+ ["EmailHarvester_python"]="${tools}/EmailHarvester/venv/bin/python3"+ ["metagoofil"]="${tools}/metagoofil/metagoofil.py"+ ["metagoofil_python"]="${tools}/metagoofil/venv/bin/python3"+ ["reconftw_ai"]="${tools}/reconftw_ai/reconftw_ai.py"+ ["reconftw_ai_python"]="${tools}/reconftw_ai/venv/bin/python3"+ )++ declare -A tools_folders=(+ ["NUCLEI_TEMPLATES_PATH"]="${NUCLEI_TEMPLATES_PATH}"+ )++ declare -A tools_commands=(+ ["python3"]="python3"+ ["curl"]="curl"+ ["wget"]="wget"+ ["zip"]="zip"+ ["nmap"]="nmap"+ ["dig"]="dig"+ ["timeout"]="${TIMEOUT_CMD:-timeout}"+ ["brutespray"]="brutespray"+ ["xnLinkFinder"]="xnLinkFinder"+ ["xnldorker"]="xnldorker"+ ["urlfinder"]="urlfinder"+ ["github-endpoints"]="github-endpoints"+ ["github-subdomains"]="github-subdomains"+ ["gitlab-subdomains"]="gitlab-subdomains"+ ["katana"]="katana"+ ["wafw00f"]="wafw00f"+ ["dnsvalidator"]="dnsvalidator"+ ["whois"]="whois"+ ["dnsx"]="dnsx"+ ["gotator"]="gotator"+ ["Nuclei"]="nuclei"+ ["gf"]="gf"+ ["Gxss"]="Gxss"+ ["subjs"]="subjs"+ ["ffuf"]="ffuf"+ ["Massdns"]="massdns"+ ["qsreplace"]="qsreplace"+ ["interlace"]="interlace"+ ["Anew"]="anew"+ ["unfurl"]="unfurl"+ ["crlfuzz"]="crlfuzz"+ ["Httpx"]="httpx"+ ["jq"]="jq"+ ["notify"]="notify"+ ["dalfox"]="dalfox"+ ["puredns"]="puredns"+ ["analyticsrelationships"]="analyticsrelationships"+ ["mapcidr"]="mapcidr"+ ["ppmap"]="ppmap"+ ["cdncheck"]="cdncheck"+ ["interactsh-client"]="interactsh-client"+ ["tlsx"]="tlsx"+ ["smap"]="smap"+ ["gitdorks_go"]="gitdorks_go"+ ["ripgen"]="ripgen"+ ["smugglex"]="smugglex"+ ["dsieve"]="dsieve"+ ["inscope"]="inscope"+ ["enumerepo"]="enumerepo"+ ["Web-Cache-Vulnerability-Scanner"]="Web-Cache-Vulnerability-Scanner"+ ["subfinder"]="subfinder"+ ["ghauri"]="ghauri"+ ["hakip2host"]="hakip2host"+ ["crt"]="crt"+ ["gitleaks"]="gitleaks"+ ["trufflehog"]="trufflehog"+ ["s3scanner"]="s3scanner"+ ["mantra"]="mantra"+ ["nmapurls"]="nmapurls"+ ["porch-pirate"]="porch-pirate"+ ["shortscan"]="shortscan"+ ["sns"]="sns"+ ["sourcemapper"]="sourcemapper"+ ["jsluice"]="jsluice"+ ["commix"]="commix"+ ["urless"]="urless"+ ["dnstake"]="dnstake"+ ["cent"]="cent"+ ["csprecon"]="csprecon"+ ["VhostFinder"]="VhostFinder"+ ["grpcurl"]="grpcurl"+ ["arjun"]="arjun"+ ["gqlspection"]="gqlspection"+ ["cloud_enum"]="cloud_enum"+ )++ # Check for tool files+ for tool in "${!tools_files[@]}"; do+ if [[ ! -f ${tools_files[$tool]} ]]; then+ # printf "%b [*] %s\t\t[NO]%b\n" "$bred" "$tool" "$reset"+ all_installed=false+ missing_tools+=("$tool")+ fi+ done++ # Check for tool folders+ for folder in "${!tools_folders[@]}"; do+ if [[ ! -d ${tools_folders[$folder]} ]]; then+ # printf "%b [*] %s\t\t[NO]%b\n" "$bred" "$folder" "$reset"+ all_installed=false+ missing_tools+=("$folder") # Correctly pushing the folder name+ fi+ done++ # Check for tool commands+ for tool in "${!tools_commands[@]}"; do+ if ! command -v "${tools_commands[$tool]}" >/dev/null 2>&1; then+ # printf "%b [*] %s\t\t[NO]%b\n" "$bred" "$tool" "$reset"+ all_installed=false+ missing_tools+=("$tool")+ fi+ done++ if [[ $all_installed == true ]]; then+ printf "%b\n Good! All tools are installed! %b\n\n" "$bgreen" "$reset"+ else+ printf "\n%bSome tools or directories are missing:%b\n\n" "$yellow" "$reset"+ for tool in "${missing_tools[@]}"; do+ printf "%b - %s %b\n" "$bred" "$tool" "$reset"+ done+ printf "\n%bTry running the installer script again: ./install.sh%b\n" "$yellow" "$reset"+ printf "%bIf it fails, try installing the missing tools manually.%b\n" "$yellow" "$reset"+ printf "%bEnsure that the %b\$tools%b variable is correctly set at the start of this script.%b\n" "$yellow" "$bred" "$yellow" "$reset"+ printf "%bIf you need assistance, feel free to contact me! :D%b\n\n" "$yellow" "$reset"+ fi++ printf "%b[%s] Tools check finished%b\n" "$bblue" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"+ printf "%b#######################################################################\n%b" "$bgreen" "$reset"++ if [[ $CHECK_TOOLS_OR_EXIT == true && $all_installed != true ]]; then+ exit 2+ fi+}++###############################################################################################################+#################################### CRITICAL DEPENDENCIES CHECK ##############################################+###############################################################################################################++# Check critical dependencies required for basic operation+# This performs a quick check of essential tools before starting+function check_critical_dependencies() {+ local critical_tools=(+ "bash:Bash shell"+ "python3:Python 3"+ "curl:Curl"+ "git:Git"+ "jq:JQ JSON processor"+ )++ local missing_critical=()+ local all_critical_ok=true++ printf "\n%b#######################################################################%b\n" "$bgreen" "$reset"+ printf "%b[%s] Checking critical dependencies%b\n\n" "$bblue" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"++ for item in "${critical_tools[@]}"; do+ local tool="${item%%:*}"+ local description="${item#*:}"++ if ! command -v "$tool" >/dev/null 2>&1; then+ printf "%b [✗] %s (%s) - MISSING%b\n" "$bred" "$description" "$tool" "$reset"+ missing_critical+=("$tool")+ all_critical_ok=false+ else+ local version=""+ case "$tool" in+ "python3")+ version=$($tool --version 2>&1 | head -n1)+ ;;+ "bash")+ version="$BASH_VERSION"+ ;;+ *)+ version=$($tool --version 2>&1 | head -n1 || echo "installed")+ ;;+ esac+ printf "%b [✓] %s (%s) - %s%b\n" "$bgreen" "$description" "$tool" "$version" "$reset"+ fi+ done++ printf "\n"++ if [[ $all_critical_ok == false ]]; then+ printf "%b[%s] ERROR: Critical dependencies missing!%b\n" "$bred" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"+ printf "%bThe following tools are required for reconFTW to function:%b\n" "$yellow" "$reset"+ for tool in "${missing_critical[@]}"; do+ printf "%b - %s%b\n" "$bred" "$tool" "$reset"+ done+ printf "\n%bPlease install these tools and try again.%b\n" "$yellow" "$reset"+ printf "%bYou can run: ./install.sh to install all dependencies.%b\n" "$yellow" "$reset"+ printf "%b#######################################################################%b\n\n" "$bgreen" "$reset"+ exit 1+ else+ printf "%b[%s] All critical dependencies are installed%b\n" "$bgreen" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"+ printf "%b#######################################################################%b\n\n" "$bgreen" "$reset"+ fi+}++###############################################################################################################+####################################### LOGGING ##################################################+###############################################################################################################++# Structured JSON logging (optional, controlled by STRUCTURED_LOGGING config)+STRUCTURED_LOGGING=${STRUCTURED_LOGGING:-false}+STRUCTURED_LOG_FILE=""++# Initialize structured logging+function log_init() {+ [[ "$STRUCTURED_LOGGING" != "true" ]] && return 0++ STRUCTURED_LOG_FILE="${dir}/.log/structured_$(date +%Y%m%d_%H%M%S).jsonl"+ mkdir -p "$(dirname "$STRUCTURED_LOG_FILE")"++ printf "%b[%s] Structured logging enabled: %s%b\n" \+ "$bgreen" "$(date +'%Y-%m-%d %H:%M:%S')" "$STRUCTURED_LOG_FILE" "$reset"+}++# Log structured JSON event+# Usage: log_json <level> <function> <message> [key1=val1] [key2=val2] ...+function log_json() {+ [[ "$STRUCTURED_LOGGING" != "true" ]] && return 0+ [[ -z "$STRUCTURED_LOG_FILE" ]] && return 0++ local level="$1"+ local function="$2"+ local message="$3"+ shift 3++ # Build JSON object+ local json_obj=$(jq -n \+ --arg ts "$(date -Iseconds)" \+ --arg lvl "$level" \+ --arg fn "$function" \+ --arg msg "$message" \+ --arg domain "${domain:-N/A}" \+ '{timestamp:$ts, level:$lvl, function:$fn, message:$msg, domain:$domain}')++ # Add extra key-value pairs if provided+ for kv in "$@"; do+ if [[ "$kv" =~ ^([^=]+)=(.+)$ ]]; then+ local key="${BASH_REMATCH[1]}"+ local val="${BASH_REMATCH[2]}"+ json_obj=$(echo "$json_obj" | jq --arg k "$key" --arg v "$val" '. + {($k): $v}')+ fi+ done++ echo "$json_obj" >>"$STRUCTURED_LOG_FILE"+}++# Convenience wrappers for different log levels+function log_info() {+ log_json "INFO" "${FUNCNAME[1]:-main}" "$@"+}++function log_warn() {+ log_json "WARN" "${FUNCNAME[1]:-main}" "$@"+}++function log_error() {+ log_json "ERROR" "${FUNCNAME[1]:-main}" "$@"+}++function log_success() {+ log_json "SUCCESS" "${FUNCNAME[1]:-main}" "$@"+}++###############################################################################################################+######################################### INCREMENTAL MODE ####################################################+###############################################################################################################++# Incremental mode - only scan new assets since last run+# This mode compares current results with previous runs and only processes new findings++INCREMENTAL_MODE=${INCREMENTAL_MODE:-false}+INCREMENTAL_DIR=".incremental"++# Initialize incremental mode structure+function incremental_init() {+ [[ "$INCREMENTAL_MODE" != "true" ]] && return 0++ mkdir -p "$INCREMENTAL_DIR"/{subdomains,webs,hosts,vulns,previous}++ printf "%b[%s] Incremental mode enabled - will only process new findings%b\n" \+ "$bgreen" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"+}++# Save current state for next incremental run+# Usage: incremental_save <type> <file>+function incremental_save() {+ [[ "$INCREMENTAL_MODE" != "true" ]] && return 0++ local type="$1"+ local file="$2"++ if [[ -s "$file" ]]; then+ cp "$file" "$INCREMENTAL_DIR/previous/${type}_$(date +%Y%m%d_%H%M%S).txt"+ cp "$file" "$INCREMENTAL_DIR/previous/${type}_latest.txt"+ printf "%b[%s] Saved %s state for incremental mode%b\n" \+ "$bgreen" "$(date +'%Y-%m-%d %H:%M:%S')" "$type" "$reset" >>"$LOGFILE"+ fi+}++# Get new items compared to previous run+# Usage: incremental_diff <type> <current_file> <output_file>+# Returns: 0 if new items found, 1 if no new items+function incremental_diff() {+ [[ "$INCREMENTAL_MODE" != "true" ]] && {+ cp "$2" "$3" 2>/dev/null+ return 0+ }++ local type="$1"+ local current_file="$2"+ local output_file="$3"+ local previous_file="$INCREMENTAL_DIR/previous/${type}_latest.txt"++ if [[ ! -f "$previous_file" ]]; then+ # First run, all items are new+ cp "$current_file" "$output_file" 2>/dev/null+ local count=$(wc -l <"$output_file" 2>/dev/null || echo 0)+ printf "%b[%s] Incremental mode: First run for %s - %d items total%b\n" \+ "$bblue" "$(date +'%Y-%m-%d %H:%M:%S')" "$type" "$count" "$reset"+ return 0+ fi++ # Compare and get only new items+ if [[ -s "$current_file" ]]; then+ comm -13 <(sort -u "$previous_file") <(sort -u "$current_file") | sed '/^$/d' >"$output_file"+ local new_count=$(wc -l <"$output_file" 2>/dev/null || echo 0)+ local total_count=$(wc -l <"$current_file" 2>/dev/null || echo 0)+ local previous_count=$(wc -l <"$previous_file" 2>/dev/null || echo 0)++ printf "%b[%s] Incremental mode %s: %d new (previous: %d, total: %d)%b\n" \+ "$bblue" "$(date +'%Y-%m-%d %H:%M:%S')" "$type" "$new_count" "$previous_count" "$total_count" "$reset"++ if [[ $new_count -eq 0 ]]; then+ return 1 # No new items+ fi+ return 0 # New items found+ else+ touch "$output_file"+ return 1+ fi+}++# Generate incremental report+function incremental_report() {+ [[ "$INCREMENTAL_MODE" != "true" ]] && return 0++ local report_file="$INCREMENTAL_DIR/incremental_report_$(date +%Y%m%d_%H%M%S).txt"++ {+ echo "==============================================="+ echo "Incremental Scan Report"+ echo "Domain: $domain"+ echo "Date: $(date +'%Y-%m-%d %H:%M:%S')"+ echo "==============================================="+ echo ""++ # Subdomain changes+ if [[ -f "$INCREMENTAL_DIR/previous/subdomains_latest.txt" ]]; then+ local new_subs=$(comm -13 <(sort -u "$INCREMENTAL_DIR/previous/subdomains_latest.txt" 2>/dev/null || touch /tmp/empty) \+ <(sort -u "subdomains/subdomains.txt" 2>/dev/null || touch /tmp/empty) | wc -l)+ echo "New Subdomains: $new_subs"+ if [[ $new_subs -gt 0 ]]; then+ echo "---"+ comm -13 <(sort -u "$INCREMENTAL_DIR/previous/subdomains_latest.txt" 2>/dev/null || touch /tmp/empty) \+ <(sort -u "subdomains/subdomains.txt" 2>/dev/null || touch /tmp/empty) | head -20+ [[ $new_subs -gt 20 ]] && echo "... and $((new_subs - 20)) more"+ echo ""+ fi+ fi++ # Web changes+ if [[ -f "$INCREMENTAL_DIR/previous/webs_latest.txt" ]]; then+ local new_webs=$(comm -13 <(sort -u "$INCREMENTAL_DIR/previous/webs_latest.txt" 2>/dev/null || touch /tmp/empty) \+ <(sort -u "webs/webs.txt" 2>/dev/null || touch /tmp/empty) | wc -l)+ echo "New Webs: $new_webs"+ if [[ $new_webs -gt 0 ]]; then+ echo "---"+ comm -13 <(sort -u "$INCREMENTAL_DIR/previous/webs_latest.txt" 2>/dev/null || touch /tmp/empty) \+ <(sort -u "webs/webs.txt" 2>/dev/null || touch /tmp/empty) | head -20+ [[ $new_webs -gt 20 ]] && echo "... and $((new_webs - 20)) more"+ echo ""+ fi+ fi++ echo "==============================================="+ echo "Full report saved to: $report_file"+ echo "==============================================="+ } | tee "$report_file"++ printf "%b[%s] Incremental report generated: %s%b\n" \+ "$bgreen" "$(date +'%Y-%m-%d %H:%M:%S')" "$report_file" "$reset"+}++# Check if incremental mode should skip heavy operations+# Usage: incremental_should_skip+# Returns: 0 to skip, 1 to continue+function incremental_should_skip() {+ [[ "$INCREMENTAL_MODE" != "true" ]] && return 1 # Don't skip++ # Check if we have new findings+ local new_subs=$(cat .tmp/subs_new_count 2>/dev/null || echo 1)+ local new_webs=$(cat .tmp/webs_new_count 2>/dev/null || echo 1)++ if [[ $new_subs -eq 0 && $new_webs -eq 0 ]]; then+ printf "%b[%s] Incremental mode: No new assets found, skipping heavy scans%b\n" \+ "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"+ return 0 # Skip+ fi++ return 1 # Don't skip+}++###############################################################################################################++function zipSnedOutputFolder {+ zip_name1=$(date +"%Y_%m_%d-%H.%M.%S")+ zip_name="${zip_name1}_${domain}.zip" 2>>"$LOGFILE" >/dev/null+ (cd "$dir" && zip -r "$zip_name" .) 2>>"$LOGFILE" >/dev/null+ echo "Sending zip file "${dir}/${zip_name}""+ if [[ -s "${dir}/$zip_name" ]]; then+ sendToNotify "$dir/$zip_name"+ rm -f "${dir}/$zip_name"+ else+ notification "No Zip file to send" warn+ fi+}++function isAsciiText {+ IS_ASCII="False"+ if [[ $(file $1 | grep -o 'ASCII text$') == "ASCII text" ]]; then+ IS_ASCII="True"+ else+ IS_ASCII="False"+ fi+}++function output() {+ mkdir -p "$dir_output"+ # Ensure both $dir and $dir_output are absolute paths+ dir="$(realpath "$dir")"+ dir_output="$(realpath "$dir_output")"++ # Prevent accidental deletion if $dir_output is a parent of $dir+ if [[ $dir == "$dir_output"* ]]; then+ echo "[!] Output directory is a parent of the working directory. Aborting to prevent data loss."+ return 1+ fi++ cp -r "$dir" "$dir_output"++ # Only delete if source and destination are clearly different and safe+ # Safety: refuse to delete outside of Recon/ directory+ if [[ "$(dirname "$dir")" != "$dir_output" ]]; then+ if [[ "$dir" == "${SCRIPTPATH}/Recon/"* ]]; then+ rm -rf -- "$dir"+ else+ echo "[!] Refusing to delete directory outside Recon/: $dir"+ return 1+ fi+ fi+}++function remove_big_files() {+ rm -rf .tmp/gotator*.txt 2>>"$LOGFILE"+ rm -rf .tmp/brute_recursive_wordlist.txt 2>>"$LOGFILE"+ rm -rf .tmp/subs_dns_tko.txt 2>>"$LOGFILE"+ rm -rf .tmp/subs_no_resolved.txt .tmp/subdomains_dns.txt .tmp/brute_dns_tko.txt .tmp/scrap_subs.txt .tmp/analytics_subs_clean.txt .tmp/gotator1.txt .tmp/gotator2.txt .tmp/passive_recursive.txt .tmp/brute_recursive_wordlist.txt .tmp/gotator1_recursive.txt .tmp/gotator2_recursive.txt 2>>"$LOGFILE"+ find .tmp -type f -size +200M -exec rm -f {} + 2>>"$LOGFILE"+}++function notification() {+ if [[ -n $1 ]] && [[ -n $2 ]]; then+ if [[ $NOTIFICATION == true ]]; then+ NOTIFY="notify -silent"+ else+ NOTIFY=""+ fi+ if [[ -z $3 ]]; then+ current_date=$(date +'%Y-%m-%d %H:%M:%S')+ else+ current_date="$3"+ fi++ case $2 in+ info)+ text="\n${bblue}[$current_date] ${1} ${reset}"+ ;;+ warn)+ text="\n${yellow}[$current_date] ${1} ${reset}"+ ;;+ error)+ text="\n${bred}[$current_date] ${1} ${reset}"+ ;;+ good)+ text="\n${bgreen}[$current_date] ${1} ${reset}"+ ;;+ esac++ # Print to terminal+ printf "${text}\n"++ # Send to notify if notifications are enabled+ if [[ -n $NOTIFY ]]; then+ # Remove color codes for the notification+ clean_text=$(printf "%b" "${text} - ${domain}" | sed 's/\x1B\[[0-9;]*[JKmsu]//g')+ printf "%s" "${clean_text}" | $NOTIFY >/dev/null 2>&1+ fi+ fi+}++function transfer {+ if [[ $# -eq 0 ]]; then+ echo "No arguments specified.\nUsage:\n transfer <file|directory>\n ... | transfer <file_name>" >&2+ return 1+ fi++ if tty -s; then+ file="$1"+ file_name=$(basename "$file")+ if [[ ! -e $file ]]; then+ echo "$file: No such file or directory" >&2+ return 1+ fi+ tar -czvf /tmp/$file_name $file >/dev/null 2>&1 && curl -s https://bashupload.com/$file.tgz --data-binary @/tmp/$file_name | grep wget+ else+ file_name=$1+ tar -czvf /tmp/$file_name $file >/dev/null 2>&1 && curl -s https://bashupload.com/$file.tgz --data-binary @/tmp/$file_name | grep wget+ fi+}++function sendToNotify {+ if [[ -z $1 ]]; then+ printf "\n${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] No file provided to send ${reset}\n"+ else+ if [[ -z $NOTIFY_CONFIG ]]; then+ NOTIFY_CONFIG=~/.config/notify/provider-config.yaml+ fi+ if [[ -n "$(find "${1}" -prune -size +8000000c)" ]]; then+ printf '%s is larger than 8MB, sending over external service\n' "${1}"+ transfer "${1}" | notify -silent+ return 0+ fi+ if grep -q '^ telegram\|^telegram\|^ telegram' $NOTIFY_CONFIG; then+ notification "[$(date +'%Y-%m-%d %H:%M:%S')] Sending ${domain} data over Telegram" info+ telegram_chat_id=$(sed -n '/^telegram:/,/^[^ ]/p' ${NOTIFY_CONFIG} | sed -n 's/^[ ]*telegram_chat_id:[ ]*"\([^"]*\)".*/\1/p')+ telegram_key=$(sed -n '/^telegram:/,/^[^ ]/p' ${NOTIFY_CONFIG} | sed -n 's/^[ ]*telegram_api_key:[ ]*"\([^"]*\)".*/\1/p')+ curl -F "chat_id=${telegram_chat_id}" -F "document=@${1}" https://api.telegram.org/bot${telegram_key}/sendDocument 2>>"$LOGFILE" >/dev/null+ fi+ if grep -q '^ discord\|^discord\|^ discord' $NOTIFY_CONFIG; then+ notification "[$(date +'%Y-%m-%d %H:%M:%S')] Sending ${domain} data over Discord" info+ discord_url=$(sed -n '/^discord:/,/^[^ ]/p' ${NOTIFY_CONFIG} | sed -n 's/^[ ]*discord_webhook_url:[ ]*"\([^"]*\)".*/\1/p')+ curl -v -i -H "Accept: application/json" -H "Content-Type: multipart/form-data" -X POST -F 'payload_json={"username": "test", "content": "hello"}' -F file1=@${1} $discord_url 2>>"$LOGFILE" >/dev/null+ fi+ if [[ -n $slack_channel ]] && [[ -n $slack_auth ]]; then+ notification "[$(date +'%Y-%m-%d %H:%M:%S')] Sending ${domain} data over Slack" info+ curl -F file=@${1} -F "initial_comment=reconftw zip file" -F channels=${slack_channel} -H "Authorization: Bearer ${slack_auth}" https://slack.com/api/files.upload 2>>"$LOGFILE" >/dev/null+ fi+ fi+}++function start_func() {+ printf "${bgreen}#######################################################################"+ notification "${2}" info+ echo "[$current_date] Start function: ${1} " >>"${LOGFILE}"+ start=$(date +%s)+}++function end_func() {+ touch "$called_fn_dir/.${2}"+ end=$(date +%s)+ getElapsedTime "$start" "$end"+ # Record timing for performance summary+ record_func_timing "${2}" "$((end - start))"+ notification "${2} Finished in ${runtime}" info+ echo "[$current_date] End function: ${2} " >>"${LOGFILE}"+ printf "${bblue}[$current_date] ${1} ${reset}\n"+ printf "${bgreen}#######################################################################${reset}\n"+}++function start_subfunc() {+ notification " ${2}" info+ echo "[$current_date] Start subfunction: ${1} " >>"${LOGFILE}"+ start_sub=$(date +%s)+}++function end_subfunc() {+ touch "$called_fn_dir/.${2}"+ end_sub=$(date +%s)+ getElapsedTime "$start_sub" "$end_sub"+ notification " ${1} in ${runtime}" good+ echo "[$current_date] End subfunction: ${1} " >>"${LOGFILE}"+}++function check_inscope() {+ cat "$1" | inscope >"${1}_tmp" && cp "${1}_tmp" "$1" && rm -f "${1}_tmp"+}++function maybe_update_nuclei() {+ # Update nuclei templates once per run per target directory+ mkdir -p .tmp+ local stamp_file=".tmp/.nuclei_updated"+ if [[ ! -f $stamp_file ]]; then+ if [[ -n ${NUCLEI_TEMPLATES_PATH-} ]]; then+ nuclei -update-templates -update-template-dir "${NUCLEI_TEMPLATES_PATH}" 2>>"$LOGFILE" >/dev/null || true # non-fatal: template update failure shouldn't block scan+ else+ nuclei -update 2>>"$LOGFILE" >/dev/null || true # non-fatal: template update failure shouldn't block scan+ fi+ touch "$stamp_file"+ fi+}++# Plugin framework+PLUGINS_LOADED=false+function plugins_load() {+ local plugdir="${SCRIPTPATH}/plugins"+ if [[ -d $plugdir ]]; then+ for f in "$plugdir"/*.sh; do+ [[ -f $f ]] && source "$f" || true+ done+ fi+ PLUGINS_LOADED=true+}++function plugins_emit() {+ local event="$1"+ shift || true+ if declare -F reconftw_plugins >/dev/null 2>&1; then+ reconftw_plugins "$event" "$@" || true+ fi+}++# Asset store+function append_asset() {+ # Usage: append_asset type key value extras...+ [[ $ASSET_STORE != true ]] && return 0+ local type="$1"+ shift+ local key="$1"+ shift+ local val="$1"+ shift+ local now+ now=$(date +'%Y-%m-%d %H:%M:%S')+ mkdir -p .tmp+ printf '{"type":"%s","%s":"%s","ts":"%s","source":"%s"}\n' \+ "$type" "$key" "${val//\"/\\\"}" "$now" "${FUNCNAME[1]}" >>assets.jsonl 2>/dev/null+}++function append_assets_from_file() {+ # Usage: append_assets_from_file type key file+ [[ $ASSET_STORE != true ]] && return 0+ local type="$1"+ local key="$2"+ local file="$3"+ [[ ! -s $file ]] && return 0+ while IFS= read -r line; do+ [[ -z $line ]] && continue+ append_asset "$type" "$key" "$line"+ done <"$file"+}++# Chunk helper+function process_in_chunks() {+ # process_in_chunks <file> <chunk_size> <command with _chunk_ placeholder>+ local infile="$1"+ local chunksize="$2"+ shift 2+ [[ ! -s $infile ]] && return 0+ local lines+ lines=$(wc -l <"$infile" 2>/dev/null || echo 0)+ if [[ $lines -le $chunksize ]]; then+ bash -lc "$*"+ return $?+ fi+ mkdir -p .tmp/chunks+ split -l "$chunksize" -d "$infile" .tmp/chunks/part_+ for part in .tmp/chunks/part_*; do+ local cmd+ cmd="${*//_chunk_/\"$part\"}"+ bash -lc "$cmd"+ done+}++###############################################################################################################+########################################## HEALTH CHECK #######################################################+###############################################################################################################++# Performance timing storage+declare -A FUNC_TIMINGS 2>/dev/null || true++function record_func_timing() {+ # Usage: record_func_timing function_name duration_seconds+ local fn="$1"+ local dur="$2"+ FUNC_TIMINGS["$fn"]=$dur 2>/dev/null || true+}++function print_timing_summary() {+ # Print sorted timing summary of all recorded functions+ if [[ ${#FUNC_TIMINGS[@]} -eq 0 ]] 2>/dev/null; then+ return 0+ fi++ printf "\n%b#######################################################################%b\n" "$bgreen" "$reset"+ printf "%b[%s] Performance Timing Summary%b\n\n" "$bblue" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"++ local total=0+ local fn dur++ # Collect and sort by duration (descending)+ for fn in "${!FUNC_TIMINGS[@]}"; do+ dur=${FUNC_TIMINGS[$fn]}+ total=$((total + dur))+ printf "%s %s\n" "$dur" "$fn"+ done | sort -rn | while read -r dur fn; do+ local pct=0+ if [[ $total -gt 0 ]]; then+ pct=$((dur * 100 / total))+ fi+ local mins=$((dur / 60))+ local secs=$((dur % 60))+ printf " %-35s %3dm %02ds (%2d%%)\n" "$fn" "$mins" "$secs" "$pct"+ done++ local total_mins=$((total / 60))+ local total_secs=$((total % 60))+ printf "\n %-35s %3dm %02ds\n" "TOTAL" "$total_mins" "$total_secs"+ printf "%b#######################################################################%b\n\n" "$bgreen" "$reset"+}++function health_check() {+ local failures=0+ local warnings=0++ printf "\n%b#######################################################################%b\n" "$bgreen" "$reset"+ printf "%b[%s] reconFTW Health Check%b\n\n" "$bblue" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"++ # 1. Check critical tools+ printf "%b[*] Checking critical tools...%b\n" "$yellow" "$reset"+ local critical_tools=("bash" "python3" "curl" "git" "jq")+ for tool in "${critical_tools[@]}"; do+ if command -v "$tool" >/dev/null 2>&1; then+ printf " %b[OK]%b %s\n" "$bgreen" "$reset" "$tool"+ else+ printf " %b[FAIL]%b %s not found\n" "$bred" "$reset" "$tool"+ ((failures++))+ fi+ done++ # 2. Check key recon tools+ printf "\n%b[*] Checking recon tools...%b\n" "$yellow" "$reset"+ local recon_tools=("subfinder" "httpx" "nuclei" "naabu" "ffuf" "dnsx" "anew" "notify")+ for tool in "${recon_tools[@]}"; do+ if command -v "$tool" >/dev/null 2>&1; then+ printf " %b[OK]%b %s\n" "$bgreen" "$reset" "$tool"+ else+ printf " %b[WARN]%b %s not found\n" "$byellow" "$reset" "$tool"+ ((warnings++))+ fi+ done++ # 3. Check network connectivity+ printf "\n%b[*] Checking network connectivity...%b\n" "$yellow" "$reset"+ if curl -s --connect-timeout 5 -o /dev/null -w "%{http_code}" "https://www.google.com" | grep -q "200\|301\|302"; then+ printf " %b[OK]%b Internet connectivity\n" "$bgreen" "$reset"+ else+ printf " %b[WARN]%b No internet connectivity\n" "$byellow" "$reset"+ ((warnings++))+ fi++ # 4. Check disk space+ printf "\n%b[*] Checking disk space...%b\n" "$yellow" "$reset"+ local avail_gb+ avail_gb=$(df -BG . 2>/dev/null | awk 'NR==2 {gsub(/G/,"",$4); print $4}' || df -g . 2>/dev/null | awk 'NR==2 {print $4}' || echo "0")+ if [[ ${avail_gb:-0} -ge 5 ]]; then+ printf " %b[OK]%b %s GB available\n" "$bgreen" "$reset" "$avail_gb"+ elif [[ ${avail_gb:-0} -ge 1 ]]; then+ printf " %b[WARN]%b Only %s GB available (recommend 5+ GB)\n" "$byellow" "$reset" "$avail_gb"+ ((warnings++))+ else+ printf " %b[FAIL]%b Less than 1 GB available\n" "$bred" "$reset"+ ((failures++))+ fi++ # 5. Check resolver files+ printf "\n%b[*] Checking resolver files...%b\n" "$yellow" "$reset"+ local resolvers_path="${resolvers:-${SCRIPTPATH}/resolvers.txt}"+ if [[ -s "$resolvers_path" ]]; then+ local count+ count=$(wc -l <"$resolvers_path")+ printf " %b[OK]%b Resolvers file: %s (%s entries)\n" "$bgreen" "$reset" "$resolvers_path" "$count"+ else+ printf " %b[WARN]%b Resolvers file not found or empty: %s\n" "$byellow" "$reset" "$resolvers_path"+ ((warnings++))+ fi++ # 6. Check API key status+ printf "\n%b[*] Checking API keys...%b\n" "$yellow" "$reset"+ local -A api_keys=(+ ["SHODAN_API_KEY"]="${SHODAN_API_KEY:-}"+ ["WHOISXML_API"]="${WHOISXML_API:-}"+ ["GITHUB_TOKEN"]="${GITHUB_TOKEN:-}"+ ["VIRUSTOTAL_API_KEY"]="${VIRUSTOTAL_API_KEY:-}"+ )+ for key_name in "${!api_keys[@]}"; do+ if [[ -n "${api_keys[$key_name]}" ]]; then+ printf " %b[OK]%b %s configured\n" "$bgreen" "$reset" "$key_name"+ else+ printf " %b[INFO]%b %s not set\n" "$bblue" "$reset" "$key_name"+ fi+ done++ # Summary+ printf "\n%b#######################################################################%b\n" "$bgreen" "$reset"+ if [[ $failures -gt 0 ]]; then+ printf "%b[%s] Health check: %d FAILURES, %d warnings%b\n" \+ "$bred" "$(date +'%Y-%m-%d %H:%M:%S')" "$failures" "$warnings" "$reset"+ elif [[ $warnings -gt 0 ]]; then+ printf "%b[%s] Health check: PASSED with %d warnings%b\n" \+ "$byellow" "$(date +'%Y-%m-%d %H:%M:%S')" "$warnings" "$reset"+ else+ printf "%b[%s] Health check: ALL PASSED%b\n" \+ "$bgreen" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"+ fi+ printf "%b#######################################################################%b\n\n" "$bgreen" "$reset"++ return $failures+}diff --git a/modules/modes.sh b/modules/modes.shnew file mode 100644index 0000000..0f54bea--- /dev/null+++ b/modules/modes.sh@@ -0,0 +1,908 @@+#!/bin/bash+# reconFTW - Mode/workflow orchestration module+# Contains: start, end, build_hotlist, passive, osint, all, vulns,+# multi_osint, recon, multi_recon, multi_custom,+# subs_menu, webs_menu, zen_menu, help+# This file is sourced by reconftw.sh - do not execute directly+[[ -z "${SCRIPTPATH:-}" ]] && {+ echo "Error: This module must be sourced by reconftw.sh" >&2+ exit 1+}++function start() {++ global_start=$(date +%s)++ # Validate configuration before starting+ validate_config || exit $?++ # Check available disk space before starting (require at least 5GB by default)+ local required_space_gb="${MIN_DISK_SPACE_GB:-5}"+ if ! check_disk_space "$required_space_gb" "."; then+ printf "%b[%s] WARNING: Low disk space detected. Continuing anyway...%b\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"+ # Not exiting, just warning - user can set MIN_DISK_SPACE_GB=0 to disable+ fi++ # Raise ulimit for long-running VPS jobs (fail-soft on failure)+ if [[ ${RAISE_ULIMIT:-true} == "true" ]]; then+ ULIMIT_TARGET=${ULIMIT_TARGET:-65535}+ ulimit -n "$ULIMIT_TARGET" 2>>"${LOGFILE:-/dev/null}" >/dev/null || true+ fi++ # Log version and key flags+ {+ printf "[%s] reconFTW version: %s\n" "$(date +'%Y-%m-%d %H:%M:%S')" "$reconftw_version"+ printf "[%s] Flags: OSINT=%s SUBDOMAINS_GENERAL=%s VULNS_GENERAL=%s DEEP=%s\n" \+ "$(date +'%Y-%m-%d %H:%M:%S')" "$OSINT" "$SUBDOMAINS_GENERAL" "$VULNS_GENERAL" "$DEEP"+ } >>"${LOGFILE:-/dev/null}"+ if [[ $upgrade_before_running == true ]]; then+ ${SCRIPTPATH}/install.sh --tools+ fi+ tools_installed++ # Initialize incremental mode if enabled+ incremental_init++ #[[ -n "$domain" ]] && ipcidr_target $domain++ if [[ -z $domain ]]; then+ if [[ -n $list ]]; then+ if [[ -z $domain ]]; then+ domain="Multi"+ dir="${SCRIPTPATH}/Recon/$domain"+ called_fn_dir="$dir"/.called_fn+ fi+ if [[ $list == /* ]]; then+ mkdir -p "$dir/webs"+ cp "$list" "$dir/webs/webs.txt"+ else+ mkdir -p "$dir/webs"+ cp "${SCRIPTPATH}/${list}" "$dir/webs/webs.txt"+ fi+ fi+ else+ dir="${SCRIPTPATH}/Recon/$domain"+ called_fn_dir="$dir"/.called_fn+ fi++ if [[ -z $domain ]]; then+ notification "${bred} No domain or list provided ${reset}\n\n" error+ exit+ fi++ if [[ ! -d $called_fn_dir ]]; then+ mkdir -p "$called_fn_dir"+ fi+ mkdir -p "$dir"+ cd "$dir" || {+ echo "Failed to cd directory in ${FUNCNAME[0]} @ line ${LINENO}"+ exit 1+ }+ if [[ $AXIOM == true ]]; then+ if [[ -n $domain ]]; then+ echo "$domain" | anew -q target.txt+ list="${dir}/target.txt"+ fi+ fi+ mkdir -p {.log,.tmp,webs,hosts,vulns,osint,screenshots,subdomains}+ chmod 700 .tmp 2>/dev/null || true++ # Load plugins and emit start event+ plugins_load+ plugins_emit start "$domain" "$dir"++ NOW=$(date +"%F")+ NOWT=$(date +"%T")+ LOGFILE="${dir}/.log/${NOW}_${NOWT}.txt"+ touch ".log/${NOW}_${NOWT}.txt"+ echo "[$(date +'%Y-%m-%d %H:%M:%S')] Start ${NOW} ${NOWT}" >"${LOGFILE}"+ enable_command_trace++ # Rotate old log files+ rotate_logs "${dir}/.log" "${MAX_LOG_FILES:-10}" "${MAX_LOG_AGE_DAYS:-30}"++ # Trap for cleanup on unexpected exit+ trap 'cleanup_on_exit' INT TERM++ # Initialize structured logging if enabled+ log_init++ # Initialize cache for wordlists/resolvers+ cache_init++ # init time saved estimator+ TIME_SAVED_EST=0++ # Non-fatal error trap: log and continue+ trap 'rc=$?; ts=$(date +"%Y-%m-%d %H:%M:%S"); cmd=${BASH_COMMAND}; loc_fn=${FUNCNAME[0]:-main}; loc_ln=${BASH_LINENO[0]:-0}; msg="[$ts] ERR($rc) @ ${loc_fn}:${loc_ln} :: ${cmd}"; if [[ -n "${LOGFILE:-}" ]]; then echo "$msg" >>"$LOGFILE"; else echo "$msg" >&2; fi' ERR++ printf "\n"+ printf "${bred}[$(date +'%Y-%m-%d %H:%M:%S')] Target: ${domain}\n\n"+ printf "%b[LEGAL]%b Authorized testing only. By running this scan you confirm you have explicit permission for the specified targets and will comply with all applicable laws and program rules. Unauthorized use is prohibited.\n\n" "$yellow" "$reset"+}++function end() {++ if [[ $opt_ai ]]; then+ notification "[$(date +'%Y-%m-%d %H:%M:%S')] Sending ${domain} data to AI" info+ mkdir -p "${dir}/ai_result" 2>>"${LOGFILE}"+ "${tools}/reconftw_ai/venv/bin/python3" "${tools}/reconftw_ai/reconftw_ai.py" --results-dir ${dir} --output-dir ${dir}/ai_result --model ${AI_MODEL} --output-format ${AI_REPORT_TYPE} --report-type ${AI_REPORT_PROFILE} --prompts-file ${tools}/reconftw_ai/prompts.json 2>>"${LOGFILE}" >/dev/null+ fi++ find "$dir" -type f -empty -print | grep -v '.called_fn' | grep -v '.log' | grep -v '.tmp' | xargs -r rm -f -- 2>>"$LOGFILE" >/dev/null+ find "$dir" -type d -empty -print -delete 2>>"$LOGFILE" >/dev/null++ echo "[$(date +'%Y-%m-%d %H:%M:%S')] End" >>"${LOGFILE}"++ if [[ $PRESERVE != true ]]; then+ find "$dir" -type f -empty | grep -v "called_fn" | xargs -r rm -f -- 2>>"$LOGFILE" >/dev/null+ find "$dir" -type d -empty | grep -v "called_fn" | xargs -r rm -rf -- 2>>"$LOGFILE" >/dev/null+ fi++ if [[ $REMOVETMP == true ]]; then+ rm -rf -- "$dir/.tmp"+ fi++ if [[ $REMOVELOG == true ]]; then+ rm -rf -- "$dir/.log"+ fi++ if [[ $FARADAY == true ]]; then+ if ! faraday-cli status 2>>"$LOGFILE" >/dev/null; then+ printf "%b[!] Faraday server is not running. Skipping Faraday integration.%b\n" "$bred" "$reset"+ else+ if [[ -s ".tmp/tko_json.txt" ]]; then+ faraday-cli tool report -w $FARADAY_WORKSPACE --plugin-id nuclei .tmp/tko_json.txt 2>>"$LOGFILE" >/dev/null+ fi+ if [[ -s "hosts/portscan_active.xml" ]]; then+ faraday-cli tool report -w $FARADAY_WORKSPACE --plugin-id nmap hosts/portscan_active.xml 2>>"$LOGFILE" >/dev/null+ fi+ if [[ -s ".tmp/fuzzparams_json.txt" ]]; then+ faraday-cli tool report -w $FARADAY_WORKSPACE --plugin-id nuclei .tmp/fuzzparams_json.txt 2>>"$LOGFILE" >/dev/null+ fi+ if [[ -s "nuclei_output/info_json.txt" ]]; then+ faraday-cli tool report -w $FARADAY_WORKSPACE --plugin-id nuclei nuclei_output/info_json.txt 2>>"$LOGFILE" >/dev/null+ fi+ if [[ -s "nuclei_output/low_json.txt" ]]; then+ faraday-cli tool report -w $FARADAY_WORKSPACE --plugin-id nuclei nuclei_output/low_json.txt 2>>"$LOGFILE" >/dev/null+ fi+ if [[ -s "nuclei_output/medium_json.txt" ]]; then+ faraday-cli tool report -w $FARADAY_WORKSPACE --plugin-id nuclei nuclei_output/medium_json.txt 2>>"$LOGFILE" >/dev/null+ fi+ if [[ -s "nuclei_output/high_json.txt" ]]; then+ faraday-cli tool report -w $FARADAY_WORKSPACE --plugin-id nuclei nuclei_output/high_json.txt 2>>"$LOGFILE" >/dev/null+ fi+ if [[ -s "nuclei_output/critical_json.txt" ]]; then+ faraday-cli tool report -w $FARADAY_WORKSPACE --plugin-id nuclei nuclei_output/critical_json.txt 2>>"$LOGFILE" >/dev/null+ fi+ notification "Information sent to Faraday" "good"+ fi+ fi++ if [[ -n $dir_output ]]; then+ output+ finaldir=$dir_output+ else+ finaldir=$dir+ fi+ #Zip the output folder and send it via tg/discord/slack+ if [[ $SENDZIPNOTIFY == true ]]; then+ zipSnedOutputFolder+ fi++ # Screenshot diffs (hashing)+ if [[ -d screenshots ]]; then+ if [[ -f screenshots/hashes.txt ]]; then mv screenshots/hashes.txt screenshots/hashes_prev.txt 2>>"$LOGFILE" || true; fi+ find screenshots -type f -name '*.png' -print0 | xargs -0 -I{} sh -c 'sha256sum "$1" 2>/dev/null || shasum -a 256 "$1"' -- {} | sed 's| ./||' >screenshots/hashes.txt 2>>"$LOGFILE" || true+ if [[ -f screenshots/hashes_prev.txt ]]; then+ comm -3 <(cut -d' ' -f1,2 screenshots/hashes_prev.txt | sort) <(cut -d' ' -f1,2 screenshots/hashes.txt | sort) | awk '{print $2}' | sed '/^$/d' >screenshots/diff_changed.txt 2>>"$LOGFILE" || true+ fi+ fi++ # Emit end plugin event+ plugins_emit end "$domain" "$dir"++ # Build hotlist (risk summary)+ build_hotlist || true++ # Incremental mode report+ incremental_report++ global_end=$(date +%s)+ getElapsedTime $global_start $global_end+ printf "${bgreen}#######################################################################${reset}\n"+ notification "Finished Recon on: ${domain} under ${finaldir} in: ${runtime}" good "$(date +'%Y-%m-%d %H:%M:%S')"+ [ "$SOFT_NOTIFICATION" = true ] && echo "[$(date +'%Y-%m-%d %H:%M:%S')] Finished Recon on: ${domain} under ${finaldir} in: ${runtime}" | notify -silent+ printf "${bgreen}#######################################################################${reset}\n"++ # Print performance timing summary+ print_timing_summary++}++function build_hotlist() {+ mkdir -p .tmp+ declare -A score+ # Nuclei high/critical+ for f in nuclei_output/high_json.txt nuclei_output/critical_json.txt; do+ [[ -s $f ]] || continue+ jq -r '.["matched-at"] // .host' "$f" 2>/dev/null | while read -r h; do+ [[ -z $h ]] && continue+ score["$h"]=$((${score["$h"]:-0} + 10))+ done+ done+ # Takeovers+ [[ -s webs/takeover.txt ]] && while read -r h; do score["$h"]=$((${score["$h"]:-0} + 8)); done <webs/takeover.txt+ # Secrets+ for s in js/js_secrets.txt js/js_secrets_jsmap.txt js/js_secrets_jsmap_jsluice.txt; do+ [[ -s $s ]] || continue+ awk '{print $1}' "$s" | while read -r h; do score["$h"]=$((${score["$h"]:-0} + 6)); done+ done+ # Real IPs via favicon+ if [[ -s hosts/favicontest.txt ]]; then+ while read -r ip; do+ score["$ip"]=$((${score["$ip"]:-0} + 4))+ done <hosts/favicontest.txt+ fi+ # New assets bonus+ for p in .tmp/subs_new_only.txt webs/url_extract.txt; do+ [[ -s $p ]] || continue+ while read -r l; do+ host=$(echo "$l" | unfurl -u domains 2>/dev/null)+ [[ -z $host ]] && continue+ score["$host"]=$((${score["$host"]:-0} + 2))+ done <"$p"+ done+ # Emit hotlist sorted+ {+ for k in "${!score[@]}"; do printf "%s %s\n" "${score[$k]}" "$k"; done | sort -nr | head -n "${HOTLIST_TOP:-50}"+ } >hotlist.txt+ [[ -s hotlist.txt ]] && notification "Hotlist ready (top ${HOTLIST_TOP:-50})" info+}++###############################################################################################################+########################################### MODES & MENUS #####################################################+###############################################################################################################++function passive() {+ start+ domain_info+ ip_info+ emails+ google_dorks+ #github_dorks+ github_repos+ metadata+ apileaks+ third_party_misconfigs+ SUBNOERROR=false+ SUBANALYTICS=false+ SUBBRUTE=false+ SUBSCRAPING=false+ SUBPERMUTE=false+ SUBREGEXPERMUTE=false+ SUB_RECURSIVE_BRUTE=false+ WEBPROBESIMPLE=false+ if [[ $AXIOM == true ]]; then+ axiom_launch+ axiom_selected+ fi++ subdomains_full+ remove_big_files+ favicon+ cdnprovider+ PORTSCAN_ACTIVE=false+ portscan+ geo_info++ if [[ $AXIOM == true ]]; then+ axiom_shutdown+ fi++ end+}++function all() {+ start+ recon+ vulns+ end+}++function osint() {+ domain_info+ ip_info+ emails+ google_dorks+ #github_dorks+ github_repos+ metadata+ apileaks+ third_party_misconfigs+ zonetransfer+ favicon+ mail_hygiene+ cloud_enum_scan+}++function vulns() {+ if [[ $VULNS_GENERAL == true ]]; then+ cors+ open_redirect+ ssrf_checks+ crlf_checks+ lfi+ ssti+ sqli+ xss+ command_injection+ prototype_pollution+ smuggling+ webcache+ spraying+ brokenLinks+ fuzzparams+ 4xxbypass+ test_ssl+ fi+}++function multi_osint() {++ global_start=$(date +%s)++ #[[ -n "$domain" ]] && ipcidr_target $domain++ if [[ -s "$list" ]]; then+ sed_i 's/\r$//' "$list"+ else+ notification "Target list not provided" error+ exit+ fi++ workdir="${SCRIPTPATH}/Recon/${multi}"+ mkdir -p "$workdir" || {+ echo "Failed to create directory '$workdir' in ${FUNCNAME[0]} @ line ${LINENO}"+ exit 1+ }+ cd "$workdir" || {+ echo "Failed to cd directory '$workdir' in ${FUNCNAME[0]} @ line ${LINENO}"+ exit 1+ }+ mkdir -p {.log,.tmp,webs,hosts,vulns,osint,screenshots,subdomains}++ NOW=$(date +"%F")+ NOWT=$(date +"%T")+ LOGFILE="${workdir}/.log/${NOW}_${NOWT}.txt"+ touch ".log/${NOW}_${NOWT}.txt"+ echo "[$(date +'%Y-%m-%d %H:%M:%S')] Start ${NOW} ${NOWT}" >"${LOGFILE}"+ enable_command_trace++ while IFS= read -r domain; do+ [[ -z "$domain" ]] && continue+ dir="$workdir/targets/$domain"+ called_fn_dir="$dir/.called_fn"+ mkdir -p "$dir"+ cd "$dir" || {+ echo "Failed to cd directory '$dir' in ${FUNCNAME[0]} @ line ${LINENO}"+ exit 1+ }+ mkdir -p {.log,.tmp,webs,hosts,vulns,osint,screenshots,subdomains}+ NOW=$(date +"%F")+ NOWT=$(date +"%T")+ LOGFILE="${dir}/.log/${NOW}_${NOWT}.txt"+ touch ".log/${NOW}_${NOWT}.txt"+ echo "[$(date +'%Y-%m-%d %H:%M:%S')] Start ${NOW} ${NOWT}" >"${LOGFILE}"+ domain_info+ ip_info+ emails+ google_dorks+ #github_dorks+ github_repos+ metadata+ apileaks+ third_party_misconfigs+ zonetransfer+ favicon+ done <"$list"+ cd "$workdir" || {+ echo "Failed to cd directory '$workdir' in ${FUNCNAME[0]} @ line ${LINENO}"+ exit 1+ }+ dir=$workdir+ domain=$multi+ end+}++function recon() {+ domain_info+ ip_info+ emails+ google_dorks+ #github_dorks+ github_repos+ metadata+ apileaks+ third_party_misconfigs+ zonetransfer+ favicon++ if [[ $AXIOM == true ]]; then+ axiom_launch+ axiom_selected+ fi++ subdomains_full+ webprobe_full+ subtakeover+ remove_big_files+ s3buckets+ cloud_extra_providers+ screenshot+ # virtualhosts+ cdnprovider+ portscan+ geo_info+ # Quick-rescan gating+ subs_new=$(cat .tmp/subs_new_count 2>/dev/null || echo 1)+ webs_new=$(cat .tmp/webs_new_count 2>/dev/null || echo 1)+ if [[ $QUICK_RESCAN == true && $subs_new -eq 0 && $webs_new -eq 0 ]]; then+ notification "Quick rescan: no new subs/webs; skipping heavy web stages" info+ # estimate time saved for skipped modules+ TIME_SAVED_EST=$((${TIME_SAVED_EST:-0} + \+ ${TIME_EST_WAF:-0} + ${TIME_EST_NUCLEI:-600} + ${TIME_EST_API:-300} + ${TIME_EST_GQL:-180} + \+ ${TIME_EST_FUZZ:-900} + ${TIME_EST_IIS:-60} + ${TIME_EST_URLCHECKS:-300} + ${TIME_EST_JSCHECKS:-300} + \+ ${TIME_EST_PARAM:-240} + ${TIME_EST_GRPC:-120}))+ else+ waf_checks+ nuclei_check+ graphql_scan+ fuzz+ iishortname+ urlchecks+ jschecks+ websocket_checks+ param_discovery+ grpc_reflection+ fi++ if [[ $AXIOM == true ]]; then+ axiom_shutdown+ fi++ cms_scanner+ url_gf+ wordlist_gen+ wordlist_gen_roboxtractor+ password_dict+ url_ext+}++function multi_recon() {++ [ "$SOFT_NOTIFICATION" = true ] && echo "$(date +'%Y-%m-%d %H:%M:%S') Recon successfully started on ${multi}" | notify -silent++ global_start=$(date +%s)++ #[[ -n "$domain" ]] && ipcidr_target $domain++ if [[ -s "$list" ]]; then+ sed_i 's/\r$//' "$list"+ mapfile -t targets <"$list"+ else+ notification "Target list not provided" error+ exit+ fi++ workdir="${SCRIPTPATH}/Recon/${multi}"+ mkdir -p "$workdir" || {+ echo "Failed to create directory '$workdir' in ${FUNCNAME[0]} @ line ${LINENO}"+ exit 1+ }+ cd "$workdir" || {+ echo "Failed to cd directory '$workdir' in ${FUNCNAME[0]} @ line ${LINENO}"+ exit 1+ }++ mkdir -p {.log,.tmp,webs,hosts,vulns,osint,screenshots,subdomains}+ NOW=$(date +"%F")+ NOWT=$(date +"%T")+ LOGFILE="${workdir}/.log/${NOW}_${NOWT}.txt"+ touch ".log/${NOW}_${NOWT}.txt"+ echo "[$(date +'%Y-%m-%d %H:%M:%S')] Start ${NOW} ${NOWT}" >"${LOGFILE}"++ [ -n "$flist" ] && LISTTOTAL=$(wc -l <"$flist")++ for domain in "${targets[@]}"; do+ [[ -z "$domain" ]] && continue+ dir="$workdir/targets/$domain"+ called_fn_dir="$dir/.called_fn"++ # Ensure directories exist+ mkdir -p "$dir" || {+ echo "Failed to create directory '$dir' in ${FUNCNAME[0]} @ line ${LINENO}"+ exit 1+ }+ mkdir -p "$called_fn_dir" || {+ echo "Failed to create directory '$called_fn_dir' in ${FUNCNAME[0]} @ line ${LINENO}"+ exit 1+ }++ cd "$dir" || {+ echo "Failed to cd to directory '$dir' in ${FUNCNAME[0]} @ line ${LINENO}"+ exit 1+ }++ mkdir -p {.log,.tmp,webs,hosts,vulns,osint,screenshots,subdomains}++ NOW=$(date +"%F")+ NOWT=$(date +"%T")+ LOGFILE="${dir}/.log/${NOW}_${NOWT}.txt"++ # Ensure the .log directory exists before touching the file+ mkdir -p .log++ touch "$LOGFILE" || {+ echo "Failed to create log file: $LOGFILE"+ exit 1+ }+ echo "[$(date +'%Y-%m-%d %H:%M:%S')] Start ${NOW} ${NOWT}" >"$LOGFILE"+ enable_command_trace+ loopstart=$(date +%s)++ domain_info+ ip_info+ emails+ google_dorks+ #github_dorks+ github_repos+ metadata+ apileaks+ third_party_misconfigs+ zonetransfer+ favicon+ currently=$(date +"%H:%M:%S")+ loopend=$(date +%s)+ getElapsedTime "$loopstart" "$loopend"+ printf "${bgreen}#######################################################################${reset}\n"+ printf "${bgreen}[$(date +'%Y-%m-%d %H:%M:%S')] $domain finished 1st loop in ${runtime} $currently ${reset}\n"+ if [[ -n $flist ]]; then+ POSINLIST=$(grep -nrE "^${domain}$" "$flist" | cut -f1 -d':')+ printf "\n${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] $domain is $POSINLIST of $LISTTOTAL${reset}\n"+ fi+ printf "${bgreen}#######################################################################${reset}\n"+ done+ cd "$workdir" || {+ echo "Failed to cd directory '$workdir' in ${FUNCNAME[0]} @ line ${LINENO}"+ exit 1+ }++ if [[ $AXIOM == true ]]; then+ axiom_launch+ axiom_selected+ fi++ for domain in "${targets[@]}"; do+ [[ -z "$domain" ]] && continue+ loopstart=$(date +%s)+ dir="$workdir/targets/$domain"+ called_fn_dir="$dir/.called_fn"+ cd "$dir" || {+ echo "Failed to cd directory '$dir' in ${FUNCNAME[0]} @ line ${LINENO}"+ exit 1+ }+ subdomains_full+ webprobe_full+ subtakeover+ remove_big_files+ screenshot+ # virtualhosts+ cdnprovider+ portscan+ geo_info+ currently=$(date +"%H:%M:%S")+ loopend=$(date +%s)+ getElapsedTime "$loopstart" "$loopend"+ printf "${bgreen}#######################################################################${reset}\n"+ printf "${bgreen}[$(date +'%Y-%m-%d %H:%M:%S')] $domain finished 2nd loop in ${runtime} $currently ${reset}\n"+ if [[ -n $flist ]]; then+ POSINLIST=$(grep -nrE "^${domain}$" "$flist" | cut -f1 -d':')+ printf "\n${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] $domain is $POSINLIST of $LISTTOTAL${reset}\n"+ fi+ printf "${bgreen}#######################################################################${reset}\n"+ done+ cd "$workdir" || {+ echo "Failed to cd directory '$workdir' in ${FUNCNAME[0]} @ line ${LINENO}"+ exit 1+ }++ notification "############################# Total data ############################" info+ NUMOFLINES_pwndb_total=$(find . -type f -name 'passwords.txt' -exec cat {} + | anew osint/passwords.txt | sed '/^$/d' | wc -l)+ NUMOFLINES_subs_total=$(find . -type f -name 'subdomains.txt' -exec cat {} + | anew subdomains/subdomains.txt | sed '/^$/d' | wc -l)+ NUMOFLINES_subtko_total=$(find . -type f -name 'takeover.txt' -exec cat {} + | anew webs/takeover.txt | sed '/^$/d' | wc -l)+ NUMOFLINES_webs_total=$(find . -type f -name 'webs.txt' -exec cat {} + | anew webs/webs.txt | sed '/^$/d' | wc -l)+ NUMOFLINES_webs_total_uncommon=$(find . -type f -name 'webs_uncommon_ports.txt' -exec cat {} + | anew webs/webs_uncommon_ports.txt | sed '/^$/d' | wc -l)+ NUMOFLINES_ips_total=$(find . -type f -name 'ips.txt' -exec cat {} + | anew hosts/ips.txt | sed '/^$/d' | wc -l)+ NUMOFLINES_cloudsprov_total=$(find . -type f -name 'cdn_providers.txt' -exec cat {} + | anew hosts/cdn_providers.txt | sed '/^$/d' | wc -l)+ find . -type f -name 'portscan_active.gnmap' -exec cat {} + | tee hosts/portscan_active.gnmap 2>>"$LOGFILE" >/dev/null+ find . -type f -name 'portscan_passive.txt' -exec cat {} + | tee hosts/portscan_passive.txt 2>&1 >>"$LOGFILE" >/dev/null++ notification "- ${NUMOFLINES_pwndb_total} total creds leaked" good+ notification "- ${NUMOFLINES_subs_total} total subdomains" good+ notification "- ${NUMOFLINES_subtko_total} total probably subdomain takeovers" good+ notification "- ${NUMOFLINES_webs_total} total websites" good+ notification "- ${NUMOFLINES_webs_total_uncommon} total websites on uncommon ports" good+ notification "- ${NUMOFLINES_ips_total} total ips" good+ notification "- ${NUMOFLINES_cloudsprov_total} total IPs belongs to cloud" good+ s3buckets+ waf_checks+ nuclei_check+ for domain in "${targets[@]}"; do+ [[ -z "$domain" ]] && continue+ loopstart=$(date +%s)+ dir="$workdir/targets/$domain"+ called_fn_dir="$dir/.called_fn"+ cd "$dir" || {+ echo "Failed to cd directory '$dir' in ${FUNCNAME[0]} @ line ${LINENO}"+ exit 1+ }+ loopstart=$(date +%s)+ fuzz+ iishortname+ urlchecks+ jschecks+ currently=$(date +"%H:%M:%S")+ loopend=$(date +%s)+ getElapsedTime "$loopstart" "$loopend"+ printf "${bgreen}#######################################################################${reset}\n"+ printf "${bgreen}[$(date +'%Y-%m-%d %H:%M:%S')] $domain finished 3rd loop in ${runtime} $currently ${reset}\n"+ if [[ -n $flist ]]; then+ POSINLIST=$(grep -nrE "^${domain}$" "$flist" | cut -f1 -d':')+ printf "\n${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] $domain is $POSINLIST of $LISTTOTAL${reset}\n"+ fi+ printf "${bgreen}#######################################################################${reset}\n"+ done++ if [[ $AXIOM == true ]]; then+ axiom_shutdown+ fi++ for domain in "${targets[@]}"; do+ [[ -z "$domain" ]] && continue+ loopstart=$(date +%s)+ dir="$workdir/targets/$domain"+ called_fn_dir="$dir/.called_fn"+ cd "$dir" || {+ echo "Failed to cd directory '$dir' in ${FUNCNAME[0]} @ line ${LINENO}"+ exit 1+ }+ cms_scanner+ url_gf+ wordlist_gen+ wordlist_gen_roboxtractor+ password_dict+ url_ext+ currently=$(date +"%H:%M:%S")+ loopend=$(date +%s)+ getElapsedTime "$loopstart" "$loopend"+ printf "${bgreen}#######################################################################${reset}\n"+ printf "${bgreen}[$(date +'%Y-%m-%d %H:%M:%S')] $domain finished final loop in ${runtime} $currently ${reset}\n"+ if [[ -n $flist ]]; then+ POSINLIST=$(grep -nrE "^${domain}$" "$flist" | cut -f1 -d':')+ printf "\n${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] $domain is $POSINLIST of $LISTTOTAL${reset}\n"+ fi+ printf "${bgreen}#######################################################################${reset}\n"+ done+ cd "$workdir" || {+ echo "Failed to cd directory '$workdir' in ${FUNCNAME[0]} @ line ${LINENO}"+ exit 1+ }+ dir=$workdir+ domain=$multi+ end+ [ "$SOFT_NOTIFICATION" = true ] && echo "$(date +'%Y-%m-%d %H:%M:%S') Finished Recon on: ${multi} in ${runtime}" | notify -silent+}++function multi_custom() {++ global_start=$(date +%s)++ if [[ -s "$list" ]]; then+ sed_i 's/\r$//' "$list"+ else+ notification "Target list not provided" error+ exit+ fi++ dir="${SCRIPTPATH}/Recon/${multi}"+ if [[ -z "$multi" || "$dir" != "${SCRIPTPATH}/Recon/"* ]]; then+ echo "[!] Refusing to remove '$dir' -- safety check failed"+ return 1+ fi+ rm -rf -- "$dir"+ mkdir -p "$dir" || {+ echo "Failed to create directory '$dir' in ${FUNCNAME[0]} @ line ${LINENO}"+ exit 1+ }+ cd "$dir" || {+ echo "Failed to cd directory '$dir' in ${FUNCNAME[0]} @ line ${LINENO}"+ exit 1+ }++ mkdir -p {.called_fn,.log}+ called_fn_dir="$dir/.called_fn"+ NOW=$(date +"%F")+ NOWT=$(date +"%T")+ LOGFILE="${dir}/.log/${NOW}_${NOWT}.txt"+ touch ".log/${NOW}_${NOWT}.txt"+ echo "[$(date +'%Y-%m-%d %H:%M:%S')] Start ${NOW} ${NOWT}" >"${LOGFILE}"+ enable_command_trace++ [ -n "$flist" ] && entries=$(wc -l <"$flist")++ if [[ $AXIOM == true ]]; then+ axiom_launch+ axiom_selected+ fi++ custom_function_list=$(echo "$custom_function" | tr ',' '\n')+ func_total=$(echo "$custom_function_list" | wc -l)++ func_count=0+ domain=$(cat "$flist")+ for custom_f in $custom_function_list; do+ ((func_count = func_count + 1))++ loopstart=$(date +%s)++ $custom_f++ currently=$(date +"%H:%M:%S")+ loopend=$(date +%s)+ getElapsedTime "$loopstart" "$loopend"+ printf "${bgreen}#######################################################################${reset}\n"+ printf "${bgreen}[$(date +'%Y-%m-%d %H:%M:%S')] Finished $custom_f ($func_count/$func_total) for $entries entries in ${runtime} $currently ${reset}\n"+ printf "${bgreen}#######################################################################${reset}\n"+ done++ if [[ $AXIOM == true ]]; then+ axiom_shutdown+ fi++ end+}++function subs_menu() {+ start++ if [[ $AXIOM == true ]]; then+ axiom_launch+ axiom_selected+ fi++ subdomains_full+ webprobe_full+ subtakeover+ remove_big_files+ screenshot+ # virtualhosts+ zonetransfer+ s3buckets++ if [[ $AXIOM == true ]]; then+ axiom_shutdown+ fi++ end+}++function webs_menu() {+ subtakeover+ remove_big_files+ screenshot+ # virtualhosts+ waf_checks+ nuclei_check+ graphql_scan+ fuzz+ cms_scanner+ iishortname+ urlchecks+ jschecks+ websocket_checks+ url_gf+ wordlist_gen+ wordlist_gen_roboxtractor+ password_dict+ url_ext+ param_discovery+ grpc_reflection+ vulns+ end+}++function zen_menu() {+ start+ if [[ $AXIOM == true ]]; then+ axiom_launch+ axiom_selected+ fi+ subdomains_full+ webprobe_full+ subtakeover+ remove_big_files+ s3buckets+ screenshot+ # virtualhosts+ cdnprovider+ waf_checks+ nuclei_check+ graphql_scan+ fuzz+ iishortname+ if [[ $AXIOM == true ]]; then+ axiom_shutdown+ fi+ cms_scanner+ end+}++function help() {+ pt_header "Usage"+ printf "\n Usage: $0 [-d domain.tld] [-m name] [-l list.txt] [-x oos.txt] [-i in.txt] "+ printf "\n [-r] [-s] [-p] [-a] [-w] [-n] [-z] [-c] [-y] [-h] [-f] [--ai] [--deep] [-o OUTPUT]\n\n"+ printf " ${bblue}TARGET OPTIONS${reset}\n"+ printf " -d domain.tld Target domain\n"+ printf " -m company Target company name\n"+ printf " -l list.txt Targets list (One on each line)\n"+ printf " -x oos.txt Excludes subdomains list (Out Of Scope)\n"+ printf " -i in.txt Includes subdomains list\n"+ printf " \n"+ printf " ${bblue}MODE OPTIONS${reset}\n"+ printf " -r, --recon Recon - Performs full recon process (without attacks)\n"+ printf " -s, --subdomains Subdomains - Performs Subdomain Enumeration, Web probing and check for sub-tko\n"+ printf " -p, --passive Passive - Performs only passive steps\n"+ printf " -a, --all All - Performs all checks and active exploitations\n"+ printf " -w, --web Web - Performs web checks from list of subdomains\n"+ printf " -n, --osint OSINT - Checks for public intel data\n"+ printf " -z, --zen Zen - Performs a recon process covering the basics and some vulns\n"+ printf " -c, --custom Custom - Launches specific function against target, u need to know the function name first\n"+ printf " -y, --ai AI - Analyzes ReconFTW results using a local LLM\n"+ printf " -h Help - Show help section\n"+ printf " \n"+ printf " ${bblue}GENERAL OPTIONS${reset}\n"+ printf " --deep Deep scan (Enable some slow options for deeper scan)\n"+ printf " -f config_file Alternate reconftw.cfg file\n"+ printf " -o output/path Define output folder\n"+ printf " -v, --vps Axiom distributed VPS\n"+ printf " -q Rate limit in requests per second\n"+ printf " --check-tools Exit if one of the tools is missing\n"+ printf " --health-check Run system health check and exit\n"+ printf " --quick-rescan Skip heavy steps if no new subs/webs this run\n"+ printf " --incremental Only scan new findings since last run\n"+ printf " --adaptive-rate Automatically adjust rate limits on errors (429/503)\n"+ printf " --dry-run Show what would be executed without running commands\n"+ printf " \n"+ printf " ${bblue}USAGE EXAMPLES${reset}\n"+ printf " ${byellow}Perform full recon (without attacks):${reset}\n"+ printf " ./reconftw.sh -d example.com -r\n"+ printf " \n"+ printf " ${byellow}Perform subdomain enumeration on multiple targets:${reset}\n"+ printf " ./reconftw.sh -l targets.txt -s\n"+ printf " \n"+ printf " ${byellow}Perform Web based scanning on a subdomains list:${reset}\n"+ printf " ./reconftw.sh -d example.com -l targets.txt -w\n"+ printf " \n"+ printf " ${byellow}Multidomain recon:${reset}\n"+ printf " ./reconftw.sh -m company -l domainlist.txt -r\n"+ printf " \n"+ printf " ${byellow}Perform full recon (with active attacks) along Out-Of-Scope subdomains list:${reset}\n"+ printf " ./reconftw.sh -d example.com -x out.txt -a\n"+ printf " \n"+ printf " ${byellow}Analyze ReconFTW results with AI:${reset}\n"+ printf " ./reconftw.sh -d example.com -r --ai\n"+ printf " \n"+ printf " ${byellow}Run custom function:${reset}\n"+ printf " ./reconftw.sh -d example.com -c nuclei_check \n"+}diff --git a/modules/osint.sh b/modules/osint.shnew file mode 100644index 0000000..769647d--- /dev/null+++ b/modules/osint.sh@@ -0,0 +1,502 @@+#!/bin/bash+# reconFTW - OSINT module+# Contains: google_dorks, github_dorks, github_repos, metadata, apileaks,+# emails, domain_info, third_party_misconfigs, spoof, mail_hygiene,+# cloud_enum_scan, ip_info+# This file is sourced by reconftw.sh - do not execute directly+[[ -z "${SCRIPTPATH:-}" ]] && {+ echo "Error: This module must be sourced by reconftw.sh" >&2+ exit 1+}++#####################################################################cc##########################################+################################################### OSINT #####################################################+###############################################################################################################++function google_dorks() {+ mkdir -p osint++ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $GOOGLE_DORKS == true ]] && [[ $OSINT == true ]]; then+ start_func "${FUNCNAME[0]}" "Running: Google Dorks in process"++ "${tools}/dorks_hunter/venv/bin/python3" "${tools}/dorks_hunter/dorks_hunter.py" -d "$domain" -o "osint/dorks.txt"+ end_func "Results are saved in $domain/osint/dorks.txt" "${FUNCNAME[0]}"+ else+ if [[ $GOOGLE_DORKS == false ]] || [[ $OSINT == false ]]; then+ printf "\n%b[%s] %s skipped due to mode or configuration settings.%b\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"+ else+ printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s %b\n\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$called_fn_dir" "${FUNCNAME[0]}" "$reset"+ fi+ fi+}++function github_dorks() {+ mkdir -p osint++ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $GITHUB_DORKS == true ]] && [[ $OSINT == true ]]; then+ start_func "${FUNCNAME[0]}" "Running: Github Dorks in process"++ if [[ -s $GITHUB_TOKENS ]]; then+ if [[ $DEEP == true ]]; then+ if ! gitdorks_go -gd "${tools}/gitdorks_go/Dorks/medium_dorks.txt" -nws 20 -target "$domain" -tf "$GITHUB_TOKENS" -ew 3 | anew -q osint/gitdorks.txt; then+ printf "%b[!] gitdorks_go command failed.%b\n" "$bred" "$reset"+ return 1+ fi+ else+ if ! gitdorks_go -gd "${tools}/gitdorks_go/Dorks/smalldorks.txt" -nws 20 -target "$domain" -tf "$GITHUB_TOKENS" -ew 3 | anew -q osint/gitdorks.txt; then+ printf "%b[!] gitdorks_go command failed.%b\n" "$bred" "$reset"+ return 1+ fi+ fi+ else+ printf "\n%b[%s] Required file %s does not exist or is empty.%b\n" "$bred" "$(date +'%Y-%m-%d %H:%M:%S')" "$GITHUB_TOKENS" "$reset"+ return 1+ fi+ end_func "Results are saved in $domain/osint/gitdorks.txt" "${FUNCNAME[0]}"+ else+ if [[ $GITHUB_DORKS == false ]] || [[ $OSINT == false ]]; then+ printf "\n%b[%s] %s skipped due to mode or configuration settings.%b\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"+ else+ printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s %b\n\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$called_fn_dir" "${FUNCNAME[0]}" "$reset"+ fi+ fi+}++function github_repos() {+ mkdir -p osint++ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $GITHUB_REPOS == true ]] && [[ $OSINT == true ]]; then+ start_func "${FUNCNAME[0]}" "Github Repos analysis in process"++ if [[ -s $GITHUB_TOKENS ]]; then+ GH_TOKEN=$(head -n 1 "$GITHUB_TOKENS")+ echo "$domain" | unfurl format %r >.tmp/company_name.txt++ if ! enumerepo -token-string "$GH_TOKEN" -usernames .tmp/company_name.txt -o .tmp/company_repos.txt 2>>"$LOGFILE" >/dev/null; then+ printf "%b[!] enumerepo command failed.%b\n" "$bred" "$reset"+ fi++ if [[ -s ".tmp/company_repos.txt" ]]; then+ if ! jq -r '.[].repos[]|.url' <.tmp/company_repos.txt >.tmp/company_repos_url.txt 2>>"$LOGFILE"; then+ printf "%b[!] jq command failed.%b\n" "$bred" "$reset"+ fi+ fi++ mkdir -p .tmp/github_repos 2>>"$LOGFILE"+ mkdir -p .tmp/github 2>>"$LOGFILE"++ if [[ -s ".tmp/company_repos_url.txt" ]]; then+ if ! interlace -tL .tmp/company_repos_url.txt -threads "$INTERLACE_THREADS" -c "git clone _target_ .tmp/github_repos/_cleantarget_" 2>>"$LOGFILE" >/dev/null; then+ printf "%b[!] interlace git clone command failed.%b\n" "$bred" "$reset"+ return 1+ fi+ else+ end_func "Results are saved in $domain/osint/github_company_secrets.json" "${FUNCNAME[0]}"+ return 1+ fi++ if [[ -d ".tmp/github_repos/" ]]; then+ ls .tmp/github_repos >.tmp/github_repos_folders.txt+ else+ end_func "Results are saved in $domain/osint/github_company_secrets.json" "${FUNCNAME[0]}"+ return 1+ fi++ if [[ -s ".tmp/github_repos_folders.txt" ]]; then+ if ! interlace -tL .tmp/github_repos_folders.txt -threads "$INTERLACE_THREADS" -c "gitleaks detect --source .tmp/github_repos/_target_ --no-banner --no-color -r .tmp/github/gh_secret_cleantarget_.json" 2>>"$LOGFILE" >/dev/null; then+ printf "%b[!] interlace gitleaks command failed.%b\n" "$bred" "$reset"+ end_func "Results are saved in $domain/osint/github_company_secrets.json" "${FUNCNAME[0]}"+ return 1+ fi+ else+ end_func "Results are saved in $domain/osint/github_company_secrets.json" "${FUNCNAME[0]}"+ return 1+ fi++ if [[ -s ".tmp/company_repos_url.txt" ]]; then+ if ! interlace -tL .tmp/company_repos_url.txt -threads "$INTERLACE_THREADS" -c "trufflehog git _target_ -j 2>&1 | jq -c > _output_/_cleantarget_" -o .tmp/github/ 2>>"$LOGFILE" >/dev/null; then+ printf "%b[!] interlace trufflehog command failed.%b\n" "$bred" "$reset"+ return 1+ fi+ fi++ if [[ -d ".tmp/github/" ]]; then+ if ! cat .tmp/github/* 2>/dev/null | jq -c | jq -r >"osint/github_company_secrets.json" 2>>"$LOGFILE"; then+ printf "%b[!] Error combining results.%b\n" "$bred" "$reset"+ return 1+ fi+ else+ end_func "Results are saved in $domain/osint/github_company_secrets.json" "${FUNCNAME[0]}"+ return 1+ fi++ end_func "Results are saved in $domain/osint/github_company_secrets.json" "${FUNCNAME[0]}"+ else+ printf "\n%s[%s] Required file %s does not exist or is empty.%b\n" "$bred" "$(date +'%Y-%m-%d %H:%M:%S')" "$GITHUB_TOKENS" "$reset"+ return 1+ fi+ else+ if [[ $GITHUB_REPOS == false ]] || [[ $OSINT == false ]]; then+ printf "\n%b[%s] %s skipped due to mode or configuration settings.%b\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"+ else+ printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s %b\n\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$called_fn_dir" "${FUNCNAME[0]}" "$reset"+ fi+ fi+}++function metadata() {+ mkdir -p osint++ # Check if the function should run+ if { [[ ! -f "${called_fn_dir}/.${FUNCNAME[0]}" ]] || [[ ${DIFF} == true ]]; } && [[ ${METADATA} == true ]] && [[ ${OSINT} == true ]] && ! [[ ${domain} =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then+ start_func "${FUNCNAME[0]}" "Scanning metadata in public files"++ mkdir -p ".tmp/metagoofil_${domain}/" 2>>"${LOGFILE}"+ pushd "${tools}/metagoofil" >/dev/null || {+ printf "%b[!] Failed to change directory to %s in %s at line %s.%b\n" "${bred}" "${tools}/metagoofil" "${FUNCNAME[0]}" "${LINENO}" "${reset}"+ return 1+ }+ "${tools}/metagoofil/venv/bin/python3" "${tools}/metagoofil/metagoofil.py" -d "${domain}" -t pdf,docx,xlsx -l 10 -w -o "${dir}/.tmp/metagoofil_${domain}/" 2>>"${LOGFILE}" >/dev/null+ popd >/dev/null || {+ printf "%b[!] Failed to return to the previous directory in %s at line %s.%b\n" "${bred}" "${FUNCNAME[0]}" "${LINENO}" "${reset}"+ return 1+ }++ exiftool -r .tmp/metagoofil_${domain}/* 2>>"${LOGFILE}" | tee /dev/null | egrep -i "Author|Creator|Email|Producer|Template" | sort -u | anew -q "osint/metadata_results.txt"++ end_func "Results are saved in ${domain}/osint/metadata_results.txt" "${FUNCNAME[0]}"+ else+ if [[ ${METADATA} == false ]] || [[ ${OSINT} == false ]]; then+ printf "\n%b[%s] %s skipped due to mode or configuration settings.%b\n" "${yellow}" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "${reset}"+ elif [[ ${domain} =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then+ return+ else+ printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s %b\n\n" "${yellow}" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "${called_fn_dir}" "${FUNCNAME[0]}" "${reset}"+ fi+ fi+}++function apileaks() {+ mkdir -p osint++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } \+ && [[ $API_LEAKS == true ]] && [[ $OSINT == true ]] \+ && ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then++ start_func "${FUNCNAME[0]}" "Scanning for leaks in public API directories"++ # Run porch-pirate and handle errors+ porch-pirate -s "$domain" -l 25 --dump 2>>"$LOGFILE" >"${dir}/osint/postman_leaks.txt"++ # Change directory to SwaggerSpy+ if ! pushd "${tools}/SwaggerSpy" >/dev/null; then+ printf "%b[!] Failed to change directory to %s in %s at line %s.%b\n" "$bred" "${tools}/SwaggerSpy" "${FUNCNAME[0]}" "$LINENO" "$reset"+ return 1+ fi++ # Run swaggerspy.py and handle errors+ local swag_cmd=("${tools}/SwaggerSpy/venv/bin/python3" "swaggerspy.py" "$domain")+ [[ -n ${TIMEOUT_CMD:-} ]] && swag_cmd=("$TIMEOUT_CMD" 2m "${swag_cmd[@]}")+ local swagger_rc=0+ {+ "${swag_cmd[@]}" 2>>"$LOGFILE" | grep -i "[*]\|URL" >"${dir}/osint/swagger_leaks.txt"+ swagger_rc=${PIPESTATUS[0]:-0} # ignore grep exit code (no matches is fine)+ } || true+ if ((swagger_rc != 0)); then+ printf "%b[%s] SwaggerSpy failed (exit %s), continuing without swagger results.%b\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "$swagger_rc" "$reset" | tee -a "$LOGFILE" >/dev/null+ fi++ # Return to the previous directory+ if ! popd >/dev/null; then+ printf "%b[!] Failed to return to the previous directory in %s at line %s.%b\n" "$bred" "${FUNCNAME[0]}" "$LINENO" "$reset"+ return 1+ fi++ # Analyze leaks with trufflehog+ if [[ -s "${dir}/osint/postman_leaks.txt" ]]; then+ run_command trufflehog filesystem "${dir}/osint/postman_leaks.txt" -j 2>/dev/null | jq -c | anew -q "${dir}/osint/postman_leaks_trufflehog.json"+ fi++ if [[ -s "${dir}/osint/swagger_leaks.txt" ]]; then+ run_command trufflehog filesystem "${dir}/osint/swagger_leaks.txt" -j 2>/dev/null | jq -c | anew -q "${dir}/osint/swagger_leaks_trufflehog.json"+ fi+ end_func "Results are saved in $domain/osint/[postman_leaks_trufflehog.json, swagger_leaks_trufflehog.json]" "${FUNCNAME[0]}"+ else+ if [[ $API_LEAKS == false ]] || [[ $OSINT == false ]]; then+ printf "\n%b[%s] %s skipped due to mode or configuration settings.%b\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"+ elif [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then+ return+ else+ printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s %b\n\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$called_fn_dir" "${FUNCNAME[0]}" "$reset"+ fi+ fi+}++function emails() {+ mkdir -p .tmp osint++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } \+ && [[ $EMAILS == true ]] && [[ $OSINT == true ]] \+ && ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then++ start_func "${FUNCNAME[0]}" "Searching for emails/users/passwords leaks"++ PYTHONWARNINGS=ignore "${tools}/EmailHarvester/venv/bin/python3" "${tools}/EmailHarvester/EmailHarvester.py" -d ${domain} -e all -l 20 2>>"$LOGFILE" | anew -q .tmp/EmailHarvester.txt || true++ # Process emailfinder results+ if [[ -s ".tmp/EmailHarvester.txt" ]]; then+ grep "@" .tmp/EmailHarvester.txt | anew -q osint/emails.txt || true+ fi++ # Change directory to LeakSearch+ if ! pushd "${tools}/LeakSearch" >/dev/null; then+ printf "%b[!] Failed to change directory to %s in %s at line %s.%b\n" "$bred" "${tools}/LeakSearch" "${FUNCNAME[0]}" "$LINENO" "$reset"+ return 1+ fi++ # Run LeakSearch.py and handle errors+ "${tools}/LeakSearch/venv/bin/python3" LeakSearch.py -k "$domain" -o "${dir}/.tmp/passwords.txt" 1>>"$LOGFILE"++ # Return to the previous directory+ if ! popd >/dev/null; then+ printf "%b[!] Failed to return to the previous directory in %s at line %s.%b\n" "$bred" "${FUNCNAME[0]}" "$LINENO" "$reset"+ return 1+ fi++ # Process passwords.txt+ if [[ -s "${dir}/.tmp/passwords.txt" ]]; then+ anew -q osint/passwords.txt <"${dir}/.tmp/passwords.txt"+ fi++ end_func "Results are saved in $domain/osint/emails.txt and passwords.txt" "${FUNCNAME[0]}"+ else+ if [[ $EMAILS == false ]] || [[ $OSINT == false ]]; then+ printf "\n%b[%s] %s skipped due to mode or configuration settings.%b\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"+ elif [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then+ return+ else+ printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s%b\n\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$called_fn_dir" "/.${FUNCNAME[0]}" "$reset"+ fi+ fi+}++function domain_info() {++ mkdir -p osint++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } \+ && [[ $DOMAIN_INFO == true ]] && [[ $OSINT == true ]] \+ && ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then++ start_func "${FUNCNAME[0]}" "Searching domain info (whois, registrant name/email domains)"++ # Run whois command and check for errors+ whois "$domain" >"osint/domain_info_general.txt"+ "${tools}/msftrecon/venv/bin/python3" "${tools}/msftrecon/msftrecon/msftrecon.py" -d ${domain} 2>>"$LOGFILE" >osint/azure_tenant_domains.txt || true++ company_name=$(unfurl format %r <<<"$domain")+ "${tools}/Scopify/venv/bin/python3" "${tools}/Scopify/scopify.py" -c ${company_name} >osint/scopify.txt++ end_func "Results are saved in ${domain}/osint/domain_info_[general/azure_tenant_domains].txt" "${FUNCNAME[0]}"++ else+ if [[ $DOMAIN_INFO == false ]] || [[ $OSINT == false ]]; then+ printf "\n%b[%s] %s skipped due to mode or configuration settings.%b\n" \+ "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"+ elif [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then+ return+ else+ printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s%b\n\n" \+ "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$called_fn_dir" "/.${FUNCNAME[0]}" "$reset"+ fi+ fi+}++function third_party_misconfigs() {+ mkdir -p osint++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } \+ && [[ $THIRD_PARTIES == true ]] && [[ $OSINT == true ]] \+ && ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then++ start_func "${FUNCNAME[0]}" "Searching for third parties misconfigurations"++ # Extract company name from domain+ company_name=$(unfurl format %r <<<"$domain")++ # Change directory to Spoofy tool+ if ! pushd "${tools}/misconfig-mapper" >/dev/null; then+ printf "%b[!] Failed to change directory to %s in %s at line %s.%b\n" \+ "$bred" "${tools}/misconfig-mapper" "${FUNCNAME[0]}" "$LINENO" "$reset"+ return 1+ fi++ # Run misconfig-mapper and handle errors+ misconfig-mapper -target "$company_name" -service "*" 2>&1 | grep -v "\-\]" | grep -v "Failed" >"${dir}/osint/3rdparts_misconfigurations.txt"++ # Return to the previous directory+ if ! popd >/dev/null; then+ printf "%b[!] Failed to return to previous directory in %s at line %s.%b\n" \+ "$bred" "${FUNCNAME[0]}" "$LINENO" "$reset"+ return 1+ fi++ end_func "Results are saved in $domain/osint/3rdparts_misconfigurations.txt" "${FUNCNAME[0]}"++ else+ if [[ $THIRD_PARTIES == false ]] || [[ $OSINT == false ]]; then+ printf "\n%b[%s] %s skipped due to mode or configuration settings.%b\n" \+ "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"+ elif [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then+ return+ else+ printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s%b\n\n" \+ "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$called_fn_dir" "/.${FUNCNAME[0]}" "$reset"+ fi+ fi+}++function spoof() {+ mkdir -p osint++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } \+ && [[ $SPOOF == true ]] && [[ $OSINT == true ]] \+ && ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then++ start_func "${FUNCNAME[0]}" "Searching for spoofable domains"++ # Change directory to Spoofy tool+ if ! pushd "${tools}/Spoofy" >/dev/null; then+ printf "%b[!] Failed to change directory to %s in %s at line %s.%b\n" \+ "$bred" "${tools}/Spoofy" "${FUNCNAME[0]}" "$LINENO" "$reset"+ return 1+ fi++ # Run spoofy.py and handle errors+ "${tools}/Spoofy/venv/bin/python3" spoofy.py -d "$domain" >"${dir}/osint/spoof.txt"++ # Return to the previous directory+ if ! popd >/dev/null; then+ printf "%b[!] Failed to return to previous directory in %s at line %s.%b\n" \+ "$bred" "${FUNCNAME[0]}" "$LINENO" "$reset"+ return 1+ fi++ end_func "Results are saved in $domain/osint/spoof.txt" "${FUNCNAME[0]}"++ else+ if [[ $SPOOF == false ]] || [[ $OSINT == false ]]; then+ printf "\n%b[%s] %s skipped due to mode or configuration settings.%b\n" \+ "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"+ elif [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then+ return+ else+ printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s%b\n\n" \+ "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$called_fn_dir" "/.${FUNCNAME[0]}" "$reset"+ fi+ fi+}++function mail_hygiene() {+ mkdir -p osint++ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } \+ && [[ $MAIL_HYGIENE == true ]] && [[ $OSINT == true ]] \+ && ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then++ start_func "${FUNCNAME[0]}" "Mail hygiene (SPF/DMARC)"+ {+ printf "Domain: %s\n" "$domain"+ printf "\nTXT records:\n"+ dig +short TXT "$domain" | sed 's/^/ /'+ printf "\nDMARC record:\n"+ dig +short TXT "_dmarc.$domain" | sed 's/^/ /'+ } >"osint/mail_hygiene.txt" 2>>"$LOGFILE"+ end_func "Results are saved in $domain/osint/mail_hygiene.txt" "${FUNCNAME[0]}"+ else+ if [[ $MAIL_HYGIENE == false ]] || [[ $OSINT == false ]]; then+ printf "\n%b[%s] %s skipped due to mode or configuration settings.%b\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"+ elif [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then+ return+ else+ printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s %b\n\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$called_fn_dir" "${FUNCNAME[0]}" "$reset"+ fi+ fi+}++function cloud_enum_scan() {+ mkdir -p osint++ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } \+ && [[ $CLOUD_ENUM == true ]] && [[ $OSINT == true ]] \+ && ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then++ start_func "${FUNCNAME[0]}" "Cloud storage enumeration"+ company_name=$(unfurl format %r <<<"$domain")+ cloud_enum -k "$company_name" -k "$domain" -k "${domain%%.*}" 2>>"$LOGFILE" | anew -q osint/cloud_enum.txt+ end_func "Results are saved in $domain/osint/cloud_enum.txt" "${FUNCNAME[0]}"+ else+ if [[ $CLOUD_ENUM == false ]] || [[ $OSINT == false ]]; then+ printf "\n%b[%s] %s skipped due to mode or configuration settings.%b\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"+ elif [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then+ return+ else+ printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s %b\n\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$called_fn_dir" "${FUNCNAME[0]}" "$reset"+ fi+ fi+}++function ip_info() {++ mkdir -p osint++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } \+ && [[ $IP_INFO == true ]] && [[ $OSINT == true ]] \+ && [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then++ start_func "${FUNCNAME[0]}" "Searching IP info"++ if [[ -n $WHOISXML_API ]]; then++ # Reverse IP lookup+ curl -s "https://reverse-ip.whoisxmlapi.com/api/v1?apiKey=${WHOISXML_API}&ip=${domain}" \+ | jq -r '.result[].name' 2>>"$LOGFILE" \+ | sed -e "s/$/ ${domain}/" \+ | anew -q "osint/ip_${domain}_relations.txt"++ # WHOIS lookup+ curl -s "https://www.whoisxmlapi.com/whoisserver/WhoisService?apiKey=${WHOISXML_API}&domainName=${domain}&outputFormat=json&da=2®istryRawText=1®istrarRawText=1&ignoreRawTexts=1" \+ | jq 2>>"$LOGFILE" \+ | anew -q "osint/ip_${domain}_whois.txt"++ # IP Geolocation+ curl -s "https://ip-geolocation.whoisxmlapi.com/api/v1?apiKey=${WHOISXML_API}&ipAddress=${domain}" \+ | jq -r '.ip,.location' 2>>"$LOGFILE" \+ | anew -q "osint/ip_${domain}_location.txt"++ end_func "Results are saved in ${domain}/osint/ip_[domain_relations|whois|location].txt" "${FUNCNAME[0]}"++ else+ printf "\n%s[%s] WHOISXML_API variable is not defined. Skipping function.%b\n" \+ "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"+ fi++ else+ if [[ $IP_INFO == false ]] || [[ $OSINT == false ]]; then+ printf "\n%b[%s] %s skipped due to mode or configuration settings.%b\n" \+ "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"+ elif ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then+ return+ else+ printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s%b\n\n" \+ "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$called_fn_dir" "/.${FUNCNAME[0]}" "$reset"+ fi+ fi++}diff --git a/modules/subdomains.sh b/modules/subdomains.shnew file mode 100644index 0000000..76c7a23--- /dev/null+++ b/modules/subdomains.sh@@ -0,0 +1,1949 @@+#!/bin/bash+# reconFTW - Subdomain enumeration module+# Contains: subdomains_full, sub_passive, sub_crt, sub_active, sub_tls,+# sub_noerror, sub_dns, sub_brute, sub_scraping, sub_analytics,+# sub_permut, sub_regex_permut, sub_ia_permut, sub_recursive_passive,+# sub_recursive_brute, subtakeover, zonetransfer, s3buckets,+# cloud_extra_providers, geo_info+# This file is sourced by reconftw.sh - do not execute directly+[[ -z "${SCRIPTPATH:-}" ]] && {+ echo "Error: This module must be sourced by reconftw.sh" >&2+ exit 1+}++###############################################################################################################+############################################### SUBDOMAINS ####################################################+###############################################################################################################++function subdomains_full() {++ # Create necessary directories+ if ! mkdir -p .tmp webs subdomains; then+ printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"+ return 1+ fi++ NUMOFLINES_subs="0"+ NUMOFLINES_probed="0"++ printf "%b#######################################################################%b\n\n" "$bgreen" "$reset"++ # Check if domain is an IP address+ if [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then+ printf "%b[%s] Scanning IP %s%b\n\n" "$bblue" "$(date +'%Y-%m-%d %H:%M:%S')" "$domain" "$reset"+ else+ printf "%b[%s] Subdomain Enumeration %s%b\n\n" "$bblue" "$(date +'%Y-%m-%d %H:%M:%S')" "$domain" "$reset"+ fi++ # Backup existing subdomains and webs+ if [[ -s "subdomains/subdomains.txt" ]]; then+ if ! cp "subdomains/subdomains.txt" ".tmp/subdomains_old.txt"; then+ printf "%b[!] Failed to backup subdomains.txt.%b\n" "$bred" "$reset"+ fi+ fi++ if [[ -s "webs/webs.txt" ]]; then+ if ! cp "webs/webs.txt" ".tmp/probed_old.txt"; then+ printf "%b[!] Failed to backup webs.txt.%b\n" "$bred" "$reset"+ fi+ fi++ # Update resolvers if necessary+ if { [[ ! -f "$called_fn_dir/.sub_active" ]] || [[ ! -f "$called_fn_dir/.sub_brute" ]] || [[ ! -f "$called_fn_dir/.sub_permut" ]] || [[ ! -f "$called_fn_dir/.sub_recursive_brute" ]]; } || [[ $DIFF == true ]]; then+ if ! resolvers_update; then+ printf "%b[!] Failed to update resolvers.%b\n" "$bred" "$reset"+ return 1+ fi+ fi++ # Add in-scope subdomains+ if [[ -s $inScope_file ]]; then+ if ! cat "$inScope_file" | anew -q subdomains/subdomains.txt; then+ printf "%b[!] Failed to update subdomains.txt with in-scope domains.%b\n" "$bred" "$reset"+ fi+ fi++ # Subdomain enumeration+ if [[ ! $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]] && [[ $SUBDOMAINS_GENERAL == true ]]; then+ sub_passive+ sub_crt+ sub_active+ sub_tls+ sub_noerror+ sub_brute+ sub_permut+ sub_regex_permut+ sub_ia_permut+ sub_recursive_passive+ sub_recursive_brute+ sub_dns+ sub_scraping+ sub_analytics+ else+ notification "IP/CIDR detected, subdomains search skipped" "info"+ if ! printf "%b\n" "$domain" | anew -q subdomains/subdomains.txt; then+ printf "%b[!] Failed to add domain to subdomains.txt.%b\n" "$bred" "$reset"+ fi+ fi++ # Web probing+ if ! webprobe_simple; then+ printf "%b[!] webprobe_simple function failed.%b\n" "$bred" "$reset"+ fi++ # Process subdomains+ if [[ -s "subdomains/subdomains.txt" ]]; then+ if [[ -s $outOfScope_file ]]; then+ if ! deleteOutScoped "$outOfScope_file" "subdomains/subdomains.txt"; then+ printf "%b[!] Failed to remove out-of-scope subdomains.%b\n" "$bred" "$reset"+ fi+ fi+ if ! NUMOFLINES_subs=$(cat "subdomains/subdomains.txt" 2>>"$LOGFILE" | anew ".tmp/subdomains_old.txt" | sed '/^$/d' | wc -l); then+ NUMOFLINES_subs="0"+ fi+ fi++ # Process webs+ if [[ -s "webs/webs.txt" ]]; then+ if [[ -s $outOfScope_file ]]; then+ if ! deleteOutScoped "$outOfScope_file" "webs/webs.txt"; then+ printf "%b[!] Failed to remove out-of-scope webs.%b\n" "$bred" "$reset"+ fi+ fi+ if ! NUMOFLINES_probed=$(cat "webs/webs.txt" 2>>"$LOGFILE" | anew ".tmp/probed_old.txt" | sed '/^$/d' | wc -l); then+ printf "%b[!] Failed to count new probed webs.%b\n" "$bred" "$reset"+ NUMOFLINES_probed="0"+ fi+ fi++ # Display results+ printf "%b\n[%s] Total subdomains:%b\n\n" "$bblue" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"+ notification "- ${NUMOFLINES_subs} alive" "good"++ if [[ -s "subdomains/subdomains.txt" ]]; then+ if ! sort "subdomains/subdomains.txt"; then+ printf "%b[!] Failed to sort subdomains.txt.%b\n" "$bred" "$reset"+ fi+ fi++ notification "- ${NUMOFLINES_probed} new web probed" "good"++ if [[ -s "webs/webs.txt" ]]; then+ if ! sort "webs/webs.txt"; then+ printf "%b[!] Failed to sort webs.txt.%b\n" "$bred" "$reset"+ fi+ fi++ notification "Subdomain Enumeration Finished" "good"+ printf "%b[%s] Results are saved in %s/subdomains/subdomains.txt and webs/webs.txt%b\n" "$bblue" "$(date +'%Y-%m-%d %H:%M:%S')" "$domain" "$reset"+ printf "%b#######################################################################%b\n\n" "$bgreen" "$reset"++ # Emit plugin event+ plugins_emit after_subdomains "$domain" "$dir"++ # Incremental mode: get new subdomains and save state+ incremental_diff "subdomains" "subdomains/subdomains.txt" "subdomains/subdomains_new.txt"+ incremental_save "subdomains" "subdomains/subdomains.txt"++ # Incremental mode: get new webs and save state+ incremental_diff "webs" "webs/webs.txt" "webs/webs_new.txt"+ incremental_save "webs" "webs/webs.txt"++ # Persist counts for quick-rescan logic+ wc -l < "subdomains/subdomains_new.txt" 2>/dev/null > .tmp/subs_new_count+ wc -l < "webs/webs_new.txt" 2>/dev/null > .tmp/webs_new_count++ # Asset store: append new subdomains+ if [[ -s subdomains/subdomains_new.txt ]]; then+ append_assets_from_file subdomain name subdomains/subdomains_new.txt+ else+ append_assets_from_file subdomain name subdomains/subdomains.txt+ fi++}++function sub_passive() {++ mkdir -p .tmp subdomains++ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $SUBPASSIVE == true ]]; then+ start_subfunc "${FUNCNAME[0]}" "Running: Passive Subdomain Enumeration"++ # Run subfinder and check for errors+ run_command subfinder -all -d "$domain" -max-time "$SUBFINDER_ENUM_TIMEOUT" -silent -o .tmp/subfinder_psub.txt 2>>"$LOGFILE" >/dev/null+ curl -s https://ip.thc.org/sb/$domain | grep -v ";;" | anew -q .tmp/subfinder_psub.txt 2>>"$LOGFILE" >/dev/null++ # Run github-subdomains if GITHUB_TOKENS is set and file is not empty+ if [[ -s $GITHUB_TOKENS ]]; then+ if [[ $DEEP == true ]]; then+ github-subdomains -d "$domain" -t "$GITHUB_TOKENS" -o .tmp/github_subdomains_psub.txt 2>>"$LOGFILE" >/dev/null+ else+ github-subdomains -d "$domain" -k -q -t "$GITHUB_TOKENS" -o .tmp/github_subdomains_psub.txt 2>>"$LOGFILE" >/dev/null+ fi+ fi++ # Run gitlab-subdomains if GITLAB_TOKENS is set and file is not empty+ if [[ -s $GITLAB_TOKENS ]]; then+ gitlab-subdomains -d "$domain" -t "$GITLAB_TOKENS" 2>>"$LOGFILE" | tee .tmp/gitlab_subdomains_psub.txt >/dev/null+ fi++ # Check if INSCOPE is true and run check_inscope+ if [[ $INSCOPE == true ]]; then+ check_inscope .tmp/subfinder_psub.txt 2>>"$LOGFILE" >/dev/null+ check_inscope .tmp/github_subdomains_psub.txt 2>>"$LOGFILE" >/dev/null+ check_inscope .tmp/gitlab_subdomains_psub.txt 2>>"$LOGFILE" >/dev/null+ fi++ # Combine results and count new lines+ NUMOFLINES=$(find .tmp -type f -iname "*_psub.txt" -exec cat {} + | sed "s/^\*\.//" | anew .tmp/passive_subs.txt | sed '/^$/d' | wc -l)+ end_subfunc "${NUMOFLINES} new subs (passive)" "${FUNCNAME[0]}"++ else+ if [[ $SUBPASSIVE == false ]]; then+ printf "\n%b[%s] %s skipped due to mode or configuration settings.%b\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"+ else+ printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s%b\n\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$called_fn_dir" "/.${FUNCNAME[0]}" "$reset"+ fi+ fi++}++function sub_crt() {++ mkdir -p .tmp subdomains++ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $SUBCRT == true ]]; then+ start_subfunc "${FUNCNAME[0]}" "Running: Crtsh Subdomain Enumeration"++ # Run crt command and check for errors+ run_command crt -s -json -l "${CTR_LIMIT}" "$domain" 2>>"$LOGFILE" \+ | jq -r '.[].subdomain' 2>>"$LOGFILE" \+ | sed -e 's/^\*\.//' >.tmp/crtsh_subdomains.txt++ run_command curl -s "https://bgp.he.net/certs/api/list?domain=$domain" | jq -r 'try .domains[].domain' | sed -e 's/^\*\.//' | anew -q .tmp/crtsh_subdomains.txt++ # Use anew to get new subdomains+ cat .tmp/crtsh_subdomains.txt | anew -q .tmp/crtsh_subs_tmp.txt+ # If INSCOPE is true, check inscope+ if [[ $INSCOPE == true ]]; then+ if ! check_inscope .tmp/crtsh_subs_tmp.txt 2>>"$LOGFILE" >/dev/null; then+ printf "%b[!] check_inscope command failed.%b\n" "$bred" "$reset"+ return 1+ fi+ fi++ # Process subdomains and append new ones to .tmp/crtsh_subs.txt, count new lines+ NUMOFLINES=$(sed 's/^\*\.//' .tmp/crtsh_subs_tmp.txt | sed '/^$/d' | anew .tmp/crtsh_subs.txt | wc -l)++ end_subfunc "${NUMOFLINES} new subs (cert transparency)" "${FUNCNAME[0]}"+ else+ if [[ $SUBCRT == false ]]; then+ printf "\n%b[%s] %s skipped due to mode or defined in reconftw.cfg.%b\n" \+ "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"+ else+ printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s%b\n\n" \+ "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$called_fn_dir" "/.${FUNCNAME[0]}" "$reset"+ fi+ fi+}++function sub_active() {++ mkdir -p .tmp subdomains++ if [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; then+ start_subfunc "${FUNCNAME[0]}" "Running: Active Subdomain Enumeration"++ # Combine subdomain files into subs_no_resolved.txt+ if ! find .tmp -type f -iname "*_subs.txt" -exec cat {} + | anew -q .tmp/subs_no_resolved.txt; then+ printf "%b[!] Failed to collect subdomains into subs_no_resolved.txt.%b\n" "$bred" "$reset"+ return 1+ fi++ # Delete out-of-scope domains if outOfScope_file exists+ if [[ -s $outOfScope_file ]]; then+ if ! deleteOutScoped "$outOfScope_file" .tmp/subs_no_resolved.txt; then+ printf "%b[!] deleteOutScoped command failed.%b\n" "$bred" "$reset"+ return 1+ fi+ fi++ if [[ $AXIOM != true ]]; then+ # Update resolvers locally+ if ! resolvers_update_quick_local; then+ printf "%b[!] resolvers_update_quick_local command failed.%b\n" "$bred" "$reset"+ return 1+ fi+ [[ $RESOLVER_IQ == true ]] && resolvers_optimize_local++ # Resolve subdomains using puredns+ if [[ -s ".tmp/subs_no_resolved.txt" ]]; then+ puredns resolve .tmp/subs_no_resolved.txt -w .tmp/subdomains_tmp.txt \+ -r "$resolvers" --resolvers-trusted "$resolvers_trusted" \+ -l "$PUREDNS_PUBLIC_LIMIT" --rate-limit-trusted "$PUREDNS_TRUSTED_LIMIT" \+ --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" \+ --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \+ 2>>"$LOGFILE" >/dev/null+ fi+ else+ # Update resolvers using axiom+ if ! resolvers_update_quick_axiom; then+ printf "%b[!] resolvers_update_quick_axiom command failed.%b\n" "$bred" "$reset"+ return 1+ fi++ # Resolve subdomains using axiom-scan+ if [[ -s ".tmp/subs_no_resolved.txt" ]]; then+ axiom-scan .tmp/subs_no_resolved.txt -m puredns-resolve \+ -r ${AXIOM_RESOLVERS_PATH} \+ --resolvers-trusted ${AXIOM_RESOLVERS_TRUSTED_PATH} \+ --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" \+ --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \+ -o .tmp/subdomains_tmp.txt $AXIOM_EXTRA_ARGS \+ 2>>"$LOGFILE" >/dev/null+ fi+ fi++ # Add the domain itself to the list if it resolves+ echo "$domain" | dnsx -retry 3 -silent -r "$resolvers_trusted" \+ 2>>"$LOGFILE" | anew -q .tmp/subdomains_tmp.txt++ # If INSCOPE is true, check inscope+ if [[ $INSCOPE == true ]]; then+ if ! check_inscope .tmp/subdomains_tmp.txt 2>>"$LOGFILE" >/dev/null; then+ printf "%b[!] check_inscope command failed.%b\n" "$bred" "$reset"+ return 1+ fi+ fi++ # Process subdomains and append new ones to subdomains.txt, count new lines+ if ! NUMOFLINES=$(grep "\.$domain$\|^$domain$" .tmp/subdomains_tmp.txt 2>>"$LOGFILE" \+ | grep -E '^([a-zA-Z0-9\.\-]+\.)+[a-zA-Z]{1,}$' \+ | anew subdomains/subdomains.txt | sed '/^$/d' | wc -l); then+ printf "%b[!] Failed to process subdomains.%b\n" "$bred" "$reset"+ return 1+ fi++ end_subfunc "${NUMOFLINES} subs DNS resolved from passive" "${FUNCNAME[0]}"+ else+ printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s%b\n\n" \+ "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" \+ "$called_fn_dir" "/.${FUNCNAME[0]}" "$reset"+ fi+}++function sub_tls() {+ mkdir -p .tmp subdomains++ if [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; then+ start_subfunc "${FUNCNAME[0]}" "Running: TLS Active Subdomain Enumeration"++ if [[ $DEEP == true ]]; then+ if [[ $AXIOM != true ]]; then+ cat subdomains/subdomains.txt | tlsx -san -cn -silent -ro -c "$TLSX_THREADS" \+ -p "$TLS_PORTS" -o .tmp/subdomains_tlsx.txt 2>>"$LOGFILE" >/dev/null+ else+ axiom-scan subdomains/subdomains.txt -m tlsx \+ -san -cn -silent -ro -c "$TLSX_THREADS" -p "$TLS_PORTS" \+ -o .tmp/subdomains_tlsx.txt $AXIOM_EXTRA_ARGS 2>>"$LOGFILE" >/dev/null+ fi+ else+ if [[ $AXIOM != true ]]; then+ cat subdomains/subdomains.txt | tlsx -san -cn -silent -ro -c "$TLSX_THREADS" >.tmp/subdomains_tlsx.txt 2>>"$LOGFILE"+ else+ axiom-scan subdomains/subdomains.txt -m tlsx \+ -san -cn -silent -ro -c "$TLSX_THREADS" \+ -o .tmp/subdomains_tlsx.txt $AXIOM_EXTRA_ARGS 2>>"$LOGFILE" >/dev/null+ fi+ fi++ if [[ -s ".tmp/subdomains_tlsx.txt" ]]; then+ grep "\.$domain$\|^$domain$" .tmp/subdomains_tlsx.txt \+ | grep -aEo 'https?://[^ ]+' \+ | sed "s/|__ //" | anew -q .tmp/subdomains_tlsx_clean.txt+ fi++ if [[ $AXIOM != true ]]; then+ if ! resolvers_update_quick_local; then+ printf "%b[!] resolvers_update_quick_local command failed.%b\n" "$bred" "$reset"+ return 1+ fi+ [[ $RESOLVER_IQ == true ]] && resolvers_optimize_local+ if [[ -s ".tmp/subdomains_tlsx_clean.txt" ]]; then+ puredns resolve .tmp/subdomains_tlsx_clean.txt -w .tmp/subdomains_tlsx_resolved.txt \+ -r "$resolvers" --resolvers-trusted "$resolvers_trusted" \+ -l "$PUREDNS_PUBLIC_LIMIT" --rate-limit-trusted "$PUREDNS_TRUSTED_LIMIT" \+ --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \+ 2>>"$LOGFILE" >/dev/null+ fi+ else+ if ! resolvers_update_quick_axiom; then+ printf "%b[!] resolvers_update_quick_axiom command failed.%b\n" "$bred" "$reset"+ return 1+ fi+ if [[ -s ".tmp/subdomains_tlsx_clean.txt" ]]; then+ axiom-scan .tmp/subdomains_tlsx_clean.txt -m puredns-resolve \+ -r ${AXIOM_RESOLVERS_PATH} --resolvers-trusted ${AXIOM_RESOLVERS_TRUSTED_PATH} \+ --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \+ -o .tmp/subdomains_tlsx_resolved.txt $AXIOM_EXTRA_ARGS \+ 2>>"$LOGFILE" >/dev/null+ fi+ fi++ if [[ $INSCOPE == true ]]; then+ if ! check_inscope .tmp/subdomains_tlsx_resolved.txt 2>>"$LOGFILE" >/dev/null; then+ printf "%b[!] check_inscope command failed.%b\n" "$bred" "$reset"+ return 1+ fi+ fi++ touch .tmp/subdomains_tlsx_resolved.txt++ if ! NUMOFLINES=$(anew subdomains/subdomains.txt <.tmp/subdomains_tlsx_resolved.txt | sed '/^$/d' | wc -l); then+ printf "%b[!] Counting new subdomains failed.%b\n" "$bred" "$reset"+ return 1+ fi++ end_subfunc "${NUMOFLINES} new subs (tls active enum)" "${FUNCNAME[0]}"+ else+ printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s%b\n\n" \+ "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" \+ "$called_fn_dir" "/.${FUNCNAME[0]}" "$reset"+ fi+}++function sub_noerror() {++ mkdir -p .tmp subdomains++ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $SUBNOERROR == true ]]; then+ start_subfunc "${FUNCNAME[0]}" "Running: Checking NOERROR DNS response"++ # Check for DNSSEC black lies+ random_subdomain="${RANDOM}thistotallynotexist${RANDOM}.$domain"+ dns_response=$(echo "$random_subdomain" | dnsx -r "$resolvers" -rcode noerror,nxdomain -retry 3 -silent | cut -d' ' -f2)++ if [[ $dns_response == "[NXDOMAIN]" ]]; then+ if ! resolvers_update_quick_local; then+ printf "%b[!] Failed to update resolvers.%b\n" "$bred" "$reset"+ return 1+ fi++ # Determine wordlist based on DEEP setting+ if [[ $DEEP == true ]]; then+ wordlist="$subs_wordlist_big"+ else+ wordlist="$subs_wordlist"+ fi++ # Run dnsx and check for errors+ dnsx -d "$domain" -r "$resolvers" -silent \+ -rcode noerror -w "$wordlist" \+ 2>>"$LOGFILE" | cut -d' ' -f1 | anew -q .tmp/subs_noerror.txt >/dev/null++ # Check inscope if INSCOPE is true+ if [[ $INSCOPE == true ]]; then+ if ! check_inscope .tmp/subs_noerror.txt 2>>"$LOGFILE" >/dev/null; then+ printf "%b[!] check_inscope command failed.%b\n" "$bred" "$reset"+ return 1+ fi+ fi++ # Process subdomains and append new ones to subdomains.txt, count new lines+ if ! NUMOFLINES=$(grep "\.$domain$\|^$domain$" .tmp/subs_noerror.txt 2>>"$LOGFILE" \+ | grep -E '^([a-zA-Z0-9\.\-]+\.)+[a-zA-Z]{1,}$' \+ | sed 's/^\*\.//' | anew subdomains/subdomains.txt | sed '/^$/d' | wc -l); then+ printf "%b[!] Failed to process subdomains.%b\n" "$bred" "$reset"+ return 1+ fi++ end_subfunc "${NUMOFLINES} new subs (DNS noerror)" "${FUNCNAME[0]}"++ else+ printf "\n%s[%s] Detected DNSSEC black lies, skipping this technique.%b\n" \+ "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"+ fi++ else+ if [[ $SUBNOERROR == false ]]; then+ printf "\n%b[%s] %s skipped due to mode or defined in reconftw.cfg.%b\n" \+ "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"+ else+ printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s%b\n\n" \+ "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" \+ "$called_fn_dir" "/.${FUNCNAME[0]}" "$reset"+ fi+ fi++}++function sub_dns() {+ mkdir -p .tmp subdomains hosts++ if [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; then+ start_subfunc "${FUNCNAME[0]}" "Running: DNS Subdomain Enumeration and PTR search"++ if [[ -s "subdomains/subdomains.txt" ]]; then+ dnsx -r "$resolvers_trusted" -recon -silent -retry 3 -json \+ -o "subdomains/subdomains_dnsregs.json" <"subdomains/subdomains.txt" 2>>"$LOGFILE" >/dev/null+ fi+ if [[ -s "subdomains/subdomains_dnsregs.json" ]]; then+ # Extract various DNS records and process them+ jq -r --arg domain "$domain" '.. | strings | select(test("\\." + $domain + "$"))' <"subdomains/subdomains_dnsregs.json" \+ | grep -E '^([a-zA-Z0-9][-a-zA-Z0-9]*\.)+[a-zA-Z]{2,}$' \+ | sort -u | anew -q .tmp/subdomains_dns.txt++ jq -r '.. | strings | select(test("^(\\d{1,3}\\.){3}\\d{1,3}$|^[0-9a-fA-F:]+$"))' <"subdomains/subdomains_dnsregs.json" \+ | sort -u | hakip2host | awk '{print $3}' | unfurl -u domains \+ | sed -e 's/^\*\.//' -e 's/\.$//' -e '/\./!d' | grep "\.$domain$" \+ | grep -E '^([a-zA-Z0-9][-a-zA-Z0-9]*\.)+[a-zA-Z]{2,}$' | sort -u \+ | anew -q .tmp/subdomains_dns.txt++ for i in $(jq -r '.. | strings | select(test("^(\\d{1,3}\\.){3}\\d{1,3}$|^[0-9a-fA-F:]+$"))' <"subdomains/subdomains_dnsregs.json" | sort -u); do+ curl -s https://ip.thc.org/$i 2>>"$LOGFILE" | grep "\.$domain$" \+ | grep -E '^([a-zA-Z0-9][-a-zA-Z0-9]*\.)+[a-zA-Z]{2,}$' | sort -u \+ | anew -q .tmp/subdomains_dns.txt+ done++ jq -r 'select(.host) |"\(.host) - \((.a // [])[])", "\(.host) - \((.aaaa // [])[])"' <"subdomains/subdomains_dnsregs.json" \+ | grep -E ' - [0-9a-fA-F:.]+$' | sort -u | anew -q "subdomains/subdomains_ips.txt"+ fi+ if [[ $AXIOM != true ]]; then+ if ! resolvers_update_quick_local; then+ printf "%b[!] Failed to update resolvers.%b\n" "$bred" "$reset"+ fi++ if [[ -s ".tmp/subdomains_dns.txt" ]]; then+ puredns resolve .tmp/subdomains_dns.txt -w .tmp/subdomains_dns_resolved.txt \+ -r "$resolvers" --resolvers-trusted "$resolvers_trusted" \+ -l "$PUREDNS_PUBLIC_LIMIT" --rate-limit-trusted "$PUREDNS_TRUSTED_LIMIT" \+ --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \+ 2>>"$LOGFILE" >/dev/null+ fi+ else+ if ! resolvers_update_quick_axiom; then+ printf "%b[!] Failed to update resolvers.%b\n" "$bred" "$reset"+ fi++ if [[ -s ".tmp/subdomains_dns.txt" ]]; then+ axiom-scan .tmp/subdomains_dns.txt -m puredns-resolve \+ -r "${AXIOM_RESOLVERS_PATH}" --resolvers-trusted "${AXIOM_RESOLVERS_TRUSTED_PATH}" \+ --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \+ -o .tmp/subdomains_dns_resolved.txt "$AXIOM_EXTRA_ARGS" \+ 2>>"$LOGFILE" >/dev/null+ fi+ fi++ cut -d ' ' -f3 subdomains/subdomains_ips.txt \+ | grep -aEiv "^(127|10|169\.254|172\.1[6-9]|172\.2[0-9]|172\.3[0-1]|192\.168)\." \+ | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b" | sort -u | anew -q hosts/ips.txt++ if [[ $INSCOPE == true ]]; then+ if ! check_inscope .tmp/subdomains_dns_resolved.txt 2>>"$LOGFILE" >/dev/null; then+ printf "%b[!] check_inscope command failed.%b\n" "$bred" "$reset"+ fi+ fi++ if ! NUMOFLINES=$(grep "\.$domain$\|^$domain$" .tmp/subdomains_dns_resolved.txt 2>>"$LOGFILE" \+ | grep -E '^([a-zA-Z0-9\-\.]+\.)+[a-zA-Z]{1,}$' \+ | anew subdomains/subdomains.txt | sed '/^$/d' | wc -l); then+ printf "%b[!] Failed to count new subdomains.%b\n" "$bred" "$reset"+ return 1+ fi++ end_subfunc "${NUMOFLINES} new subs (dns resolution)" "${FUNCNAME[0]}"+ else+ printf "\n%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s%b\n\n" \+ "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$called_fn_dir" "/.${FUNCNAME[0]}" "$reset"+ fi+}++function sub_brute() {++ mkdir -p .tmp subdomains++ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $SUBBRUTE == true ]]; then+ start_subfunc "${FUNCNAME[0]}" "Running: Bruteforce Subdomain Enumeration"++ if [[ $AXIOM != true ]]; then+ if ! resolvers_update_quick_local; then+ printf "%b[!] Failed to update resolvers.%b\n" "$bred" "$reset"+ return 1+ fi++ wordlist="$subs_wordlist"+ [[ $DEEP == true ]] && wordlist="$subs_wordlist_big"++ # Run puredns bruteforce+ puredns bruteforce "$wordlist" "$domain" -w .tmp/subs_brute.txt -r "$resolvers" --resolvers-trusted "$resolvers_trusted" \+ -l "$PUREDNS_PUBLIC_LIMIT" --rate-limit-trusted "$PUREDNS_TRUSTED_LIMIT" \+ --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \+ 2>>"$LOGFILE" >/dev/null++ # Resolve the subdomains+ if [[ -s ".tmp/subs_brute.txt" ]]; then+ puredns resolve .tmp/subs_brute.txt -w .tmp/subs_brute_valid.txt -r "$resolvers" --resolvers-trusted "$resolvers_trusted" \+ -l "$PUREDNS_PUBLIC_LIMIT" --rate-limit-trusted "$PUREDNS_TRUSTED_LIMIT" \+ --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \+ 2>>"$LOGFILE" >/dev/null+ fi++ else+ if ! resolvers_update_quick_axiom; then+ printf "%b[!] Failed to update resolvers on axiom.%b\n" "$bred" "$reset"+ return 1+ fi++ wordlist="$subs_wordlist"+ [[ $DEEP == true ]] && wordlist="$subs_wordlist_big"++ # Run axiom-scan with puredns-single+ axiom-scan "$wordlist" -m puredns-single "$domain" -r ${AXIOM_RESOLVERS_PATH} \+ --resolvers-trusted ${AXIOM_RESOLVERS_TRUSTED_PATH} \+ --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \+ -o .tmp/subs_brute.txt "$AXIOM_EXTRA_ARGS" 2>>"$LOGFILE" >/dev/null++ # Resolve the subdomains using axiom-scan+ if [[ -s ".tmp/subs_brute.txt" ]]; then+ axiom-scan .tmp/subs_brute.txt -m puredns-resolve -r ${AXIOM_RESOLVERS_PATH} \+ --resolvers-trusted ${AXIOM_RESOLVERS_TRUSTED_PATH} \+ --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \+ -o .tmp/subs_brute_valid.txt "$AXIOM_EXTRA_ARGS" 2>>"$LOGFILE" >/dev/null+ fi+ fi++ # Check inscope if INSCOPE is true+ if [[ $INSCOPE == true ]]; then+ if ! check_inscope .tmp/subs_brute_valid.txt 2>>"$LOGFILE" >/dev/null; then+ printf "%b[!] check_inscope command failed.%b\n" "$bred" "$reset"+ return 1+ fi+ fi++ # Process subdomains and append new ones to subdomains.txt, count new lines+ if ! NUMOFLINES=$(grep "\.$domain$\|^$domain$" .tmp/subs_brute_valid.txt 2>>"$LOGFILE" \+ | grep -E '^([a-zA-Z0-9\.\-]+\.)+[a-zA-Z]{1,}$' \+ | sed 's/^\*\.//' | anew subdomains/subdomains.txt | sed '/^$/d' | wc -l); then+ printf "%b[!] Failed to process subdomains.%b\n" "$bred" "$reset"+ return 1+ fi++ end_subfunc "${NUMOFLINES} new subs (bruteforce)" "${FUNCNAME[0]}"++ else+ if [[ $SUBBRUTE == false ]]; then+ printf "\n%b[%s] %s skipped due to mode or defined in reconftw.cfg.%b\n" \+ "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"+ else+ printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s%b\n\n" \+ "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" \+ "$called_fn_dir" "/.${FUNCNAME[0]}" "$reset"+ fi+ fi++}++function sub_scraping() {++ # Create necessary directories+ if ! mkdir -p .tmp subdomains; then+ printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"+ return 1+ fi++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $SUBSCRAPING == true ]]; then+ start_subfunc "${FUNCNAME[0]}" "Running: Source code scraping subdomain search"++ # Initialize scrap_subs.txt+ if ! touch .tmp/scrap_subs.txt; then+ printf "%b[!] Failed to create .tmp/scrap_subs.txt.%b\n" "$bred" "$reset"+ return 1+ fi++ # If in multi mode and subdomains.txt doesn't exist, create it+ if [[ -n $multi ]] && [[ ! -f "$dir/subdomains/subdomains.txt" ]]; then+ if ! printf "%b\n" "$domain" >"$dir/subdomains/subdomains.txt"; then+ printf "%b[!] Failed to create subdomains.txt.%b\n" "$bred" "$reset"+ return 1+ fi+ fi++ # Check if subdomains.txt exists and is not empty+ if [[ -s "$dir/subdomains/subdomains.txt" ]]; then++ subdomains_count=$(wc -l <"$dir/subdomains/subdomains.txt")+ if [[ $subdomains_count -le $DEEP_LIMIT ]] || [[ $DEEP == true ]]; then++ urlfinder -d $domain -all -o .tmp/url_extract_tmp.txt 2>>"$LOGFILE" >/dev/null++ if [[ -s ".tmp/url_extract_tmp.txt" ]]; then+ cat .tmp/url_extract_tmp.txt | grep "$domain" \+ | grep -aEo 'https?://[^ ]+' \+ | sed "s/^\*\.//" | unfurl -u domains 2>>"$LOGFILE" | anew -q .tmp/scrap_subs.txt+ fi++ if [[ $AXIOM != true ]]; then+ if ! resolvers_update_quick_local; then+ printf "%b[!] Failed to update resolvers locally.%b\n" "$bred" "$reset"+ return 1+ fi++ # Run httpx to gather web info+ run_command httpx -follow-host-redirects -status-code -threads "$HTTPX_THREADS" -rl "$HTTPX_RATELIMIT" \+ -timeout "$HTTPX_TIMEOUT" -silent -retries 2 -title -web-server -tech-detect -location \+ -no-color -json -o .tmp/web_full_info1.txt \+ <subdomains/subdomains.txt 2>>"$LOGFILE" >/dev/null++ if [[ -s ".tmp/web_full_info1.txt" ]]; then+ cat .tmp/web_full_info1.txt | jq -r 'try .url' 2>/dev/null \+ | grep "$domain" \+ | grep -aEo 'https?://[^ ]+' \+ | sed "s/^\*\.//" \+ | anew .tmp/probed_tmp_scrap.txt \+ | unfurl -u domains 2>>"$LOGFILE" \+ | anew -q .tmp/scrap_subs.txt+ fi++ if [[ -s ".tmp/probed_tmp_scrap.txt" ]]; then+ cat .tmp/probed_tmp_scrap.txt | csprecon -s | grep "$domain" | sed "s/^\*\.//" | sort -u \+ | unfurl -u domains 2>>"$LOGFILE" | anew -q .tmp/scrap_subs.txt+ fi++ if [[ -s ".tmp/probed_tmp_scrap.txt" ]]; then+ if [[ $DEEP == true ]]; then+ timeout 3h katana -silent -list .tmp/probed_tmp_scrap.txt -jc -kf all -c "$KATANA_THREADS" -d 2 \+ -fs rdn -o .tmp/katana.txt 2>>"$LOGFILE" >/dev/null+ fi+ fi++ else+ # AXIOM mode+ if ! resolvers_update_quick_axiom; then+ printf "%b[!] Failed to update resolvers on axiom.%b\n" "$bred" "$reset"+ return 1+ fi++ axiom-scan subdomains/subdomains.txt -m httpx -follow-host-redirects -random-agent -status-code \+ -threads "$HTTPX_THREADS" -rl "$HTTPX_RATELIMIT" -timeout "$HTTPX_TIMEOUT" -silent -retries 2 \+ -title -web-server -tech-detect -location -no-color -json -o .tmp/web_full_info1.txt \+ $AXIOM_EXTRA_ARGS 2>>"$LOGFILE" >/dev/null++ if [[ -s ".tmp/web_full_info1.txt" ]]; then+ cat .tmp/web_full_info1.txt | jq -r 'try .url' 2>/dev/null \+ | grep "$domain" \+ | grep -aEo 'https?://[^ ]+' \+ | sed "s/^\*\.//" \+ | anew .tmp/probed_tmp_scrap.txt \+ | unfurl -u domains 2>>"$LOGFILE" \+ | anew -q .tmp/scrap_subs.txt+ fi++ if [[ -s ".tmp/probed_tmp_scrap.txt" ]]; then+ cat .tmp/probed_tmp_scrap.txt | csprecon -s | grep "$domain" | sed "s/^\*\.//" | sort -u \+ | unfurl -u domains 2>>"$LOGFILE" | anew -q .tmp/scrap_subs.txt+ fi++ if [[ -s ".tmp/probed_tmp_scrap.txt" ]]; then+ if [[ $DEEP == true ]]; then+ axiom-scan .tmp/probed_tmp_scrap.txt -m katana -jc -kf all -d 2 -fs rdn \+ -o .tmp/katana.txt $AXIOM_EXTRA_ARGS --max-runtime 4h 2>>"$LOGFILE" >/dev/null+ fi+ fi+ fi++ if [[ -s ".tmp/katana.txt" ]]; then+ sed_i '/^.\{2048\}./d' .tmp/katana.txt++ cat .tmp/katana.txt | unfurl -u domains 2>>"$LOGFILE" \+ | grep "\.$domain$" \+ | grep -E '^([a-zA-Z0-9\.\-]+\.)+[a-zA-Z]{1,}$' \+ | anew -q .tmp/scrap_subs.txt+ fi++ if [[ -s ".tmp/scrap_subs.txt" ]]; then+ puredns resolve .tmp/scrap_subs.txt -w .tmp/scrap_subs_resolved.txt -r "$resolvers" \+ --resolvers-trusted "$resolvers_trusted" -l "$PUREDNS_PUBLIC_LIMIT" \+ --rate-limit-trusted "$PUREDNS_TRUSTED_LIMIT" --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" \+ --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" 2>>"$LOGFILE" >/dev/null+ fi++ if [[ $INSCOPE == true ]]; then+ if ! check_inscope .tmp/scrap_subs_resolved.txt 2>>"$LOGFILE" >/dev/null; then+ printf "%b[!] check_inscope command failed.%b\n" "$bred" "$reset"+ fi+ fi++ if [[ -s ".tmp/scrap_subs_resolved.txt" ]]; then+ if ! NUMOFLINES=$(cat .tmp/scrap_subs_resolved.txt 2>>"$LOGFILE" \+ | grep "\.$domain$\|^$domain$" \+ | grep -E '^([a-zA-Z0-9\.\-]+\.)+[a-zA-Z]{1,}$' \+ | anew subdomains/subdomains.txt \+ | tee .tmp/diff_scrap.txt \+ | sed '/^$/d' | wc -l); then+ NUMOFLINES=0+ fi+ else+ NUMOFLINES=0+ fi++ if [[ -s ".tmp/diff_scrap.txt" ]]; then+ httpx -follow-host-redirects -random-agent -status-code -threads "$HTTPX_THREADS" \+ -rl "$HTTPX_RATELIMIT" -timeout "$HTTPX_TIMEOUT" -silent -retries 2 -title -web-server \+ -tech-detect -location -no-color -json -o .tmp/web_full_info3.txt \+ <.tmp/diff_scrap.txt 2>>"$LOGFILE" >/dev/null++ if [[ -s ".tmp/web_full_info3.txt" ]]; then+ cat .tmp/web_full_info3.txt | jq -r 'try .url' 2>/dev/null \+ | grep "$domain" \+ | grep -aEo 'https?://[^ ]+' \+ | sed "s/^\*\.//" \+ | anew .tmp/probed_tmp_scrap.txt \+ | unfurl -u domains 2>>"$LOGFILE" \+ | anew -q .tmp/scrap_subs.txt+ fi+ fi++ cat .tmp/web_full_info1.txt .tmp/web_full_info2.txt .tmp/web_full_info3.txt 2>>"$LOGFILE" \+ | jq -s 'try .' | jq 'try unique_by(.input)' | jq 'try .[]' 2>>"$LOGFILE" >.tmp/web_full_info.txt++ end_subfunc "${NUMOFLINES} new subs (code scraping)" "${FUNCNAME[0]}"++ else+ end_subfunc "Skipping Subdomains Web Scraping: Too Many Subdomains" "${FUNCNAME[0]}"+ fi+ fi++ else+ if [[ $SUBSCRAPING == false ]]; then+ printf "\n%b[%s] %s skipped due to mode or defined in reconftw.cfg.%b\n" \+ "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"+ else+ printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s%b\n\n" \+ "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" \+ "$called_fn_dir" "/.${FUNCNAME[0]}" "$reset"+ fi+ fi++}++function sub_analytics() {++ # Create necessary directories+ if ! mkdir -p .tmp subdomains; then+ printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"+ return 1+ fi++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $SUBANALYTICS == true ]]; then+ start_subfunc "${FUNCNAME[0]}" "Running: Analytics Subdomain Enumeration"++ if [[ -s ".tmp/probed_tmp_scrap.txt" ]]; then+ # Run analyticsrelationships and check for errors+ analyticsrelationships -ch <.tmp/probed_tmp_scrap.txt >>.tmp/analytics_subs_tmp.txt 2>>"$LOGFILE"++ if [[ -s ".tmp/analytics_subs_tmp.txt" ]]; then+ grep "\.$domain$\|^$domain$" .tmp/analytics_subs_tmp.txt \+ | grep -E '^([a-zA-Z0-9\.\-]+\.)+[a-zA-Z]{1,}$' \+ | sed "s/|__ //" | anew -q .tmp/analytics_subs_clean.txt++ if [[ $AXIOM != true ]]; then+ if ! resolvers_update_quick_local; then+ printf "%b[!] Failed to update resolvers locally.%b\n" "$bred" "$reset"+ return 1+ fi++ if [[ -s ".tmp/analytics_subs_clean.txt" ]]; then+ puredns resolve .tmp/analytics_subs_clean.txt -w .tmp/analytics_subs_resolved.txt \+ -r "$resolvers" --resolvers-trusted "$resolvers_trusted" \+ -l "$PUREDNS_PUBLIC_LIMIT" --rate-limit-trusted "$PUREDNS_TRUSTED_LIMIT" \+ --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \+ 2>>"$LOGFILE" >/dev/null+ fi+ else+ if ! resolvers_update_quick_axiom; then+ printf "%b[!] Failed to update resolvers on Axiom.%b\n" "$bred" "$reset"+ return 1+ fi++ if [[ -s ".tmp/analytics_subs_clean.txt" ]]; then+ axiom-scan .tmp/analytics_subs_clean.txt -m puredns-resolve \+ -r ${AXIOM_RESOLVERS_PATH} --resolvers-trusted ${AXIOM_RESOLVERS_TRUSTED_PATH} \+ --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \+ -o .tmp/analytics_subs_resolved.txt $AXIOM_EXTRA_ARGS \+ 2>>"$LOGFILE" >/dev/null+ fi+ fi+ fi+ fi++ if [[ $INSCOPE == true ]]; then+ if ! check_inscope .tmp/analytics_subs_resolved.txt 2>>"$LOGFILE" >/dev/null; then+ printf "%b[!] check_inscope command failed.%b\n" "$bred" "$reset"+ fi+ fi++ if ! NUMOFLINES=$(cat .tmp/analytics_subs_resolved.txt 2>/dev/null | anew subdomains/subdomains.txt 2>/dev/null | sed '/^$/d' | wc -l); then+ NUMOFLINES=0+ fi++ end_subfunc "${NUMOFLINES} new subs (analytics relationship)" "${FUNCNAME[0]}"++ else+ if [[ $SUBANALYTICS == false ]]; then+ printf "\n%b[%s] %s skipped due to mode or defined in reconftw.cfg.%b\n" \+ "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"+ else+ printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s%b\n\n" \+ "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$called_fn_dir" "/.${FUNCNAME[0]}" "$reset"+ fi+ fi+}++function sub_permut() {++ mkdir -p .tmp subdomains++ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $SUBPERMUTE == true ]]; then+ start_subfunc "${FUNCNAME[0]}" "Running: Permutations Subdomain Enumeration"++ # If in multi mode and subdomains.txt doesn't exist, create it with the domain+ if [[ -n $multi ]] && [[ ! -f "$dir/subdomains/subdomains.txt" ]]; then+ echo "$domain" >"$dir/subdomains/subdomains.txt"+ fi++ # Determine the number of subdomains+ subdomain_count=$(wc -l <subdomains/subdomains.txt)++ # Check if DEEP mode is enabled or subdomains are within DEEP_LIMIT+ if [[ $DEEP == true ]] || [[ $subdomain_count -le $DEEP_LIMIT ]]; then++ # Select the permutations tool+ if [[ $PERMUTATIONS_OPTION == "gotator" ]]; then+ if [[ -s "subdomains/subdomains.txt" ]]; then+ gotator -sub subdomains/subdomains.txt -perm "${tools}/permutations_list.txt" $GOTATOR_FLAGS \+ -silent 2>>"$LOGFILE" | head -c "$PERMUTATIONS_LIMIT" >.tmp/gotator1.txt+ fi+ else+ if [[ -s "subdomains/subdomains.txt" ]]; then+ ripgen -d subdomains/subdomains.txt -w "${tools}/permutations_list.txt" \+ 2>>"$LOGFILE" | head -c "$PERMUTATIONS_LIMIT" >.tmp/gotator1.txt+ fi+ fi++ elif [[ "$(wc -l <.tmp/subs_no_resolved.txt)" -le $DEEP_LIMIT2 ]]; then++ if [[ $PERMUTATIONS_OPTION == "gotator" ]]; then+ if [[ -s ".tmp/subs_no_resolved.txt" ]]; then+ gotator -sub .tmp/subs_no_resolved.txt -perm "${tools}/permutations_list.txt" $GOTATOR_FLAGS \+ -silent 2>>"$LOGFILE" | head -c "$PERMUTATIONS_LIMIT" >.tmp/gotator1.txt+ fi+ else+ if [[ -s ".tmp/subs_no_resolved.txt" ]]; then+ ripgen -d .tmp/subs_no_resolved.txt -w "${tools}/permutations_list.txt" \+ 2>>"$LOGFILE" | head -c "$PERMUTATIONS_LIMIT" >.tmp/gotator1.txt+ fi+ fi++ else+ end_subfunc "Skipping Permutations: Too Many Subdomains" "${FUNCNAME[0]}"+ return 0+ fi++ # Resolve the permutations+ if [[ $AXIOM != true ]]; then+ if ! resolvers_update_quick_local; then+ printf "%b[!] Failed to update resolvers.%b\n" "$bred" "$reset"+ return 1+ fi+ if [[ -s ".tmp/gotator1.txt" ]]; then+ puredns resolve .tmp/gotator1.txt -w .tmp/permute1.txt -r "$resolvers" --resolvers-trusted "$resolvers_trusted" \+ -l "$PUREDNS_PUBLIC_LIMIT" --rate-limit-trusted "$PUREDNS_TRUSTED_LIMIT" \+ --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \+ 2>>"$LOGFILE" >/dev/null+ fi+ else+ if ! resolvers_update_quick_axiom; then+ printf "%b[!] Failed to update resolvers on axiom.%b\n" "$bred" "$reset"+ return 1+ fi+ if [[ -s ".tmp/gotator1.txt" ]]; then+ axiom-scan .tmp/gotator1.txt -m puredns-resolve -r ${AXIOM_RESOLVERS_PATH} \+ --resolvers-trusted ${AXIOM_RESOLVERS_TRUSTED_PATH} \+ --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \+ -o .tmp/permute1.txt $AXIOM_EXTRA_ARGS 2>>"$LOGFILE" >/dev/null+ fi+ fi++ # Generate second round of permutations+ if [[ $PERMUTATIONS_OPTION == "gotator" ]]; then+ if [[ -s ".tmp/permute1.txt" ]]; then+ gotator -sub .tmp/permute1.txt -perm "${tools}/permutations_list.txt" \+ $GOTATOR_FLAGS -silent 2>>"$LOGFILE" | head -c "$PERMUTATIONS_LIMIT" >.tmp/gotator2.txt+ fi+ else+ if [[ -s ".tmp/permute1.txt" ]]; then+ ripgen -d .tmp/permute1.txt -w "${tools}/permutations_list.txt" \+ 2>>"$LOGFILE" | head -c "$PERMUTATIONS_LIMIT" >.tmp/gotator2.txt+ fi+ fi++ # Resolve the second round of permutations+ if [[ $AXIOM != true ]]; then+ if [[ -s ".tmp/gotator2.txt" ]]; then+ puredns resolve .tmp/gotator2.txt -w .tmp/permute2.txt -r "$resolvers" --resolvers-trusted "$resolvers_trusted" \+ -l "$PUREDNS_PUBLIC_LIMIT" --rate-limit-trusted "$PUREDNS_TRUSTED_LIMIT" \+ --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \+ 2>>"$LOGFILE" >/dev/null+ fi+ else+ if [[ -s ".tmp/gotator2.txt" ]]; then+ axiom-scan .tmp/gotator2.txt -m puredns-resolve -r ${AXIOM_RESOLVERS_PATH} \+ --resolvers-trusted ${AXIOM_RESOLVERS_TRUSTED_PATH} \+ --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \+ -o .tmp/permute2.txt $AXIOM_EXTRA_ARGS 2>>"$LOGFILE" >/dev/null+ fi+ fi++ # Combine results+ if [[ -s ".tmp/permute1.txt" ]] || [[ -s ".tmp/permute2.txt" ]]; then+ cat .tmp/permute1.txt .tmp/permute2.txt 2>>"$LOGFILE" | anew -q .tmp/permute_subs.txt++ # Remove out-of-scope domains if applicable+ if [[ -s $outOfScope_file ]]; then+ if ! deleteOutScoped "$outOfScope_file" .tmp/permute_subs.txt; then+ printf "%b[!] deleteOutScoped command failed.%b\n" "$bred" "$reset"+ fi+ fi++ # Check inscope if INSCOPE is true+ if [[ $INSCOPE == true ]]; then+ if ! check_inscope .tmp/permute_subs.txt 2>>"$LOGFILE" >/dev/null; then+ printf "%b[!] check_inscope command failed.%b\n" "$bred" "$reset"+ fi+ fi++ # Process subdomains and append new ones to subdomains.txt, count new lines+ if ! NUMOFLINES=$(grep "\.$domain$\|^$domain$" .tmp/permute_subs.txt 2>>"$LOGFILE" \+ | grep -E '^([a-zA-Z0-9\.\-]+\.)+[a-zA-Z]{1,}$' \+ | anew subdomains/subdomains.txt | sed '/^$/d' | wc -l); then+ printf "%b[!] Failed to process subdomains.%b\n" "$bred" "$reset"+ return 1+ fi+ else+ NUMOFLINES=0+ fi++ end_subfunc "${NUMOFLINES} new subs (permutations)" "${FUNCNAME[0]}"++ else+ if [[ $SUBPERMUTE == false ]]; then+ printf "\n%b[%s] %s skipped due to mode or defined in reconftw.cfg.%b\n" \+ "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"+ else+ printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s%b\n\n" \+ "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" \+ "$called_fn_dir" "/.${FUNCNAME[0]}" "$reset"+ fi+ fi++}++function sub_regex_permut() {++ # Create necessary directories+ if ! mkdir -p .tmp subdomains; then+ printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"+ return 1+ fi++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $SUBREGEXPERMUTE == true ]]; then+ start_subfunc "${FUNCNAME[0]}" "Running: Permutations by regex analysis"++ # Change to the regulator directory+ if ! pushd "${tools}/regulator" >/dev/null; then+ printf "%b[!] Failed to change directory to %s.%b\n" "$bred" "${tools}/regulator" "$reset"+ return 1+ fi++ # If in multi mode and subdomains.txt doesn't exist, create it+ if [[ -n $multi ]] && [[ ! -f "$dir/subdomains/subdomains.txt" ]]; then+ printf "%b\n" "$domain" >"$dir/subdomains/subdomains.txt"+ fi++ # Run the main.py script+ "${tools}/regulator/venv/bin/python3" main.py -t "$domain" -f "${dir}/subdomains/subdomains.txt" -o "${dir}/.tmp/${domain}.brute" \+ 2>>"$LOGFILE" >/dev/null++ # Return to the previous directory+ if ! popd >/dev/null; then+ printf "%b[!] Failed to return to previous directory.%b\n" "$bred" "$reset"+ return 1+ fi++ # Resolve the generated domains+ if [[ $AXIOM != true ]]; then+ if ! resolvers_update_quick_local; then+ printf "%b[!] Failed to update resolvers locally.%b\n" "$bred" "$reset"+ return 1+ fi++ if [[ -s ".tmp/${domain}.brute" ]]; then+ puredns resolve ".tmp/${domain}.brute" -w .tmp/regulator.txt -r "$resolvers" --resolvers-trusted "$resolvers_trusted" \+ -l "$PUREDNS_PUBLIC_LIMIT" --rate-limit-trusted "$PUREDNS_TRUSTED_LIMIT" \+ --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \+ 2>>"$LOGFILE" >/dev/null+ fi+ else+ if ! resolvers_update_quick_axiom; then+ printf "%b[!] Failed to update resolvers on Axiom.%b\n" "$bred" "$reset"+ return 1+ fi++ if [[ -s ".tmp/${domain}.brute" ]]; then+ axiom-scan ".tmp/${domain}.brute" -m puredns-resolve \+ -r ${AXIOM_RESOLVERS_PATH} --resolvers-trusted ${AXIOM_RESOLVERS_TRUSTED_PATH} \+ --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \+ -o .tmp/regulator.txt $AXIOM_EXTRA_ARGS \+ 2>>"$LOGFILE" >/dev/null+ fi+ fi++ # Process the resolved domains+ if [[ -s ".tmp/regulator.txt" ]]; then+ if [[ -s $outOfScope_file ]]; then+ if ! deleteOutScoped "$outOfScope_file" .tmp/regulator.txt; then+ printf "%b[!] deleteOutScoped command failed.%b\n" "$bred" "$reset"+ fi+ fi++ if [[ $INSCOPE == true ]]; then+ if ! check_inscope .tmp/regulator.txt 2>>"$LOGFILE" >/dev/null; then+ printf "%b[!] check_inscope command failed.%b\n" "$bred" "$reset"+ fi+ fi++ if ! NUMOFLINES=$(grep "\.$domain$\|^$domain$" .tmp/regulator.txt 2>>"$LOGFILE" \+ | grep -E '^([a-zA-Z0-9\.\-]+\.)+[a-zA-Z]{1,}$' \+ | anew subdomains/subdomains.txt \+ | sed '/^$/d' \+ | wc -l); then+ NUMOFLINES=0+ fi+ else+ NUMOFLINES=0+ fi++ end_subfunc "${NUMOFLINES} new subs (permutations by regex)" "${FUNCNAME[0]}"++ else+ if [[ $SUBREGEXPERMUTE == false ]]; then+ printf "\n%b[%s] %s skipped due to mode or defined in reconftw.cfg.%b\n" \+ "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"+ else+ printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s%b\n\n" \+ "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$called_fn_dir" "/.${FUNCNAME[0]}" "$reset"+ fi+ fi++}++function sub_ia_permut() {++ # Create necessary directories+ if ! mkdir -p .tmp subdomains; then+ printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"+ return 1+ fi++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $SUBIAPERMUTE == true ]]; then+ start_subfunc "${FUNCNAME[0]}" "Running: Permutations by AI analysis"++ subwiz -i subdomains/subdomains.txt --no-resolve -o .tmp/subwiz.txt 2>>"$LOGFILE" >/dev/null++ # Resolve the generated domains+ if [[ $AXIOM != true ]]; then+ if ! resolvers_update_quick_local; then+ printf "%b[!] Failed to update resolvers locally.%b\n" "$bred" "$reset"+ return 1+ fi++ if [[ -s ".tmp/subwiz.txt" ]]; then+ puredns resolve ".tmp/subwiz.txt" -w .tmp/subwiz_resolved.txt -r "$resolvers" --resolvers-trusted "$resolvers_trusted" \+ -l "$PUREDNS_PUBLIC_LIMIT" --rate-limit-trusted "$PUREDNS_TRUSTED_LIMIT" \+ --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \+ 2>>"$LOGFILE" >/dev/null+ fi+ else+ if ! resolvers_update_quick_axiom; then+ printf "%b[!] Failed to update resolvers on Axiom.%b\n" "$bred" "$reset"+ return 1+ fi++ if [[ -s ".tmp/subwiz.txt" ]]; then+ axiom-scan ".tmp/subwiz.txt" -m puredns-resolve \+ -r ${AXIOM_RESOLVERS_PATH} --resolvers-trusted ${AXIOM_RESOLVERS_TRUSTED_PATH} \+ --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \+ -o .tmp/subwiz_resolved.txt $AXIOM_EXTRA_ARGS \+ 2>>"$LOGFILE" >/dev/null+ fi+ fi++ # Process the resolved domains+ if [[ -s ".tmp/subwiz_resolved.txt" ]]; then+ if [[ -s $outOfScope_file ]]; then+ if ! deleteOutScoped "$outOfScope_file" .tmp/subwiz_resolved.txt; then+ printf "%b[!] deleteOutScoped command failed.%b\n" "$bred" "$reset"+ fi+ fi++ if [[ $INSCOPE == true ]]; then+ if ! check_inscope .tmp/subwiz_resolved.txt 2>>"$LOGFILE" >/dev/null; then+ printf "%b[!] check_inscope command failed.%b\n" "$bred" "$reset"+ fi+ fi++ if ! NUMOFLINES=$(grep "\.$domain$\|^$domain$" .tmp/subwiz_resolved.txt 2>>"$LOGFILE" \+ | grep -E '^([a-zA-Z0-9\.\-]+\.)+[a-zA-Z]{1,}$' \+ | anew subdomains/subdomains.txt \+ | sed '/^$/d' \+ | wc -l); then+ NUMOFLINES=0+ fi+ else+ NUMOFLINES=0+ fi++ end_subfunc "${NUMOFLINES} new subs (permutations by IA)" "${FUNCNAME[0]}"++ else+ if [[ $SUBIAPERMUTE == false ]]; then+ printf "\n%b[%s] %s skipped due to mode or defined in reconftw.cfg.%b\n" \+ "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"+ else+ printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s%b\n\n" \+ "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$called_fn_dir" "/.${FUNCNAME[0]}" "$reset"+ fi+ fi++}++function sub_recursive_passive() {++ # Create necessary directories+ if ! mkdir -p .tmp subdomains; then+ printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"+ return 1+ fi++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $SUB_RECURSIVE_PASSIVE == true ]] && [[ -s "subdomains/subdomains.txt" ]]; then+ start_subfunc "${FUNCNAME[0]}" "Running: Subdomains recursive search passive"++ # If in multi mode and subdomains.txt doesn't exist, create it with the domain+ if [[ -n $multi ]] && [[ ! -f "$dir/subdomains/subdomains.txt" ]]; then+ printf "%b\n" "$domain" >"$dir/subdomains/subdomains.txt"+ fi++ # Passive recursive+ if [[ -s "subdomains/subdomains.txt" ]]; then+ dsieve -if subdomains/subdomains.txt -f 3 -top "$DEEP_RECURSIVE_PASSIVE" >.tmp/subdomains_recurs_top.txt+ fi++ if [[ $AXIOM != true ]]; then+ if ! resolvers_update_quick_local; then+ printf "%b[!] Failed to update resolvers locally.%b\n" "$bred" "$reset"+ return 1+ fi++ if [[ -s ".tmp/subdomains_recurs_top.txt" ]]; then+ subfinder -all -dL .tmp/subdomains_recurs_top.txt -max-time "${SUBFINDER_ENUM_TIMEOUT}" \+ -silent -o .tmp/passive_recursive_tmp.txt 2>>"$LOGFILE"+ else+ return 1+ fi++ if [[ -s ".tmp/passive_recursive_tmp.txt" ]]; then+ cat .tmp/passive_recursive_tmp.txt | anew -q .tmp/passive_recursive.txt+ fi++ if [[ -s ".tmp/passive_recursive.txt" ]]; then+ puredns resolve .tmp/passive_recursive.txt -w .tmp/passive_recurs_tmp.txt -r "$resolvers" --resolvers-trusted "$resolvers_trusted" \+ -l "$PUREDNS_PUBLIC_LIMIT" --rate-limit-trusted "$PUREDNS_TRUSTED_LIMIT" \+ --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \+ 2>>"$LOGFILE" >/dev/null+ fi++ else+ if ! resolvers_update_quick_axiom; then+ printf "%b[!] Failed to update resolvers on Axiom.%b\n" "$bred" "$reset"+ return 1+ fi++ if [[ -s ".tmp/subdomains_recurs_top.txt" ]]; then+ axiom-scan .tmp/subdomains_recurs_top.txt -m subfinder -all -o .tmp/subfinder_prec.txt "$AXIOM_EXTRA_ARGS" 2>>"$LOGFILE" >/dev/null+ else+ return 1+ fi++ if [[ -s ".tmp/subfinder_prec.txt" ]]; then+ cat .tmp/subfinder_prec.txt | anew -q .tmp/passive_recursive.txt+ fi++ if [[ -s ".tmp/passive_recursive.txt" ]]; then+ axiom-scan .tmp/passive_recursive.txt -m puredns-resolve \+ -r ${AXIOM_RESOLVERS_PATH} --resolvers-trusted ${AXIOM_RESOLVERS_TRUSTED_PATH} \+ --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \+ -o .tmp/passive_recurs_tmp.txt "$AXIOM_EXTRA_ARGS" 2>>"$LOGFILE" >/dev/null+ fi+ fi++ if [[ $INSCOPE == true ]]; then+ if ! check_inscope .tmp/passive_recurs_tmp.txt 2>>"$LOGFILE" >/dev/null; then+ printf "%b[!] check_inscope command failed.%b\n" "$bred" "$reset"+ fi+ fi++ if [[ -s ".tmp/passive_recurs_tmp.txt" ]]; then+ if ! NUMOFLINES=$(grep "\.$domain$\|^$domain$" .tmp/passive_recurs_tmp.txt 2>>"$LOGFILE" \+ | grep -E '^([a-zA-Z0-9\.\-]+\.)+[a-zA-Z]{1,}$' \+ | sed '/^$/d' \+ | anew subdomains/subdomains.txt \+ | wc -l); then+ NUMOFLINES=0+ fi+ else+ NUMOFLINES=0+ fi++ end_subfunc "${NUMOFLINES} new subs (recursive)" "${FUNCNAME[0]}"++ else+ if [[ $SUB_RECURSIVE_PASSIVE == false ]]; then+ printf "\n%b[%s] %s skipped due to mode or defined in reconftw.cfg.%b\n" \+ "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"+ elif [[ ! -s "subdomains/subdomains.txt" ]]; then+ printf "\n%s[%s] No subdomains to process.%b\n" \+ "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"+ else+ printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s%b\n\n" \+ "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$called_fn_dir" "/.${FUNCNAME[0]}" "$reset"+ fi+ fi++}++function sub_recursive_brute() {+ # Create necessary directories+ if ! mkdir -p .tmp subdomains; then+ printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"+ return 1+ fi++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $SUB_RECURSIVE_BRUTE == true ]] && [[ -s "subdomains/subdomains.txt" ]]; then+ start_subfunc "${FUNCNAME[0]}" "Running: Subdomains recursive search active"++ # If in multi mode and subdomains.txt doesn't exist, create it with the domain+ if [[ -n $multi ]] && [[ ! -f "$dir/subdomains/subdomains.txt" ]]; then+ echo "$domain" >"$dir/subdomains/subdomains.txt"+ fi++ # Check the number of subdomains+ subdomain_count=$(wc -l <subdomains/subdomains.txt)+ if [[ $subdomain_count -le $DEEP_LIMIT ]]; then+ # Generate top subdomains if not already done+ if [[ ! -s ".tmp/subdomains_recurs_top.txt" ]]; then+ dsieve -if subdomains/subdomains.txt -f 3 -top "$DEEP_RECURSIVE_PASSIVE" >.tmp/subdomains_recurs_top.txt+ fi++ for subdomain_top in $(cat .tmp/subdomains_recurs_top.txt); do+ if [[ $AXIOM != true ]]; then+ if ! resolvers_update_quick_local; then+ printf "%b[!] Failed to update resolvers locally.%b\n" "$bred" "$reset"+ return 1+ fi+ puredns bruteforce "$subs_wordlist" "$subdomain_top" -r "$resolvers" --resolvers-trusted "$resolvers_trusted" \+ -l "$PUREDNS_PUBLIC_LIMIT" --rate-limit-trusted "$PUREDNS_TRUSTED_LIMIT" \+ --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \+ -w .tmp/brute_recursive_result_part.txt 2>>"$LOGFILE" >/dev/null+ cat .tmp/brute_recursive_result_part.txt | anew -q .tmp/brute_recursive.txt+ else+ if ! resolvers_update_quick_axiom; then+ printf "%b[!] Failed to update resolvers on axiom.%b\n" "$bred" "$reset"+ return 1+ fi+ axiom-scan "$subs_wordlist" -m puredns-single "$subdomain_top" \+ -r ${AXIOM_RESOLVERS_PATH} --resolvers-trusted ${AXIOM_RESOLVERS_TRUSTED_PATH} \+ --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \+ -o .tmp/brute_recursive_result_part.txt $AXIOM_EXTRA_ARGS \+ 2>>"$LOGFILE" >/dev/null+ cat .tmp/brute_recursive_result_part.txt | anew -q .tmp/brute_recursive.txt+ fi+ done++ # Generate permutations+ if [[ $PERMUTATIONS_OPTION == "gotator" ]]; then+ if [[ -s ".tmp/brute_recursive.txt" ]]; then+ gotator -sub .tmp/brute_recursive.txt -perm "${tools}/permutations_list.txt" $GOTATOR_FLAGS -silent \+ 2>>"$LOGFILE" | head -c "$PERMUTATIONS_LIMIT" >.tmp/gotator1_recursive.txt+ fi+ else+ if [[ -s ".tmp/brute_recursive.txt" ]]; then+ ripgen -d .tmp/brute_recursive.txt -w "${tools}/permutations_list.txt" \+ 2>>"$LOGFILE" | head -c "$PERMUTATIONS_LIMIT" >.tmp/gotator1_recursive.txt+ fi+ fi++ # Resolve permutations+ if [[ $AXIOM != true ]]; then+ if [[ -s ".tmp/gotator1_recursive.txt" ]]; then+ puredns resolve .tmp/gotator1_recursive.txt -w .tmp/permute1_recursive.txt \+ -r "$resolvers" --resolvers-trusted "$resolvers_trusted" \+ -l "$PUREDNS_PUBLIC_LIMIT" --rate-limit-trusted "$PUREDNS_TRUSTED_LIMIT" \+ --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \+ 2>>"$LOGFILE" >/dev/null+ fi+ else+ if [[ -s ".tmp/gotator1_recursive.txt" ]]; then+ axiom-scan .tmp/gotator1_recursive.txt -m puredns-resolve \+ -r ${AXIOM_RESOLVERS_PATH} --resolvers-trusted ${AXIOM_RESOLVERS_TRUSTED_PATH} \+ --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \+ -o .tmp/permute1_recursive.txt $AXIOM_EXTRA_ARGS \+ 2>>"$LOGFILE" >/dev/null+ fi+ fi++ # Second round of permutations+ if [[ $PERMUTATIONS_OPTION == "gotator" ]]; then+ if [[ -s ".tmp/permute1_recursive.txt" ]]; then+ gotator -sub .tmp/permute1_recursive.txt -perm "${tools}/permutations_list.txt" $GOTATOR_FLAGS -silent \+ 2>>"$LOGFILE" | head -c "$PERMUTATIONS_LIMIT" >.tmp/gotator2_recursive.txt+ fi+ else+ if [[ -s ".tmp/permute1_recursive.txt" ]]; then+ ripgen -d .tmp/permute1_recursive.txt -w "${tools}/permutations_list.txt" \+ 2>>"$LOGFILE" | head -c "$PERMUTATIONS_LIMIT" >.tmp/gotator2_recursive.txt+ fi+ fi++ # Resolve second round of permutations+ if [[ $AXIOM != true ]]; then+ if [[ -s ".tmp/gotator2_recursive.txt" ]]; then+ puredns resolve .tmp/gotator2_recursive.txt -w .tmp/permute2_recursive.txt \+ -r "$resolvers" --resolvers-trusted "$resolvers_trusted" \+ -l "$PUREDNS_PUBLIC_LIMIT" --rate-limit-trusted "$PUREDNS_TRUSTED_LIMIT" \+ --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \+ 2>>"$LOGFILE" >/dev/null+ fi+ else+ if [[ -s ".tmp/gotator2_recursive.txt" ]]; then+ axiom-scan .tmp/gotator2_recursive.txt -m puredns-resolve \+ -r ${AXIOM_RESOLVERS_PATH} --resolvers-trusted ${AXIOM_RESOLVERS_TRUSTED_PATH} \+ --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \+ -o .tmp/permute2_recursive.txt $AXIOM_EXTRA_ARGS \+ 2>>"$LOGFILE" >/dev/null+ fi+ fi++ # Combine permutations+ if [[ -s ".tmp/permute1_recursive.txt" ]] || [[ -s ".tmp/permute2_recursive.txt" ]]; then+ cat .tmp/permute1_recursive.txt .tmp/permute2_recursive.txt 2>>"$LOGFILE" | anew -q .tmp/permute_recursive.txt+ fi+ else+ end_subfunc "Skipping recursive search: Too many subdomains" "${FUNCNAME[0]}"+ return 0+ fi++ # Check inscope if applicable+ if [[ $INSCOPE == true ]]; then+ if [[ -s ".tmp/permute_recursive.txt" ]]; then+ if ! check_inscope .tmp/permute_recursive.txt 2>>"$LOGFILE" >/dev/null; then+ printf "%b[!] check_inscope command failed on permute_recursive.txt.%b\n" "$bred" "$reset"+ fi+ fi+ if [[ -s ".tmp/brute_recursive.txt" ]]; then+ if ! check_inscope .tmp/brute_recursive.txt 2>>"$LOGFILE" >/dev/null; then+ printf "%b[!] check_inscope command failed on brute_recursive.txt.%b\n" "$bred" "$reset"+ fi+ fi+ fi++ # Combine results for final validation+ if [[ -s ".tmp/permute_recursive.txt" ]] || [[ -s ".tmp/brute_recursive.txt" ]]; then+ if ! cat .tmp/permute_recursive.txt .tmp/brute_recursive.txt 2>>"$LOGFILE" | anew -q .tmp/brute_perm_recursive.txt; then+ printf "%b[!] Failed to combine final results.%b\n" "$bred" "$reset"+ return 1+ fi+ fi++ # Final resolve+ if [[ $AXIOM != true ]]; then+ if [[ -s ".tmp/brute_perm_recursive.txt" ]]; then+ puredns resolve .tmp/brute_perm_recursive.txt -w .tmp/brute_perm_recursive_final.txt \+ -r "$resolvers" --resolvers-trusted "$resolvers_trusted" \+ -l "$PUREDNS_PUBLIC_LIMIT" --rate-limit-trusted "$PUREDNS_TRUSTED_LIMIT" \+ --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \+ 2>>"$LOGFILE" >/dev/null+ fi+ else+ if [[ -s ".tmp/brute_perm_recursive.txt" ]]; then+ axiom-scan .tmp/brute_perm_recursive.txt -m puredns-resolve \+ -r ${AXIOM_RESOLVERS_PATH} --resolvers-trusted ${AXIOM_RESOLVERS_TRUSTED_PATH} \+ --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \+ -o .tmp/brute_perm_recursive_final.txt $AXIOM_EXTRA_ARGS \+ 2>>"$LOGFILE" >/dev/null+ fi+ fi++ # Process final results+ if [[ -s ".tmp/brute_perm_recursive_final.txt" ]]; then+ if ! NUMOFLINES=$(grep "\.$domain$\|^$domain$" .tmp/brute_perm_recursive_final.txt 2>>"$LOGFILE" \+ | grep -E '^([a-zA-Z0-9\.\-]+\.)+[a-zA-Z]{1,}$' \+ | sed '/^$/d' \+ | anew subdomains/subdomains.txt \+ | wc -l); then+ NUMOFLINES=0+ fi+ else+ NUMOFLINES=0+ fi++ end_subfunc "${NUMOFLINES} new subs (recursive active)" "${FUNCNAME[0]}"++ else+ if [[ $SUB_RECURSIVE_BRUTE == false ]]; then+ printf "\n%b[%s] %s skipped due to mode or defined in reconftw.cfg.%b\n" \+ "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"+ elif [[ ! -s "subdomains/subdomains.txt" ]]; then+ printf "\n%s[%s] No subdomains to process.%b\n" \+ "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"+ else+ printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s%b\n\n" \+ "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" \+ "$called_fn_dir" "/.${FUNCNAME[0]}" "$reset"+ fi+ fi+}++function subtakeover() {++ # Create necessary directories+ if ! mkdir -p .tmp webs subdomains; then+ printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"+ return 1+ fi++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $SUBTAKEOVER == true ]]; then+ start_func "${FUNCNAME[0]}" "Looking for possible subdomain and DNS takeover"++ # Initialize takeover file+ if ! touch .tmp/tko.txt; then+ printf "%b[!] Failed to create .tmp/tko.txt.%b\n" "$bred" "$reset"+ return 1+ fi++ # Combine webs.txt and webs_uncommon_ports.txt if webs_all.txt doesn't exist+ if [[ ! -s "webs/webs_all.txt" ]]; then+ cat webs/webs.txt webs/webs_uncommon_ports.txt 2>/dev/null | anew -q webs/webs_all.txt+ fi++ #cent update -p ${NUCLEI_TEMPLATES_PATH} &>/dev/null+ if [[ $AXIOM != true ]]; then+ maybe_update_nuclei+ cat subdomains/subdomains.txt webs/webs_all.txt 2>/dev/null | run_command nuclei -silent -nh -tags takeover \+ -severity info,low,medium,high,critical -retries 3 -rl "$NUCLEI_RATELIMIT" \+ -t "${NUCLEI_TEMPLATES_PATH}" -j -o .tmp/tko_json.txt 2>>"$LOGFILE" >/dev/null+ else+ cat subdomains/subdomains.txt webs/webs_all.txt 2>>"$LOGFILE" | sed '/^$/d' | anew -q .tmp/webs_subs.txt+ if [[ -s ".tmp/webs_subs.txt" ]]; then+ run_command axiom-scan .tmp/webs_subs.txt -m nuclei --nuclei-templates "${NUCLEI_TEMPLATES_PATH}" \+ -tags takeover -nh -severity info,low,medium,high,critical -retries 3 -rl "$NUCLEI_RATELIMIT" \+ -t "${NUCLEI_TEMPLATES_PATH}" -j -o .tmp/tko_json.txt $AXIOM_EXTRA_ARGS 2>>"$LOGFILE" >/dev/null+ fi+ fi++ # Convert JSON to text+ if [[ -s ".tmp/tko_json.txt" ]]; then+ jq -r '["[" + .["template-id"] + (if .["matcher-name"] != null then ":" + .["matcher-name"] else "" end) + "] [" + .["type"] + "] [" + .info.severity + "] " + (.["matched-at"] // .host) + (if .["extracted-results"] != null then " " + (.["extracted-results"] | @json) else "" end)] | .[]' .tmp/tko_json.txt >.tmp/tko.txt+ fi++ # DNS Takeover+ cat .tmp/subs_no_resolved.txt .tmp/subdomains_dns.txt .tmp/scrap_subs.txt \+ .tmp/analytics_subs_clean.txt .tmp/passive_recursive.txt 2>/dev/null | anew -q .tmp/subs_dns_tko.txt++ if [[ -s ".tmp/subs_dns_tko.txt" ]]; then+ cat .tmp/subs_dns_tko.txt 2>/dev/null | dnstake -c "$DNSTAKE_THREADS" -s 2>>"$LOGFILE" \+ | sed '/^$/d' | anew -q .tmp/tko.txt+ fi++ # Remove empty lines from tko.txt+ sed_i '/^$/d' .tmp/tko.txt++ # Count new takeover entries+ if ! NUMOFLINES=$(cat .tmp/tko.txt 2>>"$LOGFILE" | anew webs/takeover.txt | sed '/^$/d' | wc -l); then+ printf "%b[!] Failed to count takeover entries.%b\n" "$bred" "$reset"+ NUMOFLINES=0+ fi++ if [[ $NUMOFLINES -gt 0 ]]; then+ notification "${NUMOFLINES} new possible takeovers found" info+ fi++ if [[ $FARADAY == true ]]; then+ if ! faraday-cli status 2>>"$LOGFILE" >/dev/null; then+ printf "%b[!] Faraday server is not running. Skipping Faraday integration.%b\n" "$bred" "$reset"+ else+ if [[ -s ".tmp/tko_json.txt" ]]; then+ faraday-cli tool report -w $FARADAY_WORKSPACE --plugin-id nuclei .tmp/tko_json.txt 2>>"$LOGFILE" >/dev/null+ fi+ fi+ fi++ end_func "Results are saved in $domain/webs/takeover.txt" "${FUNCNAME[0]}"++ else+ if [[ $SUBTAKEOVER == false ]]; then+ printf "\n%b[%s] %s skipped due to mode or defined in reconftw.cfg.%b\n" \+ "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"+ else+ printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s %b\n\n" \+ "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$called_fn_dir" ".${FUNCNAME[0]}" "$reset"+ fi+ fi++}++function zonetransfer() {++ # Create necessary directories+ if ! mkdir -p subdomains; then+ printf "%b[!] Failed to create subdomains directory.%b\n" "$bred" "$reset"+ return 1+ fi++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $ZONETRANSFER == true ]] && ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then+ start_func "${FUNCNAME[0]}" "Zone transfer check"++ # Initialize output file+ if ! : >"subdomains/zonetransfer.txt"; then+ printf "%b[!] Failed to create zonetransfer.txt.%b\n" "$bred" "$reset"+ return 1+ fi++ # Perform zone transfer check+ for ns in $(dig +short ns "$domain" 2>/dev/null); do+ dig axfr "${domain}" @"$ns" 2>>"$LOGFILE" | tee -a "subdomains/zonetransfer.txt" >/dev/null+ done++ # Check if zone transfer was successful+ if [[ -s "subdomains/zonetransfer.txt" ]]; then+ if ! grep -q "Transfer failed" "subdomains/zonetransfer.txt"; then+ notification "Zone transfer found on ${domain}!" "info"+ fi+ fi++ end_func "Results are saved in $domain/subdomains/zonetransfer.txt" "${FUNCNAME[0]}"++ else+ if [[ $ZONETRANSFER == false ]]; then+ printf "\n%b[%s] %s skipped due to mode or defined in reconftw.cfg.%b\n" \+ "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"+ elif [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then+ printf "\n%s[%s] Domain is an IP address; skipping zone transfer.%b\n" \+ "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"+ else+ printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s%b\n\n" \+ "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$called_fn_dir" ".${FUNCNAME[0]}" "$reset"+ fi+ fi++}++function s3buckets() {+ # Create necessary directories+ if ! mkdir -p .tmp subdomains; then+ printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"+ return 1+ fi++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $S3BUCKETS == true ]] && ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then+ start_func "${FUNCNAME[0]}" "AWS S3 buckets search"++ # If in multi mode and subdomains.txt doesn't exist, create it+ if [[ -n $multi ]] && [[ ! -f "$dir/subdomains/subdomains.txt" ]]; then+ if ! printf "%b\n" "$domain" >"$dir/subdomains/subdomains.txt"; then+ printf "%b[!] Failed to create subdomains.txt.%b\n" "$bred" "$reset"+ return 1+ fi+ fi++ # Debug: Print current directory and tools variable+ printf "Current directory: %s\n" "$(pwd)" >>"$LOGFILE"+ printf "Tools directory: %s\n" "$tools" >>"$LOGFILE"++ # S3Scanner+ if [[ $AXIOM != true ]]; then+ if [[ -s "subdomains/subdomains.txt" ]]; then+ s3scanner -bucket-file subdomains/subdomains.txt 2>>"$LOGFILE" | anew -q .tmp/s3buckets.txt+ fi+ else+ axiom-scan subdomains/subdomains.txt -m s3scanner -o .tmp/s3buckets_tmp.txt "$AXIOM_EXTRA_ARGS" 2>>"$LOGFILE" >/dev/null++ if [[ -s ".tmp/s3buckets_tmp.txt" ]]; then+ if ! cat .tmp/s3buckets_tmp.txt .tmp/s3buckets_tmp2.txt 2>>"$LOGFILE" | anew -q .tmp/s3buckets.txt; then+ printf "%b[!] Failed to process s3buckets_tmp.txt.%b\n" "$bred" "$reset"+ fi+ if ! sed_i '/^$/d' .tmp/s3buckets.txt; then+ printf "%b[!] Failed to clean s3buckets.txt.%b\n" "$bred" "$reset"+ fi+ fi+ fi++ # Initialize the output file in the subdomains folder+ if ! : >subdomains/cloudhunter_open_buckets.txt; then+ printf "%b[!] Failed to initialize cloudhunter_open_buckets.txt.%b\n" "$bred" "$reset"+ fi++ # Determine the CloudHunter permutations flag based on the config+ PERMUTATION_FLAG=""+ case "$CLOUDHUNTER_PERMUTATION" in+ DEEP)+ PERMUTATION_FLAG="-p $tools/CloudHunter/permutations-big.txt"+ ;;+ NORMAL)+ PERMUTATION_FLAG="-p $tools/CloudHunter/permutations.txt"+ ;;+ NONE)+ PERMUTATION_FLAG=""+ ;;+ *)+ printf "%b[!] Invalid value for CLOUDHUNTER_PERMUTATION: %s.%b\n" "$bred" "$CLOUDHUNTER_PERMUTATION" "$reset"+ return 1+ ;;+ esac++ # Debug: Print the full CloudHunter command+ #printf "CloudHunter command: %s/venv/bin/python3 %s/cloudhunter.py %s -r %s/resolvers.txt -t 50 [URL]\n" "$tools/CloudHunter" "$tools/CloudHunter" "$PERMUTATION_FLAG" "$tools/CloudHunter" >>"$LOGFILE"++ # Debug: Check if files exist+ if [[ -f "$tools/CloudHunter/cloudhunter.py" ]]; then+ printf "cloudhunter.py exists\n" >>"$LOGFILE"+ else+ printf "cloudhunter.py not found\n" >>"$LOGFILE"+ fi++ if [[ -n $PERMUTATION_FLAG ]]; then+ permutation_file="${PERMUTATION_FLAG}"+ if [[ -f $permutation_file ]]; then+ printf "Permutations file exists\n" >>"$LOGFILE"+ else+ printf "Permutations file not found: %s\n" "$permutation_file" >>"$LOGFILE"+ fi+ fi++ if [[ -f "$tools/CloudHunter/resolvers.txt" ]]; then+ printf "resolvers.txt exists\n" >>"$LOGFILE"+ else+ printf "resolvers.txt not found\n" >>"$LOGFILE"+ fi++ printf "Processing domain: %s\n" "$domain" >>"$LOGFILE"+ (+ if ! cd "$tools/CloudHunter"; then+ printf "%b[!] Failed to cd to %s.%b\n" "$bred" "$tools/CloudHunter" "$reset"+ return 1+ fi+ if ! "${tools}/CloudHunter/venv/bin/python3" ./cloudhunter.py -p ${PERMUTATION_FLAG} -r ./resolvers.txt -t 50 "$domain"; then+ printf "%b[!] CloudHunter command failed for domain %s.%b\n" "$bred" "$domain" "$reset"+ fi+ ) >>"$dir/subdomains/cloudhunter_open_buckets.txt" 2>>"$LOGFILE"++ # Process CloudHunter results+ if [[ -s "subdomains/cloudhunter_open_buckets.txt" ]]; then+ if ! NUMOFLINES1=$(cat subdomains/cloudhunter_open_buckets.txt 2>>"$LOGFILE" | anew subdomains/cloud_assets.txt | wc -l); then+ printf "%b[!] Failed to process cloudhunter_open_buckets.txt.%b\n" "$bred" "$reset"+ NUMOFLINES1=0+ fi+ if [[ $NUMOFLINES1 -gt 0 ]]; then+ notification "${NUMOFLINES1} new cloud assets found" "info"+ fi+ else+ NUMOFLINES1=0+ fi++ # Process s3buckets results+ if [[ -s ".tmp/s3buckets.txt" ]]; then+ if ! NUMOFLINES2=$(cat .tmp/s3buckets.txt 2>>"$LOGFILE" | grep -aiv "not_exist" | grep -aiv "Warning:" | grep -aiv "invalid_name" | grep -aiv "^http" | awk 'NF' | anew subdomains/s3buckets.txt | sed '/^$/d' | wc -l); then+ printf "%b[!] Failed to process s3buckets.txt.%b\n" "$bred" "$reset"+ NUMOFLINES2=0+ fi+ if [[ $NUMOFLINES2 -gt 0 ]]; then+ notification "${NUMOFLINES2} new S3 buckets found" "info"+ fi+ else+ NUMOFLINES2=0+ fi++ # Run trufflehog for S3 buckets+ if [[ -s "subdomains/s3buckets.txt" ]]; then+ while IFS= read -r bucket; do+ trufflehog s3 --bucket="$bucket" -j 2>/dev/null | jq -c | anew -q subdomains/s3buckets_trufflehog.txt+ done <subdomains/s3buckets.txt+ fi++ # Run trufflehog for open buckets found by CloudHunter+ if [[ -s "subdomains/cloudhunter_open_buckets.txt" ]]; then+ while IFS= read -r line; do+ if echo "$line" | grep -q "Aws Cloud"; then+ # AWS S3 Bucket+ bucket_name=$(echo "$line" | awk '{print $3}')+ trufflehog s3 --bucket="$bucket_name" -j 2>/dev/null | jq -c | anew -q subdomains/cloudhunter_buckets_trufflehog.txt+ elif echo "$line" | grep -q "Google Cloud"; then+ # Google Cloud Storage+ bucket_name=$(echo "$line" | awk '{print $3}')+ trufflehog gcs --project-id="$bucket_name" -j 2>/dev/null | jq -c | anew -q subdomains/cloudhunter_buckets_trufflehog.txt+ fi+ done <subdomains/cloudhunter_open_buckets.txt+ fi++ # Append cloud assets to asset store+ append_assets_from_file cloud asset subdomains/cloudhunter_open_buckets.txt+ append_assets_from_file cloud s3bucket subdomains/s3buckets.txt++ end_func "Results are saved in subdomains/s3buckets.txt, subdomains/cloud_assets.txt, subdomains/s3buckets_trufflehog.txt, and subdomains/cloudhunter_buckets_trufflehog.txt" "${FUNCNAME[0]}"+ else+ if [[ $S3BUCKETS == false ]]; then+ printf "\n%b[%s] %s skipped due to mode or defined in reconftw.cfg.%b\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"+ elif [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then+ printf "\n%s[%s] Domain is an IP address; skipping S3 buckets search.%b\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"+ return 0+ else+ printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s%b\n\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$called_fn_dir" ".${FUNCNAME[0]}" "$reset"+ fi+ fi+}++function cloud_extra_providers() {+ mkdir -p subdomains .tmp++ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then+ start_func "${FUNCNAME[0]}" "Extra cloud providers checks"+ # Candidate names from domain and subdomains+ company=$(unfurl format %r <<<"$domain")+ printf "%s\n%s\n${domain%%.*}" "$company" "$domain" | sed 's/[^a-zA-Z0-9-]//g' | awk 'length>2' | sort -u >.tmp/cloudnames.txt+ [[ -s subdomains/subdomains.txt ]] && awk -F. -v r=$(echo "$domain" | awk -F. '{print $(NF-1)"."$NF}') '{print $(NF-2)}' subdomains/subdomains.txt 2>/dev/null | sed 's/[^a-zA-Z0-9-]//g' | awk 'length>2' | sort -u >>.tmp/cloudnames.txt+ sed_i 's/^\///; s/\.$//' .tmp/cloudnames.txt+ sort -u .tmp/cloudnames.txt -o .tmp/cloudnames.txt++ # Common container names for Azure (best-effort)+ printf "public\nstatic\nmedia\nimages\nassets\nbackup\nbackups\nfiles\ncdn" >.tmp/azcontainers.txt++ : >subdomains/cloud_extra.txt++ while IFS= read -r name; do+ # GCS+ for u in \+ "https://storage.googleapis.com/$name/" \+ "https://$name.storage.googleapis.com/"; do+ code=$(curl -sk -o /dev/null -w '%{http_code}' "$u" || true)+ if [[ $code =~ ^20|403$ ]]; then printf "GCS %s %s\n" "$name" "$u" | anew -q subdomains/cloud_extra.txt; fi+ done++ # Azure Blob (requires container; try a few)+ while IFS= read -r c; do+ u="https://$name.blob.core.windows.net/$c?restype=container&comp=list"+ code=$(curl -sk -o /dev/null -w '%{http_code}' "$u" || true)+ if [[ $code =~ ^20|403$ ]]; then printf "AZURE %s %s\n" "$name/$c" "$u" | anew -q subdomains/cloud_extra.txt; fi+ done <.tmp/azcontainers.txt++ # DigitalOcean Spaces (regional)+ for r in ams3 nyc3 sfo3 sgp1 fra1 blr1; do+ u="https://$name.$r.digitaloceanspaces.com/"+ code=$(curl -sk -o /dev/null -w '%{http_code}' "$u" || true)+ if [[ $code =~ ^20|403$ ]]; then printf "DOSPACE %s %s\n" "$name.$r" "$u" | anew -q subdomains/cloud_extra.txt; fi+ done++ # Backblaze B2 (best-effort listing)+ u="https://f000.backblazeb2.com/file/$name/"+ code=$(curl -sk -o /dev/null -w '%{http_code}' "$u" || true)+ if [[ $code =~ ^20|403$ ]]; then printf "B2 %s %s\n" "$name" "$u" | anew -q subdomains/cloud_extra.txt; fi++ done <.tmp/cloudnames.txt++ append_assets_from_file cloud asset subdomains/cloud_extra.txt+ end_func "Results are saved in subdomains/cloud_extra.txt" "${FUNCNAME[0]}"+ else+ printf "\n${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} skipped or already processed.${reset}\n"+ fi+}++###############################################################################################################+############################################# GEOLOCALIZATION INFO ############################################+###############################################################################################################++function geo_info() {++ # Create necessary directories+ if ! mkdir -p hosts; then+ printf "%b[!] Failed to create hosts directory.%b\n" "$bred" "$reset"+ return 1+ fi++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $GEO_INFO == true ]]; then+ start_func "${FUNCNAME[0]}" "Running: ipinfo"++ ips_file="${dir}/hosts/ips.txt"++ # Check if ips.txt exists or is empty; if so, attempt to generate it+ if [[ ! -s $ips_file ]]; then+ # Attempt to generate hosts/ips.txt+ if ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then+ if [[ -s "subdomains/subdomains_dnsregs.json" ]]; then+ jq -r 'select(.host) |"\(.host) - \((.a // [])[])", "\(.host) - \((.aaaa // [])[])"' <"subdomains/subdomains_dnsregs.json" \+ | grep -E ' - [0-9a-fA-F:.]+$' | sort -u | anew -q "subdomains/subdomains_ips.txt"+ fi++ if [[ -s "subdomains/subdomains_ips.txt" ]]; then+ cut -d ' ' -f3 subdomains/subdomains_ips.txt \+ | grep -aEiv "^(127|10|169\.254|172\.1[6-9]|172\.2[0-9]|172\.3[0-1]|192\.168)\." \+ | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b" \+ | anew -q hosts/ips.txt+ fi+ else+ printf "%b\n" "$domain" \+ | grep -aEiv "^(127|10|169\.254|172\.1[6-9]|172\.2[0-9]|172\.3[0-1]|192\.168)\." \+ | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b" \+ | anew -q hosts/ips.txt+ fi+ fi++ if [[ -s $ips_file ]]; then+ if ! touch "${dir}/hosts/ipinfo.txt"; then+ printf "%b[!] Failed to create ipinfo.txt.%b\n" "$bred" "$reset"+ fi++ while IFS= read -r ip; do+ curl -s "https://ipinfo.io/widget/demo/$ip" >>"${dir}/hosts/ipinfo.txt"+ done <"$ips_file"+ fi++ end_func "Results are saved in hosts/ipinfo.txt" "${FUNCNAME[0]}"+ else+ if [[ $GEO_INFO == false ]]; then+ printf "\n%b[%s] %s skipped due to mode or defined in reconftw.cfg.%b\n" \+ "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"+ else+ printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s%b\n\n" \+ "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$called_fn_dir" ".${FUNCNAME[0]}" "$reset"+ fi+ fi++}diff --git a/modules/utils.sh b/modules/utils.shnew file mode 100644index 0000000..5fd18e1--- /dev/null+++ b/modules/utils.sh@@ -0,0 +1,521 @@+#!/bin/bash+# reconFTW - Utility functions module+# Contains: deleteOutScoped, cleanup, rotate_logs, sanitization, validation,+# getElapsedTime, retry, disk check, rate limiting, caching+# This file is sourced by reconftw.sh - do not execute directly+[[ -z "${SCRIPTPATH:-}" ]] && {+ echo "Error: This module must be sourced by reconftw.sh" >&2+ exit 1+}++###############################################################################################################+########################################## OPTIONS & MGMT #####################################################+###############################################################################################################++function deleteOutScoped() {+ if [[ -s "$1" ]]; then+ while IFS= read -r outscoped; do+ [[ -z "$outscoped" ]] && continue+ # Escape regex metacharacters to prevent injection+ local escaped+ escaped=$(printf '%s' "$outscoped" | sed 's/[.[\*^$()+?{|\\]/\\&/g')+ if grep -q "^[*]" <<<"$outscoped"; then+ escaped=$(printf '%s' "${outscoped:1}" | sed 's/[.[\*^$()+?{|\\]/\\&/g')+ sed_i "/${escaped}$/d" "$2"+ else+ sed_i "/${escaped}/d" "$2"+ fi+ done <"$1"+ fi+}++function cleanup_on_exit() {+ printf "\n%b[%s] Interrupted. Cleaning up...%b\n" "$bred" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"+ # Clean temporary chunk files+ rm -rf -- "${dir:-.}/.tmp/chunks" 2>/dev/null+ # Kill any background processes we spawned+ jobs -p 2>/dev/null | xargs -r kill 2>/dev/null || true+ # Log the interruption+ echo "[$(date +'%Y-%m-%d %H:%M:%S')] Interrupted by signal" >>"${LOGFILE:-/dev/null}"+ exit 130+}++function rotate_logs() {+ local log_dir="$1"+ local max_logs="${2:-10}"+ local max_age_days="${3:-30}"++ [[ ! -d "$log_dir" ]] && return 0++ # Delete logs older than max_age_days+ find "$log_dir" -name "*.txt" -type f -mtime +"${max_age_days}" -delete 2>/dev/null || true++ # If still too many, keep only the newest max_logs+ local count+ count=$(find "$log_dir" -name "*.txt" -type f 2>/dev/null | wc -l)+ if [[ $count -gt $max_logs ]]; then+ find "$log_dir" -name "*.txt" -type f -printf '%T@ %p\n' 2>/dev/null \+ | sort -n | head -n $((count - max_logs)) | cut -d' ' -f2- \+ | xargs -r rm -f -- 2>/dev/null || true+ fi+}++function sanitize_interlace_input() {+ # Remove lines containing shell metacharacters that could be exploited+ # via interlace template substitution (_target_, _output_, _cleantarget_)+ local infile="$1"+ local outfile="${2:-$1}"+ if [[ "$infile" == "$outfile" ]]; then+ local tmpfile+ tmpfile=$(mktemp)+ grep -v '[;|&$`\\(){}]' "$infile" >"$tmpfile" 2>/dev/null || true+ mv "$tmpfile" "$outfile"+ else+ grep -v '[;|&$`\\(){}]' "$infile" >"$outfile" 2>/dev/null || true+ fi+}++function validate_config() {+ local warnings=0+ local errors=0++ # Check conflicting configs+ if [[ ${VULNS_GENERAL:-false} == true && ${SUBDOMAINS_GENERAL:-false} == false ]]; then+ printf "%b[WARN] VULNS_GENERAL=true but SUBDOMAINS_GENERAL=false -- vulnerability scans need subdomain data%b\n" "$yellow" "$reset"+ warnings=$((warnings + 1))+ fi++ # Validate numeric thread/rate variables+ for var in FFUF_THREADS HTTPX_THREADS DALFOX_THREADS KATANA_THREADS HTTPX_RATELIMIT NUCLEI_RATELIMIT FFUF_RATELIMIT; do+ if [[ -n "${!var:-}" && ! "${!var}" =~ ^[0-9]+$ ]]; then+ printf "%b[ERROR] %s must be numeric, got: %s%b\n" "$bred" "$var" "${!var}" "$reset"+ errors=$((errors + 1))+ fi+ done++ # Check Axiom tool availability if enabled+ if [[ ${AXIOM:-false} == true ]] && ! command -v axiom-scan >/dev/null 2>&1; then+ printf "%b[WARN] AXIOM=true but axiom-scan not found in PATH%b\n" "$yellow" "$reset"+ warnings=$((warnings + 1))+ fi++ if [[ $errors -gt 0 ]]; then+ printf "%b[ERROR] Configuration has %d error(s). Please fix before running.%b\n" "$bred" "$errors" "$reset"+ return $E_CONFIG+ fi+ if [[ $warnings -gt 0 ]]; then+ printf "%b[INFO] Configuration has %d warning(s).%b\n" "$yellow" "$warnings" "$reset"+ fi+ return 0+}++function getElapsedTime {+ runtime=""+ local T=$2-$1+ local D=$((T / 60 / 60 / 24))+ local H=$((T / 60 / 60 % 24))+ local M=$((T / 60 % 60))+ local S=$((T % 60))+ ((D > 0)) && runtime="$runtime$D days, "+ ((H > 0)) && runtime="$runtime$H hours, "+ ((M > 0)) && runtime="$runtime$M minutes, "+ runtime="$runtime$S seconds."+}++# Retry with exponential backoff+# Usage: retry_with_backoff <max_attempts> <command> [args...]+# Example: retry_with_backoff 3 curl -s "https://example.com"+function retry_with_backoff() {+ local max_attempts="$1"+ shift+ local attempt=1+ local delay=1+ local max_delay=60++ while [ $attempt -le "$max_attempts" ]; do+ if "$@"; then+ return 0+ fi++ if [ $attempt -lt "$max_attempts" ]; then+ printf "%b[%s] Attempt %d/%d failed. Retrying in %d seconds...%b\n" \+ "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "$attempt" "$max_attempts" "$delay" "$reset" >>"$LOGFILE"+ sleep "$delay"++ # Exponential backoff with max cap+ delay=$((delay * 2))+ if [ $delay -gt $max_delay ]; then+ delay=$max_delay+ fi+ fi++ attempt=$((attempt + 1))+ done++ printf "%b[%s] Command failed after %d attempts: %s%b\n" \+ "$bred" "$(date +'%Y-%m-%d %H:%M:%S')" "$max_attempts" "$*" "$reset" >>"$LOGFILE"+ return 1+}++# Check available disk space+# Usage: check_disk_space <required_gb> <path>+# Returns 0 if enough space, 1 otherwise+function check_disk_space() {+ local required_gb="$1"+ local check_path="${2:-.}"++ # Get available space in GB+ local available_gb+ if [[ "$OSTYPE" == "darwin"* ]]; then+ # macOS+ available_gb=$(df -g "$check_path" | awk 'NR==2 {print $4}')+ else+ # Linux+ available_gb=$(df -BG "$check_path" | awk 'NR==2 {gsub(/G/, "", $4); print $4}')+ fi++ if [ -z "$available_gb" ] || [ "$available_gb" -lt "$required_gb" ]; then+ printf "%b[%s] WARNING: Insufficient disk space. Required: %dGB, Available: %dGB at %s%b\n" \+ "$bred" "$(date +'%Y-%m-%d %H:%M:%S')" "$required_gb" "${available_gb:-0}" "$check_path" "$reset"+ return 1+ fi++ printf "%b[%s] Disk space OK: %dGB available at %s%b\n" \+ "$bgreen" "$(date +'%Y-%m-%d %H:%M:%S')" "$available_gb" "$check_path" "$reset"+ return 0+}++# Show progress bar for operations+# Usage: progress_bar <current> <total> <message>+function progress_bar() {+ local current=$1+ local total=$2+ local message="${3:-Processing}"+ local width=50++ # Calculate percentage+ local percent=$((current * 100 / total))+ local filled=$((width * current / total))+ local empty=$((width - filled))++ # Build progress bar+ local bar=""+ for ((i = 0; i < filled; i++)); do bar="${bar}█"; done+ for ((i = 0; i < empty; i++)); do bar="${bar}░"; done++ # Print progress (using \r to overwrite the line)+ printf "\r%b[%s] %s [%s] %d%% (%d/%d)%b" \+ "$bblue" "$(date +'%Y-%m-%d %H:%M:%S')" "$message" "$bar" "$percent" "$current" "$total" "$reset"++ # Print newline when complete+ if [ "$current" -eq "$total" ]; then+ printf "\n"+ fi+}++# Execute command in dry-run mode if enabled+# Usage: run_command <command> [args...]+function run_command() {+ if [[ "${DRY_RUN:-false}" == "true" ]]; then+ printf "%b[DRY-RUN] Would execute: %s%b\n" "$yellow" "$*" "$reset"+ return 0+ fi++ if [[ "${ADAPTIVE_RATE_LIMIT:-false}" == "true" ]]; then+ run_with_adaptive_rate "$@"+ else+ "$@"+ fi+}++# Cross-platform sed_i wrapper+# Usage: sed_i 's/old/new/g' file.txt+# Works on both macOS (BSD sed) and Linux (GNU sed)+function sed_i() {+ if [[ $# -lt 2 ]]; then+ echo "Usage: sed_i 'pattern' file" >&2+ return 1+ fi++ local pattern="$1"+ local file="$2"++ # Check if we're using GNU sed or BSD sed+ if sed --version >/dev/null 2>&1; then+ # GNU sed (Linux or installed via brew on macOS)+ sed -i "$pattern" "$file"+ else+ # BSD sed (default macOS)+ sed -i '' "$pattern" "$file"+ fi+}++###############################################################################################################+#################################### RATE LIMITING ADAPTATIVO #################################################+###############################################################################################################++# Adaptive rate limiting - detects rate limit errors and adjusts automatically+# Global variables for rate limiting+ADAPTIVE_RATE_LIMIT=${ADAPTIVE_RATE_LIMIT:-false}+CURRENT_RATE_LIMIT=${NUCLEI_RATELIMIT:-150}+MIN_RATE_LIMIT=10+MAX_RATE_LIMIT=500+RATE_LIMIT_BACKOFF_FACTOR=0.5+RATE_LIMIT_INCREASE_FACTOR=1.2++# Detect rate limit errors in command output+# Usage: detect_rate_limit_error <output_file_or_string>+function detect_rate_limit_error() {+ local output="$1"++ # Check for common rate limit indicators+ if grep -qiE "(429|too many requests|rate limit|limit exceeded|503|service unavailable)" <<<"$output"; then+ return 0 # Rate limit detected+ fi+ return 1 # No rate limit detected+}++# Adjust rate limit based on errors+# Usage: adjust_rate_limit <increase|decrease>+function adjust_rate_limit() {+ local action="$1"++ [[ "$ADAPTIVE_RATE_LIMIT" != "true" ]] && return 0++ case "$action" in+ decrease)+ local new_limit=$(awk "BEGIN {printf \"%.0f\", $CURRENT_RATE_LIMIT * $RATE_LIMIT_BACKOFF_FACTOR}")+ if [ "$new_limit" -lt "$MIN_RATE_LIMIT" ]; then+ new_limit=$MIN_RATE_LIMIT+ fi+ CURRENT_RATE_LIMIT=$new_limit+ printf "%b[%s] Rate limit decreased to %d req/s due to errors%b\n" \+ "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "$CURRENT_RATE_LIMIT" "$reset" | tee -a "$LOGFILE"+ ;;+ increase)+ local new_limit=$(awk "BEGIN {printf \"%.0f\", $CURRENT_RATE_LIMIT * $RATE_LIMIT_INCREASE_FACTOR}")+ if [ "$new_limit" -gt "$MAX_RATE_LIMIT" ]; then+ new_limit=$MAX_RATE_LIMIT+ fi+ CURRENT_RATE_LIMIT=$new_limit+ printf "%b[%s] Rate limit increased to %d req/s%b\n" \+ "$bgreen" "$(date +'%Y-%m-%d %H:%M:%S')" "$CURRENT_RATE_LIMIT" "$reset" >>"$LOGFILE"+ ;;+ esac++ # Update tool-specific rate limits+ NUCLEI_RATELIMIT=$CURRENT_RATE_LIMIT+ FFUF_RATELIMIT=$CURRENT_RATE_LIMIT+ HTTPX_RATELIMIT=$CURRENT_RATE_LIMIT+}++# Execute command with adaptive rate limiting+# Usage: run_with_adaptive_rate <command> [args...]+function run_with_adaptive_rate() {+ [[ "$ADAPTIVE_RATE_LIMIT" != "true" ]] && {+ "$@"+ return $?+ }++ local max_retries=3+ local retry=0+ local temp_output=$(mktemp)++ while [ $retry -lt $max_retries ]; do+ if "$@" 2>&1 | tee "$temp_output"; then+ # Command succeeded, check if we can increase rate+ if [ $retry -eq 0 ]; then+ adjust_rate_limit increase+ fi+ rm -f "$temp_output"+ return 0+ fi++ # Check if failure was due to rate limiting+ if detect_rate_limit_error "$(cat "$temp_output")"; then+ adjust_rate_limit decrease+ retry=$((retry + 1))+ if [ $retry -lt $max_retries ]; then+ printf "%b[%s] Retrying with lower rate limit (%d/%d)...%b\n" \+ "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "$retry" "$max_retries" "$reset" | tee -a "$LOGFILE"+ sleep 2+ fi+ else+ # Non rate-limit error, don't retry+ rm -f "$temp_output"+ return 1+ fi+ done++ rm -f "$temp_output"+ return 1+}++###############################################################################################################+####################################### SECURITY ################################################+###############################################################################################################++# Sanitize domain input to prevent command injection+# Usage: sanitize_domain <domain>+# Returns: sanitized domain string (lowercase)+function sanitize_domain() {+ local input_domain="$1"++ # Remove any characters that are not alphanumeric, dots, or hyphens+ # This prevents command injection via malicious domain names+ local sanitized+ sanitized=$(echo "$input_domain" | tr -cd 'a-zA-Z0-9.-')++ # Convert to lowercase for consistency+ sanitized=$(echo "$sanitized" | tr '[:upper:]' '[:lower:]')++ # Remove leading/trailing dots and hyphens+ sanitized=$(echo "$sanitized" | sed 's/^[.-]*//; s/[.-]*$//')++ # Check if domain is empty after sanitization+ if [[ -z "$sanitized" ]]; then+ printf "%b[%s] ERROR: Invalid domain after sanitization: '%s'%b\n" \+ "$bred" "$(date +'%Y-%m-%d %H:%M:%S')" "$input_domain" "$reset" >&2+ return 1+ fi++ # Check for basic domain format (at least one dot for TLD)+ if [[ ! "$sanitized" =~ \. ]]; then+ printf "%b[%s] WARNING: Domain '%s' has no TLD, may be invalid%b\n" \+ "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "$sanitized" "$reset" >&2+ fi++ # If sanitization removed characters, warn user+ if [[ "$input_domain" != "$sanitized" ]]; then+ printf "%b[%s] INFO: Domain sanitized from '%s' to '%s'%b\n" \+ "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "$input_domain" "$sanitized" "$reset" >&2+ fi++ echo "$sanitized"+ return 0+}++# Validate and sanitize IP/CIDR input+# Usage: sanitize_ip <ip_or_cidr>+function sanitize_ip() {+ local input="$1"++ # Allow digits, dots, and slash for CIDR+ local sanitized=$(echo "$input" | tr -cd '0-9./,')++ if [[ -z "$sanitized" ]]; then+ printf "%b[%s] ERROR: Invalid IP/CIDR after sanitization: '%s'%b\n" \+ "$bred" "$(date +'%Y-%m-%d %H:%M:%S')" "$input" "$reset" >&2+ return 1+ fi++ echo "$sanitized"+ return 0+}++###############################################################################################################+####################################### CACHÉ DE RECURSOS #####################################################+###############################################################################################################++CACHE_DIR="${SCRIPTPATH}/.cache"+CACHE_MAX_AGE_DAYS=30 # 1 month++# Initialize cache directory+function cache_init() {+ mkdir -p "$CACHE_DIR"/{wordlists,resolvers,tools}+}++# Check if cached file is still valid (less than 30 days old)+# Usage: cache_is_valid <cache_file>+# Returns: 0 if valid, 1 if expired or missing+function cache_is_valid() {+ local cache_file="$1"++ [[ ! -f "$cache_file" ]] && return 1++ # Get file age in days+ local file_age_seconds+ if [[ "$OSTYPE" == "darwin"* ]]; then+ # macOS+ file_age_seconds=$(($(date +%s) - $(stat -f %m "$cache_file")))+ else+ # Linux+ file_age_seconds=$(($(date +%s) - $(stat -c %Y "$cache_file")))+ fi++ local file_age_days=$((file_age_seconds / 86400))++ if [ $file_age_days -lt $CACHE_MAX_AGE_DAYS ]; then+ printf "%b[%s] Using cached file (age: %d days): %s%b\n" \+ "$bgreen" "$(date +'%Y-%m-%d %H:%M:%S')" "$file_age_days" "$(basename "$cache_file")" "$reset" >>"$LOGFILE"+ return 0+ else+ printf "%b[%s] Cache expired (age: %d days): %s%b\n" \+ "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "$file_age_days" "$(basename "$cache_file")" "$reset" >>"$LOGFILE"+ return 1+ fi+}++# Download file with caching support+# Usage: cached_download <url> <destination> [cache_name]+# If cache exists and is valid, copies from cache instead of downloading+function cached_download() {+ local url="$1"+ local destination="$2"+ local cache_name="${3:-$(basename "$url")}"+ local cache_file="$CACHE_DIR/$cache_name"++ cache_init++ # Check if we have valid cached version+ if cache_is_valid "$cache_file"; then+ cp "$cache_file" "$destination"+ return 0+ fi++ # Download fresh copy+ printf "%b[%s] Downloading: %s%b\n" \+ "$bblue" "$(date +'%Y-%m-%d %H:%M:%S')" "$(basename "$url")" "$reset"++ if curl -sL "$url" -o "$destination"; then+ # Save to cache for future use+ cp "$destination" "$cache_file"+ printf "%b[%s] Cached for future use: %s%b\n" \+ "$bgreen" "$(date +'%Y-%m-%d %H:%M:%S')" "$cache_name" "$reset" >>"$LOGFILE"+ return 0+ else+ printf "%b[%s] Download failed: %s%b\n" \+ "$bred" "$(date +'%Y-%m-%d %H:%M:%S')" "$url" "$reset" >&2+ return 1+ fi+}++# Clear old cache files+# Usage: cache_clean [max_age_days]+function cache_clean() {+ local max_age="${1:-$CACHE_MAX_AGE_DAYS}"++ [[ ! -d "$CACHE_DIR" ]] && return 0++ local cleaned=0+ while IFS= read -r -d '' file; do+ local file_age_seconds+ if [[ "$OSTYPE" == "darwin"* ]]; then+ file_age_seconds=$(($(date +%s) - $(stat -f %m "$file")))+ else+ file_age_seconds=$(($(date +%s) - $(stat -c %Y "$file")))+ fi++ local file_age_days=$((file_age_seconds / 86400))++ if [ $file_age_days -gt $max_age ]; then+ rm -f "$file"+ cleaned=$((cleaned + 1))+ fi+ done < <(find "$CACHE_DIR" -type f -print0 2>/dev/null)++ if [ $cleaned -gt 0 ]; then+ printf "%b[%s] Cleaned %d expired cache files%b\n" \+ "$bgreen" "$(date +'%Y-%m-%d %H:%M:%S')" "$cleaned" "$reset"+ fi+}diff --git a/modules/vulns.sh b/modules/vulns.shnew file mode 100644index 0000000..af518e4--- /dev/null+++ b/modules/vulns.sh@@ -0,0 +1,932 @@+#!/bin/bash+# reconFTW - Vulnerability scanning module+# Contains: xss, cors, open_redirect, ssrf_checks, crlf_checks, lfi, ssti,+# sqli, test_ssl, spraying, command_injection, 4xxbypass,+# prototype_pollution, smuggling, webcache, fuzzparams+# This file is sourced by reconftw.sh - do not execute directly+[[ -z "${SCRIPTPATH:-}" ]] && {+ echo "Error: This module must be sourced by reconftw.sh" >&2+ exit 1+}++function xss() {++ # Create necessary directories+ if ! mkdir -p .tmp webs vulns; then+ printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"+ return 1+ fi++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $XSS == true ]] && [[ -s "gf/xss.txt" ]] \+ && ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then++ start_func "${FUNCNAME[0]}" "XSS Analysis"++ # Process gf/xss.txt with qsreplace and Gxss+ if [[ -s "gf/xss.txt" ]]; then+ printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: XSS Payload Generation${reset}\n\n"+ qsreplace FUZZ <"gf/xss.txt" | sed '/FUZZ/!d' | Gxss -c 100 -p Xss | qsreplace FUZZ | sed '/FUZZ/!d' \+ | anew -q ".tmp/xss_reflected.txt"+ fi++ # Determine whether to use Axiom or Katana for scanning+ if [[ $AXIOM != true ]]; then+ # Using Katana+ if [[ $DEEP == true ]]; then+ DEPTH=3+ else+ DEPTH=2+ fi++ if [[ -n $XSS_SERVER ]]; then+ OPTIONS="-b ${XSS_SERVER} -w $DALFOX_THREADS"+ else+ printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] No XSS_SERVER defined, blind XSS skipped\n\n"+ OPTIONS="-w $DALFOX_THREADS"+ fi++ # Run Dalfox with Katana output+ if [[ -s ".tmp/xss_reflected.txt" ]]; then+ printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: Dalfox with Katana${reset}\n\n"+ run_command dalfox pipe --silence --no-color --no-spinner --only-poc r --ignore-return 302,404,403 --skip-bav $OPTIONS -d "$DEPTH" <".tmp/xss_reflected.txt" 2>>"$LOGFILE" |+ anew -q "vulns/xss.txt"+ fi+++ else+ # Using Axiom+ if [[ $DEEP == true ]]; then+ DEPTH=3+ AXIOM_ARGS="$AXIOM_EXTRA_ARGS"+ else+ DEPTH=2+ AXIOM_ARGS="$AXIOM_EXTRA_ARGS"+ fi++ if [[ -n $XSS_SERVER ]]; then+ OPTIONS="-b ${XSS_SERVER} -w $DALFOX_THREADS"+ else+ printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] No XSS_SERVER defined, blind XSS skipped\n\n"+ OPTIONS="-w $DALFOX_THREADS"+ fi++ # Run Dalfox with Axiom-scan output+ if [[ -s ".tmp/xss_reflected.txt" ]]; then+ printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: Dalfox with Axiom${reset}\n\n"+ axiom-scan ".tmp/xss_reflected.txt" -m dalfox --skip-bav $OPTIONS -d "$DEPTH" -o "vulns/xss.txt" $AXIOM_ARGS 2>>"$LOGFILE" >/dev/null+ fi+ fi++ end_func "Results are saved in vulns/xss.txt" "${FUNCNAME[0]}"+ else+ # Handle cases where XSS is false, no vulnerable URLs, or already processed+ if [[ $XSS == false ]]; then+ pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"+ elif [[ ! -s "gf/xss.txt" ]]; then+ pt_msg_warn "${FUNCNAME[0]} skipped: no candidate URLs for XSS"+ else+ pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"+ fi+ fi++}++function cors() {++ # Create necessary directories+ if ! mkdir -p .tmp webs vulns; then+ printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"+ return 1+ fi++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $CORS == true ]] \+ && ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then++ start_func "${FUNCNAME[0]}" "CORS Scan"++ # Combine webs.txt and webs_uncommon_ports.txt into webs_all.txt if it doesn't exist+ if [[ ! -s "webs/webs_all.txt" ]]; then+ cat webs/webs.txt webs/webs_uncommon_ports.txt 2>/dev/null | anew -q "webs/webs_all.txt"+ fi++ # Proceed only if webs_all.txt exists and is non-empty+ if [[ -s "webs/webs_all.txt" ]]; then+ printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: Corsy for CORS Scan${reset}\n\n"+ "${tools}/Corsy/venv/bin/python3" "${tools}/Corsy/corsy.py" -i "webs/webs_all.txt" -o "vulns/cors.txt" 2>>"$LOGFILE" >/dev/null+ else+ end_func "No webs/webs_all.txt file found, CORS Scan skipped." "${FUNCNAME[0]}"+ return+ fi++ end_func "Results are saved in vulns/cors.txt" "${FUNCNAME[0]}"++ else+ # Handle cases where CORS is false, no vulnerable URLs, or already processed+ if [[ $CORS == false ]]; then+ pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"+ elif [[ ! -s "gf/xss.txt" ]]; then+ pt_msg_warn "${FUNCNAME[0]} skipped: no candidate URLs for CORS"+ else+ pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"+ fi+ fi++}++function open_redirect() {++ # Create necessary directories+ if ! mkdir -p .tmp webs vulns; then+ printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"+ return 1+ fi++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $OPEN_REDIRECT == true ]] \+ && [[ -s "gf/redirect.txt" ]] && ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then++ start_func "${FUNCNAME[0]}" "Open Redirects Checks"++ # Determine whether to proceed based on DEEP flag or number of URLs+ URL_COUNT=$(wc -l <"gf/redirect.txt")+ if [[ $DEEP == true ]] || [[ $URL_COUNT -le $DEEP_LIMIT ]]; then++ printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: Open Redirects Payload Generation${reset}\n\n"++ # Process redirect.txt with qsreplace and filter lines containing 'FUZZ'+ qsreplace FUZZ <"gf/redirect.txt" | sed '/FUZZ/!d' | anew -q ".tmp/tmp_redirect.txt"++ # Run Oralyzer with the generated payloads+ "${tools}/Oralyzer/venv/bin/python3" "${tools}/Oralyzer/oralyzer.py" -l ".tmp/tmp_redirect.txt" -p "${tools}/Oralyzer/payloads.txt" >"vulns/redirect.txt" 2>>"$LOGFILE"++ # Remove ANSI color codes from the output+ sed -r -i "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2})?)?[mGK]//g" "vulns/redirect.txt"++ end_func "Results are saved in vulns/redirect.txt" "${FUNCNAME[0]}"+ else+ end_func "Skipping Open Redirects: Too many URLs to test, try with --deep flag." "${FUNCNAME[0]}"+ printf "${bgreen}#######################################################################${reset}\n"+ fi+ else+ # Handle cases where OPEN_REDIRECT is false, no vulnerable URLs, or already processed+ if [[ $OPEN_REDIRECT == false ]]; then+ pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"+ elif [[ ! -s "gf/redirect.txt" ]]; then+ pt_msg_warn "${FUNCNAME[0]} skipped: no candidate URLs for open redirect"+ else+ pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"+ fi+ fi++}++function ssrf_checks() {++ # Create necessary directories+ if ! mkdir -p .tmp gf vulns; then+ printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"+ return 1+ fi++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $SSRF_CHECKS == true ]] \+ && [[ -s "gf/ssrf.txt" ]] && ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then++ start_func "${FUNCNAME[0]}" "SSRF Checks"++ # Handle COLLAB_SERVER configuration+ if [[ -z $COLLAB_SERVER ]]; then+ interactsh-client &>.tmp/ssrf_callback.txt &+ INTERACTSH_PID=$!+ sleep 2++ # Extract FFUFHASH from interactsh_callback.txt+ COLLAB_SERVER_FIX="FFUFHASH.$(tail -n1 .tmp/ssrf_callback.txt | cut -c 16-)"+ COLLAB_SERVER_URL="http://$COLLAB_SERVER_FIX"+ INTERACT=true+ else+ COLLAB_SERVER_FIX="FFUFHASH.$(echo "$COLLAB_SERVER" | sed -r "s|https?://||")"+ INTERACT=false+ fi++ # Determine whether to proceed based on DEEP flag or URL count+ URL_COUNT=$(wc -l <"gf/ssrf.txt")+ if [[ $DEEP == true ]] || [[ $URL_COUNT -le $DEEP_LIMIT ]]; then++ printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: SSRF Payload Generation${reset}\n\n"++ # Generate temporary SSRF payloads+ qsreplace "$COLLAB_SERVER_FIX" <"gf/ssrf.txt" | anew -q ".tmp/tmp_ssrf.txt"++ qsreplace "$COLLAB_SERVER_URL" <"gf/ssrf.txt" | anew -q ".tmp/tmp_ssrf.txt"++ # Run FFUF to find requested URLs+ printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: FFUF for SSRF Requested URLs${reset}\n\n"+ run_command ffuf -v -H "${HEADER}" -t "$FFUF_THREADS" -rate "$FFUF_RATELIMIT" -w ".tmp/tmp_ssrf.txt" -u "FUZZ" 2>/dev/null \+ | anew -q "vulns/ssrf_requested.txt"++ # Run FFUF with header injection for SSRF+ printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: FFUF for SSRF Requested Headers with COLLAB_SERVER_FIX${reset}\n\n"+ run_command ffuf -v -w ".tmp/tmp_ssrf.txt:W1,${tools}/headers_inject.txt:W2" -H "${HEADER}" -H "W2: ${COLLAB_SERVER_FIX}" -t "$FFUF_THREADS" \+ -rate "$FFUF_RATELIMIT" -u "W1" 2>/dev/null | anew -q "vulns/ssrf_requested_headers.txt"++ printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: FFUF for SSRF Requested Headers with COLLAB_SERVER_URL${reset}\n\n"+ run_command ffuf -v -w ".tmp/tmp_ssrf.txt:W1,${tools}/headers_inject.txt:W2" -H "${HEADER}" -H "W2: ${COLLAB_SERVER_URL}" -t "$FFUF_THREADS" \+ -rate "$FFUF_RATELIMIT" -u "W1" 2>/dev/null | anew -q "vulns/ssrf_requested_headers.txt"++ # Allow time for callbacks to be received+ sleep 5++ # Process SSRF callback results if INTERACT is enabled+ if [[ $INTERACT == true ]] && [[ -s ".tmp/ssrf_callback.txt" ]]; then+ tail -n +11 .tmp/ssrf_callback.txt | anew -q "vulns/ssrf_callback.txt"+ NUMOFLINES=$(tail -n +12 .tmp/ssrf_callback.txt | sed '/^$/d' | wc -l)+ notification "SSRF: ${NUMOFLINES} callbacks received" info+ fi++ end_func "Results are saved in vulns/ssrf_*" "${FUNCNAME[0]}"+ else+ end_func "Skipping SSRF: Too many URLs to test, try with --deep flag." "${FUNCNAME[0]}"+ printf "${bgreen}#######################################################################${reset}\n"+ fi++ # Terminate interactsh-client if it was started+ if [[ $INTERACT == true ]] && [[ -n "${INTERACTSH_PID:-}" ]]; then+ kill "$INTERACTSH_PID" 2>/dev/null || true+ unset INTERACTSH_PID+ fi++ else+ # Handle cases where SSRF_CHECKS is false, no vulnerable URLs, or already processed+ if [[ $SSRF_CHECKS == false ]]; then+ pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"+ elif [[ ! -s "gf/ssrf.txt" ]]; then+ pt_msg_warn "${FUNCNAME[0]} skipped: no candidate URLs for SSRF"+ else+ pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"+ fi+ fi++}++function crlf_checks() {++ # Create necessary directories+ if ! mkdir -p webs vulns; then+ printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"+ return 1+ fi++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $CRLF_CHECKS == true ]] \+ && ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then++ start_func "${FUNCNAME[0]}" "CRLF Checks"++ # Combine webs.txt and webs_uncommon_ports.txt into webs_all.txt if it doesn't exist+ if [[ ! -s "webs/webs_all.txt" ]]; then+ cat webs/webs.txt webs/webs_uncommon_ports.txt 2>/dev/null | anew -q "webs/webs_all.txt"+ fi++ # Determine whether to proceed based on DEEP flag or number of URLs+ URL_COUNT=$(wc -l <"webs/webs_all.txt")+ if [[ $DEEP == true ]] || [[ $URL_COUNT -le $DEEP_LIMIT ]]; then++ printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: CRLF Fuzzing${reset}\n\n"++ # Run CRLFuzz+ crlfuzz -l "webs/webs_all.txt" -o "vulns/crlf.txt" 2>>"$LOGFILE" >/dev/null++ end_func "Results are saved in vulns/crlf.txt" "${FUNCNAME[0]}"+ else+ end_func "Skipping CRLF: Too many URLs to test, try with --deep flag." "${FUNCNAME[0]}"+ fi+ else+ # Handle cases where CRLF_CHECKS is false, no vulnerable URLs, or already processed+ if [[ $CRLF_CHECKS == false ]]; then+ pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"+ elif [[ ! -s "vulns/crlf.txt" ]]; then+ pt_msg_warn "${FUNCNAME[0]} skipped: no candidate URLs for CRLF"+ else+ pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"+ fi+ fi++}++function lfi() {++ # Create necessary directories+ if ! mkdir -p .tmp gf vulns; then+ printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"+ return 1+ fi++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $LFI == true ]] \+ && [[ -s "gf/lfi.txt" ]] && ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then++ start_func "${FUNCNAME[0]}" "LFI Checks"++ # Ensure gf/lfi.txt is not empty+ if [[ -s "gf/lfi.txt" ]]; then+ printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: LFI Payload Generation${reset}\n\n"++ # Process lfi.txt with qsreplace and filter lines containing 'FUZZ'+ qsreplace "FUZZ" <"gf/lfi.txt" | sed '/FUZZ/!d' | anew -q ".tmp/tmp_lfi.txt"++ # Determine whether to proceed based on DEEP flag or number of URLs+ URL_COUNT=$(wc -l <".tmp/tmp_lfi.txt")+ if [[ $DEEP == true ]] || [[ $URL_COUNT -le $DEEP_LIMIT ]]; then++ printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: LFI Fuzzing with FFUF${reset}\n\n"++ # Use Interlace to parallelize FFUF scanning+ interlace -tL ".tmp/tmp_lfi.txt" -threads "$INTERLACE_THREADS" -c "ffuf -v -r -t ${FFUF_THREADS} -rate ${FFUF_RATELIMIT} -H \"${HEADER}\" -w \"${lfi_wordlist}\" -u \"_target_\" -mr \"root:\" " 2>>"$LOGFILE" \+ | grep "URL" | sed 's/| URL | //' | anew -q "vulns/lfi.txt"++ end_func "Results are saved in vulns/lfi.txt" "${FUNCNAME[0]}"+ else+ end_func "Skipping LFI: Too many URLs to test, try with --deep flag." "${FUNCNAME[0]}"+ fi+ else+ end_func "No gf/lfi.txt file found, LFI Checks skipped." "${FUNCNAME[0]}"+ return+ fi+ else+ # Handle cases where LFI is false, no vulnerable URLs, or already processed+ if [[ $LFI == false ]]; then+ pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"+ elif [[ ! -s "gf/lfi.txt" ]]; then+ pt_msg_warn "${FUNCNAME[0]} skipped: no candidate URLs for LFI"+ else+ pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"+ fi+ fi++}++function ssti() {++ # Create necessary directories+ if ! mkdir -p .tmp gf vulns; then+ printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"+ return 1+ fi++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $SSTI == true ]] \+ && [[ -s "gf/ssti.txt" ]] && ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then++ start_func "${FUNCNAME[0]}" "SSTI Checks"++ # Ensure gf/ssti.txt is not empty+ if [[ -s "gf/ssti.txt" ]]; then+ printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: SSTI Payload Generation${reset}\n\n"++ # Process ssti.txt with qsreplace and filter lines containing 'FUZZ'+ qsreplace "FUZZ" <"gf/ssti.txt" | sed '/FUZZ/!d' | anew -q ".tmp/tmp_ssti.txt"++ # Determine whether to proceed based on DEEP flag or number of URLs+ URL_COUNT=$(wc -l <".tmp/tmp_ssti.txt")+ if [[ $DEEP == true ]] || [[ $URL_COUNT -le $DEEP_LIMIT ]]; then++ printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: SSTI Fuzzing with FFUF${reset}\n\n"++ # Use Interlace to parallelize FFUF scanning+ interlace -tL ".tmp/tmp_ssti.txt" -threads "$INTERLACE_THREADS" -c "ffuf -v -r -t ${FFUF_THREADS} -rate ${FFUF_RATELIMIT} -H \"${HEADER}\" -w \"${ssti_wordlist}\" -u \"_target_\" -mr \"ssti49\"" 2>>"$LOGFILE" \+ | grep "URL" | sed 's/| URL | //' | anew -q "vulns/ssti.txt"++ end_func "Results are saved in vulns/ssti.txt" "${FUNCNAME[0]}"+ else+ end_func "Skipping SSTI: Too many URLs to test, try with --deep flag." "${FUNCNAME[0]}"+ fi+ else+ end_func "No gf/ssti.txt file found, SSTI Checks skipped." "${FUNCNAME[0]}"+ return+ fi+ else+ # Handle cases where SSTI is false, no vulnerable URLs, or already processed+ if [[ $SSTI == false ]]; then+ pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"+ elif [[ ! -s "gf/ssti.txt" ]]; then+ pt_msg_warn "${FUNCNAME[0]} skipped: no candidate URLs for SSTI"+ else+ pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"+ fi+ fi++}++function sqli() {++ # Create necessary directories+ if ! mkdir -p .tmp gf vulns; then+ printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"+ return 1+ fi++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $SQLI == true ]] \+ && [[ -s "gf/sqli.txt" ]] && ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then++ start_func "${FUNCNAME[0]}" "SQLi Checks"++ # Ensure gf/sqli.txt is not empty+ if [[ -s "gf/sqli.txt" ]]; then+ printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: SQLi Payload Generation${reset}\n\n"++ # Process sqli.txt with qsreplace and filter lines containing 'FUZZ'+ qsreplace "FUZZ" <"gf/sqli.txt" | sed '/FUZZ/!d' | anew -q ".tmp/tmp_sqli.txt"++ # Determine whether to proceed based on DEEP flag or number of URLs+ URL_COUNT=$(wc -l <".tmp/tmp_sqli.txt")+ if [[ $DEEP == true ]] || [[ $URL_COUNT -le $DEEP_LIMIT ]]; then++ # Check if SQLMAP is enabled and run SQLMap+ if [[ $SQLMAP == true ]]; then+ printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: SQLMap for SQLi Checks${reset}\n\n"+ run_command python3 "${tools}/sqlmap/sqlmap.py" -m ".tmp/tmp_sqli.txt" -b -o --smart \+ --batch --disable-coloring --random-agent --output-dir="vulns/sqlmap" 2>>"$LOGFILE" >/dev/null+ fi+ # Check if GHAURI is enabled and run Ghauri+ if [[ $GHAURI == true ]]; then+ printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: Ghauri for SQLi Checks${reset}\n\n"+ interlace -tL ".tmp/tmp_sqli.txt" -threads "$INTERLACE_THREADS" -c "ghauri -u _target_ --batch -H \"${HEADER}\" --force-ssl >> vulns/ghauri_log.txt" 2>>"$LOGFILE" >/dev/null+ fi++ end_func "Results are saved in vulns/sqlmap folder" "${FUNCNAME[0]}"+ else+ end_func "Skipping SQLi: Too many URLs to test, try with --deep flag." "${FUNCNAME[0]}"+ fi+ else+ end_func "No gf/sqli.txt file found, SQLi Checks skipped." "${FUNCNAME[0]}"+ return+ fi+ else+ # Handle cases where SQLI is false, no vulnerable URLs, or already processed+ if [[ $SQLI == false ]]; then+ pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"+ elif [[ ! -s "gf/sqli.txt" ]]; then+ pt_msg_warn "${FUNCNAME[0]} skipped: no candidate URLs for SQLi"+ else+ pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"+ fi+ fi++}++function test_ssl() {++ # Create necessary directories+ if ! mkdir -p hosts vulns; then+ printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"+ return 1+ fi++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $TEST_SSL == true ]]; then++ start_func "${FUNCNAME[0]}" "SSL Test"++ # Handle multi-domain scenarios+ if [[ -n $multi ]] && [[ ! -f "$dir/hosts/ips.txt" ]]; then+ echo "$domain" >"$dir/hosts/ips.txt"+ fi++ # Run testssl.sh+ printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: SSL Test with testssl.sh${reset}\n\n"+ "${tools}/testssl.sh/testssl.sh" --quiet --color 0 -U -iL "$dir/hosts/ips.txt" 2>>"$LOGFILE" >"vulns/testssl.txt"++ end_func "Results are saved in vulns/testssl.txt" "${FUNCNAME[0]}"++ else+ # Handle cases where TEST_SSL is false, no vulnerable URLs, or already processed+ if [[ $TEST_SSL == false ]]; then+ pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"+ elif [[ ! -s "vulns/testssl.txt" ]]; then+ pt_msg_warn "${FUNCNAME[0]} skipped: no candidate targets for SSL tests"+ else+ pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"+ fi+ fi++}++function spraying() {++ # Create necessary directories+ if ! mkdir -p "vulns"; then+ printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"+ return 1+ fi++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $SPRAY == true ]] \+ && [[ -s "$dir/hosts/portscan_active.gnmap" ]] && ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then++ start_func "${FUNCNAME[0]}" "Password Spraying"++ # Ensure portscan_active.gnmap exists and is not empty+ if [[ ! -s "$dir/hosts/portscan_active.gnmap" ]]; then+ printf "%b[!] File $dir/hosts/portscan_active.gnmap does not exist or is empty.%b\n" "$bred" "$reset"+ end_func "Port scan results missing. Password Spraying aborted." "${FUNCNAME[0]}"+ return 1+ fi++ printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: Password Spraying with BruteSpray${reset}\n\n"++ # Run BruteSpray for password spraying+ brutespray -f "$dir/hosts/portscan_active.gnmap" -T "$BRUTESPRAY_CONCURRENCE" -o "$dir/vulns/brutespray" 2>>"$LOGFILE" >/dev/null++ end_func "Results are saved in vulns/brutespray folder" "${FUNCNAME[0]}"++ else+ # Handle cases where SPRAY is false, required files are missing, or already processed+ if [[ $SPRAY == false ]]; then+ pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"+ elif [[ ! -s "$dir/hosts/portscan_active.gnmap" ]]; then+ pt_msg_warn "${FUNCNAME[0]} skipped: missing active port scan"+ else+ pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"+ fi+ fi++}++function command_injection() {++ # Create necessary directories+ if ! mkdir -p .tmp gf vulns; then+ printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"+ return 1+ fi++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $COMM_INJ == true ]] \+ && [[ -s "gf/rce.txt" ]] && ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then++ start_func "${FUNCNAME[0]}" "Command Injection Checks"++ # Ensure gf/rce.txt is not empty and process it+ if [[ -s "gf/rce.txt" ]]; then+ printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: Command Injection Payload Generation${reset}\n\n"++ # Process rce.txt with qsreplace and filter lines containing 'FUZZ'+ qsreplace "FUZZ" <"gf/rce.txt" | sed '/FUZZ/!d' | anew -q ".tmp/tmp_rce.txt"++ # Determine whether to proceed based on DEEP flag or number of URLs+ URL_COUNT=$(wc -l <".tmp/tmp_rce.txt")+ if [[ $DEEP == true ]] || [[ $URL_COUNT -le $DEEP_LIMIT ]]; then++ # Run Commix if enabled+ if [[ $COMMIX == true ]]; then+ printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: Commix for Command Injection Checks${reset}\n\n"+ run_command commix --batch -m ".tmp/tmp_rce.txt" --output-dir "vulns/command_injection" 2>>"$LOGFILE" >/dev/null+ fi++ # Additional tools can be integrated here (e.g., Ghauri, sqlmap)++ end_func "Results are saved in vulns/command_injection folder" "${FUNCNAME[0]}"+ else+ end_func "Skipping Command Injection: Too many URLs to test, try with --deep flag." "${FUNCNAME[0]}"+ fi+ else+ end_func "No gf/rce.txt file found, Command Injection Checks skipped." "${FUNCNAME[0]}"+ return+ fi+ else+ # Handle cases where COMM_INJ is false, no vulnerable URLs, or already processed+ if [[ $COMM_INJ == false ]]; then+ pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"+ elif [[ ! -s "gf/rce.txt" ]]; then+ pt_msg_warn "${FUNCNAME[0]} skipped: no candidate URLs for command injection"+ else+ pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"+ fi+ fi++}++function 4xxbypass() {++ # Create necessary directories+ if ! mkdir -p .tmp fuzzing vulns; then+ printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"+ return 1+ fi++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $BYPASSER4XX == true ]] \+ && ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then++ # Extract relevant URLs starting with 4xx but not 404+ printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: 403 Bypass${reset}\n\n"+ grep -E '^4' "fuzzing/fuzzing_full.txt" 2>/dev/null | grep -Ev '^404' | awk '{print $3}' | anew -q ".tmp/403test.txt"++ # Count the number of URLs to process+ URL_COUNT=$(wc -l <".tmp/403test.txt")+ if [[ $DEEP == true ]] || [[ $URL_COUNT -le $DEEP_LIMIT ]]; then++ start_func "${FUNCNAME[0]}" "403 Bypass"++ # Navigate to nomore403 tool directory+ if ! pushd "${tools}/nomore403" >/dev/null; then+ printf "%b[!] Failed to navigate to nomore403 directory.%b\n" "$bred" "$reset"+ end_func "Failed to navigate to nomore403 directory during 403 Bypass." "${FUNCNAME[0]}"+ return 1+ fi++ # Run nomore403 on the processed URLs+ ./nomore403 <"$dir/.tmp/403test.txt" >"$dir/.tmp/4xxbypass.txt" 2>>"$LOGFILE"++ # Return to the original directory+ if ! popd >/dev/null; then+ printf "%b[!] Failed to return to the original directory.%b\n" "$bred" "$reset"+ end_func "Failed to return to the original directory during 403 Bypass." "${FUNCNAME[0]}"+ return 1+ fi++ # Append unique bypassed URLs to the vulns directory+ if [[ -s "$dir/.tmp/4xxbypass.txt" ]]; then+ cat "$dir/.tmp/4xxbypass.txt" | anew -q "vulns/4xxbypass.txt"+ fi++ end_func "Results are saved in vulns/4xxbypass.txt" "${FUNCNAME[0]}"++ else+ notification "Too many URLs to bypass, skipping" warn+ end_func "Skipping Command Injection: Too many URLs to test, try with --deep flag." "${FUNCNAME[0]}"+ fi++ else+ # Handle cases where BYPASSER4XX is false, no vulnerable URLs, or already processed+ if [[ $BYPASSER4XX == false ]]; then+ pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"+ elif [[ ! -s "fuzzing/fuzzing_full.txt" ]]; then+ pt_msg_warn "${FUNCNAME[0]} skipped: no candidate URLs for 4xx bypass"+ else+ pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"+ fi+ fi++}++function prototype_pollution() {++ # Create necessary directories+ if ! mkdir -p .tmp webs vulns; then+ printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"+ return 1+ fi++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $PROTO_POLLUTION == true ]] \+ && ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then++ start_func "${FUNCNAME[0]}" "Prototype Pollution Checks"++ # Determine whether to proceed based on DEEP flag or number of URLs+ URL_COUNT=$(wc -l <"webs/url_extract_nodupes.txt" 2>/dev/null)+ if [[ $DEEP == true ]] || [[ $URL_COUNT -le $DEEP_LIMIT ]]; then++ # Ensure fuzzing_full.txt exists and has content+ if [[ -s "webs/url_extract_nodupes.txt" ]]; then+ printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: Prototype Pollution Mapping${reset}\n\n"++ # Process URL list with ppmap and save results+ ppmap <"webs/url_extract_nodupes.txt" >".tmp/prototype_pollution.txt" 2>>"$LOGFILE"++ # Filter and save relevant results+ if [[ -s ".tmp/prototype_pollution.txt" ]]; then+ grep "EXPL" ".tmp/prototype_pollution.txt" | anew -q "vulns/prototype_pollution.txt"+ fi++ end_func "Results are saved in vulns/prototype_pollution.txt" "${FUNCNAME[0]}"+ else+ printf "%b[!] File webs/url_extract_nodupes.txt is missing or empty.%b\n" "$bred" "$reset"+ end_func "File webs/url_extract_nodupes.txt is missing or empty." "${FUNCNAME[0]}"+ return 1+ fi++ else+ end_func "Skipping Prototype Pollution: Too many URLs to test, try with --deep flag." "${FUNCNAME[0]}"+ fi++ else+ # Handle cases where PROTO_POLLUTION is false, no vulnerable URLs, or already processed+ if [[ $PROTO_POLLUTION == false ]]; then+ pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"+ elif [[ ! -s "webs/url_extract_nodupes.txt" ]]; then+ pt_msg_warn "${FUNCNAME[0]} skipped: no candidate URLs for prototype pollution"+ else+ pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"+ fi+ fi++}++function smuggling() {++ # Create necessary directories+ if ! mkdir -p .tmp webs vulns/smuggling; then+ printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"+ return 1+ fi++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $SMUGGLING == true ]] \+ && ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then++ start_func "${FUNCNAME[0]}" "HTTP Request Smuggling Checks"++ # Combine webs.txt and webs_uncommon_ports.txt into webs_all.txt if it doesn't exist+ if [[ ! -s "webs/webs_all.txt" ]]; then+ cat "webs/webs.txt" "webs/webs_uncommon_ports.txt" 2>/dev/null | anew -q "webs/webs_all.txt"+ fi++ # Determine whether to proceed based on DEEP flag or number of URLs+ URL_COUNT=$(wc -l <"webs/webs_all.txt")+ if [[ $DEEP == true ]] || [[ $URL_COUNT -le $DEEP_LIMIT ]]; then++ printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: HTTP Request Smuggling Checks${reset}\n\n"++ # Run smugglex on the list of URLs+ cat "$dir/webs/webs_all.txt" | smugglex -f plain -o "$dir/.tmp/smuggling.txt" 2>>"$LOGFILE" >/dev/null++ # Append unique smuggling results to vulns directory+ if [[ -s "$dir/.tmp/smuggling.txt" ]]; then+ jq -c < "$dir/.tmp/smuggling.txt" 2>>"$LOGFILE" | anew -q "vulns/smuggling.txt"+ fi++ end_func "Findings are saved in vulns/smuggling.txt" "${FUNCNAME[0]}"++ else+ notification "Too many URLs to bypass, skipping" warn+ end_func "Skipping HTTP Request Smuggling: Too many URLs to test, try with --deep flag." "${FUNCNAME[0]}"+ fi++ else+ # Handle cases where SMUGGLING is false, no vulnerable URLs, or already processed+ if [[ $SMUGGLING == false ]]; then+ pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"+ elif [[ ! -s "webs/webs_all.txt" ]]; then+ pt_msg_warn "${FUNCNAME[0]} skipped: no candidate URLs for HTTP request smuggling"+ else+ pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"+ fi+ fi++}++function webcache() {++ # Create necessary directories+ if ! mkdir -p .tmp webs vulns; then+ printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"+ return 1+ fi++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $WEBCACHE == true ]] \+ && ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then++ start_func "${FUNCNAME[0]}" "Web Cache Poisoning Checks"++ # Combine webs.txt and webs_uncommon_ports.txt into webs_all.txt if it doesn't exist+ if [[ ! -s "webs/webs_all.txt" ]]; then+ cat webs/webs.txt webs/webs_uncommon_ports.txt 2>/dev/null | anew -q "webs/webs_all.txt"+ fi++ # Determine whether to proceed based on DEEP flag or number of URLs+ URL_COUNT=$(wc -l <"webs/webs_all.txt")+ if [[ $DEEP == true ]] || [[ $URL_COUNT -le $DEEP_LIMIT ]]; then++ printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: Web Cache Poisoning Checks${reset}\n\n"++ # Navigate to Web-Cache-Vulnerability-Scanner tool directory+ if ! pushd "${tools}/Web-Cache-Vulnerability-Scanner" >/dev/null; then+ printf "%b[!] Failed to navigate to Web-Cache-Vulnerability-Scanner directory.%b\n" "$bred" "$reset"+ end_func "Failed to navigate to Web-Cache-Vulnerability-Scanner directory during Web Cache Poisoning Checks." "${FUNCNAME[0]}"+ return 1+ fi++ # Run the Web-Cache-Vulnerability-Scanner+ Web-Cache-Vulnerability-Scanner -u "file:$dir/webs/webs_all.txt" -v 0 2>>"$LOGFILE" \+ | anew -q "$dir/.tmp/webcache.txt"++ # Return to the original directory+ if ! popd >/dev/null; then+ printf "%b[!] Failed to return to the original directory.%b\n" "$bred" "$reset"+ end_func "Failed to return to the original directory during Web Cache Poisoning Checks." "${FUNCNAME[0]}"+ return 1+ fi++ # Append unique findings to vulns/webcache.txt+ if [[ -s "$dir/.tmp/webcache.txt" ]]; then+ cat "$dir/.tmp/webcache.txt" | anew -q "vulns/webcache.txt"+ fi++ end_func "Results are saved in vulns/webcache.txt" "${FUNCNAME[0]}"++ else+ end_func "Skipping Web Cache Poisoning: Too many URLs to test, try with --deep flag." "${FUNCNAME[0]}"+ fi++ else+ # Handle cases where WEBCACHE is false, no vulnerable URLs, or already processed+ if [[ $WEBCACHE == false ]]; then+ pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"+ elif [[ ! -s "fuzzing/fuzzing_full.txt" ]]; then+ pt_msg_warn "${FUNCNAME[0]} skipped: no candidate URLs for web cache tests"+ else+ pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"+ fi+ fi++}++function fuzzparams() {++ # Create necessary directories+ if ! mkdir -p .tmp webs vulns; then+ printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"+ return 1+ fi++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $FUZZPARAMS == true ]] \+ && ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then++ start_func "${FUNCNAME[0]}" "Fuzzing Parameters Values Checks"++ # Determine if we should proceed based on DEEP flag or number of URLs+ URL_COUNT=$(wc -l <"webs/url_extract_nodupes.txt")+ if [[ $DEEP == true ]] || [[ $URL_COUNT -le $DEEP_LIMIT2 ]]; then++ #cent update -p ${NUCLEI_TEMPLATES_PATH} &>/dev/null++ if [[ $AXIOM != true ]]; then+ printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: Nuclei Setup and Execution${reset}\n\n"++ # Update Nuclei once per run+ maybe_update_nuclei++ # Execute Nuclei with the fuzzing templates++ run_command nuclei -l webs/url_extract_nodupes.txt -nh -rl "$NUCLEI_RATELIMIT" -silent -retries 2 ${NUCLEI_EXTRA_ARGS} -t ${NUCLEI_TEMPLATES_PATH}/dast -dast -j -o ".tmp/fuzzparams_json.txt" <"webs/url_extract_nodupes.txt" 2>>"$LOGFILE" >/dev/null++ else++ printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: Axiom with Nuclei${reset}\n\n"++ run_command axiom-scan webs/url_extract_nodupes.txt -m nuclei \++ -dast -nh -rl "$NUCLEI_RATELIMIT" \++ -silent -retries 2 "$NUCLEI_EXTRA_ARGS" -dast -j -o ".tmp/fuzzparams_json.txt" $AXIOM_EXTRA_ARGS 2>>"$LOGFILE" >/dev/null++ fi++++ # Convert JSON output to text+ jq -r '["[" + .["template-id"] + (if .["matcher-name"] != null then ":" + .["matcher-name"] else "" end) + "] [" + .["type"] + "] [" + .info.severity + "] " + (.["matched-at"] // .host) + (if .["extracted-results"] != null then " " + (.["extracted-results"] | @json) else "" end)] | .[]' .tmp/fuzzparams_json.txt >.tmp/fuzzparams.txt++ # Append unique results to vulns/fuzzparams.txt+ if [[ -s ".tmp/fuzzparams.txt" ]]; then+ cat ".tmp/fuzzparams.txt" | anew -q "vulns/fuzzparams.txt"+ fi++ # Faraday integration+ if [[ $FARADAY == true ]]; then+ # Check if the Faraday server is running+ if ! faraday-cli status 2>>"$LOGFILE" >/dev/null; then+ printf "%b[!] Faraday server is not running. Skipping Faraday integration.%b\n" "$bred" "$reset"+ else+ if [[ -s ".tmp/fuzzparams_json.txt" ]]; then+ faraday-cli tool report -w $FARADAY_WORKSPACE --plugin-id nuclei .tmp/fuzzparams_json.txt 2>>"$LOGFILE" >/dev/null+ fi+ fi+ fi++ end_func "Results are saved in vulns/fuzzparams.txt" "${FUNCNAME[0]}"++ else+ end_func "Fuzzing Parameters Values: Too many entries to test, try with --deep flag" "${FUNCNAME[0]}"+ fi++ else+ # Handle cases where FUZZPARAMS is false, no vulnerable URLs, or already processed+ if [[ $FUZZPARAMS == false ]]; then+ pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"+ elif [[ ! -s "webs/url_extract_nodupes.txt" ]]; then+ pt_msg_warn "${FUNCNAME[0]} skipped: no candidate URLs for parameter fuzzing"+ else+ pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"+ fi+ fi++}diff --git a/modules/web.sh b/modules/web.shnew file mode 100644index 0000000..b2e11a4--- /dev/null+++ b/modules/web.sh@@ -0,0 +1,1715 @@+#!/bin/bash+# reconFTW - Web analysis module+# Contains: webprobe_simple, webprobe_full, screenshot, virtualhosts, favicon,+# portscan, cdnprovider, waf_checks, nuclei_check, graphql_scan,+# param_discovery, grpc_reflection, fuzz, iishortname, cms_scanner,+# urlchecks, url_gf, url_ext, jschecks, websocket_checks,+# wordlist_gen, wordlist_gen_roboxtractor, password_dict, brokenLinks+# This file is sourced by reconftw.sh - do not execute directly+[[ -z "${SCRIPTPATH:-}" ]] && {+ echo "Error: This module must be sourced by reconftw.sh" >&2+ exit 1+}++###############################################################################################################+########################################### WEB DETECTION #####################################################+###############################################################################################################++function webprobe_simple() {++ # Create necessary directories+ if ! mkdir -p .tmp webs subdomains; then+ printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"+ return 1+ fi++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $WEBPROBESIMPLE == true ]]; then+ start_subfunc "${FUNCNAME[0]}" "Running: HTTP probing $domain"++ # If in multi mode and subdomains.txt doesn't exist, create it+ if [[ -n $multi ]] && [[ ! -f "$dir/subdomains/subdomains.txt" ]]; then+ printf "%b\n" "$domain" >"$dir/subdomains/subdomains.txt"+ touch .tmp/web_full_info.txt webs/web_full_info.txt+ fi++ # Run httpx or axiom-scan+ if [[ $AXIOM != true ]]; then+ httpx ${HTTPX_FLAGS} -no-color -json -random-agent -threads "$HTTPX_THREADS" -rl "$HTTPX_RATELIMIT" \+ -retries 2 -timeout "$HTTPX_TIMEOUT" -o .tmp/web_full_info_probe.txt \+ <subdomains/subdomains.txt 2>>"$LOGFILE" >/dev/null+ else+ axiom-scan subdomains/subdomains.txt -m httpx ${HTTPX_FLAGS} -no-color -json -random-agent \+ -threads "$HTTPX_THREADS" -rl "$HTTPX_RATELIMIT" -retries 2 -timeout "$HTTPX_TIMEOUT" \+ -o .tmp/web_full_info_probe.txt "$AXIOM_EXTRA_ARGS" 2>>"$LOGFILE" >/dev/null+ fi++ # Merge web_full_info files+ cat .tmp/web_full_info.txt 2>>"$LOGFILE" \+ | jq -s 'try .' | jq 'try unique_by(.input)' | jq 'try .[]' 2>>"$LOGFILE" >webs/web_full_info.txt++ # Extract URLs+ if [[ -s "webs/web_full_info.txt" ]]; then+ jq -r 'try .url' webs/web_full_info.txt 2>/dev/null \+ | grep "$domain" \+ | grep -aEo 'https?://[^ ]+' \+ | sed 's/*.//' | anew -q .tmp/probed_tmp.txt+ fi++ # Adaptive throttling heuristics: mark slow hosts (429/403) from httpx+ if [[ -s "webs/web_full_info.txt" ]]; then+ jq -r 'try select(.status_code==403 or .status_code==429) | .url' webs/web_full_info.txt 2>/dev/null \+ | awk -F/ '{print $3}' | sed 's/\:$//' | sort -u >.tmp/slow_hosts.txt+ fi++ # Extract web info to plain text+ if [[ -s "webs/web_full_info.txt" ]]; then+ jq -r 'try . |"\(.url) [\(.status_code)] [\(.title)] [\(.webserver)] \(.tech)"' webs/web_full_info.txt \+ | grep "$domain" | anew -q webs/web_full_info_plain.txt+ fi++ # Remove out-of-scope entries+ if [[ -s $outOfScope_file ]]; then+ if ! deleteOutScoped "$outOfScope_file" .tmp/probed_tmp.txt; then+ printf "%b[!] Failed to delete out-of-scope entries.%b\n" "$bred" "$reset"+ fi+ fi++ touch .tmp/probed_tmp.txt++ # Count new websites+ if ! NUMOFLINES=$(anew webs/webs.txt <.tmp/probed_tmp.txt 2>/dev/null | sed '/^$/d' | wc -l); then+ printf "%b[!] Failed to count new websites.%b\n" "$bred" "$reset"+ NUMOFLINES=0+ fi++ # Update webs_all.txt+ cat webs/webs.txt webs/webs_uncommon_ports.txt 2>/dev/null | anew -q webs/webs_all.txt++ # Asset store: append probed webs+ append_assets_from_file web url webs/webs.txt++ end_subfunc "${NUMOFLINES} new websites resolved" "${FUNCNAME[0]}"++ # Send websites to proxy if conditions met+ if [[ $PROXY == true ]] && [[ -n $proxy_url ]] && [[ $(wc -l <webs/webs.txt) -le $DEEP_LIMIT2 ]]; then+ notification "Sending websites to proxy" "info"+ ffuf -mc all -w webs/webs.txt -u FUZZ -replay-proxy "$proxy_url" 2>>"$LOGFILE" >/dev/null+ fi++ else+ if [[ $WEBPROBESIMPLE == false ]]; then+ pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"+ else+ pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"+ fi+ fi++ # Emit plugin event+ plugins_emit after_webprobe "$domain" "$dir"++}++function webprobe_full() {++ # Create necessary directories+ if ! mkdir -p .tmp webs subdomains; then+ printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"+ return 1+ fi++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $WEBPROBEFULL == true ]]; then+ start_func "${FUNCNAME[0]}" "HTTP Probing Non-Standard Ports"++ # If in multi mode and subdomains.txt doesn't exist, create it+ if [[ -n $multi ]] && [[ ! -f "$dir/subdomains/subdomains.txt" ]]; then+ printf "%b\n" "$domain" >"$dir/subdomains/subdomains.txt"+ touch webs/webs.txt+ fi++ # Check if subdomains.txt is non-empty+ if [[ -s "subdomains/subdomains.txt" ]]; then+ if [[ $AXIOM != true ]]; then+ # Run httpx on subdomains.txt+ run_command httpx -follow-host-redirects -random-agent -status-code \+ -p "$UNCOMMON_PORTS_WEB" -threads "$HTTPX_UNCOMMONPORTS_THREADS" \+ -timeout "$HTTPX_UNCOMMONPORTS_TIMEOUT" -silent -retries 2 \+ -title -web-server -tech-detect -location -no-color -json \+ -o .tmp/web_full_info_uncommon.txt <subdomains/subdomains.txt 2>>"$LOGFILE" >/dev/null+ else+ # Run axiom-scan with httpx module on subdomains.txt+ run_command axiom-scan subdomains/subdomains.txt -m httpx -follow-host-redirects \+ -H "${HEADER}" -status-code -p "$UNCOMMON_PORTS_WEB" \+ -threads "$HTTPX_UNCOMMONPORTS_THREADS" -timeout "$HTTPX_UNCOMMONPORTS_TIMEOUT" \+ -silent -retries 2 -title -web-server -tech-detect -location -no-color -json \+ -o .tmp/web_full_info_uncommon.txt "$AXIOM_EXTRA_ARGS" 2>>"$LOGFILE" >/dev/null+ fi+ fi++ # Process web_full_info_uncommon.txt+ if [[ -s ".tmp/web_full_info_uncommon.txt" ]]; then+ # Extract URLs+ jq -r 'try .url' .tmp/web_full_info_uncommon.txt 2>/dev/null \+ | grep "$domain" \+ | grep -aEo 'https?://[^ ]+' \+ | sed 's/*.//' \+ | anew -q .tmp/probed_uncommon_ports_tmp.txt++ # Extract plain web info+ jq -r 'try . | "\(.url) [\(.status_code)] [\(.title)] [\(.webserver)] \(.tech)"' .tmp/web_full_info_uncommon.txt \+ | grep "$domain" \+ | anew -q webs/web_full_info_uncommon_plain.txt++ # Update webs_full_info_uncommon.txt based on whether domain is IP+ if [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then+ cat .tmp/web_full_info_uncommon.txt 2>>"$LOGFILE" | anew -q webs/web_full_info_uncommon.txt+ else+ grep "$domain" .tmp/web_full_info_uncommon.txt | anew -q webs/web_full_info_uncommon.txt+ fi++ # Count new websites+ if ! NUMOFLINES=$(anew webs/webs_uncommon_ports.txt <.tmp/probed_uncommon_ports_tmp.txt | sed '/^$/d' | wc -l); then+ printf "%b[!] Failed to count new websites.%b\n" "$bred" "$reset"+ NUMOFLINES=0+ fi++ # Notify user+ notification "Uncommon web ports: ${NUMOFLINES} new websites" "good"++ # Display new uncommon ports websites+ if [[ -s "webs/webs_uncommon_ports.txt" ]]; then+ cat "webs/webs_uncommon_ports.txt"+ fi++ # Update webs_all.txt+ cat webs/webs.txt webs/webs_uncommon_ports.txt 2>/dev/null | anew -q webs/webs_all.txt++ # Send to proxy if conditions met+ if [[ $PROXY == true ]] && [[ -n $proxy_url ]] && [[ $(wc -l <webs/webs_uncommon_ports.txt) -le $DEEP_LIMIT2 ]]; then+ notification "Sending websites with uncommon ports to proxy" "info"+ ffuf -mc all -w webs/webs_uncommon_ports.txt -u FUZZ -replay-proxy "$proxy_url" 2>>"$LOGFILE" >/dev/null+ fi+ fi+ end_func "Results are saved in $domain/webs/webs_uncommon_ports.txt" "${FUNCNAME[0]}"+ else+ if [[ $WEBPROBEFULL == false ]]; then+ pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"+ else+ pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"+ fi+ fi++}++function screenshot() {++ # Create necessary directories+ if ! mkdir -p webs screenshots; then+ printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"+ return 1+ fi++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $WEBSCREENSHOT == true ]]; then+ start_func "${FUNCNAME[0]}" "Web Screenshots"++ # Combine webs.txt and webs_uncommon_ports.txt into webs_all.txt if it doesn't exist+ if [[ ! -s "webs/webs_all.txt" ]]; then+ cat webs/webs.txt webs/webs_uncommon_ports.txt 2>/dev/null | anew -q webs/webs_all.txt+ fi++ # Run nuclei or axiom-scan based on AXIOM flag+ if [[ $AXIOM != true ]]; then+ if [[ -s "webs/webs_all.txt" ]]; then+ nuclei -headless -id screenshot -V dir='screenshots' <webs/webs_all.txt 2>>"$LOGFILE"+ fi+ else+ if [[ -s "webs/webs_all.txt" ]]; then+ axiom-scan webs/webs_all.txt -m nuclei-screenshots -o screenshots "$AXIOM_EXTRA_ARGS" 2>>"$LOGFILE" >/dev/null+ fi+ fi+ end_func "Results are saved in $domain/screenshots" "${FUNCNAME[0]}"+ else+ if [[ $WEBSCREENSHOT == false ]]; then+ pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"+ else+ pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"+ fi+ fi++}++function virtualhosts() {++ # Create necessary directories+ if ! mkdir -p .tmp/virtualhosts virtualhosts webs; then+ printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"+ return 1+ fi++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $VIRTUALHOSTS == true ]]; then+ start_func "${FUNCNAME[0]}" "Virtual Hosts Discovery"++ # Combine webs.txt and webs_uncommon_ports.txt into webs_all.txt if it doesn't exist+ if [[ ! -s "webs/webs_all.txt" ]]; then+ cat webs/webs.txt webs/webs_uncommon_ports.txt 2>/dev/null | anew -q webs/webs_all.txt+ fi++ # Proceed only if webs_all.txt exists and is non-empty+ if [[ -s "subdomains/subdomains.txt" ]] && [[ -s "hosts/ips.txt" ]]; then+ VhostFinder -ips hosts/ips.txt -wordlist subdomains/subdomains.txt -verify | grep "+" | anew -q "$dir/webs/virtualhosts.txt"+ end_func "Results are saved in $domain/webs/virtualhosts.txt" "${FUNCNAME[0]}"++ else+ end_func "No subdomains or hosts file found, virtualhosts skipped." "${FUNCNAME[0]}"+ fi++ # Optionally send to proxy if conditions are met+ if [[ $PROXY == true ]] && [[ -n $proxy_url ]] && [[ $(wc -l <webs/webs_uncommon_ports.txt) -le $DEEP_LIMIT2 ]]; then+ notification "Sending websites with uncommon ports to proxy" "info"+ ffuf -mc all -w webs/webs_uncommon_ports.txt -u FUZZ -replay-proxy "$proxy_url" 2>>"$LOGFILE" >/dev/null+ fi++ else+ if [[ $VIRTUALHOSTS == false ]]; then+ printf "\n${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} skipped in this mode or defined in reconftw.cfg ${reset}\n"+ else+ printf "${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} has already been processed. To force execution, delete:\n $called_fn_dir/.${FUNCNAME[0]} ${reset}\n\n"+ fi+ fi++}++###############################################################################################################+############################################# HOST SCAN #######################################################+###############################################################################################################++function favicon() {++ # Create necessary directories+ if ! mkdir -p hosts .tmp/virtualhosts; then+ printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"+ return 1+ fi++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } \+ && [[ $FAVICON == true ]] \+ && ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then++ start_func "${FUNCNAME[0]}" "Favicon IP Lookup"++ # Navigate to the fav-up tool directory+ if ! pushd "${tools}/fav-up" >/dev/null; then+ printf "%b[!] Failed to change directory to %s in %s @ line %s.%b\n" \+ "$bred" "${tools}/fav-up" "${FUNCNAME[0]}" "${LINENO}" "$reset"+ return 1+ fi++ # Run the favicon IP lookup tool+ timeout 10m "${tools}/fav-up/venv/bin/python3" "${tools}/fav-up/favUp.py" -w "$domain" -sc -o favicontest.json 2>>"$LOGFILE" >/dev/null++ # Process the results if favicontest.json exists and is not empty+ if [[ -s "favicontest.json" ]]; then+ jq -r 'try .found_ips' favicontest.json 2>>"$LOGFILE" \+ | grep -v "not-found" >favicontest.txt++ # Replace '|' with newlines+ sed_i "s/|/\n/g" favicontest.txt++ # Move the processed IPs to the hosts directory+ mv favicontest.txt "$dir/hosts/favicontest.txt" 2>>"$LOGFILE"++ # Remove the JSON file+ rm -f favicontest.json 2>>"$LOGFILE"+ fi++ # Return to the original directory+ if ! popd >/dev/null; then+ printf "%b[!] Failed to return to the previous directory in %s @ line %s.%b\n" \+ "$bred" "${FUNCNAME[0]}" "${LINENO}" "$reset"+ fi++ end_func "Results are saved in hosts/favicontest.txt" "${FUNCNAME[0]}"++ else+ if [[ $FAVICON == false ]]; then+ printf "\n${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} skipped due to configuration settings.${reset}\n"+ elif [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then+ # Domain is an IP, do nothing+ return+ else+ printf "${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} has already been processed. To force execution, delete:\n $called_fn_dir/.${FUNCNAME[0]}${reset}\n\n"+ fi+ fi++}++function portscan() {++ # Create necessary directories+ if ! mkdir -p .tmp subdomains hosts webs; then+ printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"+ return 1+ fi++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $PORTSCANNER == true ]]; then+ start_func "${FUNCNAME[0]}" "Port scan"++ # Determine if domain is IP address or domain name+ if ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then+ # Not an IP address+ if [[ -s "subdomains/subdomains_ips.txt" ]]; then+ cut -d ' ' -f3 subdomains/subdomains_ips.txt \+ | grep -aEiv "^(127|10|169\.254|172\.1[6-9]|172\.2[0-9]|172\.3[0-1]|192\.168)\." \+ | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b" \+ | anew -q hosts/ips.txt+ fi++ else+ # Domain is an IP address+ printf "%b\n" "$domain" | grep -aEiv "^(127|10|169\.254|172\.1[6-9]|172\.2[0-9]|172\.3[0-1]|192\.168)\." | grep -oE '\b([0-9]{1,3}\.){3}[0-9]{1,3}\b' | anew -q hosts/ips.txt+ fi++ # Check for CDN providers+ if [[ ! -s "hosts/cdn_providers.txt" ]]; then+ if [[ -s "hosts/ips.txt" ]]; then+ cat hosts/ips.txt | cdncheck -silent -resp -cdn -waf -nc 2>/dev/null | anew -q hosts/cdn_providers.txt+ fi+ fi++ if [[ -s "hosts/ips.txt" ]]; then+ # Remove CDN IPs+ comm -23 <(sort -u hosts/ips.txt) <(cut -d'[' -f1 hosts/cdn_providers.txt | sed 's/[[:space:]]*$//' | sort -u) \+ | grep -aEiv "^(127|10|169\.254|172\.1[6-9]|172\.2[0-9]|172\.3[0-1]|192\.168)\." | grep -oE '\b([0-9]{1,3}\.){3}[0-9]{1,3}\b' \+ | sort -u | anew -q .tmp/ips_nocdn.txt+ fi++ # Display resolved IPs without CDN+ printf "%b\n[%s] Resolved IP addresses (No CDN):%b\n\n" "$bblue" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"+ if [[ -s ".tmp/ips_nocdn.txt" ]]; then+ sort ".tmp/ips_nocdn.txt"+ fi++ printf "%b\n[%s] Scanning ports...%b\n\n" "$bblue" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"++ ips_file="${dir}/hosts/ips.txt"++ # Discover IPv6 addresses from DNS JSON if enabled+ if [[ $IPV6_SCAN == true ]]; then+ if [[ -s "subdomains/subdomains_dnsregs.json" ]]; then+ jq -r '.. | strings | select(test("^[0-9a-fA-F:]+$"))' <"subdomains/subdomains_dnsregs.json" \+ | grep -v '\\.' | sort -u | anew -q hosts/ips_v6.txt+ fi+ # Add target if it's an IPv6 literal+ if [[ $domain =~ : ]]; then echo "$domain" | anew -q hosts/ips_v6.txt; fi+ fi++ if [[ $PORTSCAN_PASSIVE == true ]]; then+ if [[ ! -f $ips_file ]]; then+ printf "%b[!] File %s does not exist.%b\n" "$bred" "$ips_file" "$reset"+ else+ json_array=()+ while IFS= read -r cip; do+ if ! json_result=$(curl -s "https://internetdb.shodan.io/${cip}"); then+ printf "%b[!] Failed to retrieve data for IP %s.%b\n" "$bred" "$cip" "$reset"+ else+ json_array+=("$json_result")+ fi+ done <"$ips_file"+ formatted_json="["+ for ((i = 0; i < ${#json_array[@]}; i++)); do+ formatted_json+="$(echo "${json_array[i]}" | tr -d '\n')"+ if [ $i -lt $((${#json_array[@]} - 1)) ]; then+ formatted_json+=", "+ fi+ done+ formatted_json+="]"+ if ! echo "$formatted_json" >"${dir}/hosts/portscan_shodan.txt"; then+ printf "%b[!] Failed to write portscan_shodan.txt.%b\n" "$bred" "$reset"+ fi+ fi+ fi++ if [[ $PORTSCAN_PASSIVE == true ]] && [[ ! -f "hosts/portscan_passive.txt" ]] && [[ -s ".tmp/ips_nocdn.txt" ]]; then+ smap -iL .tmp/ips_nocdn.txt >hosts/portscan_passive.txt+ fi++ if [[ $PORTSCAN_ACTIVE == true ]]; then+ if [[ $AXIOM != true ]]; then+ if [[ -s ".tmp/ips_nocdn.txt" ]]; then+ run_command $SUDO nmap $PORTSCAN_ACTIVE_OPTIONS -iL .tmp/ips_nocdn.txt -oA hosts/portscan_active 2>>"$LOGFILE" >/dev/null+ fi+ if [[ $IPV6_SCAN == true && -s "hosts/ips_v6.txt" ]]; then+ run_command $SUDO nmap -6 $PORTSCAN_ACTIVE_OPTIONS -iL hosts/ips_v6.txt -oA hosts/portscan_active_v6 2>>"$LOGFILE" >/dev/null+ fi+ else+ if [[ -s ".tmp/ips_nocdn.txt" ]]; then+ run_command axiom-scan .tmp/ips_nocdn.txt -m nmapx $PORTSCAN_ACTIVE_OPTIONS \+ -oA hosts/portscan_active $AXIOM_EXTRA_ARGS 2>>"$LOGFILE" >/dev/null+ fi+ fi+ fi++ if [[ -s "hosts/portscan_active.xml" ]]; then+ nmapurls <hosts/portscan_active.xml 2>>"$LOGFILE" | anew -q hosts/webs.txt+ fi+ if [[ -s "hosts/portscan_active_v6.xml" ]]; then+ nmapurls <hosts/portscan_active_v6.xml 2>>"$LOGFILE" | anew -q hosts/webs_v6.txt+ [[ -s hosts/webs_v6.txt ]] && cat hosts/webs_v6.txt | anew -q webs/webs.txt+ fi++ if [[ $FARADAY == true ]]; then+ # Check if the Faraday server is running+ if ! faraday-cli status 2>>"$LOGFILE" >/dev/null; then+ printf "%b[!] Faraday server is not running. Skipping Faraday integration.%b\n" "$bred" "$reset"+ else+ if [[ -s "hosts/portscan_active.xml" ]]; then+ faraday-cli tool report -w $FARADAY_WORKSPACE --plugin-id nmap hosts/portscan_active.xml 2>>"$LOGFILE" >/dev/null+ fi+ fi+ fi++ if [[ -s "hosts/webs.txt" ]]; then+ if ! NUMOFLINES=$(wc -l <hosts/webs.txt); then+ printf "%b[!] Failed to count lines in hosts/webs.txt.%b\n" "$bred" "$reset"+ NUMOFLINES=0+ fi+ notification "Webs detected from port scan: ${NUMOFLINES} new websites" "good"+ cat hosts/webs.txt+ append_assets_from_file web url hosts/webs.txt+ fi++ end_func "Results are saved in hosts/portscan_[passive|active|shodan].[txt|xml]" "${FUNCNAME[0]}"++ else+ if [[ $PORTSCANNER == false ]]; then+ printf "\n%b[%s] %s skipped due to mode or defined in reconftw.cfg.%b\n" \+ "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"+ else+ printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s%b\n\n" \+ "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$called_fn_dir" ".${FUNCNAME[0]}" "$reset"+ fi+ fi++}++function cdnprovider() {++ # Create necessary directories+ if ! mkdir -p .tmp subdomains hosts; then+ printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"+ return 1+ fi++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } \+ && [[ $CDN_IP == true ]] \+ && ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then++ start_func "${FUNCNAME[0]}" "CDN Provider Check"++ # Check if subdomains_dnsregs.json exists and is not empty+ if [[ -s "subdomains/subdomains_ips.txt" ]]; then+ cut -d ' ' -f3 subdomains/subdomains_ips.txt \+ | grep -aEiv "^(127|10|169\.254|172\.1[6-9]|172\.2[0-9]|172\.3[0-1]|192\.168)\." \+ | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b" \+ | anew -q hosts/ips.txt+ fi++ # Check if ips_cdn.txt exists and is not empty+ if [[ -s "hosts/ips.txt" ]]; then+ # Run cdncheck on the IPs and save to cdn_providers.txt+ cdncheck -silent -resp -nc <hosts/ips.txt | anew -q "$dir/hosts/cdn_providers.txt"+ fi++ end_func "Results are saved in hosts/cdn_providers.txt" "${FUNCNAME[0]}"++ else+ if [[ $CDN_IP == false ]]; then+ printf "\n${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} skipped due to configuration settings.${reset}\n"+ elif [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then+ # Domain is an IP, do nothing+ return+ else+ printf "${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} has already been processed. To force execution, delete:\n $called_fn_dir/.${FUNCNAME[0]}${reset}\n\n"+ fi+ fi++}++###############################################################################################################+############################################# WEB SCAN ########################################################+###############################################################################################################++function waf_checks() {++ # Create necessary directories+ if ! mkdir -p .tmp webs; then+ printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"+ return 1+ fi++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $WAF_DETECTION == true ]]; then+ start_func "${FUNCNAME[0]}" "Website's WAF Detection"++ # Combine webs.txt and webs_uncommon_ports.txt into webs_all.txt if it doesn't exist+ if [[ ! -s "webs/webs_all.txt" ]]; then+ cat webs/webs.txt webs/webs_uncommon_ports.txt 2>/dev/null | anew -q webs/webs_all.txt+ fi++ # Proceed only if webs_all.txt exists and is non-empty+ if [[ -s "webs/webs_all.txt" ]]; then+ if [[ $AXIOM != true ]]; then+ # Run wafw00f on webs_all.txt+ wafw00f -i "webs/webs_all.txt" -o ".tmp/wafs.txt" 2>>"$LOGFILE" >/dev/null+ else+ # Run axiom-scan with wafw00f module on webs_all.txt+ axiom-scan "webs/webs_all.txt" -m wafw00f -o ".tmp/wafs.txt" "$AXIOM_EXTRA_ARGS" 2>>"$LOGFILE" >/dev/null+ fi++ # Process wafs.txt if it exists and is not empty+ if [[ -s ".tmp/wafs.txt" ]]; then+ # Format the wafs.txt file+ sed -e 's/^[ \t]*//' -e 's/ \+ /\t/g' -e '/(None)/d' ".tmp/wafs.txt" | tr -s "\t" ";" >"webs/webs_wafs.txt"++ # Count the number of websites protected by WAF+ if ! NUMOFLINES=$(sed '/^$/d' "webs/webs_wafs.txt" 2>>"$LOGFILE" | wc -l); then+ printf "%b[!] Failed to count lines in webs_wafs.txt.%b\n" "$bred" "$reset"+ NUMOFLINES=0+ fi++ # Send a notification about the number of WAF-protected websites+ notification "${NUMOFLINES} websites protected by WAF" "info"++ # End the function with a success message+ end_func "Results are saved in webs/webs_wafs.txt" "${FUNCNAME[0]}"+ else+ # End the function indicating no results were found+ end_func "No results found" "${FUNCNAME[0]}"+ fi+ else+ # End the function indicating there are no websites to scan+ end_func "No websites to scan" "${FUNCNAME[0]}"+ fi+ else+ # Handle cases where WAF_DETECTION is false or the function has already been processed+ if [[ $WAF_DETECTION == false ]]; then+ pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"+ elif [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then+ # Domain is an IP address; skip the function+ return+ else+ pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"+ fi+ fi++}++function nuclei_check() {++ # Create necessary directories+ if ! mkdir -p .tmp webs subdomains nuclei_output; then+ printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"+ return 1+ fi++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $NUCLEICHECK == true ]]; then+ start_func "${FUNCNAME[0]}" "Templates-based Web Scanner"+ #cent update -p ${NUCLEI_TEMPLATES_PATH} &>/dev/null+ # Update nuclei templates once per run+ maybe_update_nuclei++ # Handle multi mode and initialize subdomains.txt if necessary+ if [[ -n $multi ]] && [[ ! -f "$dir/subdomains/subdomains.txt" ]]; then+ printf "%b\n" "$domain" >"$dir/subdomains/subdomains.txt"+ touch webs/webs.txt webs/webs_uncommon_ports.txt+ fi++ # Combine webs.txt and webs_uncommon_ports.txt into webs_all.txt if it doesn't exist+ if [[ ! -s "webs/webs_all.txt" ]]; then+ cat webs/webs.txt webs/webs_uncommon_ports.txt 2>/dev/null | anew -q webs/webs_all.txt+ fi++ # Combine url_extract_nodupes.txt, subdomains.txt, and webs_all.txt into webs_subs.txt if it doesn't exist+ if [[ ! -s ".tmp/webs_subs.txt" ]]; then+ cat subdomains/subdomains.txt webs/webs_all.txt 2>>"$LOGFILE" >.tmp/webs_subs.txt+ fi++ # Prepare WAF-aware lists+ WAF_LIST=.tmp/webs_waf.txt+ NOWAF_LIST=.tmp/webs_nowaf.txt+ if [[ -s webs/webs_wafs.txt ]]; then+ cut -d';' -f1 webs/webs_wafs.txt | sed 's/https\?:\/\///' | sed 's/\/$//' | sort -u >.tmp/waf_hosts.txt+ awk -F/ '{print $3}' .tmp/webs_subs.txt | sed 's/\:$//' | while read -r host; do+ if grep -q "^$host$" .tmp/waf_hosts.txt; then+ grep "://${host}[:/\n]" .tmp/webs_subs.txt | anew -q "$WAF_LIST"+ else+ grep "://${host}[:/\n]" .tmp/webs_subs.txt | anew -q "$NOWAF_LIST"+ fi+ done+ else+ cp .tmp/webs_subs.txt "$NOWAF_LIST"+ fi++ # Include slow hosts (429/403) into WAF list as well+ if [[ -s .tmp/slow_hosts.txt ]]; then+ while read -r host; do+ grep "://${host}[:/\n]" .tmp/webs_subs.txt | anew -q "$WAF_LIST"+ done <.tmp/slow_hosts.txt+ fi++ # Check if AXIOM is enabled+ if [[ $AXIOM != true ]]; then+ # Split severity levels into an array+ IFS=',' read -ra severity_array <<<"$NUCLEI_SEVERITY"++ for crit in "${severity_array[@]}"; do+ printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: Nuclei Severity: $crit ${reset}\n\n"+ # Non-WAF at default rate+ if [[ -s $NOWAF_LIST ]]; then+ run_command nuclei -l "$NOWAF_LIST" -severity "$crit" -nh -rl "$NUCLEI_RATELIMIT" -silent -retries 2 ${NUCLEI_EXTRA_ARGS} -t ${NUCLEI_TEMPLATES_PATH} -j -o "nuclei_output/${crit}_json.txt" 2>>"$LOGFILE" >/dev/null+ fi+ # WAF hosts at slower rate+ if [[ -s $WAF_LIST ]]; then+ local slow_rl+ slow_rl=$((NUCLEI_RATELIMIT / 3 + 1))+ run_command nuclei -l "$WAF_LIST" -severity "$crit" -nh -rl "$slow_rl" -silent -retries 2 ${NUCLEI_EXTRA_ARGS} -t ${NUCLEI_TEMPLATES_PATH} -j -o "nuclei_output/${crit}_waf_json.txt" 2>>"$LOGFILE" >/dev/null+ [[ -s nuclei_output/${crit}_waf_json.txt ]] && cat nuclei_output/${crit}_waf_json.txt >>nuclei_output/${crit}_json.txt+ fi+ # Parse the JSON output and save the results to a text file+ if [[ -s "nuclei_output/${crit}_json.txt" ]]; then+ jq -r '["[" + .["template-id"] + (if .["matcher-name"] != null then ":" + .["matcher-name"] else "" end) + "] [" + .["type"] + "] [" + .info.severity + "] " + (.["matched-at"] // .host) + (if .["extracted-results"] != null then " " + (.["extracted-results"] | @json) else "" end)] | .[]' nuclei_output/${crit}_json.txt >nuclei_output/${crit}.txt+ # Asset store: append findings+ append_assets_from_file finding value nuclei_output/${crit}.txt+ # Display the results if the output file exists and is not empty+ if [[ -s "nuclei_output/${crit}.txt" ]]; then+ cat "nuclei_output/${crit}.txt"+ fi+ fi+ done+ printf "\n\n"+ else+ # Split severity levels into an array+ IFS=',' read -ra severity_array <<<"$NUCLEI_SEVERITY"++ for crit in "${severity_array[@]}"; do+ printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: Axiom Nuclei Severity: $crit. Check results in nuclei_output folder.${reset}\n\n"+ # Run axiom-scan with nuclei module for each severity level+ run_command axiom-scan .tmp/webs_subs.txt -m nuclei \+ --nuclei-templates "$NUCLEI_TEMPLATES_PATH" \+ -severity "$crit" -nh -rl "$NUCLEI_RATELIMIT" \+ -silent -retries 2 "$NUCLEI_EXTRA_ARGS" -j -o "nuclei_output/${crit}_json.txt" "$AXIOM_EXTRA_ARGS" 2>>"$LOGFILE" >/dev/null+ # Parse the JSON output and save the results to a text file+ if [[ -s "nuclei_output/${crit}_json.txt" ]]; then+ jq -r '["[" + .["template-id"] + (if .["matcher-name"] != null then ":" + .["matcher-name"] else "" end) + "] [" + .["type"] + "] [" + .info.severity + "] " + (.["matched-at"] // .host) + (if .["extracted-results"] != null then " " + (.["extracted-results"] | @json) else "" end)] | .[]' nuclei_output/${crit}_json.txt >nuclei_output/${crit}.txt++ # Display the results if the output file exists and is not empty+ if [[ -s "nuclei_output/${crit}.txt" ]]; then+ cat "nuclei_output/${crit}.txt"+ fi+ fi+ done+ printf "\n\n"+ fi++ # Faraday integration+ if [[ $FARADAY == true ]]; then+ # Check if the Faraday server is running+ if ! faraday-cli status 2>>"$LOGFILE" >/dev/null; then+ printf "%b[!] Faraday server is not running. Skipping Faraday integration.%b\n" "$bred" "$reset"+ else+ if [[ -s "nuclei_output/${crit}_json.txt" ]]; then+ faraday-cli tool report -w $FARADAY_WORKSPACE --plugin-id nuclei nuclei_output/${crit}_json.txt 2>>"$LOGFILE" >/dev/null+ fi+ fi+ fi++ end_func "Results are saved in $domain/nuclei_output folder" "${FUNCNAME[0]}"++ # Emit plugin event+ plugins_emit after_nuclei "$domain" "$dir"+ else+ # Handle cases where NUCLEICHECK is false or the function has already been processed+ if [[ $NUCLEICHECK == false ]]; then+ pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"+ elif [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then+ # Domain is an IP address; skip the function+ return+ else+ pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"+ fi+ fi++}++function graphql_scan() {+ # Detect GraphQL endpoints and introspection+ mkdir -p .tmp webs nuclei_output vulns/graphql++ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $GRAPHQL_CHECK == true ]]; then+ start_func "${FUNCNAME[0]}" "GraphQL detection"+ # Prepare input+ [[ ! -s .tmp/webs_subs.txt ]] && cat subdomains/subdomains.txt webs/webs_all.txt 2>>"$LOGFILE" >.tmp/webs_subs.txt+ maybe_update_nuclei+ if [[ -s .tmp/webs_subs.txt ]]; then+ nuclei -l .tmp/webs_subs.txt -tags graphql -nh -rl "$NUCLEI_RATELIMIT" -silent -retries 2 -t ${NUCLEI_TEMPLATES_PATH} -j -o nuclei_output/graphql_json.txt 2>>"$LOGFILE" >/dev/null+ if [[ -s nuclei_output/graphql_json.txt ]]; then+ jq -r '["[" + .["template-id"] + "] [" + .info.severity + "] " + (.["matched-at"] // .host)] | .[]' nuclei_output/graphql_json.txt >nuclei_output/graphql.txt+ # Optionally run GQLSpection on endpoints+ if [[ $GQLSPECTION == true ]]; then+ jq -r '.["matched-at"] // .host' nuclei_output/graphql_json.txt | sort -u | while read -r ep; do+ [[ -z $ep ]] && continue+ hostfile="vulns/graphql/$(echo "$ep" | sed 's|^[^/]*//||; s|/.*$||')"+ mkdir -p "$(dirname "$hostfile")" 2>>"$LOGFILE" || true+ gqlspection -t "$ep" -o "${hostfile}.json" 2>>"$LOGFILE" >/dev/null || true+ done+ fi+ fi+ fi+ end_func "Results are saved in nuclei_output/graphql* and vulns/graphql" "${FUNCNAME[0]}"+ else+ if [[ $GRAPHQL_CHECK == false ]]; then+ printf "\n${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} skipped due to configuration settings.${reset}\n"+ else+ printf "${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} has already been processed. To force execution, delete:\n $called_fn_dir/.${FUNCNAME[0]}${reset}\n\n"+ fi+ fi+}++function param_discovery() {+ mkdir -p webs .tmp++ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $PARAM_DISCOVERY == true ]]; then+ start_func "${FUNCNAME[0]}" "Parameter discovery (arjun)"+ local input_file="webs/url_extract_nodupes.txt"+ [[ ! -s $input_file ]] && input_file="webs/webs_all.txt"+ if [[ -s $input_file ]]; then+ arjun -i "$input_file" -t "$ARJUN_THREADS" -oJ .tmp/arjun.json 2>>"$LOGFILE" >/dev/null || true+ if [[ -s .tmp/arjun.json ]]; then+ jq -r '..|.url? // empty' .tmp/arjun.json | sed 's/^/URL: /' | anew -q webs/params_discovered.txt+ jq -r '..|.params? // empty | to_entries[] | .key' .tmp/arjun.json | sed 's/^/PARAM: /' | sort -u | anew -q webs/params_discovered.txt+ fi+ fi+ end_func "Results are saved in webs/params_discovered.txt" "${FUNCNAME[0]}"+ else+ if [[ $PARAM_DISCOVERY == false ]]; then+ printf "\n${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} skipped due to configuration settings.${reset}\n"+ else+ printf "${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} has already been processed. To force execution, delete:\n $called_fn_dir/.${FUNCNAME[0]}${reset}\n\n"+ fi+ fi+}++function grpc_reflection() {+ mkdir -p hosts .tmp++ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $GRPC_SCAN == true ]]; then+ start_func "${FUNCNAME[0]}" "gRPC reflection probing"+ # Build target IP list+ local ips_file="hosts/ips.txt"+ local targets=()+ [[ -s $ips_file ]] && targets+=($(cat "$ips_file"))+ [[ -s "hosts/ips_v6.txt" ]] && targets+=($(cat "hosts/ips_v6.txt"))+ printf "%s\n" "${targets[@]}" | sort -u >.tmp/grpc_ips.txt+ if [[ -s .tmp/grpc_ips.txt ]]; then+ # Probe common plaintext gRPC ports+ while read -r ip; do+ for p in 50051 50052; do+ grpcurl -plaintext -max-msg-sz 10485760 -d '{}' "$ip:$p" list 2>>"$LOGFILE" | sed "s/^/[$ip:$p] /" | anew -q hosts/grpc_reflection.txt || true+ done+ done <.tmp/grpc_ips.txt+ fi+ end_func "Results are saved in hosts/grpc_reflection.txt" "${FUNCNAME[0]}"+ else+ if [[ $GRPC_SCAN == false ]]; then+ printf "\n${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} skipped due to configuration settings.${reset}\n"+ else+ printf "${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} has already been processed. To force execution, delete:\n $called_fn_dir/.${FUNCNAME[0]}${reset}\n\n"+ fi+ fi+}++function fuzz() {++ # Create necessary directories+ mkdir -p .tmp/fuzzing webs fuzzing++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $FUZZ == true ]] \+ && ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then++ start_func "${FUNCNAME[0]}" "Web Directory Fuzzing"++ # Handle multi mode and initialize subdomains.txt if necessary+ if [[ -n $multi ]] && [[ ! -f "$dir/webs/webs.txt" ]]; then+ if ! printf "%b\n" "$domain" >"$dir/webs/webs.txt"; then+ printf "%b[!] Failed to create webs.txt.%b\n" "$bred" "$reset"+ fi+ if ! touch webs/webs_uncommon_ports.txt; then+ printf "%b[!] Failed to initialize webs_uncommon_ports.txt.%b\n" "$bred" "$reset"+ fi+ fi++ # Combine webs.txt and webs_uncommon_ports.txt into webs_all.txt if it doesn't exist+ if [[ ! -s "webs/webs_all.txt" ]]; then+ cat webs/webs.txt webs/webs_uncommon_ports.txt 2>/dev/null | anew -q webs/webs_all.txt+ fi++ if [[ -s "webs/webs_all.txt" ]]; then+ if [[ $AXIOM != true ]]; then+ # Split targets by slow hosts+ >.tmp/webs_slow.txt+ >.tmp/webs_normal.txt+ if [[ -s .tmp/slow_hosts.txt ]]; then+ while read -r host; do+ grep "://${host}[:/\n]" webs/webs_all.txt | anew -q .tmp/webs_slow.txt+ done <.tmp/slow_hosts.txt+ comm -23 <(sort -u webs/webs_all.txt) <(sort -u .tmp/webs_slow.txt) >.tmp/webs_normal.txt+ else+ cp webs/webs_all.txt .tmp/webs_normal.txt+ fi++ # Normal targets+ if [[ -s .tmp/webs_normal.txt ]]; then+ interlace -tL .tmp/webs_normal.txt -threads ${INTERLACE_THREADS} -c "ffuf ${FFUF_FLAGS} -t ${FFUF_THREADS} -rate ${FFUF_RATELIMIT} -H \"${HEADER}\" -w ${fuzz_wordlist} -maxtime ${FFUF_MAXTIME} -u _target_/FUZZ -o _output_/_cleantarget_.json" -o $dir/.tmp/fuzzing 2>>"$LOGFILE" >/dev/null+ fi+ # Slow targets with reduced threads/rate+ if [[ -s .tmp/webs_slow.txt ]]; then+ slow_threads=$((FFUF_THREADS / 3))+ [[ $slow_threads -lt 5 ]] && slow_threads=5+ slow_rate=$FFUF_RATELIMIT+ [[ ${FFUF_RATELIMIT:-0} -eq 0 ]] && slow_rate=50 || slow_rate=$((FFUF_RATELIMIT / 3 + 1))+ interlace -tL .tmp/webs_slow.txt -threads ${INTERLACE_THREADS} -c "ffuf ${FFUF_FLAGS} -t ${slow_threads} -rate ${slow_rate} -H \"${HEADER}\" -w ${fuzz_wordlist} -maxtime ${FFUF_MAXTIME} -u _target_/FUZZ -o _output_/_cleantarget_.json" -o $dir/.tmp/fuzzing 2>>"$LOGFILE" >/dev/null+ fi+ for sub in $(cat webs/webs_all.txt); do+ sub_out=$(echo $sub | sed -e 's|^[^/]*//||' -e 's|/.*$||')++ [ -s "$dir/.tmp/fuzzing/${sub_out}.json" ] && cat $dir/.tmp/fuzzing/${sub_out}.json | jq -r 'try .results[] | "\(.status) \(.length) \(.url)"' | sort -k1 | anew -q $dir/fuzzing/${sub_out}.txt+ done+ find $dir/fuzzing/ -type f -iname "*.txt" -exec cat {} + 2>>"$LOGFILE" | sort -k1 | anew -q $dir/fuzzing/fuzzing_full.txt+ else+ cached_download "${fuzzing_remote_list}" ".tmp/fuzzing_remote_list.txt" "onelistforallmicro.txt"+ axiom-scan webs/webs_all.txt -m ffuf -wL .tmp/fuzzing_remote_list.txt -H "${HEADER}" $FFUF_FLAGS -s -maxtime $FFUF_MAXTIME -oJ $dir/.tmp/ffuf-content.json $AXIOM_EXTRA_ARGS 2>>"$LOGFILE" >/dev/null++ for sub in $(cat webs/webs_all.txt); do+ sub_out=$(echo $sub | sed -e 's|^[^/]*//||' -e 's|/.*$||')+ [ -s "$dir/.tmp/ffuf-content.json" ] && cat $dir/.tmp/ffuf-content.json | jq -r 'try .results[] | "\(.status) \(.length) \(.url)"' | grep $sub | sort -k1 | anew -q fuzzing/${sub_out}.txt+ done+ find $dir/fuzzing/ -type f -iname "*.txt" -exec cat {} + 2>>"$LOGFILE" | sort -k1 | anew -q $dir/fuzzing/fuzzing_full.txt+ fi+ end_func "Results are saved in $domain/fuzzing/*subdomain*.txt" ${FUNCNAME[0]}+ else+ end_func "No $domain/webs/webs_all.txt file found, fuzzing skipped " ${FUNCNAME[0]}+ fi++ else+ if [[ $FUZZ == false ]]; then+ pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"+ else+ pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"+ fi+ fi++}++function iishortname() {++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $IIS_SHORTNAME == true ]]; then+ start_func "${FUNCNAME[0]}" "IIS Shortname Scanner"++ # Ensure nuclei_output/info.txt exists and is not empty+ if [[ -s "nuclei_output/info.txt" ]]; then+ # Extract IIS version information and save to .tmp/iis_sites.txt+ grep "iis-version" "nuclei_output/info.txt" | cut -d " " -f4 >.tmp/iis_sites.txt+ fi++ # Proceed only if iis_sites.txt exists and is non-empty+ if [[ -s ".tmp/iis_sites.txt" ]]; then+ # Create necessary directories+ mkdir -p "$dir/vulns/iis-shortname-shortscan/" "$dir/vulns/iis-shortname-sns/"++ # Run shortscan using interlace+ interlace -tL .tmp/iis_sites.txt -threads "$INTERLACE_THREADS" \+ -c "shortscan _target_ -F -s -p 1 > _output_/_cleantarget_.txt" \+ -o "$dir/vulns/iis-shortname-shortscan/" 2>>"$LOGFILE" >/dev/null++ # Remove non-vulnerable shortscan results+ find "$dir/vulns/iis-shortname-shortscan/" -type f -iname "*.txt" -print0 \+ | xargs --null grep -Z -L 'Vulnerable: Yes' \+ | xargs --null rm 2>>"$LOGFILE" >/dev/null++ # Run sns using interlace+ interlace -tL .tmp/iis_sites.txt -threads "$INTERLACE_THREADS" \+ -c "sns -u _target_ > _output_/_cleantarget_.txt" \+ -o "$dir/vulns/iis-shortname-sns/" 2>>"$LOGFILE" >/dev/null++ # Remove non-vulnerable sns results+ find "$dir/vulns/iis-shortname-sns/" -type f -iname "*.txt" -print0 \+ | xargs --null grep -Z 'Target is not vulnerable' \+ | xargs --null rm 2>>"$LOGFILE" >/dev/null++ fi+ end_func "Results are saved in vulns/iis-shortname/" "${FUNCNAME[0]}"+ else+ # Handle cases where IIS_SHORTNAME is false or the function has already been processed+ if [[ $IIS_SHORTNAME == false ]]; then+ printf "\n${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} skipped due to configuration settings.${reset}\n"+ elif [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then+ # Domain is an IP address; skip the function+ return+ else+ printf "${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} has already been processed. To force execution, delete:\n $called_fn_dir/.${FUNCNAME[0]}${reset}\n\n"+ fi+ fi++}++function cms_scanner() {++ # Create necessary directories+ if ! mkdir -p .tmp/fuzzing webs cms; then+ printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"+ return 1+ fi++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $CMS_SCANNER == true ]] \+ && ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then++ start_func "${FUNCNAME[0]}" "CMS Scanner"++ rm -rf "$dir/cms/"*++ # Handle multi mode and initialize webs.txt if necessary+ if [[ -n $multi ]] && [[ ! -f "$dir/webs/webs.txt" ]]; then+ printf "%b\n" "$domain" >"$dir/webs/webs.txt"+ touch webs/webs_uncommon_ports.txt+ fi++ # Combine webs.txt and webs_uncommon_ports.txt into webs_all.txt if it doesn't exist+ if [[ ! -s "webs/webs_all.txt" ]]; then+ cat webs/webs.txt webs/webs_uncommon_ports.txt 2>/dev/null | anew -q webs/webs_all.txt+ fi++ # Combine webs_all.txt into .tmp/cms.txt as a comma-separated list+ if [[ -s "webs/webs_all.txt" ]]; then+ tr '\n' ',' <webs/webs_all.txt >.tmp/cms.txt 2>>"$LOGFILE"+ else+ end_func "No webs/webs_all.txt file found, cms scanner skipped." "${FUNCNAME[0]}"+ return+ fi++ # Run CMSeeK with timeout+ if ! timeout -k 1m "${CMSSCAN_TIMEOUT}s" "${tools}/CMSeeK/venv/bin/python3" "${tools}/CMSeeK/cmseek.py" -l .tmp/cms.txt --batch -r &>>"$LOGFILE"; then+ exit_status=$?+ if [[ ${exit_status} -eq 124 || ${exit_status} -eq 137 ]]; then+ echo "TIMEOUT cmseek.py - investigate manually for $dir" >>"$LOGFILE"+ end_func "TIMEOUT cmseek.py - investigate manually for $dir" "${FUNCNAME[0]}"+ return+ elif [[ ${exit_status} -ne 0 ]]; then+ echo "ERROR cmseek.py - investigate manually for $dir" >>"$LOGFILE"+ end_func "ERROR cmseek.py - investigate manually for $dir" "${FUNCNAME[0]}"+ return+ fi+ fi++ # Process CMSeeK results+ while IFS= read -r sub; do+ sub_out=$(echo "$sub" | sed -e 's|^[^/]*//||' -e 's|/.*$||')+ cms_json_path="${tools}/CMSeeK/Result/${sub_out}/cms.json"++ if [[ -s $cms_json_path ]]; then+ cms_id=$(jq -r 'try .cms_id' "$cms_json_path")+ if [[ -n $cms_id ]]; then+ mv -f "${tools}/CMSeeK/Result/${sub_out}" "$dir/cms/" 2>>"$LOGFILE"+ else+ rm -rf "${tools}/CMSeeK/Result/${sub_out}" 2>>"$LOGFILE"+ fi+ fi+ done <"webs/webs_all.txt"++ end_func "Results are saved in $domain/cms/*subdomain* folder" "${FUNCNAME[0]}"+ else+ # Handle cases where CMS_SCANNER is false or the function has already been processed+ if [[ $CMS_SCANNER == false ]]; then+ pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"+ elif [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then+ # Domain is an IP address; skip the function+ return+ else+ pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"+ fi+ fi+}++function urlchecks() {++ # Create necessary directories+ if ! mkdir -p .tmp webs; then+ printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"+ return 1+ fi++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $URL_CHECK == true ]]; then+ start_func "${FUNCNAME[0]}" "URL Extraction"++ # Combine webs.txt and webs_uncommon_ports.txt if webs_all.txt doesn't exist+ if [[ ! -s "webs/webs_all.txt" ]]; then+ cat webs/webs.txt webs/webs_uncommon_ports.txt 2>/dev/null | anew -q webs/webs_all.txt+ fi++ if [[ -s "webs/webs_all.txt" ]]; then++ if [[ $URL_CHECK_PASSIVE == true ]]; then+ urlfinder -d $domain -all -o .tmp/url_extract_tmp.txt 2>>"$LOGFILE" >/dev/null+ if [[ -s $GITHUB_TOKENS ]]; then+ github-endpoints -q -k -d "$domain" -t "$GITHUB_TOKENS" -o .tmp/github-endpoints.txt 2>>"$LOGFILE" >/dev/null+ if [[ -s ".tmp/github-endpoints.txt" ]]; then+ cat .tmp/github-endpoints.txt | anew -q .tmp/url_extract_tmp.txt+ fi+ fi+ fi++ if [[ $AXIOM != true ]]; then+ diff_webs=$(diff <(sort -u .tmp/probed_tmp.txt 2>>"$LOGFILE") <(sort -u webs/webs_all.txt 2>>"$LOGFILE") | wc -l)+ if [[ $diff_webs != "0" ]] || [[ ! -s ".tmp/katana.txt" ]]; then+ if [[ $URL_CHECK_ACTIVE == true ]]; then+ # Split slow vs normal targets based on httpx status (403/429)+ >.tmp/katana_targets_slow.txt+ >.tmp/katana_targets_normal.txt+ if [[ -s .tmp/slow_hosts.txt ]]; then+ while read -r host; do+ grep "://${host}[:/\n]" webs/webs_all.txt | anew -q .tmp/katana_targets_slow.txt+ done <.tmp/slow_hosts.txt+ comm -23 <(sort -u webs/webs_all.txt) <(sort -u .tmp/katana_targets_slow.txt) >.tmp/katana_targets_normal.txt+ else+ cp webs/webs_all.txt .tmp/katana_targets_normal.txt+ fi++ >.tmp/katana.txt+ # Normal targets+ if [[ -s .tmp/katana_targets_normal.txt ]]; then+ LINES=$(wc -l <.tmp/katana_targets_normal.txt)+ if [[ $LINES -gt ${CHUNK_LIMIT:-2000} ]]; then+ if [[ $DEEP == true ]]; then+ process_in_chunks .tmp/katana_targets_normal.txt ${CHUNK_LIMIT:-2000} "katana -silent -list _chunk_ -jc -kf all -c $KATANA_THREADS -d 3 -fs rdn >> .tmp/katana.txt 2>>\"$LOGFILE\" >/dev/null"+ else+ process_in_chunks .tmp/katana_targets_normal.txt ${CHUNK_LIMIT:-2000} "katana -silent -list _chunk_ -jc -kf all -c $KATANA_THREADS -d 2 -fs rdn >> .tmp/katana.txt 2>>\"$LOGFILE\" >/dev/null"+ fi+ else+ if [[ $DEEP == true ]]; then+ timeout 4h katana -silent -list .tmp/katana_targets_normal.txt -jc -kf all -c "$KATANA_THREADS" -d 3 -fs rdn >>.tmp/katana.txt 2>>"$LOGFILE" >/dev/null+ else+ timeout 3h katana -silent -list .tmp/katana_targets_normal.txt -jc -kf all -c "$KATANA_THREADS" -d 2 -fs rdn >>.tmp/katana.txt 2>>"$LOGFILE" >/dev/null+ fi+ fi+ fi++ # Slow targets with reduced concurrency+ if [[ -s .tmp/katana_targets_slow.txt ]]; then+ slow_c=$((KATANA_THREADS / 3))+ [[ $slow_c -lt 2 ]] && slow_c=2+ LINES=$(wc -l <.tmp/katana_targets_slow.txt)+ if [[ $LINES -gt ${CHUNK_LIMIT:-2000} ]]; then+ if [[ $DEEP == true ]]; then+ process_in_chunks .tmp/katana_targets_slow.txt ${CHUNK_LIMIT:-2000} "katana -silent -list _chunk_ -jc -kf all -c $slow_c -d 3 -fs rdn >> .tmp/katana.txt 2>>\"$LOGFILE\" >/dev/null"+ else+ process_in_chunks .tmp/katana_targets_slow.txt ${CHUNK_LIMIT:-2000} "katana -silent -list _chunk_ -jc -kf all -c $slow_c -d 2 -fs rdn >> .tmp/katana.txt 2>>\"$LOGFILE\" >/dev/null"+ fi+ else+ if [[ $DEEP == true ]]; then+ timeout 4h katana -silent -list .tmp/katana_targets_slow.txt -jc -kf all -c "$slow_c" -d 3 -fs rdn >>.tmp/katana.txt 2>>"$LOGFILE" >/dev/null+ else+ timeout 3h katana -silent -list .tmp/katana_targets_slow.txt -jc -kf all -c "$slow_c" -d 2 -fs rdn >>.tmp/katana.txt 2>>"$LOGFILE" >/dev/null+ fi+ fi+ fi+ fi+ fi+ else+ diff_webs=$(diff <(sort -u .tmp/probed_tmp.txt) <(sort -u webs/webs_all.txt) | wc -l)+ if [[ $diff_webs != "0" ]] || [[ ! -s ".tmp/katana.txt" ]]; then+ if [[ $URL_CHECK_ACTIVE == true ]]; then+ if [[ $DEEP == true ]]; then+ axiom-scan webs/webs_all.txt -m katana -jc -kf all -d 3 -fs rdn --max-runtime 4h -o .tmp/katana.txt "$AXIOM_EXTRA_ARGS" 2>>"$LOGFILE" >/dev/null+ else+ axiom-scan webs/webs_all.txt -m katana -jc -kf all -d 2 -fs rdn --max-runtime 3h -o .tmp/katana.txt "$AXIOM_EXTRA_ARGS" 2>>"$LOGFILE" >/dev/null+ fi+ fi+ fi+ fi++ if [[ -s ".tmp/katana.txt" ]]; then+ sed_i '/^.\{2048\}./d' .tmp/katana.txt+ cat .tmp/katana.txt | anew -q .tmp/url_extract_tmp.txt+ fi++ if [[ -s ".tmp/url_extract_tmp.txt" ]]; then+ grep -a "$domain" .tmp/url_extract_tmp.txt | grep -aEo 'https?://[^ ]+' | grep -iE '\.js([?#].*)?$|\.js([/?&].*)' | anew -q .tmp/url_extract_js.txt+ grep -a "$domain" .tmp/url_extract_tmp.txt | grep -aEo 'https?://[^ ]+' | grep -iE '\.map([/?#].*)?$' | anew -q .tmp/url_extract_jsmap.txt+ if [[ $DEEP == true ]] && [[ -s ".tmp/url_extract_js.txt" ]]; then+ interlace -tL .tmp/url_extract_js.txt -threads 10 -c "${tools}/JSA/venv/bin/python3 ${tools}/JSA/jsa.py -f _target_ | anew -q .tmp/url_extract_tmp.txt" &>/dev/null+ fi++ grep -a "$domain" .tmp/url_extract_tmp.txt | grep -aEo 'https?://[^ ]+' | grep "=" | qsreplace -a 2>>"$LOGFILE" | grep -aEiv "\.(eot|jpg|jpeg|gif|css|tif|tiff|png|ttf|otf|woff|woff2|ico|pdf|svg)$" | anew -q .tmp/url_extract_tmp2.txt++ if [[ -s ".tmp/url_extract_tmp2.txt" ]]; then+ urless <.tmp/url_extract_tmp2.txt | anew -q .tmp/url_extract_uddup.txt 2>>"$LOGFILE" >/dev/null+ fi++ if [[ -s ".tmp/url_extract_uddup.txt" ]]; then+ if ! NUMOFLINES=$(anew webs/url_extract.txt <.tmp/url_extract_uddup.txt | sed '/^$/d' | wc -l); then+ printf "%b[!] Failed to update url_extract.txt.%b\n" "$bred" "$reset"+ NUMOFLINES=0+ fi+ notification "${NUMOFLINES} new URLs with parameters" "info"+ # Asset store: append new URLs+ append_assets_from_file url value webs/url_extract.txt+ else+ NUMOFLINES=0+ fi++ end_func "Results are saved in $domain/webs/url_extract.txt" "${FUNCNAME[0]}"++ p1radup -i webs/url_extract.txt -o webs/url_extract_nodupes.txt -s 2>>"$LOGFILE" >/dev/null++ if [[ $PROXY == true ]] && [[ -n $proxy_url ]] && [[ $(wc -l <webs/url_extract.txt) -le $DEEP_LIMIT2 ]]; then+ notification "Sending URLs to proxy" "info"+ ffuf -mc all -w webs/url_extract.txt -u FUZZ -replay-proxy "$proxy_url" 2>>"$LOGFILE" >/dev/null+ fi+ fi+ fi+ else+ if [[ $URL_CHECK == false ]]; then+ pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"+ else+ pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"+ fi+ fi++}++function url_gf() {++ # Create necessary directories+ if ! mkdir -p .tmp webs gf; then+ printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"+ return 1+ fi++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $URL_GF == true ]] \+ && ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then++ start_func "${FUNCNAME[0]}" "Vulnerable Pattern Search"++ # Ensure webs/url_extract.txt exists and is not empty+ if [[ -s "webs/url_extract.txt" ]]; then+ # Define an array of GF patterns+ declare -A gf_patterns=(+ ["xss"]="gf/xss.txt"+ ["ssti"]="gf/ssti.txt"+ ["ssrf"]="gf/ssrf.txt"+ ["sqli"]="gf/sqli.txt"+ ["redirect"]="gf/redirect.txt"+ ["rce"]="gf/rce.txt"+ ["potential"]="gf/potential.txt"+ ["lfi"]="gf/lfi.txt"+ )++ # Iterate over GF patterns and process each+ for pattern in "${!gf_patterns[@]}"; do+ output_file="${gf_patterns[$pattern]}"+ printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: GF Pattern '$pattern'${reset}\n\n"+ if [[ $pattern == "potential" ]]; then+ # Special handling for 'potential' pattern+ gf "$pattern" "webs/url_extract.txt" | cut -d ':' -f3-5 | anew -q "$output_file"+ elif [[ $pattern == "redirect" && -s "gf/ssrf.txt" ]]; then+ # Append SSFR results to redirect if ssrf.txt exists+ gf "$pattern" "webs/url_extract.txt" | anew -q "$output_file"+ else+ # General handling for other patterns+ gf "$pattern" "webs/url_extract.txt" | anew -q "$output_file"+ fi+ done++ # Process endpoints extraction+ if [[ -s ".tmp/url_extract_tmp.txt" ]]; then+ printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Extracting endpoints...${reset}\n\n"+ grep -aEiv "\.(eot|jpg|jpeg|gif|css|tif|tiff|png|ttf|otf|woff|woff2|ico|pdf|svg|txt|js)$" ".tmp/url_extract_tmp.txt" \+ | unfurl -u format '%s://%d%p' 2>>"$LOGFILE" | anew -q "gf/endpoints.txt"+ fi++ else+ end_func "No webs/url_extract.txt file found, URL_GF check skipped." "${FUNCNAME[0]}"+ return+ fi++ end_func "Results are saved in $domain/gf folder" "${FUNCNAME[0]}"+ else+ # Handle cases where URL_GF is false or the function has already been processed+ if [[ $URL_GF == false ]]; then+ printf "\n${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} skipped due to configuration settings.${reset}\n"+ elif [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then+ # Domain is an IP address; skip the function+ return+ else+ printf "${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} has already been processed. To force execution, delete:\n $called_fn_dir/.${FUNCNAME[0]}${reset}\n\n"+ fi+ fi++}++function url_ext() {++ # Create necessary directories+ if ! mkdir -p .tmp webs gf; then+ printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"+ return 1+ fi++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $URL_EXT == true ]] \+ && ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then++ if [[ -s ".tmp/url_extract_tmp.txt" ]]; then+ start_func "${FUNCNAME[0]}" "Vulnerable Pattern Search"++ # Define an array of file extensions+ ext=("7z" "achee" "action" "adr" "apk" "arj" "ascx" "asmx" "asp" "aspx" "axd" "backup" "bak" "bat" "bin" "bkf" "bkp" "bok" "cab" "cer" "cfg" "cfm" "cnf" "conf" "config" "cpl" "crt" "csr" "csv" "dat" "db" "dbf" "deb" "dmg" "dmp" "doc" "docx" "drv" "email" "eml" "emlx" "env" "exe" "gadget" "gz" "html" "ica" "inf" "ini" "iso" "jar" "java" "jhtml" "json" "jsp" "key" "log" "lst" "mai" "mbox" "mbx" "md" "mdb" "msg" "msi" "nsf" "ods" "oft" "old" "ora" "ost" "pac" "passwd" "pcf" "pdf" "pem" "pgp" "php" "php3" "php4" "php5" "phtm" "phtml" "pkg" "pl" "plist" "pst" "pwd" "py" "rar" "rb" "rdp" "reg" "rpm" "rtf" "sav" "sh" "shtm" "shtml" "skr" "sql" "swf" "sys" "tar" "tar.gz" "tmp" "toast" "tpl" "txt" "url" "vcd" "vcf" "wml" "wpd" "wsdl" "wsf" "xls" "xlsm" "xlsx" "xml" "xsd" "yaml" "yml" "z" "zip")++ # Initialize the output file+ if ! : >webs/urls_by_ext.txt; then+ printf "%b[!] Failed to initialize webs/urls_by_ext.txt.%b\n" "$bred" "$reset"+ fi++ # Iterate over extensions and extract matching URLs+ for t in "${ext[@]}"; do++ # Extract unique matching URLs+ matches=$(grep -aEi "\.(${t})($|/|\?)" ".tmp/url_extract_tmp.txt" | sort -u | sed '/^$/d')++ NUMOFLINES=$(echo "$matches" | wc -l)++ if [[ $NUMOFLINES -gt 0 ]]; then+ printf "\n############################\n + %s + \n############################\n" "$t" >>webs/urls_by_ext.txt+ echo "$matches" >>webs/urls_by_ext.txt+ fi+ done++ # Append ssrf.txt to redirect.txt if ssrf.txt exists and is not empty+ if [[ -s "gf/ssrf.txt" ]]; then+ cat "gf/ssrf.txt" | anew -q "gf/redirect.txt"+ fi++ end_func "Results are saved in $domain/webs/urls_by_ext.txt" "${FUNCNAME[0]}"++ else+ end_func "No .tmp/url_extract_tmp.txt file found, URL_EXT check skipped." "${FUNCNAME[0]}"+ fi++ else+ # Handle cases where URL_EXT is false or function already processed+ if [[ $URL_EXT == false ]]; then+ printf "\n${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} skipped in this mode or defined in reconftw.cfg ${reset}\n"+ elif [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then+ # Domain is an IP address; skip the function+ return+ else+ printf "${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} has already been processed. To force execution, delete:\n $called_fn_dir/.${FUNCNAME[0]}${reset}\n\n"+ fi+ fi++}++function jschecks() {++ # Create necessary directories+ if ! mkdir -p .tmp webs subdomains js; then+ printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"+ return 1+ fi++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $JSCHECKS == true ]]; then+ start_func "${FUNCNAME[0]}" "JavaScript Scan"++ [[ ! -s ".tmp/url_extract_js.txt" ]] && cat js/url_extract_js.txt | anew -q .tmp/url_extract_js.txt++ if [[ -s ".tmp/url_extract_js.txt" ]]; then++ printf "%bRunning: Fetching URLs 1/6%b\n" "$yellow" "$reset"+ if [[ $AXIOM != true ]]; then+ subjs -ua "Mozilla/5.0 (X11; Linux x86_64; rv:72.0) Gecko/20100101 Firefox/72.0" -c 40 <.tmp/url_extract_js.txt \+ | grep "$domain" \+ | grep -aEo 'https?://[^ ]+' | anew -q .tmp/subjslinks.txt+ else+ axiom-scan .tmp/url_extract_js.txt -m subjs -o .tmp/subjslinks.txt "$AXIOM_EXTRA_ARGS" 2>>"$LOGFILE" >/dev/null+ fi++ if [[ -s ".tmp/subjslinks.txt" ]]; then+ grep -Eiv "\.(eot|jpg|jpeg|gif|css|tif|tiff|png|ttf|otf|woff|woff2|ico|pdf|svg|txt|js)$" .tmp/subjslinks.txt \+ | anew -q js/nojs_links.txt+ grep -iE '\.js([?#].*)?$|\.js([/?&].*)' .tmp/subjslinks.txt | anew -q .tmp/url_extract_js.txt+ fi++ urless <.tmp/url_extract_js.txt \+ | anew -q js/url_extract_js.txt 2>>"$LOGFILE" >/dev/null++ printf "%bRunning: Resolving JS URLs 2/6%b\n" "$yellow" "$reset"+ if [[ $AXIOM != true ]]; then+ if [[ -s "js/url_extract_js.txt" ]]; then+ httpx -follow-redirects -random-agent -silent -timeout "$HTTPX_TIMEOUT" -threads "$HTTPX_THREADS" \+ -rl "$HTTPX_RATELIMIT" -status-code -content-type -retries 2 -no-color <js/url_extract_js.txt \+ | grep "[200]" | grep "javascript" | cut -d ' ' -f1 | anew -q js/js_livelinks.txt+ fi+ else+ if [[ -s "js/url_extract_js.txt" ]]; then+ axiom-scan js/url_extract_js.txt -m httpx -follow-host-redirects -H "$HEADER" -status-code \+ -threads "$HTTPX_THREADS" -rl "$HTTPX_RATELIMIT" -timeout "$HTTPX_TIMEOUT" -silent \+ -content-type -retries 2 -no-color -o .tmp/js_livelinks.txt "$AXIOM_EXTRA_ARGS" 2>>"$LOGFILE" >/dev/null+ if [[ -s ".tmp/js_livelinks.txt" ]]; then+ cat .tmp/js_livelinks.txt | anew .tmp/web_full_info.txt \+ | grep "[200]" | grep "javascript" | cut -d ' ' -f1 | anew -q js/js_livelinks.txt+ fi+ fi+ fi++ printf "%bRunning: Extracting JS from sourcemaps 3/6%b\n" "$yellow" "$reset"+ if ! mkdir -p .tmp/sourcemapper; then+ printf "%b[!] Failed to create sourcemapper directory.%b\n" "$bred" "$reset"+ fi+ if [[ -s "js/js_livelinks.txt" ]]; then+ interlace -tL js/js_livelinks.txt -threads "$INTERLACE_THREADS" \+ -c "sourcemapper -jsurl '_target_' -output _output_/_cleantarget_" \+ -o .tmp/sourcemapper 2>>"$LOGFILE" >/dev/null+ fi++ if [[ -s ".tmp/url_extract_jsmap.txt" ]]; then+ interlace -tL js/url_extract_jsmap.txt -threads "$INTERLACE_THREADS" \+ -c "sourcemapper -url '_target_' -output _output_/_cleantarget_" \+ -o .tmp/sourcemapper 2>>"$LOGFILE" >/dev/null+ fi++ find .tmp/sourcemapper/ \( -name "*.js" -o -name "*.ts" \) -type f \+ | jsluice urls | jq -r .url | anew -q .tmp/js_endpoints.txt++ printf "%bRunning: Gathering endpoints 4/6%b\n" "$yellow" "$reset"+ if [[ -s "js/js_livelinks.txt" ]]; then+ xnLinkFinder -i js/js_livelinks.txt -sf subdomains/subdomains.txt -d "$XNLINKFINDER_DEPTH" \+ -o .tmp/js_endpoints.txt 2>>"$LOGFILE" >/dev/null+ fi++ if [[ -s ".tmp/js_endpoints.txt" ]]; then+ sed_i '/^\//!d' .tmp/js_endpoints.txt+ cat .tmp/js_endpoints.txt | anew -q js/js_endpoints.txt+ fi++ printf "%bRunning: Gathering secrets 5/6%b\n" "$yellow" "$reset"+ if [[ -s "js/js_livelinks.txt" ]]; then+ if [[ $AXIOM != true ]]; then+ cat js/js_livelinks.txt | mantra -ua \"$HEADER\" -s | anew -q js/js_secrets.txt 2>>"$LOGFILE" >/dev/null+ else+ axiom-exec "go install github.com/Brosck/mantra@latest" 2>>"$LOGFILE" >/dev/null+ axiom-scan js/js_livelinks.txt -m mantra -ua "$HEADER" -s -o js/js_secrets.txt "$AXIOM_EXTRA_ARGS" &>/dev/null+ fi+ mkdir -p .tmp/sourcemapper/secrets+ for i in $(cat js/js_secrets.txt | cut -d' ' -f2); do wget -q -P .tmp/sourcemapper/secrets $i; done+ trufflehog filesystem .tmp/sourcemapper/ -j 2>/dev/null | jq -c | anew -q js/js_secrets_jsmap.txt+ find .tmp/sourcemapper/ -type f -name "*.js" | jsluice secrets -j --patterns=~/Tools/jsluice_patterns.json | anew -q js/js_secrets_jsmap_jsluice.txt+ fi++ printf "%bRunning: Building wordlist 6/6%b\n" "$yellow" "$reset"+ if [[ -s "js/js_livelinks.txt" ]]; then+ interlace -tL js/js_livelinks.txt -threads "$INTERLACE_THREADS" \+ -c "python3 ${tools}/getjswords.py '_target_' | anew -q webs/dict_words.txt" 2>>"$LOGFILE" >/dev/null+ fi+ end_func "Results are saved in $domain/js folder" "${FUNCNAME[0]}"+ else+ end_func "No JS files to process" "${FUNCNAME[0]}"+ fi+ else+ if [[ $JSCHECKS == false ]]; then+ pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"+ else+ pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"+ fi+ fi++}++function websocket_checks() {+ mkdir -p webs vulns .tmp++ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $URL_CHECK == true ]]; then+ start_func "${FUNCNAME[0]}" "WebSocket discovery and handshake"+ # Collect ws/wss endpoints from JS endpoints and URLs+ touch .tmp/ws_endpoints_raw.txt+ [[ -s js/js_endpoints.txt ]] && grep -aEo 'wss?://[^ ]+' js/js_endpoints.txt | anew -q .tmp/ws_endpoints_raw.txt+ [[ -s webs/url_extract.txt ]] && grep -aEo 'wss?://[^ ]+' webs/url_extract.txt | anew -q .tmp/ws_endpoints_raw.txt+ if [[ -s .tmp/ws_endpoints_raw.txt ]]; then+ # Normalize and de-dup+ cat .tmp/ws_endpoints_raw.txt | sed 's/\"//g' | sed 's/[\]\[ ]//g' | sort -u >.tmp/ws_endpoints.txt+ # Handshake test and origin check+ while IFS= read -r ws; do+ [[ -z $ws ]] && continue+ url_no_proto=$(echo "$ws" | sed 's|^wss\?://||')+ host=$(echo "$url_no_proto" | cut -d'/' -f1)+ # Prepare Sec-WebSocket headers for accurate handshake+ wskey=$(head -c 16 /dev/urandom | base64 2>/dev/null || echo dGVzdGtleQ==)+ code=$(curl -sk --http1.1 -o /dev/null -w '%{http_code}' \+ -H 'Connection: Upgrade' -H 'Upgrade: websocket' \+ -H "Host: $host" \+ -H "Sec-WebSocket-Key: $wskey" \+ -H 'Sec-WebSocket-Version: 13' \+ "$ws" || true)+ if [[ $code == "101" ]]; then+ printf "HANDSHAKE %s\n" "$ws" | anew -q vulns/websockets.txt+ # Origin test: send a cross-origin header, expect failure ideally+ wskey2=$(head -c 16 /dev/urandom | base64 2>/dev/null || echo dGVzdGtleQ==)+ code2=$(curl -sk --http1.1 -o /dev/null -w '%{http_code}' \+ -H 'Connection: Upgrade' -H 'Upgrade: websocket' \+ -H "Origin: https://evil.example" -H "Host: $host" \+ -H "Sec-WebSocket-Key: $wskey2" \+ -H 'Sec-WebSocket-Version: 13' \+ "$ws" || true)+ if [[ $code2 == "101" ]]; then+ printf "ORIGIN-ALLOWED %s\n" "$ws" | anew -q vulns/websocket_misconfig.txt+ fi+ fi+ done <.tmp/ws_endpoints.txt+ fi+ end_func "Results are saved in vulns/websocket_misconfig.txt" "${FUNCNAME[0]}"+ else+ printf "\n${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} skipped or already processed.${reset}\n"+ fi+}++function wordlist_gen() {++ # Create necessary directories+ if ! mkdir -p .tmp webs; then+ printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"+ return 1+ fi++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $WORDLIST == true ]] \+ && ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then++ start_func "${FUNCNAME[0]}" "Wordlist Generation"++ [[ -s ".tmp/url_extract_tmp.txt" ]] && cat webs/url_extract.txt | anew -q .tmp/url_extract_tmp.txt+ # Ensure url_extract_tmp.txt exists and is not empty+ if [[ -s ".tmp/url_extract_tmp.txt" ]]; then+ # Define patterns for keys and values+ cat ".tmp/url_extract_tmp.txt" | unfurl -u keys 2>>"$LOGFILE" \+ | sed 's/[][]//g' | sed 's/[#]//g' | sed 's/[}{]//g' \+ | anew -q webs/dict_keys.txt++ cat ".tmp/url_extract_tmp.txt" | unfurl -u values 2>>"$LOGFILE" \+ | sed 's/[][]//g' | sed 's/[#]//g' | sed 's/[}{]//g' \+ | anew -q webs/dict_values.txt++ printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Extracting words...${reset}\n"+ tr "[:punct:]" "\n" <".tmp/url_extract_tmp.txt" | anew -q "webs/dict_words.txt"+ fi++ end_func "Results are saved in $domain/webs/dict_[words|paths].txt" "${FUNCNAME[0]}"++ else+ # Handle cases where WORDLIST is false or function already processed+ if [[ $WORDLIST == false ]]; then+ printf "\n${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} skipped in this mode or defined in reconftw.cfg ${reset}\n"+ elif [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then+ # Domain is an IP address; skip the function+ return+ else+ printf "${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} has already been processed. To force execution, delete:\n $called_fn_dir/.${FUNCNAME[0]}${reset}\n\n"+ fi+ fi++}++function wordlist_gen_roboxtractor() {++ # Create necessary directories+ if ! mkdir -p .tmp webs gf; then+ printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"+ return 1+ fi++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $ROBOTSWORDLIST == true ]] \+ && ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then++ start_func "${FUNCNAME[0]}" "Robots Wordlist Generation"++ # Combine webs.txt and webs_uncommon_ports.txt into webs_all.txt if it doesn't exist+ if [[ ! -s "webs/webs_all.txt" ]]; then+ cat webs/webs.txt webs/webs_uncommon_ports.txt 2>/dev/null | anew -q "webs/webs_all.txt"+ fi++ # Proceed only if webs_all.txt exists and is non-empty+ if [[ -s "webs/webs_all.txt" ]]; then+ # Extract URLs using roboxtractor and append unique entries to robots_wordlist.txt+ printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: Roboxtractor for Robots Wordlist${reset}\n\n"+ roboxtractor -m 1 -wb <"webs/webs_all.txt" 2>>"$LOGFILE" | anew -q "webs/robots_wordlist.txt"+ else+ end_func "No webs/webs_all.txt file found, Robots Wordlist generation skipped." "${FUNCNAME[0]}"+ return+ fi++ end_func "Results are saved in $domain/webs/robots_wordlist.txt" "${FUNCNAME[0]}"++ # Handle Proxy if conditions are met+ if [[ $PROXY == true ]] && [[ -n $proxy_url ]] && [[ "$(wc -l <"webs/robots_wordlist.txt")" -le $DEEP_LIMIT2 ]]; then+ notification "Sending URLs to proxy" info+ ffuf -mc all -w "webs/robots_wordlist.txt" -u "FUZZ" -replay-proxy "$proxy_url" 2>>"$LOGFILE" >/dev/null+ fi++ else+ # Handle cases where ROBOTSWORDLIST is false or function already processed+ if [[ $ROBOTSWORDLIST == false ]]; then+ printf "\n${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} skipped due to configuration settings.${reset}\n"+ elif [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then+ # Domain is an IP address; skip the function+ return+ else+ printf "${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} has already been processed. To force execution, delete:\n $called_fn_dir/.${FUNCNAME[0]}${reset}\n\n"+ fi+ fi++}++function password_dict() {++ # Create necessary directories+ if ! mkdir -p "$dir/webs"; then+ printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"+ return 1+ fi++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $PASSWORD_DICT == true ]] \+ && ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then++ start_func "${FUNCNAME[0]}" "Password Dictionary Generation"++ # Extract the first part of the domain+ word="${domain%%.*}"++ # Run pydictor.py with specified parameters+ python3 "${tools}/pydictor/pydictor.py" -extend "$word" --leet 0 1 2 11 21 --len "$PASSWORD_MIN_LENGTH" "$PASSWORD_MAX_LENGTH" -o "$dir/webs/password_dict.txt" 2>>"$LOGFILE" >/dev/null+ end_func "Results are saved in $domain/webs/password_dict.txt" "${FUNCNAME[0]}"++ # Optionally, create a marker file to indicate the function has been processed+ touch "$called_fn_dir/.${FUNCNAME[0]}"++ else+ # Handle cases where PASSWORD_DICT is false or function already processed+ if [[ $PASSWORD_DICT == false ]]; then+ printf "\n${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} skipped due to configuration settings.${reset}\n"+ elif [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then+ # Domain is an IP address; skip the function+ return+ else+ printf "${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} has already been processed. To force execution, delete:\n $called_fn_dir/.${FUNCNAME[0]}${reset}\n\n"+ fi+ fi++}++###############################################################################################################+######################################### VULNERABILITIES #####################################################+###############################################################################################################++function brokenLinks() {++ # Create necessary directories+ if ! mkdir -p .tmp webs vulns; then+ printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"+ return 1+ fi++ # Check if the function should run+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $BROKENLINKS == true ]] \+ && ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then++ start_func "${FUNCNAME[0]}" "Broken Links Checks"++ # Combine webs.txt and webs_uncommon_ports.txt into webs_all.txt if it doesn't exist+ if [[ ! -s "webs/webs_all.txt" ]]; then+ cat webs/webs.txt webs/webs_uncommon_ports.txt 2>/dev/null | anew -q "webs/webs_all.txt"+ fi++ # Check if webs_all.txt exists and is not empty+ if [[ -s "webs/webs_all.txt" ]]; then+ if [[ $AXIOM != true ]]; then+ # Use katana for scanning+ if [[ ! -s ".tmp/katana.txt" ]]; then+ if [[ $DEEP == true ]]; then+ timeout 4h katana -silent -list "webs/webs_all.txt" -jc -kf all -c "$KATANA_THREADS" -d 3 -o ".tmp/katana.txt" 2>>"$LOGFILE" >/dev/null+ else+ timeout 3h katana -silent -list "webs/webs_all.txt" -jc -kf all -c "$KATANA_THREADS" -d 2 -o ".tmp/katana.txt" 2>>"$LOGFILE" >/dev/null+ fi+ fi+ # Remove lines longer than 2048 characters+ if [[ -s ".tmp/katana.txt" ]]; then+ sed_i '/^.\{2048\}./d' ".tmp/katana.txt"+ fi+ else+ # Use axiom-scan for scanning+ if [[ ! -s ".tmp/katana.txt" ]]; then+ if [[ $DEEP == true ]]; then+ axiom-scan "webs/webs_all.txt" -m katana -jc -kf all -d 3 --max-runtime 4h -o ".tmp/katana.txt" $AXIOM_EXTRA_ARGS 2>>"$LOGFILE" >/dev/null+ else+ axiom-scan "webs/webs_all.txt" -m katana -jc -kf all -d 2 --max-runtime 3h -o ".tmp/katana.txt" $AXIOM_EXTRA_ARGS 2>>"$LOGFILE" >/dev/null+ fi+ # Remove lines longer than 2048 characters+ if [[ -s ".tmp/katana.txt" ]]; then+ sed_i '/^.\{2048\}./d' ".tmp/katana.txt"+ fi+ fi+ fi++ # Process katana.txt to find broken links+ if [[ -s ".tmp/katana.txt" ]]; then+ httpx -follow-redirects -random-agent -status-code -threads "$HTTPX_THREADS" -rl "$HTTPX_RATELIMIT" -timeout "$HTTPX_TIMEOUT" -silent -retries 2 -no-color <".tmp/katana.txt" 2>>"$LOGFILE" \+ | grep "\[4" | cut -d ' ' -f1 | anew -q ".tmp/brokenLinks_total.txt"+ fi++ # Update brokenLinks.txt with unique entries+ if [[ -s ".tmp/brokenLinks_total.txt" ]]; then+ NUMOFLINES=$(wc -l <".tmp/brokenLinks_total.txt" 2>>"$LOGFILE" | awk '{print $1}')+ cat .tmp/brokenLinks_total.txt | anew -q "vulns/brokenLinks.txt"+ NUMOFLINES=$(sed '/^$/d' "vulns/brokenLinks.txt" | wc -l)+ notification "${NUMOFLINES} new broken links found" info+ fi++ end_func "Results are saved in vulns/brokenLinks.txt" "${FUNCNAME[0]}"+ else+ end_func "No webs/webs_all.txt file found, Broken Links check skipped." "${FUNCNAME[0]}"+ return+ fi+ else+ # Handle cases where BROKENLINKS is false or function already processed+ if [[ $BROKENLINKS == false ]]; then+ pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"+ elif [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then+ # Domain is an IP address; skip the function+ return+ else+ pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"+ fi+ fi++}diff --git a/reconftw.sh b/reconftw.shindex 2ae2071..f6ba898 100755--- a/reconftw.sh+++ b/reconftw.sh@@ -6,7484 +6,73 @@ set -Eset +eIFS=$'\n\t'-# Standard exit/return codes-readonly E_SUCCESS=0-readonly E_GENERAL=1-readonly E_MISSING_DEP=2-readonly E_INVALID_INPUT=3-readonly E_NETWORK=4-readonly E_DISK_SPACE=5-readonly E_PERMISSION=6-readonly E_TIMEOUT=7-readonly E_CONFIG=8--# Welcome to reconFTW main script-# ██▀███ ▓█████ ▄████▄ ▒█████ ███▄ █ █████▒▄▄▄█████▓ █ █░-# ▓██ ▒ ██▒▓█ ▀ ▒██▀ ▀█ ▒██▒ ██▒ ██ ▀█ █ ▓██ ▒ ▓ ██▒ ▓▒▓█░ █ ░█░-# ▓██ ░▄█ ▒▒███ ▒▓█ ▄ ▒██░ ██▒▓██ ▀█ ██▒▒████ ░ ▒ ▓██░ ▒░▒█░ █ ░█-# ▒██▀▀█▄ ▒▓█ ▄ ▒▓▓▄ ▄██▒▒██ ██░▓██▒ ▐▌██▒░▓█▒ ░ ░ ▓██▓ ░ ░█░ █ ░█-# ░██▓ ▒██▒░▒████▒▒ ▓███▀ ░░ ████▓▒░▒██░ ▓██░░▒█░ ▒██▒ ░ ░░██▒██▓-# ░ ▒▓ ░▒▓░░░ ▒░ ░░ ░▒ ▒ ░░ ▒░▒░▒░ ░ ▒░ ▒ ▒ ▒ ░ ▒ ░░ ░ ▓░▒ ▒-# ░▒ ░ ▒░ ░ ░ ░ ░ ▒ ░ ▒ ▒░ ░ ░░ ░ ▒░ ░ ░ ▒ ░ ░-# ░░ ░ ░ ░ ░ ░ ░ ▒ ░ ░ ░ ░ ░ ░ ░ ░-# ░ ░ ░░ ░ ░ ░ ░ ░-#--# Detect if the script is being run in MacOS with Homebrew Bash-if [[ $OSTYPE == "darwin"* && $BASH != "/opt/homebrew/bin/bash" ]]; then- exec /opt/homebrew/bin/bash "$0" "$@"-fi--# timeout/gtimeout compatibility-if command -v timeout >/dev/null 2>&1; then- TIMEOUT_CMD="timeout"-elif command -v gtimeout >/dev/null 2>&1; then- TIMEOUT_CMD="gtimeout"-else- TIMEOUT_CMD=""-fi--# ---------------------------------------# Classic UI wrappers (no tput/icons)-# ----------------------------------------pt_header() { :; }-pt_msg_run() { printf "\n%b[%s] %s%b\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "$1" "$reset"; }-pt_msg_ok() { printf "\n%b[%s] %s%b\n" "$bgreen" "$(date +'%Y-%m-%d %H:%M:%S')" "$1" "$reset"; }-pt_msg_warn() { printf "\n%b[%s] %s%b\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "$1" "$reset"; }-pt_msg_err() { printf "\n%b[%s] %s%b\n" "$bred" "$(date +'%Y-%m-%d %H:%M:%S')" "$1" "$reset"; }--# Ensure a safe default for early log redirections-# If LOGFILE is unset or empty, send logs to /dev/null until later initialization-: "${LOGFILE:=/dev/null}"--enable_command_trace() {- # Enable bash xtrace to the current LOGFILE when SHOW_COMMANDS=true- if [[ ${SHOW_COMMANDS:-false} != true ]]; then- return- fi- [[ -z ${LOGFILE:-} ]] && return-- # Close any previous trace descriptor (native bash {varname} redirect syntax)- if [[ -n ${TRACE_FD:-} ]]; then- exec {TRACE_FD}>&- 2>/dev/null || true- fi-- # Open a new descriptor against the active log- if ! exec {TRACE_FD}>>"$LOGFILE"; then- return- fi- export BASH_XTRACEFD=$TRACE_FD- export PS4='+ ${BASH_SOURCE##*/}:${LINENO}: '- set -x-}--function banner_grabber() {- local banner_file="${SCRIPTPATH}/banners.txt"-- # Check if the banner file exists- if [[ ! -f $banner_file ]]; then- echo "Banner file not found: $banner_file" >&2- return 1- fi-- # Source the banner file- source "$banner_file"-- # Collect all banner variable names- mapfile -t banner_vars < <(compgen -A variable | grep '^banner[0-9]\+$')-- # Check if any banners are available- if [[ ${#banner_vars[@]} -eq 0 ]]; then- echo "No banners found in $banner_file" >&2- return 1- fi-- # Select a random banner- local rand_index=$((RANDOM % ${#banner_vars[@]}))- local banner_var="${banner_vars[$rand_index]}"- local banner_code="${!banner_var}"-- # Output the banner code- printf "%b\n" "$banner_code"-}--function banner() {- local banner_code- if banner_code=$(banner_grabber); then- printf "\n%b%s" "$bgreen" "$banner_code"- printf "\n %s by @six2dez%b\n" "$reconftw_version" "$reset"- else- printf "\n%bFailed to load banner.%b\n" "$bgreen" "$reset"- fi-}--###############################################################################################################-################################################### TOOLS #####################################################-###############################################################################################################--function check_version() {-- # Check if git is installed- if ! command -v git >/dev/null 2>&1; then- printf "\n%bGit is not installed. Cannot check for updates.%b\n\n" "$bred" "$reset"- return 1- fi-- # Check if current directory is a git repository- if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then- printf "\n%bCurrent directory is not a git repository. Cannot check for updates.%b\n\n" "$bred" "$reset"- return 1- fi-- # Fetch updates with a timeout (supports gtimeout on macOS)- if ! { [[ -n $TIMEOUT_CMD ]] && $TIMEOUT_CMD 10 git fetch >/dev/null 2>&1; } && ! git fetch >/dev/null 2>&1; then- printf "\n%bUnable to check updates (git fetch timed out).%b\n\n" "$bred" "$reset"- return 1- fi-- # Get current branch name- local BRANCH- BRANCH=$(git rev-parse --abbrev-ref HEAD)-- # Get upstream branch- local UPSTREAM- UPSTREAM=$(git rev-parse --abbrev-ref --symbolic-full-name "@{u}" 2>/dev/null)- if [[ -z $UPSTREAM ]]; then- printf "\n%bNo upstream branch set for '%s'. Cannot check for updates.%b\n\n" "$bred" "$BRANCH" "$reset"- return 1- fi-- # Get local and remote commit hashes- local LOCAL REMOTE- LOCAL=$(git rev-parse HEAD)- REMOTE=$(git rev-parse "$UPSTREAM")-- # Compare local and remote hashes- if [[ $LOCAL != "$REMOTE" ]]; then- printf "\n%bThere is a new version available. Run ./install.sh to get the latest version.%b\n\n" "$yellow" "$reset"- fi-}--function tools_installed() {- # Check if all tools are installed- printf "\n\n%b#######################################################################%b\n" "$bgreen" "$reset"- printf "%b[%s] Checking installed tools %b\n\n" "$bblue" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"-- local all_installed=true- local missing_tools=()-- # Check environment variables- local env_vars=("GOPATH" "GOROOT" "PATH")- for var in "${env_vars[@]}"; do- if [[ -z ${!var} ]]; then- printf "%b [*] %s variable\t\t[NO]%b\n" "$bred" "$var" "$reset"- all_installed=false- missing_tools+=("$var environment variable")- fi- done-- # Define tools and their paths/commands- declare -A tools_files=(- ["dorks_hunter"]="${tools}/dorks_hunter/dorks_hunter.py"- ["dorks_hunter_python"]="${tools}/dorks_hunter/venv/bin/python3"- ["fav-up"]="${tools}/fav-up/favUp.py"- ["fav-up_python"]="${tools}/fav-up/venv/bin/python3"- ["Corsy"]="${tools}/Corsy/corsy.py"- ["Corsy_python"]="${tools}/Corsy/venv/bin/python3"- ["testssl.sh"]="${tools}/testssl.sh/testssl.sh"- ["CMSeeK"]="${tools}/CMSeeK/cmseek.py"- ["CMSeeK_python"]="${tools}/CMSeeK/venv/bin/python3"- ["OneListForAll"]="$fuzz_wordlist"- ["lfi_wordlist"]="$lfi_wordlist"- ["ssti_wordlist"]="$ssti_wordlist"- ["subs_wordlist"]="$subs_wordlist"- ["subs_wordlist_big"]="$subs_wordlist_big"- ["resolvers"]="$resolvers"- ["resolvers_trusted"]="$resolvers_trusted"- ["getjswords"]="${tools}/getjswords.py"- ["JSA"]="${tools}/JSA/jsa.py"- ["JSA_python"]="${tools}/JSA/venv/bin/python3"- ["CloudHunter"]="${tools}/CloudHunter/cloudhunter.py"- ["CloudHunter_python"]="${tools}/CloudHunter/venv/bin/python3"- ["nmap-parse-output"]="${tools}/ultimate-nmap-parser/ultimate-nmap-parser.sh"- ["pydictor"]="${tools}/pydictor/pydictor.py"- ["regulator"]="${tools}/regulator/main.py"- ["regulator_python"]="${tools}/regulator/venv/bin/python3"- ["nomore403"]="${tools}/nomore403/nomore403"- ["ffufPostprocessing"]="${tools}/ffufPostprocessing/ffufPostprocessing"- ["spoofy"]="${tools}/Spoofy/spoofy.py"- ["spoofy_python"]="${tools}/Spoofy/venv/bin/python3"- ["swaggerspy"]="${tools}/SwaggerSpy/swaggerspy.py"- ["swaggerspy_python"]="${tools}/SwaggerSpy/venv/bin/python3"- ["LeakSearch"]="${tools}/LeakSearch/LeakSearch.py"- ["LeakSearch_python"]="${tools}/LeakSearch/venv/bin/python3"- ["Oralyzer"]="${tools}/Oralyzer/oralyzer.py"- ["Oralyzer_python"]="${tools}/Oralyzer/venv/bin/python3"- ["msftrecon"]="${tools}/msftrecon/msftrecon/msftrecon.py"- ["msftrecon_python"]="${tools}/msftrecon/venv/bin/python3"- ["Scopify"]="${tools}/Scopify/scopify.py"- ["Scopify_python"]="${tools}/Scopify/venv/bin/python3"- ["EmailHarvester"]="${tools}/EmailHarvester/EmailHarvester.py"- ["EmailHarvester_python"]="${tools}/EmailHarvester/venv/bin/python3"- ["metagoofil"]="${tools}/metagoofil/metagoofil.py"- ["metagoofil_python"]="${tools}/metagoofil/venv/bin/python3"- ["reconftw_ai"]="${tools}/reconftw_ai/reconftw_ai.py"- ["reconftw_ai_python"]="${tools}/reconftw_ai/venv/bin/python3"- )-- declare -A tools_folders=(- ["NUCLEI_TEMPLATES_PATH"]="${NUCLEI_TEMPLATES_PATH}"- ["NUCLEI_FUZZING_TEMPLATES_PATH"]="${NUCLEI_FUZZING_TEMPLATES_PATH}"- )-- declare -A tools_commands=(- ["python3"]="python3"- ["curl"]="curl"- ["wget"]="wget"- ["zip"]="zip"- ["nmap"]="nmap"- ["dig"]="dig"- ["timeout"]="${TIMEOUT_CMD:-timeout}"- ["brutespray"]="brutespray"- ["xnLinkFinder"]="xnLinkFinder"- ["xnldorker"]="xnldorker"- ["urlfinder"]="urlfinder"- ["github-endpoints"]="github-endpoints"- ["github-subdomains"]="github-subdomains"- ["gitlab-subdomains"]="gitlab-subdomains"- ["katana"]="katana"- ["wafw00f"]="wafw00f"- ["dnsvalidator"]="dnsvalidator"- ["whois"]="whois"- ["dnsx"]="dnsx"- ["gotator"]="gotator"- ["Nuclei"]="nuclei"- ["gf"]="gf"- ["Gxss"]="Gxss"- ["subjs"]="subjs"- ["ffuf"]="ffuf"- ["Massdns"]="massdns"- ["qsreplace"]="qsreplace"- ["interlace"]="interlace"- ["Anew"]="anew"- ["unfurl"]="unfurl"- ["crlfuzz"]="crlfuzz"- ["Httpx"]="httpx"- ["jq"]="jq"- ["notify"]="notify"- ["dalfox"]="dalfox"- ["puredns"]="puredns"- ["analyticsrelationships"]="analyticsrelationships"- ["mapcidr"]="mapcidr"- ["ppmap"]="ppmap"- ["cdncheck"]="cdncheck"- ["interactsh-client"]="interactsh-client"- ["tlsx"]="tlsx"- ["smap"]="smap"- ["gitdorks_go"]="gitdorks_go"- ["ripgen"]="ripgen"- ["smugglex"]="smugglex"- ["dsieve"]="dsieve"- ["inscope"]="inscope"- ["enumerepo"]="enumerepo"- ["Web-Cache-Vulnerability-Scanner"]="Web-Cache-Vulnerability-Scanner"- ["subfinder"]="subfinder"- ["ghauri"]="ghauri"- ["hakip2host"]="hakip2host"- ["crt"]="crt"- ["gitleaks"]="gitleaks"- ["trufflehog"]="trufflehog"- ["s3scanner"]="s3scanner"- ["mantra"]="mantra"- ["nmapurls"]="nmapurls"- ["porch-pirate"]="porch-pirate"- ["shortscan"]="shortscan"- ["sns"]="sns"- ["sourcemapper"]="sourcemapper"- ["jsluice"]="jsluice"- ["commix"]="commix"- ["urless"]="urless"- ["dnstake"]="dnstake"- ["cent"]="cent"- ["csprecon"]="csprecon"- ["VhostFinder"]="VhostFinder"- ["grpcurl"]="grpcurl"- ["arjun"]="arjun"- ["gqlspection"]="gqlspection"- ["cloud_enum"]="cloud_enum"- )-- # Check for tool files- for tool in "${!tools_files[@]}"; do- if [[ ! -f ${tools_files[$tool]} ]]; then- # printf "%b [*] %s\t\t[NO]%b\n" "$bred" "$tool" "$reset"- all_installed=false- missing_tools+=("$tool")- fi- done-- # Check for tool folders- for folder in "${!tools_folders[@]}"; do- if [[ ! -d ${tools_folders[$folder]} ]]; then- # printf "%b [*] %s\t\t[NO]%b\n" "$bred" "$folder" "$reset"- all_installed=false- missing_tools+=("$folder") # Correctly pushing the folder name- fi- done-- # Check for tool commands- for tool in "${!tools_commands[@]}"; do- if ! command -v "${tools_commands[$tool]}" >/dev/null 2>&1; then- # printf "%b [*] %s\t\t[NO]%b\n" "$bred" "$tool" "$reset"- all_installed=false- missing_tools+=("$tool")- fi- done-- if [[ $all_installed == true ]]; then- printf "%b\n Good! All tools are installed! %b\n\n" "$bgreen" "$reset"- else- printf "\n%bSome tools or directories are missing:%b\n\n" "$yellow" "$reset"- for tool in "${missing_tools[@]}"; do- printf "%b - %s %b\n" "$bred" "$tool" "$reset"- done- printf "\n%bTry running the installer script again: ./install.sh%b\n" "$yellow" "$reset"- printf "%bIf it fails, try installing the missing tools manually.%b\n" "$yellow" "$reset"- printf "%bEnsure that the %b\$tools%b variable is correctly set at the start of this script.%b\n" "$yellow" "$bred" "$yellow" "$reset"- printf "%bIf you need assistance, feel free to contact me! :D%b\n\n" "$yellow" "$reset"- fi-- printf "%b[%s] Tools check finished%b\n" "$bblue" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"- printf "%b#######################################################################\n%b" "$bgreen" "$reset"-- if [[ $CHECK_TOOLS_OR_EXIT == true && $all_installed != true ]]; then- exit 2- fi-}--###############################################################################################################-#################################### CRITICAL DEPENDENCIES CHECK ##############################################-###############################################################################################################--# Check critical dependencies required for basic operation-# This performs a quick check of essential tools before starting-function check_critical_dependencies() {- local critical_tools=(- "bash:Bash shell"- "python3:Python 3"- "curl:Curl"- "git:Git"- "jq:JQ JSON processor"- )-- local missing_critical=()- local all_critical_ok=true-- printf "\n%b#######################################################################%b\n" "$bgreen" "$reset"- printf "%b[%s] Checking critical dependencies%b\n\n" "$bblue" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"-- for item in "${critical_tools[@]}"; do- local tool="${item%%:*}"- local description="${item#*:}"-- if ! command -v "$tool" >/dev/null 2>&1; then- printf "%b [✗] %s (%s) - MISSING%b\n" "$bred" "$description" "$tool" "$reset"- missing_critical+=("$tool")- all_critical_ok=false- else- local version=""- case "$tool" in- "python3")- version=$($tool --version 2>&1 | head -n1)- ;;- "bash")- version="$BASH_VERSION"- ;;- *)- version=$($tool --version 2>&1 | head -n1 || echo "installed")- ;;- esac- printf "%b [✓] %s (%s) - %s%b\n" "$bgreen" "$description" "$tool" "$version" "$reset"- fi- done-- printf "\n"-- if [[ $all_critical_ok == false ]]; then- printf "%b[%s] ERROR: Critical dependencies missing!%b\n" "$bred" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"- printf "%bThe following tools are required for reconFTW to function:%b\n" "$yellow" "$reset"- for tool in "${missing_critical[@]}"; do- printf "%b - %s%b\n" "$bred" "$tool" "$reset"- done- printf "\n%bPlease install these tools and try again.%b\n" "$yellow" "$reset"- printf "%bYou can run: ./install.sh to install all dependencies.%b\n" "$yellow" "$reset"- printf "%b#######################################################################%b\n\n" "$bgreen" "$reset"- exit 1- else- printf "%b[%s] All critical dependencies are installed%b\n" "$bgreen" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"- printf "%b#######################################################################%b\n\n" "$bgreen" "$reset"- fi-}--#####################################################################cc##########################################-################################################### OSINT #####################################################-###############################################################################################################--function google_dorks() {- mkdir -p osint-- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $GOOGLE_DORKS == true ]] && [[ $OSINT == true ]]; then- start_func "${FUNCNAME[0]}" "Running: Google Dorks in process"-- "${tools}/dorks_hunter/venv/bin/python3" "${tools}/dorks_hunter/dorks_hunter.py" -d "$domain" -o "osint/dorks.txt"- end_func "Results are saved in $domain/osint/dorks.txt" "${FUNCNAME[0]}"- else- if [[ $GOOGLE_DORKS == false ]] || [[ $OSINT == false ]]; then- printf "\n%b[%s] %s skipped due to mode or configuration settings.%b\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"- else- printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s %b\n\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$called_fn_dir" "${FUNCNAME[0]}" "$reset"- fi- fi-}--function github_dorks() {- mkdir -p osint-- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $GITHUB_DORKS == true ]] && [[ $OSINT == true ]]; then- start_func "${FUNCNAME[0]}" "Running: Github Dorks in process"-- if [[ -s $GITHUB_TOKENS ]]; then- if [[ $DEEP == true ]]; then- if ! gitdorks_go -gd "${tools}/gitdorks_go/Dorks/medium_dorks.txt" -nws 20 -target "$domain" -tf "$GITHUB_TOKENS" -ew 3 | anew -q osint/gitdorks.txt; then- printf "%b[!] gitdorks_go command failed.%b\n" "$bred" "$reset"- return 1- fi- else- if ! gitdorks_go -gd "${tools}/gitdorks_go/Dorks/smalldorks.txt" -nws 20 -target "$domain" -tf "$GITHUB_TOKENS" -ew 3 | anew -q osint/gitdorks.txt; then- printf "%b[!] gitdorks_go command failed.%b\n" "$bred" "$reset"- return 1- fi- fi- else- printf "\n%b[%s] Required file %s does not exist or is empty.%b\n" "$bred" "$(date +'%Y-%m-%d %H:%M:%S')" "$GITHUB_TOKENS" "$reset"- return 1- fi- end_func "Results are saved in $domain/osint/gitdorks.txt" "${FUNCNAME[0]}"- else- if [[ $GITHUB_DORKS == false ]] || [[ $OSINT == false ]]; then- printf "\n%b[%s] %s skipped due to mode or configuration settings.%b\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"- else- printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s %b\n\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$called_fn_dir" "${FUNCNAME[0]}" "$reset"- fi- fi-}--function github_repos() {- mkdir -p osint-- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $GITHUB_REPOS == true ]] && [[ $OSINT == true ]]; then- start_func "${FUNCNAME[0]}" "Github Repos analysis in process"-- if [[ -s $GITHUB_TOKENS ]]; then- GH_TOKEN=$(head -n 1 "$GITHUB_TOKENS")- echo "$domain" | unfurl format %r >.tmp/company_name.txt-- if ! enumerepo -token-string "$GH_TOKEN" -usernames .tmp/company_name.txt -o .tmp/company_repos.txt 2>>"$LOGFILE" >/dev/null; then- printf "%b[!] enumerepo command failed.%b\n" "$bred" "$reset"- fi-- if [[ -s ".tmp/company_repos.txt" ]]; then- if ! jq -r '.[].repos[]|.url' <.tmp/company_repos.txt >.tmp/company_repos_url.txt 2>>"$LOGFILE"; then- printf "%b[!] jq command failed.%b\n" "$bred" "$reset"- fi- fi-- mkdir -p .tmp/github_repos 2>>"$LOGFILE"- mkdir -p .tmp/github 2>>"$LOGFILE"-- if [[ -s ".tmp/company_repos_url.txt" ]]; then- if ! interlace -tL .tmp/company_repos_url.txt -threads "$INTERLACE_THREADS" -c "git clone _target_ .tmp/github_repos/_cleantarget_" 2>>"$LOGFILE" >/dev/null; then- printf "%b[!] interlace git clone command failed.%b\n" "$bred" "$reset"- return 1- fi- else- end_func "Results are saved in $domain/osint/github_company_secrets.json" "${FUNCNAME[0]}"- return 1- fi-- if [[ -d ".tmp/github_repos/" ]]; then- ls .tmp/github_repos >.tmp/github_repos_folders.txt- else- end_func "Results are saved in $domain/osint/github_company_secrets.json" "${FUNCNAME[0]}"- return 1- fi-- if [[ -s ".tmp/github_repos_folders.txt" ]]; then- if ! interlace -tL .tmp/github_repos_folders.txt -threads "$INTERLACE_THREADS" -c "gitleaks detect --source .tmp/github_repos/_target_ --no-banner --no-color -r .tmp/github/gh_secret_cleantarget_.json" 2>>"$LOGFILE" >/dev/null; then- printf "%b[!] interlace gitleaks command failed.%b\n" "$bred" "$reset"- end_func "Results are saved in $domain/osint/github_company_secrets.json" "${FUNCNAME[0]}"- return 1- fi- else- end_func "Results are saved in $domain/osint/github_company_secrets.json" "${FUNCNAME[0]}"- return 1- fi-- if [[ -s ".tmp/company_repos_url.txt" ]]; then- if ! interlace -tL .tmp/company_repos_url.txt -threads "$INTERLACE_THREADS" -c "trufflehog git _target_ -j 2>&1 | jq -c > _output_/_cleantarget_" -o .tmp/github/ 2>>"$LOGFILE" >/dev/null; then- printf "%b[!] interlace trufflehog command failed.%b\n" "$bred" "$reset"- return 1- fi- fi-- if [[ -d ".tmp/github/" ]]; then- if ! cat .tmp/github/* 2>/dev/null | jq -c | jq -r >"osint/github_company_secrets.json" 2>>"$LOGFILE"; then- printf "%b[!] Error combining results.%b\n" "$bred" "$reset"- return 1- fi- else- end_func "Results are saved in $domain/osint/github_company_secrets.json" "${FUNCNAME[0]}"- return 1- fi-- end_func "Results are saved in $domain/osint/github_company_secrets.json" "${FUNCNAME[0]}"- else- printf "\n%s[%s] Required file %s does not exist or is empty.%b\n" "$bred" "$(date +'%Y-%m-%d %H:%M:%S')" "$GITHUB_TOKENS" "$reset"- return 1- fi- else- if [[ $GITHUB_REPOS == false ]] || [[ $OSINT == false ]]; then- printf "\n%b[%s] %s skipped due to mode or configuration settings.%b\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"- else- printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s %b\n\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$called_fn_dir" "${FUNCNAME[0]}" "$reset"- fi- fi-}--function metadata() {- mkdir -p osint-- # Check if the function should run- if { [[ ! -f "${called_fn_dir}/.${FUNCNAME[0]}" ]] || [[ ${DIFF} == true ]]; } && [[ ${METADATA} == true ]] && [[ ${OSINT} == true ]] && ! [[ ${domain} =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then- start_func "${FUNCNAME[0]}" "Scanning metadata in public files"-- mkdir -p ".tmp/metagoofil_${domain}/" 2>>"${LOGFILE}"- pushd "${tools}/metagoofil" >/dev/null || {- printf "%b[!] Failed to change directory to %s in %s at line %s.%b\n" "${bred}" "${tools}/metagoofil" "${FUNCNAME[0]}" "${LINENO}" "${reset}"- return 1- }- "${tools}/metagoofil/venv/bin/python3" "${tools}/metagoofil/metagoofil.py" -d "${domain}" -t pdf,docx,xlsx -l 10 -w -o "${dir}/.tmp/metagoofil_${domain}/" 2>>"${LOGFILE}" >/dev/null- popd >/dev/null || {- printf "%b[!] Failed to return to the previous directory in %s at line %s.%b\n" "${bred}" "${FUNCNAME[0]}" "${LINENO}" "${reset}"- return 1- }-- exiftool -r .tmp/metagoofil_${domain}/* 2>>"${LOGFILE}" | tee /dev/null | egrep -i "Author|Creator|Email|Producer|Template" | sort -u | anew -q "osint/metadata_results.txt"-- end_func "Results are saved in ${domain}/osint/metadata_results.txt" "${FUNCNAME[0]}"- else- if [[ ${METADATA} == false ]] || [[ ${OSINT} == false ]]; then- printf "\n%b[%s] %s skipped due to mode or configuration settings.%b\n" "${yellow}" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "${reset}"- elif [[ ${domain} =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then- return- else- printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s %b\n\n" "${yellow}" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "${called_fn_dir}" "${FUNCNAME[0]}" "${reset}"- fi- fi-}--function apileaks() {- mkdir -p osint-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } &&- [[ $API_LEAKS == true ]] && [[ $OSINT == true ]] &&- ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then-- start_func "${FUNCNAME[0]}" "Scanning for leaks in public API directories"-- # Run porch-pirate and handle errors- porch-pirate -s "$domain" -l 25 --dump 2>>"$LOGFILE" >"${dir}/osint/postman_leaks.txt"-- # Change directory to SwaggerSpy- if ! pushd "${tools}/SwaggerSpy" >/dev/null; then- printf "%b[!] Failed to change directory to %s in %s at line %s.%b\n" "$bred" "${tools}/SwaggerSpy" "${FUNCNAME[0]}" "$LINENO" "$reset"- return 1- fi-- # Run swaggerspy.py and handle errors- local swag_cmd=("${tools}/SwaggerSpy/venv/bin/python3" "swaggerspy.py" "$domain")- [[ -n ${TIMEOUT_CMD:-} ]] && swag_cmd=("$TIMEOUT_CMD" 2m "${swag_cmd[@]}")- local swagger_rc=0- {- "${swag_cmd[@]}" 2>>"$LOGFILE" | grep -i "[*]\|URL" >"${dir}/osint/swagger_leaks.txt"- swagger_rc=${PIPESTATUS[0]:-0} # ignore grep exit code (no matches is fine)- } || true- if (( swagger_rc != 0 )); then- printf "%b[%s] SwaggerSpy failed (exit %s), continuing without swagger results.%b\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "$swagger_rc" "$reset" | tee -a "$LOGFILE" >/dev/null- fi-- # Return to the previous directory- if ! popd >/dev/null; then- printf "%b[!] Failed to return to the previous directory in %s at line %s.%b\n" "$bred" "${FUNCNAME[0]}" "$LINENO" "$reset"- return 1- fi-- # Analyze leaks with trufflehog- if [[ -s "${dir}/osint/postman_leaks.txt" ]]; then- trufflehog filesystem "${dir}/osint/postman_leaks.txt" -j 2>/dev/null | jq -c | anew -q "${dir}/osint/postman_leaks_trufflehog.json"- fi-- if [[ -s "${dir}/osint/swagger_leaks.txt" ]]; then- trufflehog filesystem "${dir}/osint/swagger_leaks.txt" -j 2>/dev/null | jq -c | anew -q "${dir}/osint/swagger_leaks_trufflehog.json"- fi-- end_func "Results are saved in $domain/osint/[postman_leaks_trufflehog.json, swagger_leaks_trufflehog.json]" "${FUNCNAME[0]}"- else- if [[ $API_LEAKS == false ]] || [[ $OSINT == false ]]; then- printf "\n%b[%s] %s skipped due to mode or configuration settings.%b\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"- elif [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then- return- else- printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s %b\n\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$called_fn_dir" "${FUNCNAME[0]}" "$reset"- fi- fi-}--function emails() {- mkdir -p .tmp osint-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } &&- [[ $EMAILS == true ]] && [[ $OSINT == true ]] &&- ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then-- start_func "${FUNCNAME[0]}" "Searching for emails/users/passwords leaks"-- PYTHONWARNINGS=ignore "${tools}/EmailHarvester/venv/bin/python3" "${tools}/EmailHarvester/EmailHarvester.py" -d ${domain} -e all -l 20 2>>"$LOGFILE" | anew -q .tmp/EmailHarvester.txt || true-- # Process emailfinder results- if [[ -s ".tmp/EmailHarvester.txt" ]]; then- grep "@" .tmp/EmailHarvester.txt | anew -q osint/emails.txt || true- fi-- # Change directory to LeakSearch- if ! pushd "${tools}/LeakSearch" >/dev/null; then- printf "%b[!] Failed to change directory to %s in %s at line %s.%b\n" "$bred" "${tools}/LeakSearch" "${FUNCNAME[0]}" "$LINENO" "$reset"- return 1- fi-- # Run LeakSearch.py and handle errors- "${tools}/LeakSearch/venv/bin/python3" LeakSearch.py -k "$domain" -o "${dir}/.tmp/passwords.txt" 1>>"$LOGFILE"-- # Return to the previous directory- if ! popd >/dev/null; then- printf "%b[!] Failed to return to the previous directory in %s at line %s.%b\n" "$bred" "${FUNCNAME[0]}" "$LINENO" "$reset"- return 1- fi-- # Process passwords.txt- if [[ -s "${dir}/.tmp/passwords.txt" ]]; then- anew -q osint/passwords.txt <"${dir}/.tmp/passwords.txt"- fi-- end_func "Results are saved in $domain/osint/emails.txt and passwords.txt" "${FUNCNAME[0]}"- else- if [[ $EMAILS == false ]] || [[ $OSINT == false ]]; then- printf "\n%b[%s] %s skipped due to mode or configuration settings.%b\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"- elif [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then- return- else- printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s%b\n\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$called_fn_dir" "/.${FUNCNAME[0]}" "$reset"- fi- fi-}--function domain_info() {-- mkdir -p osint-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } &&- [[ $DOMAIN_INFO == true ]] && [[ $OSINT == true ]] &&- ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then-- start_func "${FUNCNAME[0]}" "Searching domain info (whois, registrant name/email domains)"-- # Run whois command and check for errors- whois "$domain" >"osint/domain_info_general.txt"- "${tools}/msftrecon/venv/bin/python3" "${tools}/msftrecon/msftrecon/msftrecon.py" -d ${domain} 2>>"$LOGFILE" >osint/azure_tenant_domains.txt || true-- company_name=$(unfurl format %r <<<"$domain")- "${tools}/Scopify/venv/bin/python3" "${tools}/Scopify/scopify.py" -c ${company_name} >osint/scopify.txt-- end_func "Results are saved in ${domain}/osint/domain_info_[general/azure_tenant_domains].txt" "${FUNCNAME[0]}"-- else- if [[ $DOMAIN_INFO == false ]] || [[ $OSINT == false ]]; then- printf "\n%b[%s] %s skipped due to mode or configuration settings.%b\n" \- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"- elif [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then- return- else- printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s%b\n\n" \- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$called_fn_dir" "/.${FUNCNAME[0]}" "$reset"- fi- fi-}--function third_party_misconfigs() {- mkdir -p osint-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } &&- [[ $THIRD_PARTIES == true ]] && [[ $OSINT == true ]] &&- ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then-- start_func "${FUNCNAME[0]}" "Searching for third parties misconfigurations"-- # Extract company name from domain- company_name=$(unfurl format %r <<<"$domain")-- # Change directory to Spoofy tool- if ! pushd "${tools}/misconfig-mapper" >/dev/null; then- printf "%b[!] Failed to change directory to %s in %s at line %s.%b\n" \- "$bred" "${tools}/misconfig-mapper" "${FUNCNAME[0]}" "$LINENO" "$reset"- return 1- fi-- # Run misconfig-mapper and handle errors- misconfig-mapper -target "$company_name" -service "*" 2>&1 | grep -v "\-\]" | grep -v "Failed" >"${dir}/osint/3rdparts_misconfigurations.txt"-- # Return to the previous directory- if ! popd >/dev/null; then- printf "%b[!] Failed to return to previous directory in %s at line %s.%b\n" \- "$bred" "${FUNCNAME[0]}" "$LINENO" "$reset"- return 1- fi-- end_func "Results are saved in $domain/osint/3rdparts_misconfigurations.txt" "${FUNCNAME[0]}"-- else- if [[ $THIRD_PARTIES == false ]] || [[ $OSINT == false ]]; then- printf "\n%b[%s] %s skipped due to mode or configuration settings.%b\n" \- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"- elif [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then- return- else- printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s%b\n\n" \- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$called_fn_dir" "/.${FUNCNAME[0]}" "$reset"- fi- fi-}--function spoof() {- mkdir -p osint-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } &&- [[ $SPOOF == true ]] && [[ $OSINT == true ]] &&- ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then-- start_func "${FUNCNAME[0]}" "Searching for spoofable domains"-- # Change directory to Spoofy tool- if ! pushd "${tools}/Spoofy" >/dev/null; then- printf "%b[!] Failed to change directory to %s in %s at line %s.%b\n" \- "$bred" "${tools}/Spoofy" "${FUNCNAME[0]}" "$LINENO" "$reset"- return 1- fi-- # Run spoofy.py and handle errors- "${tools}/Spoofy/venv/bin/python3" spoofy.py -d "$domain" >"${dir}/osint/spoof.txt"-- # Return to the previous directory- if ! popd >/dev/null; then- printf "%b[!] Failed to return to previous directory in %s at line %s.%b\n" \- "$bred" "${FUNCNAME[0]}" "$LINENO" "$reset"- return 1- fi-- end_func "Results are saved in $domain/osint/spoof.txt" "${FUNCNAME[0]}"-- else- if [[ $SPOOF == false ]] || [[ $OSINT == false ]]; then- printf "\n%b[%s] %s skipped due to mode or configuration settings.%b\n" \- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"- elif [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then- return- else- printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s%b\n\n" \- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$called_fn_dir" "/.${FUNCNAME[0]}" "$reset"- fi- fi-}--function mail_hygiene() {- mkdir -p osint-- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } &&- [[ $MAIL_HYGIENE == true ]] && [[ $OSINT == true ]] &&- ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then-- start_func "${FUNCNAME[0]}" "Mail hygiene (SPF/DMARC)"- {- printf "Domain: %s\n" "$domain"- printf "\nTXT records:\n"- dig +short TXT "$domain" | sed 's/^/ /'- printf "\nDMARC record:\n"- dig +short TXT "_dmarc.$domain" | sed 's/^/ /'- } >"osint/mail_hygiene.txt" 2>>"$LOGFILE"- end_func "Results are saved in $domain/osint/mail_hygiene.txt" "${FUNCNAME[0]}"- else- if [[ $MAIL_HYGIENE == false ]] || [[ $OSINT == false ]]; then- printf "\n%b[%s] %s skipped due to mode or configuration settings.%b\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"- elif [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then- return- else- printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s %b\n\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$called_fn_dir" "${FUNCNAME[0]}" "$reset"- fi- fi-}--function cloud_enum_scan() {- mkdir -p osint-- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } &&- [[ $CLOUD_ENUM == true ]] && [[ $OSINT == true ]] &&- ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then-- start_func "${FUNCNAME[0]}" "Cloud storage enumeration"- company_name=$(unfurl format %r <<<"$domain")- cloud_enum -k "$company_name" -k "$domain" -k "${domain%%.*}" 2>>"$LOGFILE" | anew -q osint/cloud_enum.txt- end_func "Results are saved in $domain/osint/cloud_enum.txt" "${FUNCNAME[0]}"- else- if [[ $CLOUD_ENUM == false ]] || [[ $OSINT == false ]]; then- printf "\n%b[%s] %s skipped due to mode or configuration settings.%b\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"- elif [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then- return- else- printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s %b\n\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$called_fn_dir" "${FUNCNAME[0]}" "$reset"- fi- fi-}--function ip_info() {-- mkdir -p osint-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } &&- [[ $IP_INFO == true ]] && [[ $OSINT == true ]] &&- [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then-- start_func "${FUNCNAME[0]}" "Searching IP info"-- if [[ -n $WHOISXML_API ]]; then-- # Reverse IP lookup- curl -s "https://reverse-ip.whoisxmlapi.com/api/v1?apiKey=${WHOISXML_API}&ip=${domain}" |- jq -r '.result[].name' 2>>"$LOGFILE" |- sed -e "s/$/ ${domain}/" |- anew -q "osint/ip_${domain}_relations.txt"-- # WHOIS lookup- curl -s "https://www.whoisxmlapi.com/whoisserver/WhoisService?apiKey=${WHOISXML_API}&domainName=${domain}&outputFormat=json&da=2®istryRawText=1®istrarRawText=1&ignoreRawTexts=1" |- jq 2>>"$LOGFILE" |- anew -q "osint/ip_${domain}_whois.txt"-- # IP Geolocation- curl -s "https://ip-geolocation.whoisxmlapi.com/api/v1?apiKey=${WHOISXML_API}&ipAddress=${domain}" |- jq -r '.ip,.location' 2>>"$LOGFILE" |- anew -q "osint/ip_${domain}_location.txt"-- end_func "Results are saved in ${domain}/osint/ip_[domain_relations|whois|location].txt" "${FUNCNAME[0]}"-- else- printf "\n%s[%s] WHOISXML_API variable is not defined. Skipping function.%b\n" \- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"- fi-- else- if [[ $IP_INFO == false ]] || [[ $OSINT == false ]]; then- printf "\n%b[%s] %s skipped due to mode or configuration settings.%b\n" \- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"- elif ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then- return- else- printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s%b\n\n" \- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$called_fn_dir" "/.${FUNCNAME[0]}" "$reset"- fi- fi--}--###############################################################################################################-############################################### SUBDOMAINS ####################################################-###############################################################################################################--function subdomains_full() {-- # Create necessary directories- if ! mkdir -p .tmp webs subdomains; then- printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"- return 1- fi-- NUMOFLINES_subs="0"- NUMOFLINES_probed="0"-- printf "%b#######################################################################%b\n\n" "$bgreen" "$reset"-- # Check if domain is an IP address- if [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then- printf "%b[%s] Scanning IP %s%b\n\n" "$bblue" "$(date +'%Y-%m-%d %H:%M:%S')" "$domain" "$reset"- else- printf "%b[%s] Subdomain Enumeration %s%b\n\n" "$bblue" "$(date +'%Y-%m-%d %H:%M:%S')" "$domain" "$reset"- fi-- # Backup existing subdomains and webs- if [[ -s "subdomains/subdomains.txt" ]]; then- if ! cp "subdomains/subdomains.txt" ".tmp/subdomains_old.txt"; then- printf "%b[!] Failed to backup subdomains.txt.%b\n" "$bred" "$reset"- fi- fi-- if [[ -s "webs/webs.txt" ]]; then- if ! cp "webs/webs.txt" ".tmp/probed_old.txt"; then- printf "%b[!] Failed to backup webs.txt.%b\n" "$bred" "$reset"- fi- fi-- # Update resolvers if necessary- if { [[ ! -f "$called_fn_dir/.sub_active" ]] || [[ ! -f "$called_fn_dir/.sub_brute" ]] || [[ ! -f "$called_fn_dir/.sub_permut" ]] || [[ ! -f "$called_fn_dir/.sub_recursive_brute" ]]; } || [[ $DIFF == true ]]; then- if ! resolvers_update; then- printf "%b[!] Failed to update resolvers.%b\n" "$bred" "$reset"- return 1- fi- fi-- # Add in-scope subdomains- if [[ -s $inScope_file ]]; then- if ! cat "$inScope_file" | anew -q subdomains/subdomains.txt; then- printf "%b[!] Failed to update subdomains.txt with in-scope domains.%b\n" "$bred" "$reset"- fi- fi-- # Subdomain enumeration- if [[ ! $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]] && [[ $SUBDOMAINS_GENERAL == true ]]; then- sub_passive- sub_crt- sub_active- sub_tls- sub_noerror- sub_brute- sub_permut- sub_regex_permut- sub_ia_permut- sub_recursive_passive- sub_recursive_brute- sub_dns- sub_scraping- sub_analytics- else- notification "IP/CIDR detected, subdomains search skipped" "info"- if ! printf "%b\n" "$domain" | anew -q subdomains/subdomains.txt; then- printf "%b[!] Failed to add domain to subdomains.txt.%b\n" "$bred" "$reset"- fi- fi-- # Web probing- if ! webprobe_simple; then- printf "%b[!] webprobe_simple function failed.%b\n" "$bred" "$reset"- fi-- # Process subdomains- if [[ -s "subdomains/subdomains.txt" ]]; then- if [[ -s $outOfScope_file ]]; then- if ! deleteOutScoped "$outOfScope_file" "subdomains/subdomains.txt"; then- printf "%b[!] Failed to remove out-of-scope subdomains.%b\n" "$bred" "$reset"- fi- fi- if ! NUMOFLINES_subs=$(cat "subdomains/subdomains.txt" 2>>"$LOGFILE" | anew ".tmp/subdomains_old.txt" | sed '/^$/d' | wc -l); then- NUMOFLINES_subs="0"- fi- fi-- # Process webs- if [[ -s "webs/webs.txt" ]]; then- if [[ -s $outOfScope_file ]]; then- if ! deleteOutScoped "$outOfScope_file" "webs/webs.txt"; then- printf "%b[!] Failed to remove out-of-scope webs.%b\n" "$bred" "$reset"- fi- fi- if ! NUMOFLINES_probed=$(cat "webs/webs.txt" 2>>"$LOGFILE" | anew ".tmp/probed_old.txt" | sed '/^$/d' | wc -l); then- printf "%b[!] Failed to count new probed webs.%b\n" "$bred" "$reset"- NUMOFLINES_probed="0"- fi- fi-- # Display results- printf "%b\n[%s] Total subdomains:%b\n\n" "$bblue" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"- notification "- ${NUMOFLINES_subs} alive" "good"-- if [[ -s "subdomains/subdomains.txt" ]]; then- if ! sort "subdomains/subdomains.txt"; then- printf "%b[!] Failed to sort subdomains.txt.%b\n" "$bred" "$reset"- fi- fi-- notification "- ${NUMOFLINES_probed} new web probed" "good"-- if [[ -s "webs/webs.txt" ]]; then- if ! sort "webs/webs.txt"; then- printf "%b[!] Failed to sort webs.txt.%b\n" "$bred" "$reset"- fi- fi-- notification "Subdomain Enumeration Finished" "good"- printf "%b[%s] Results are saved in %s/subdomains/subdomains.txt and webs/webs.txt%b\n" "$bblue" "$(date +'%Y-%m-%d %H:%M:%S')" "$domain" "$reset"- printf "%b#######################################################################%b\n\n" "$bgreen" "$reset"-- # Emit plugin event- plugins_emit after_subdomains "$domain" "$dir"-- # Persist counts for quick-rescan logic- echo "$NUMOFLINES_subs" >.tmp/subs_new_count- echo "$NUMOFLINES_probed" >.tmp/webs_new_count-- # Asset store: append new subdomains- if [[ -s .tmp/subdomains_old.txt ]]; then- comm -13 <(sort -u .tmp/subdomains_old.txt) <(sort -u subdomains/subdomains.txt) | sed '/^$/d' >.tmp/subs_new_only.txt- append_assets_from_file subdomain name .tmp/subs_new_only.txt- else- append_assets_from_file subdomain name subdomains/subdomains.txt- fi--}--function sub_passive() {-- mkdir -p .tmp subdomains-- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $SUBPASSIVE == true ]]; then- start_subfunc "${FUNCNAME[0]}" "Running: Passive Subdomain Enumeration"-- # Run subfinder and check for errors- subfinder -all -d "$domain" -max-time "$SUBFINDER_ENUM_TIMEOUT" -silent -o .tmp/subfinder_psub.txt 2>>"$LOGFILE" >/dev/null- curl -s https://ip.thc.org/sb/$domain | grep -v ";;" | anew -q .tmp/subfinder_psub.txt 2>>"$LOGFILE" >/dev/null-- # Run github-subdomains if GITHUB_TOKENS is set and file is not empty- if [[ -s $GITHUB_TOKENS ]]; then- if [[ $DEEP == true ]]; then- github-subdomains -d "$domain" -t "$GITHUB_TOKENS" -o .tmp/github_subdomains_psub.txt 2>>"$LOGFILE" >/dev/null- else- github-subdomains -d "$domain" -k -q -t "$GITHUB_TOKENS" -o .tmp/github_subdomains_psub.txt 2>>"$LOGFILE" >/dev/null- fi- fi-- # Run gitlab-subdomains if GITLAB_TOKENS is set and file is not empty- if [[ -s $GITLAB_TOKENS ]]; then- gitlab-subdomains -d "$domain" -t "$GITLAB_TOKENS" 2>>"$LOGFILE" | tee .tmp/gitlab_subdomains_psub.txt >/dev/null- fi-- # Check if INSCOPE is true and run check_inscope- if [[ $INSCOPE == true ]]; then- check_inscope .tmp/subfinder_psub.txt 2>>"$LOGFILE" >/dev/null- check_inscope .tmp/github_subdomains_psub.txt 2>>"$LOGFILE" >/dev/null- check_inscope .tmp/gitlab_subdomains_psub.txt 2>>"$LOGFILE" >/dev/null- fi-- # Combine results and count new lines- NUMOFLINES=$(find .tmp -type f -iname "*_psub.txt" -exec cat {} + | sed "s/^\*\.//" | anew .tmp/passive_subs.txt | sed '/^$/d' | wc -l)- end_subfunc "${NUMOFLINES} new subs (passive)" "${FUNCNAME[0]}"-- else- if [[ $SUBPASSIVE == false ]]; then- printf "\n%b[%s] %s skipped due to mode or configuration settings.%b\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"- else- printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s%b\n\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$called_fn_dir" "/.${FUNCNAME[0]}" "$reset"- fi- fi--}--function sub_crt() {-- mkdir -p .tmp subdomains-- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $SUBCRT == true ]]; then- start_subfunc "${FUNCNAME[0]}" "Running: Crtsh Subdomain Enumeration"-- # Run crt command and check for errors- crt -s -json -l "${CTR_LIMIT}" "$domain" 2>>"$LOGFILE" |- jq -r '.[].subdomain' 2>>"$LOGFILE" |- sed -e 's/^\*\.//' >.tmp/crtsh_subdomains.txt-- # Use anew to get new subdomains- cat .tmp/crtsh_subdomains.txt | anew -q .tmp/crtsh_subs_tmp.txt-- # If INSCOPE is true, check inscope- if [[ $INSCOPE == true ]]; then- if ! check_inscope .tmp/crtsh_subs_tmp.txt 2>>"$LOGFILE" >/dev/null; then- printf "%b[!] check_inscope command failed.%b\n" "$bred" "$reset"- return 1- fi- fi-- # Process subdomains and append new ones to .tmp/crtsh_subs.txt, count new lines- NUMOFLINES=$(sed 's/^\*\.//' .tmp/crtsh_subs_tmp.txt | sed '/^$/d' | anew .tmp/crtsh_subs.txt | wc -l)-- end_subfunc "${NUMOFLINES} new subs (cert transparency)" "${FUNCNAME[0]}"- else- if [[ $SUBCRT == false ]]; then- printf "\n%b[%s] %s skipped due to mode or defined in reconftw.cfg.%b\n" \- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"- else- printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s%b\n\n" \- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$called_fn_dir" "/.${FUNCNAME[0]}" "$reset"- fi- fi-}--function sub_active() {-- mkdir -p .tmp subdomains-- if [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; then- start_subfunc "${FUNCNAME[0]}" "Running: Active Subdomain Enumeration"-- # Combine subdomain files into subs_no_resolved.txt- if ! find .tmp -type f -iname "*_subs.txt" -exec cat {} + | anew -q .tmp/subs_no_resolved.txt; then- printf "%b[!] Failed to collect subdomains into subs_no_resolved.txt.%b\n" "$bred" "$reset"- return 1- fi-- # Delete out-of-scope domains if outOfScope_file exists- if [[ -s $outOfScope_file ]]; then- if ! deleteOutScoped "$outOfScope_file" .tmp/subs_no_resolved.txt; then- printf "%b[!] deleteOutScoped command failed.%b\n" "$bred" "$reset"- return 1- fi- fi-- if [[ $AXIOM != true ]]; then- # Update resolvers locally- if ! resolvers_update_quick_local; then- printf "%b[!] resolvers_update_quick_local command failed.%b\n" "$bred" "$reset"- return 1- fi- [[ $RESOLVER_IQ == true ]] && resolvers_optimize_local-- # Resolve subdomains using puredns- if [[ -s ".tmp/subs_no_resolved.txt" ]]; then- puredns resolve .tmp/subs_no_resolved.txt -w .tmp/subdomains_tmp.txt \- -r "$resolvers" --resolvers-trusted "$resolvers_trusted" \- -l "$PUREDNS_PUBLIC_LIMIT" --rate-limit-trusted "$PUREDNS_TRUSTED_LIMIT" \- --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" \- --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \- 2>>"$LOGFILE" >/dev/null- fi- else- # Update resolvers using axiom- if ! resolvers_update_quick_axiom; then- printf "%b[!] resolvers_update_quick_axiom command failed.%b\n" "$bred" "$reset"- return 1- fi-- # Resolve subdomains using axiom-scan- if [[ -s ".tmp/subs_no_resolved.txt" ]]; then- axiom-scan .tmp/subs_no_resolved.txt -m puredns-resolve \- -r ${AXIOM_RESOLVERS_PATH} \- --resolvers-trusted ${AXIOM_RESOLVERS_TRUSTED_PATH} \- --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" \- --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \- -o .tmp/subdomains_tmp.txt $AXIOM_EXTRA_ARGS \- 2>>"$LOGFILE" >/dev/null- fi- fi-- # Add the domain itself to the list if it resolves- echo "$domain" | dnsx -retry 3 -silent -r "$resolvers_trusted" \- 2>>"$LOGFILE" | anew -q .tmp/subdomains_tmp.txt-- # If INSCOPE is true, check inscope- if [[ $INSCOPE == true ]]; then- if ! check_inscope .tmp/subdomains_tmp.txt 2>>"$LOGFILE" >/dev/null; then- printf "%b[!] check_inscope command failed.%b\n" "$bred" "$reset"- return 1- fi- fi-- # Process subdomains and append new ones to subdomains.txt, count new lines- if ! NUMOFLINES=$(grep "\.$domain$\|^$domain$" .tmp/subdomains_tmp.txt 2>>"$LOGFILE" |- grep -E '^([a-zA-Z0-9\.\-]+\.)+[a-zA-Z]{1,}$' |- anew subdomains/subdomains.txt | sed '/^$/d' | wc -l); then- printf "%b[!] Failed to process subdomains.%b\n" "$bred" "$reset"- return 1- fi-- end_subfunc "${NUMOFLINES} subs DNS resolved from passive" "${FUNCNAME[0]}"- else- printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s%b\n\n" \- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" \- "$called_fn_dir" "/.${FUNCNAME[0]}" "$reset"- fi-}--function sub_tls() {- mkdir -p .tmp subdomains-- if [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; then- start_subfunc "${FUNCNAME[0]}" "Running: TLS Active Subdomain Enumeration"-- if [[ $DEEP == true ]]; then- if [[ $AXIOM != true ]]; then- cat subdomains/subdomains.txt | tlsx -san -cn -silent -ro -c "$TLSX_THREADS" \- -p "$TLS_PORTS" -o .tmp/subdomains_tlsx.txt 2>>"$LOGFILE" >/dev/null- else- axiom-scan subdomains/subdomains.txt -m tlsx \- -san -cn -silent -ro -c "$TLSX_THREADS" -p "$TLS_PORTS" \- -o .tmp/subdomains_tlsx.txt $AXIOM_EXTRA_ARGS 2>>"$LOGFILE" >/dev/null- fi- else- if [[ $AXIOM != true ]]; then- cat subdomains/subdomains.txt | tlsx -san -cn -silent -ro -c "$TLSX_THREADS" >.tmp/subdomains_tlsx.txt 2>>"$LOGFILE"- else- axiom-scan subdomains/subdomains.txt -m tlsx \- -san -cn -silent -ro -c "$TLSX_THREADS" \- -o .tmp/subdomains_tlsx.txt $AXIOM_EXTRA_ARGS 2>>"$LOGFILE" >/dev/null- fi- fi-- if [[ -s ".tmp/subdomains_tlsx.txt" ]]; then- grep "\.$domain$\|^$domain$" .tmp/subdomains_tlsx.txt |- grep -aEo 'https?://[^ ]+' |- sed "s/|__ //" | anew -q .tmp/subdomains_tlsx_clean.txt- fi-- if [[ $AXIOM != true ]]; then- if ! resolvers_update_quick_local; then- printf "%b[!] resolvers_update_quick_local command failed.%b\n" "$bred" "$reset"- return 1- fi- [[ $RESOLVER_IQ == true ]] && resolvers_optimize_local- if [[ -s ".tmp/subdomains_tlsx_clean.txt" ]]; then- puredns resolve .tmp/subdomains_tlsx_clean.txt -w .tmp/subdomains_tlsx_resolved.txt \- -r "$resolvers" --resolvers-trusted "$resolvers_trusted" \- -l "$PUREDNS_PUBLIC_LIMIT" --rate-limit-trusted "$PUREDNS_TRUSTED_LIMIT" \- --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \- 2>>"$LOGFILE" >/dev/null- fi- else- if ! resolvers_update_quick_axiom; then- printf "%b[!] resolvers_update_quick_axiom command failed.%b\n" "$bred" "$reset"- return 1- fi- if [[ -s ".tmp/subdomains_tlsx_clean.txt" ]]; then- axiom-scan .tmp/subdomains_tlsx_clean.txt -m puredns-resolve \- -r ${AXIOM_RESOLVERS_PATH} --resolvers-trusted ${AXIOM_RESOLVERS_TRUSTED_PATH} \- --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \- -o .tmp/subdomains_tlsx_resolved.txt $AXIOM_EXTRA_ARGS \- 2>>"$LOGFILE" >/dev/null- fi- fi-- if [[ $INSCOPE == true ]]; then- if ! check_inscope .tmp/subdomains_tlsx_resolved.txt 2>>"$LOGFILE" >/dev/null; then- printf "%b[!] check_inscope command failed.%b\n" "$bred" "$reset"- return 1- fi- fi-- touch .tmp/subdomains_tlsx_resolved.txt-- if ! NUMOFLINES=$(anew subdomains/subdomains.txt <.tmp/subdomains_tlsx_resolved.txt | sed '/^$/d' | wc -l); then- printf "%b[!] Counting new subdomains failed.%b\n" "$bred" "$reset"- return 1- fi-- end_subfunc "${NUMOFLINES} new subs (tls active enum)" "${FUNCNAME[0]}"- else- printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s%b\n\n" \- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" \- "$called_fn_dir" "/.${FUNCNAME[0]}" "$reset"- fi-}--function sub_noerror() {-- mkdir -p .tmp subdomains-- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $SUBNOERROR == true ]]; then- start_subfunc "${FUNCNAME[0]}" "Running: Checking NOERROR DNS response"-- # Check for DNSSEC black lies- random_subdomain="${RANDOM}thistotallynotexist${RANDOM}.$domain"- dns_response=$(echo "$random_subdomain" | dnsx -r "$resolvers" -rcode noerror,nxdomain -retry 3 -silent | cut -d' ' -f2)-- if [[ $dns_response == "[NXDOMAIN]" ]]; then- if ! resolvers_update_quick_local; then- printf "%b[!] Failed to update resolvers.%b\n" "$bred" "$reset"- return 1- fi-- # Determine wordlist based on DEEP setting- if [[ $DEEP == true ]]; then- wordlist="$subs_wordlist_big"- else- wordlist="$subs_wordlist"- fi-- # Run dnsx and check for errors- dnsx -d "$domain" -r "$resolvers" -silent \- -rcode noerror -w "$wordlist" \- 2>>"$LOGFILE" | cut -d' ' -f1 | anew -q .tmp/subs_noerror.txt >/dev/null-- # Check inscope if INSCOPE is true- if [[ $INSCOPE == true ]]; then- if ! check_inscope .tmp/subs_noerror.txt 2>>"$LOGFILE" >/dev/null; then- printf "%b[!] check_inscope command failed.%b\n" "$bred" "$reset"- return 1- fi- fi-- # Process subdomains and append new ones to subdomains.txt, count new lines- if ! NUMOFLINES=$(grep "\.$domain$\|^$domain$" .tmp/subs_noerror.txt 2>>"$LOGFILE" |- grep -E '^([a-zA-Z0-9\.\-]+\.)+[a-zA-Z]{1,}$' |- sed 's/^\*\.//' | anew subdomains/subdomains.txt | sed '/^$/d' | wc -l); then- printf "%b[!] Failed to process subdomains.%b\n" "$bred" "$reset"- return 1- fi-- end_subfunc "${NUMOFLINES} new subs (DNS noerror)" "${FUNCNAME[0]}"-- else- printf "\n%s[%s] Detected DNSSEC black lies, skipping this technique.%b\n" \- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"- fi-- else- if [[ $SUBNOERROR == false ]]; then- printf "\n%b[%s] %s skipped due to mode or defined in reconftw.cfg.%b\n" \- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"- else- printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s%b\n\n" \- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" \- "$called_fn_dir" "/.${FUNCNAME[0]}" "$reset"- fi- fi--}--function sub_dns() {- mkdir -p .tmp subdomains hosts-- if [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; then- start_subfunc "${FUNCNAME[0]}" "Running: DNS Subdomain Enumeration and PTR search"-- if [[ -s "subdomains/subdomains.txt" ]]; then- dnsx -r "$resolvers_trusted" -recon -silent -retry 3 -json \- -o "subdomains/subdomains_dnsregs.json" <"subdomains/subdomains.txt" 2>>"$LOGFILE" >/dev/null- fi- if [[ -s "subdomains/subdomains_dnsregs.json" ]]; then- # Extract various DNS records and process them- jq -r --arg domain "$domain" '.. | strings | select(test("\\." + $domain + "$"))' <"subdomains/subdomains_dnsregs.json" |- grep -E '^([a-zA-Z0-9][-a-zA-Z0-9]*\.)+[a-zA-Z]{2,}$' |- sort -u | anew -q .tmp/subdomains_dns.txt-- jq -r '.. | strings | select(test("^(\\d{1,3}\\.){3}\\d{1,3}$|^[0-9a-fA-F:]+$"))' <"subdomains/subdomains_dnsregs.json" |- sort -u | hakip2host | awk '{print $3}' | unfurl -u domains |- sed -e 's/^\*\.//' -e 's/\.$//' -e '/\./!d' | grep "\.$domain$" |- grep -E '^([a-zA-Z0-9][-a-zA-Z0-9]*\.)+[a-zA-Z]{2,}$' | sort -u |- anew -q .tmp/subdomains_dns.txt-- for i in $( jq -r '.. | strings | select(test("^(\\d{1,3}\\.){3}\\d{1,3}$|^[0-9a-fA-F:]+$"))' <"subdomains/subdomains_dnsregs.json" | sort -u ); do- curl -s https://ip.thc.org/$i 2>>"$LOGFILE" | grep "\.$domain$" |- grep -E '^([a-zA-Z0-9][-a-zA-Z0-9]*\.)+[a-zA-Z]{2,}$' | sort -u |- anew -q .tmp/subdomains_dns.txt- done-- jq -r 'select(.host) |"\(.host) - \((.a // [])[])", "\(.host) - \((.aaaa // [])[])"' <"subdomains/subdomains_dnsregs.json" |- grep -E ' - [0-9a-fA-F:.]+$' | sort -u | anew -q "subdomains/subdomains_ips.txt"- fi- if [[ $AXIOM != true ]]; then- if ! resolvers_update_quick_local; then- printf "%b[!] Failed to update resolvers.%b\n" "$bred" "$reset"- fi-- if [[ -s ".tmp/subdomains_dns.txt" ]]; then- puredns resolve .tmp/subdomains_dns.txt -w .tmp/subdomains_dns_resolved.txt \- -r "$resolvers" --resolvers-trusted "$resolvers_trusted" \- -l "$PUREDNS_PUBLIC_LIMIT" --rate-limit-trusted "$PUREDNS_TRUSTED_LIMIT" \- --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \- 2>>"$LOGFILE" >/dev/null- fi- else- if ! resolvers_update_quick_axiom; then- printf "%b[!] Failed to update resolvers.%b\n" "$bred" "$reset"- fi-- if [[ -s ".tmp/subdomains_dns.txt" ]]; then- axiom-scan .tmp/subdomains_dns.txt -m puredns-resolve \- -r "${AXIOM_RESOLVERS_PATH}" --resolvers-trusted "${AXIOM_RESOLVERS_TRUSTED_PATH}" \- --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \- -o .tmp/subdomains_dns_resolved.txt "$AXIOM_EXTRA_ARGS" \- 2>>"$LOGFILE" >/dev/null- fi- fi-- cut -d ' ' -f3 subdomains/subdomains_ips.txt |- grep -aEiv "^(127|10|169\.254|172\.1[6-9]|172\.2[0-9]|172\.3[0-1]|192\.168)\." |- grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b" | sort -u | anew -q hosts/ips.txt-- if [[ $INSCOPE == true ]]; then- if ! check_inscope .tmp/subdomains_dns_resolved.txt 2>>"$LOGFILE" >/dev/null; then- printf "%b[!] check_inscope command failed.%b\n" "$bred" "$reset"- fi- fi-- if ! NUMOFLINES=$(grep "\.$domain$\|^$domain$" .tmp/subdomains_dns_resolved.txt 2>>"$LOGFILE" |- grep -E '^([a-zA-Z0-9\-\.]+\.)+[a-zA-Z]{1,}$' |- anew subdomains/subdomains.txt | sed '/^$/d' | wc -l); then- printf "%b[!] Failed to count new subdomains.%b\n" "$bred" "$reset"- return 1- fi-- end_subfunc "${NUMOFLINES} new subs (dns resolution)" "${FUNCNAME[0]}"- else- printf "\n%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s%b\n\n" \- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$called_fn_dir" "/.${FUNCNAME[0]}" "$reset"- fi-}--function sub_brute() {-- mkdir -p .tmp subdomains-- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $SUBBRUTE == true ]]; then- start_subfunc "${FUNCNAME[0]}" "Running: Bruteforce Subdomain Enumeration"-- if [[ $AXIOM != true ]]; then- if ! resolvers_update_quick_local; then- printf "%b[!] Failed to update resolvers.%b\n" "$bred" "$reset"- return 1- fi-- wordlist="$subs_wordlist"- [[ $DEEP == true ]] && wordlist="$subs_wordlist_big"-- # Run puredns bruteforce- puredns bruteforce "$wordlist" "$domain" -w .tmp/subs_brute.txt -r "$resolvers" --resolvers-trusted "$resolvers_trusted" \- -l "$PUREDNS_PUBLIC_LIMIT" --rate-limit-trusted "$PUREDNS_TRUSTED_LIMIT" \- --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \- 2>>"$LOGFILE" >/dev/null-- # Resolve the subdomains- if [[ -s ".tmp/subs_brute.txt" ]]; then- puredns resolve .tmp/subs_brute.txt -w .tmp/subs_brute_valid.txt -r "$resolvers" --resolvers-trusted "$resolvers_trusted" \- -l "$PUREDNS_PUBLIC_LIMIT" --rate-limit-trusted "$PUREDNS_TRUSTED_LIMIT" \- --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \- 2>>"$LOGFILE" >/dev/null- fi-- else- if ! resolvers_update_quick_axiom; then- printf "%b[!] Failed to update resolvers on axiom.%b\n" "$bred" "$reset"- return 1- fi-- wordlist="$subs_wordlist"- [[ $DEEP == true ]] && wordlist="$subs_wordlist_big"-- # Run axiom-scan with puredns-single- axiom-scan "$wordlist" -m puredns-single "$domain" -r ${AXIOM_RESOLVERS_PATH} \- --resolvers-trusted ${AXIOM_RESOLVERS_TRUSTED_PATH} \- --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \- -o .tmp/subs_brute.txt "$AXIOM_EXTRA_ARGS" 2>>"$LOGFILE" >/dev/null-- # Resolve the subdomains using axiom-scan- if [[ -s ".tmp/subs_brute.txt" ]]; then- axiom-scan .tmp/subs_brute.txt -m puredns-resolve -r ${AXIOM_RESOLVERS_PATH} \- --resolvers-trusted ${AXIOM_RESOLVERS_TRUSTED_PATH} \- --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \- -o .tmp/subs_brute_valid.txt "$AXIOM_EXTRA_ARGS" 2>>"$LOGFILE" >/dev/null- fi- fi-- # Check inscope if INSCOPE is true- if [[ $INSCOPE == true ]]; then- if ! check_inscope .tmp/subs_brute_valid.txt 2>>"$LOGFILE" >/dev/null; then- printf "%b[!] check_inscope command failed.%b\n" "$bred" "$reset"- return 1- fi- fi-- # Process subdomains and append new ones to subdomains.txt, count new lines- if ! NUMOFLINES=$(grep "\.$domain$\|^$domain$" .tmp/subs_brute_valid.txt 2>>"$LOGFILE" |- grep -E '^([a-zA-Z0-9\.\-]+\.)+[a-zA-Z]{1,}$' |- sed 's/^\*\.//' | anew subdomains/subdomains.txt | sed '/^$/d' | wc -l); then- printf "%b[!] Failed to process subdomains.%b\n" "$bred" "$reset"- return 1- fi-- end_subfunc "${NUMOFLINES} new subs (bruteforce)" "${FUNCNAME[0]}"-- else- if [[ $SUBBRUTE == false ]]; then- printf "\n%b[%s] %s skipped due to mode or defined in reconftw.cfg.%b\n" \- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"- else- printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s%b\n\n" \- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" \- "$called_fn_dir" "/.${FUNCNAME[0]}" "$reset"- fi- fi--}--function sub_scraping() {-- # Create necessary directories- if ! mkdir -p .tmp subdomains; then- printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"- return 1- fi-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $SUBSCRAPING == true ]]; then- start_subfunc "${FUNCNAME[0]}" "Running: Source code scraping subdomain search"-- # Initialize scrap_subs.txt- if ! touch .tmp/scrap_subs.txt; then- printf "%b[!] Failed to create .tmp/scrap_subs.txt.%b\n" "$bred" "$reset"- return 1- fi-- # If in multi mode and subdomains.txt doesn't exist, create it- if [[ -n $multi ]] && [[ ! -f "$dir/subdomains/subdomains.txt" ]]; then- if ! printf "%b\n" "$domain" >"$dir/subdomains/subdomains.txt"; then- printf "%b[!] Failed to create subdomains.txt.%b\n" "$bred" "$reset"- return 1- fi- fi-- # Check if subdomains.txt exists and is not empty- if [[ -s "$dir/subdomains/subdomains.txt" ]]; then-- subdomains_count=$(wc -l <"$dir/subdomains/subdomains.txt")- if [[ $subdomains_count -le $DEEP_LIMIT ]] || [[ $DEEP == true ]]; then-- urlfinder -d $domain -all -o .tmp/url_extract_tmp.txt 2>>"$LOGFILE" >/dev/null-- if [[ -s ".tmp/url_extract_tmp.txt" ]]; then- cat .tmp/url_extract_tmp.txt | grep "$domain" |- grep -aEo 'https?://[^ ]+' |- sed "s/^\*\.//" | unfurl -u domains 2>>"$LOGFILE" | anew -q .tmp/scrap_subs.txt- fi-- if [[ $AXIOM != true ]]; then- if ! resolvers_update_quick_local; then- printf "%b[!] Failed to update resolvers locally.%b\n" "$bred" "$reset"- return 1- fi-- # Run httpx to gather web info- httpx -follow-host-redirects -status-code -threads "$HTTPX_THREADS" -rl "$HTTPX_RATELIMIT" \- -timeout "$HTTPX_TIMEOUT" -silent -retries 2 -title -web-server -tech-detect -location \- -no-color -json -o .tmp/web_full_info1.txt \- <subdomains/subdomains.txt 2>>"$LOGFILE" >/dev/null-- if [[ -s ".tmp/web_full_info1.txt" ]]; then- cat .tmp/web_full_info1.txt | jq -r 'try .url' 2>/dev/null |- grep "$domain" |- grep -aEo 'https?://[^ ]+' |- sed "s/^\*\.//" |- anew .tmp/probed_tmp_scrap.txt |- unfurl -u domains 2>>"$LOGFILE" |- anew -q .tmp/scrap_subs.txt- fi-- if [[ -s ".tmp/probed_tmp_scrap.txt" ]]; then- cat .tmp/probed_tmp_scrap.txt | csprecon -s | grep "$domain" | sed "s/^\*\.//" | sort -u |- unfurl -u domains 2>>"$LOGFILE" | anew -q .tmp/scrap_subs.txt- fi-- if [[ -s ".tmp/probed_tmp_scrap.txt" ]]; then- if [[ $DEEP == true ]]; then- timeout 3h katana -silent -list .tmp/probed_tmp_scrap.txt -jc -kf all -c "$KATANA_THREADS" -d 2 \- -fs rdn -o .tmp/katana.txt 2>>"$LOGFILE" >/dev/null- fi- fi-- else- # AXIOM mode- if ! resolvers_update_quick_axiom; then- printf "%b[!] Failed to update resolvers on axiom.%b\n" "$bred" "$reset"- return 1- fi-- axiom-scan subdomains/subdomains.txt -m httpx -follow-host-redirects -random-agent -status-code \- -threads "$HTTPX_THREADS" -rl "$HTTPX_RATELIMIT" -timeout "$HTTPX_TIMEOUT" -silent -retries 2 \- -title -web-server -tech-detect -location -no-color -json -o .tmp/web_full_info1.txt \- $AXIOM_EXTRA_ARGS 2>>"$LOGFILE" >/dev/null-- if [[ -s ".tmp/web_full_info1.txt" ]]; then- cat .tmp/web_full_info1.txt | jq -r 'try .url' 2>/dev/null |- grep "$domain" |- grep -aEo 'https?://[^ ]+' |- sed "s/^\*\.//" |- anew .tmp/probed_tmp_scrap.txt |- unfurl -u domains 2>>"$LOGFILE" |- anew -q .tmp/scrap_subs.txt- fi-- if [[ -s ".tmp/probed_tmp_scrap.txt" ]]; then- cat .tmp/probed_tmp_scrap.txt | csprecon -s | grep "$domain" | sed "s/^\*\.//" | sort -u |- unfurl -u domains 2>>"$LOGFILE" | anew -q .tmp/scrap_subs.txt- fi-- if [[ -s ".tmp/probed_tmp_scrap.txt" ]]; then- if [[ $DEEP == true ]]; then- axiom-scan .tmp/probed_tmp_scrap.txt -m katana -jc -kf all -d 2 -fs rdn \- -o .tmp/katana.txt $AXIOM_EXTRA_ARGS --max-runtime 4h 2>>"$LOGFILE" >/dev/null- fi- fi- fi-- if [[ -s ".tmp/katana.txt" ]]; then- sed_i '/^.\{2048\}./d' .tmp/katana.txt-- cat .tmp/katana.txt | unfurl -u domains 2>>"$LOGFILE" |- grep "\.$domain$" |- grep -E '^([a-zA-Z0-9\.\-]+\.)+[a-zA-Z]{1,}$' |- anew -q .tmp/scrap_subs.txt- fi-- if [[ -s ".tmp/scrap_subs.txt" ]]; then- puredns resolve .tmp/scrap_subs.txt -w .tmp/scrap_subs_resolved.txt -r "$resolvers" \- --resolvers-trusted "$resolvers_trusted" -l "$PUREDNS_PUBLIC_LIMIT" \- --rate-limit-trusted "$PUREDNS_TRUSTED_LIMIT" --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" \- --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" 2>>"$LOGFILE" >/dev/null- fi-- if [[ $INSCOPE == true ]]; then- if ! check_inscope .tmp/scrap_subs_resolved.txt 2>>"$LOGFILE" >/dev/null; then- printf "%b[!] check_inscope command failed.%b\n" "$bred" "$reset"- fi- fi-- if [[ -s ".tmp/scrap_subs_resolved.txt" ]]; then- if ! NUMOFLINES=$(cat .tmp/scrap_subs_resolved.txt 2>>"$LOGFILE" |- grep "\.$domain$\|^$domain$" |- grep -E '^([a-zA-Z0-9\.\-]+\.)+[a-zA-Z]{1,}$' |- anew subdomains/subdomains.txt |- tee .tmp/diff_scrap.txt |- sed '/^$/d' | wc -l); then- NUMOFLINES=0- fi- else- NUMOFLINES=0- fi-- if [[ -s ".tmp/diff_scrap.txt" ]]; then- httpx -follow-host-redirects -random-agent -status-code -threads "$HTTPX_THREADS" \- -rl "$HTTPX_RATELIMIT" -timeout "$HTTPX_TIMEOUT" -silent -retries 2 -title -web-server \- -tech-detect -location -no-color -json -o .tmp/web_full_info3.txt \- <.tmp/diff_scrap.txt 2>>"$LOGFILE" >/dev/null-- if [[ -s ".tmp/web_full_info3.txt" ]]; then- cat .tmp/web_full_info3.txt | jq -r 'try .url' 2>/dev/null |- grep "$domain" |- grep -aEo 'https?://[^ ]+' |- sed "s/^\*\.//" |- anew .tmp/probed_tmp_scrap.txt |- unfurl -u domains 2>>"$LOGFILE" |- anew -q .tmp/scrap_subs.txt- fi- fi-- cat .tmp/web_full_info1.txt .tmp/web_full_info2.txt .tmp/web_full_info3.txt 2>>"$LOGFILE" |- jq -s 'try .' | jq 'try unique_by(.input)' | jq 'try .[]' 2>>"$LOGFILE" >.tmp/web_full_info.txt-- end_subfunc "${NUMOFLINES} new subs (code scraping)" "${FUNCNAME[0]}"-- else- end_subfunc "Skipping Subdomains Web Scraping: Too Many Subdomains" "${FUNCNAME[0]}"- fi- fi-- else- if [[ $SUBSCRAPING == false ]]; then- printf "\n%b[%s] %s skipped due to mode or defined in reconftw.cfg.%b\n" \- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"- else- printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s%b\n\n" \- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" \- "$called_fn_dir" "/.${FUNCNAME[0]}" "$reset"- fi- fi--}--function sub_analytics() {-- # Create necessary directories- if ! mkdir -p .tmp subdomains; then- printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"- return 1- fi-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $SUBANALYTICS == true ]]; then- start_subfunc "${FUNCNAME[0]}" "Running: Analytics Subdomain Enumeration"-- if [[ -s ".tmp/probed_tmp_scrap.txt" ]]; then- # Run analyticsrelationships and check for errors- analyticsrelationships -ch <.tmp/probed_tmp_scrap.txt >>.tmp/analytics_subs_tmp.txt 2>>"$LOGFILE"-- if [[ -s ".tmp/analytics_subs_tmp.txt" ]]; then- grep "\.$domain$\|^$domain$" .tmp/analytics_subs_tmp.txt |- grep -E '^([a-zA-Z0-9\.\-]+\.)+[a-zA-Z]{1,}$' |- sed "s/|__ //" | anew -q .tmp/analytics_subs_clean.txt-- if [[ $AXIOM != true ]]; then- if ! resolvers_update_quick_local; then- printf "%b[!] Failed to update resolvers locally.%b\n" "$bred" "$reset"- return 1- fi-- if [[ -s ".tmp/analytics_subs_clean.txt" ]]; then- puredns resolve .tmp/analytics_subs_clean.txt -w .tmp/analytics_subs_resolved.txt \- -r "$resolvers" --resolvers-trusted "$resolvers_trusted" \- -l "$PUREDNS_PUBLIC_LIMIT" --rate-limit-trusted "$PUREDNS_TRUSTED_LIMIT" \- --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \- 2>>"$LOGFILE" >/dev/null- fi- else- if ! resolvers_update_quick_axiom; then- printf "%b[!] Failed to update resolvers on Axiom.%b\n" "$bred" "$reset"- return 1- fi-- if [[ -s ".tmp/analytics_subs_clean.txt" ]]; then- axiom-scan .tmp/analytics_subs_clean.txt -m puredns-resolve \- -r ${AXIOM_RESOLVERS_PATH} --resolvers-trusted ${AXIOM_RESOLVERS_TRUSTED_PATH} \- --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \- -o .tmp/analytics_subs_resolved.txt $AXIOM_EXTRA_ARGS \- 2>>"$LOGFILE" >/dev/null- fi- fi- fi- fi-- if [[ $INSCOPE == true ]]; then- if ! check_inscope .tmp/analytics_subs_resolved.txt 2>>"$LOGFILE" >/dev/null; then- printf "%b[!] check_inscope command failed.%b\n" "$bred" "$reset"- fi- fi-- if ! NUMOFLINES=$(cat .tmp/analytics_subs_resolved.txt 2>/dev/null | anew subdomains/subdomains.txt 2>/dev/null | sed '/^$/d' | wc -l); then- NUMOFLINES=0- fi-- end_subfunc "${NUMOFLINES} new subs (analytics relationship)" "${FUNCNAME[0]}"-- else- if [[ $SUBANALYTICS == false ]]; then- printf "\n%b[%s] %s skipped due to mode or defined in reconftw.cfg.%b\n" \- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"- else- printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s%b\n\n" \- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$called_fn_dir" "/.${FUNCNAME[0]}" "$reset"- fi- fi-}--function sub_permut() {-- mkdir -p .tmp subdomains-- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $SUBPERMUTE == true ]]; then- start_subfunc "${FUNCNAME[0]}" "Running: Permutations Subdomain Enumeration"-- # If in multi mode and subdomains.txt doesn't exist, create it with the domain- if [[ -n $multi ]] && [[ ! -f "$dir/subdomains/subdomains.txt" ]]; then- echo "$domain" >"$dir/subdomains/subdomains.txt"- fi-- # Determine the number of subdomains- subdomain_count=$(wc -l <subdomains/subdomains.txt)-- # Check if DEEP mode is enabled or subdomains are within DEEP_LIMIT- if [[ $DEEP == true ]] || [[ $subdomain_count -le $DEEP_LIMIT ]]; then-- # Select the permutations tool- if [[ $PERMUTATIONS_OPTION == "gotator" ]]; then- if [[ -s "subdomains/subdomains.txt" ]]; then- gotator -sub subdomains/subdomains.txt -perm "${tools}/permutations_list.txt" $GOTATOR_FLAGS \- -silent 2>>"$LOGFILE" | head -c "$PERMUTATIONS_LIMIT" >.tmp/gotator1.txt- fi- else- if [[ -s "subdomains/subdomains.txt" ]]; then- ripgen -d subdomains/subdomains.txt -w "${tools}/permutations_list.txt" \- 2>>"$LOGFILE" | head -c "$PERMUTATIONS_LIMIT" >.tmp/gotator1.txt- fi- fi-- elif [[ "$(wc -l <.tmp/subs_no_resolved.txt)" -le $DEEP_LIMIT2 ]]; then-- if [[ $PERMUTATIONS_OPTION == "gotator" ]]; then- if [[ -s ".tmp/subs_no_resolved.txt" ]]; then- gotator -sub .tmp/subs_no_resolved.txt -perm "${tools}/permutations_list.txt" $GOTATOR_FLAGS \- -silent 2>>"$LOGFILE" | head -c "$PERMUTATIONS_LIMIT" >.tmp/gotator1.txt- fi- else- if [[ -s ".tmp/subs_no_resolved.txt" ]]; then- ripgen -d .tmp/subs_no_resolved.txt -w "${tools}/permutations_list.txt" \- 2>>"$LOGFILE" | head -c "$PERMUTATIONS_LIMIT" >.tmp/gotator1.txt- fi- fi-- else- end_subfunc "Skipping Permutations: Too Many Subdomains" "${FUNCNAME[0]}"- return 0- fi-- # Resolve the permutations- if [[ $AXIOM != true ]]; then- if ! resolvers_update_quick_local; then- printf "%b[!] Failed to update resolvers.%b\n" "$bred" "$reset"- return 1- fi- if [[ -s ".tmp/gotator1.txt" ]]; then- puredns resolve .tmp/gotator1.txt -w .tmp/permute1.txt -r "$resolvers" --resolvers-trusted "$resolvers_trusted" \- -l "$PUREDNS_PUBLIC_LIMIT" --rate-limit-trusted "$PUREDNS_TRUSTED_LIMIT" \- --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \- 2>>"$LOGFILE" >/dev/null- fi- else- if ! resolvers_update_quick_axiom; then- printf "%b[!] Failed to update resolvers on axiom.%b\n" "$bred" "$reset"- return 1- fi- if [[ -s ".tmp/gotator1.txt" ]]; then- axiom-scan .tmp/gotator1.txt -m puredns-resolve -r ${AXIOM_RESOLVERS_PATH} \- --resolvers-trusted ${AXIOM_RESOLVERS_TRUSTED_PATH} \- --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \- -o .tmp/permute1.txt $AXIOM_EXTRA_ARGS 2>>"$LOGFILE" >/dev/null- fi- fi-- # Generate second round of permutations- if [[ $PERMUTATIONS_OPTION == "gotator" ]]; then- if [[ -s ".tmp/permute1.txt" ]]; then- gotator -sub .tmp/permute1.txt -perm "${tools}/permutations_list.txt" \- $GOTATOR_FLAGS -silent 2>>"$LOGFILE" | head -c "$PERMUTATIONS_LIMIT" >.tmp/gotator2.txt- fi- else- if [[ -s ".tmp/permute1.txt" ]]; then- ripgen -d .tmp/permute1.txt -w "${tools}/permutations_list.txt" \- 2>>"$LOGFILE" | head -c "$PERMUTATIONS_LIMIT" >.tmp/gotator2.txt- fi- fi-- # Resolve the second round of permutations- if [[ $AXIOM != true ]]; then- if [[ -s ".tmp/gotator2.txt" ]]; then- puredns resolve .tmp/gotator2.txt -w .tmp/permute2.txt -r "$resolvers" --resolvers-trusted "$resolvers_trusted" \- -l "$PUREDNS_PUBLIC_LIMIT" --rate-limit-trusted "$PUREDNS_TRUSTED_LIMIT" \- --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \- 2>>"$LOGFILE" >/dev/null- fi- else- if [[ -s ".tmp/gotator2.txt" ]]; then- axiom-scan .tmp/gotator2.txt -m puredns-resolve -r ${AXIOM_RESOLVERS_PATH} \- --resolvers-trusted ${AXIOM_RESOLVERS_TRUSTED_PATH} \- --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \- -o .tmp/permute2.txt $AXIOM_EXTRA_ARGS 2>>"$LOGFILE" >/dev/null- fi- fi-- # Combine results- if [[ -s ".tmp/permute1.txt" ]] || [[ -s ".tmp/permute2.txt" ]]; then- cat .tmp/permute1.txt .tmp/permute2.txt 2>>"$LOGFILE" | anew -q .tmp/permute_subs.txt-- # Remove out-of-scope domains if applicable- if [[ -s $outOfScope_file ]]; then- if ! deleteOutScoped "$outOfScope_file" .tmp/permute_subs.txt; then- printf "%b[!] deleteOutScoped command failed.%b\n" "$bred" "$reset"- fi- fi-- # Check inscope if INSCOPE is true- if [[ $INSCOPE == true ]]; then- if ! check_inscope .tmp/permute_subs.txt 2>>"$LOGFILE" >/dev/null; then- printf "%b[!] check_inscope command failed.%b\n" "$bred" "$reset"- fi- fi-- # Process subdomains and append new ones to subdomains.txt, count new lines- if ! NUMOFLINES=$(grep "\.$domain$\|^$domain$" .tmp/permute_subs.txt 2>>"$LOGFILE" |- grep -E '^([a-zA-Z0-9\.\-]+\.)+[a-zA-Z]{1,}$' |- anew subdomains/subdomains.txt | sed '/^$/d' | wc -l); then- printf "%b[!] Failed to process subdomains.%b\n" "$bred" "$reset"- return 1- fi- else- NUMOFLINES=0- fi-- end_subfunc "${NUMOFLINES} new subs (permutations)" "${FUNCNAME[0]}"-- else- if [[ $SUBPERMUTE == false ]]; then- printf "\n%b[%s] %s skipped due to mode or defined in reconftw.cfg.%b\n" \- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"- else- printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s%b\n\n" \- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" \- "$called_fn_dir" "/.${FUNCNAME[0]}" "$reset"- fi- fi--}--function sub_regex_permut() {-- # Create necessary directories- if ! mkdir -p .tmp subdomains; then- printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"- return 1- fi-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $SUBREGEXPERMUTE == true ]]; then- start_subfunc "${FUNCNAME[0]}" "Running: Permutations by regex analysis"-- # Change to the regulator directory- if ! pushd "${tools}/regulator" >/dev/null; then- printf "%b[!] Failed to change directory to %s.%b\n" "$bred" "${tools}/regulator" "$reset"- return 1- fi-- # If in multi mode and subdomains.txt doesn't exist, create it- if [[ -n $multi ]] && [[ ! -f "$dir/subdomains/subdomains.txt" ]]; then- printf "%b\n" "$domain" >"$dir/subdomains/subdomains.txt"- fi-- # Run the main.py script- "${tools}/regulator/venv/bin/python3" main.py -t "$domain" -f "${dir}/subdomains/subdomains.txt" -o "${dir}/.tmp/${domain}.brute" \- 2>>"$LOGFILE" >/dev/null-- # Return to the previous directory- if ! popd >/dev/null; then- printf "%b[!] Failed to return to previous directory.%b\n" "$bred" "$reset"- return 1- fi-- # Resolve the generated domains- if [[ $AXIOM != true ]]; then- if ! resolvers_update_quick_local; then- printf "%b[!] Failed to update resolvers locally.%b\n" "$bred" "$reset"- return 1- fi-- if [[ -s ".tmp/${domain}.brute" ]]; then- puredns resolve ".tmp/${domain}.brute" -w .tmp/regulator.txt -r "$resolvers" --resolvers-trusted "$resolvers_trusted" \- -l "$PUREDNS_PUBLIC_LIMIT" --rate-limit-trusted "$PUREDNS_TRUSTED_LIMIT" \- --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \- 2>>"$LOGFILE" >/dev/null- fi- else- if ! resolvers_update_quick_axiom; then- printf "%b[!] Failed to update resolvers on Axiom.%b\n" "$bred" "$reset"- return 1- fi-- if [[ -s ".tmp/${domain}.brute" ]]; then- axiom-scan ".tmp/${domain}.brute" -m puredns-resolve \- -r ${AXIOM_RESOLVERS_PATH} --resolvers-trusted ${AXIOM_RESOLVERS_TRUSTED_PATH} \- --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \- -o .tmp/regulator.txt $AXIOM_EXTRA_ARGS \- 2>>"$LOGFILE" >/dev/null- fi- fi-- # Process the resolved domains- if [[ -s ".tmp/regulator.txt" ]]; then- if [[ -s $outOfScope_file ]]; then- if ! deleteOutScoped "$outOfScope_file" .tmp/regulator.txt; then- printf "%b[!] deleteOutScoped command failed.%b\n" "$bred" "$reset"- fi- fi-- if [[ $INSCOPE == true ]]; then- if ! check_inscope .tmp/regulator.txt 2>>"$LOGFILE" >/dev/null; then- printf "%b[!] check_inscope command failed.%b\n" "$bred" "$reset"- fi- fi-- if ! NUMOFLINES=$(grep "\.$domain$\|^$domain$" .tmp/regulator.txt 2>>"$LOGFILE" |- grep -E '^([a-zA-Z0-9\.\-]+\.)+[a-zA-Z]{1,}$' |- anew subdomains/subdomains.txt |- sed '/^$/d' |- wc -l); then- NUMOFLINES=0- fi- else- NUMOFLINES=0- fi-- end_subfunc "${NUMOFLINES} new subs (permutations by regex)" "${FUNCNAME[0]}"-- else- if [[ $SUBREGEXPERMUTE == false ]]; then- printf "\n%b[%s] %s skipped due to mode or defined in reconftw.cfg.%b\n" \- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"- else- printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s%b\n\n" \- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$called_fn_dir" "/.${FUNCNAME[0]}" "$reset"- fi- fi--}--function sub_ia_permut() {-- # Create necessary directories- if ! mkdir -p .tmp subdomains; then- printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"- return 1- fi-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $SUBIAPERMUTE == true ]]; then- start_subfunc "${FUNCNAME[0]}" "Running: Permutations by AI analysis"-- subwiz -i subdomains/subdomains.txt --no-resolve -o .tmp/subwiz.txt 2>>"$LOGFILE" >/dev/null-- # Resolve the generated domains- if [[ $AXIOM != true ]]; then- if ! resolvers_update_quick_local; then- printf "%b[!] Failed to update resolvers locally.%b\n" "$bred" "$reset"- return 1- fi-- if [[ -s ".tmp/subwiz.txt" ]]; then- puredns resolve ".tmp/subwiz.txt" -w .tmp/subwiz_resolved.txt -r "$resolvers" --resolvers-trusted "$resolvers_trusted" \- -l "$PUREDNS_PUBLIC_LIMIT" --rate-limit-trusted "$PUREDNS_TRUSTED_LIMIT" \- --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \- 2>>"$LOGFILE" >/dev/null- fi- else- if ! resolvers_update_quick_axiom; then- printf "%b[!] Failed to update resolvers on Axiom.%b\n" "$bred" "$reset"- return 1- fi-- if [[ -s ".tmp/subwiz.txt" ]]; then- axiom-scan ".tmp/subwiz.txt" -m puredns-resolve \- -r ${AXIOM_RESOLVERS_PATH} --resolvers-trusted ${AXIOM_RESOLVERS_TRUSTED_PATH} \- --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \- -o .tmp/subwiz_resolved.txt $AXIOM_EXTRA_ARGS \- 2>>"$LOGFILE" >/dev/null- fi- fi-- # Process the resolved domains- if [[ -s ".tmp/subwiz_resolved.txt" ]]; then- if [[ -s $outOfScope_file ]]; then- if ! deleteOutScoped "$outOfScope_file" .tmp/subwiz_resolved.txt; then- printf "%b[!] deleteOutScoped command failed.%b\n" "$bred" "$reset"- fi- fi-- if [[ $INSCOPE == true ]]; then- if ! check_inscope .tmp/subwiz_resolved.txt 2>>"$LOGFILE" >/dev/null; then- printf "%b[!] check_inscope command failed.%b\n" "$bred" "$reset"- fi- fi-- if ! NUMOFLINES=$(grep "\.$domain$\|^$domain$" .tmp/subwiz_resolved.txt 2>>"$LOGFILE" |- grep -E '^([a-zA-Z0-9\.\-]+\.)+[a-zA-Z]{1,}$' |- anew subdomains/subdomains.txt |- sed '/^$/d' |- wc -l); then- NUMOFLINES=0- fi- else- NUMOFLINES=0- fi-- end_subfunc "${NUMOFLINES} new subs (permutations by IA)" "${FUNCNAME[0]}"-- else- if [[ $SUBIAPERMUTE == false ]]; then- printf "\n%b[%s] %s skipped due to mode or defined in reconftw.cfg.%b\n" \- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"- else- printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s%b\n\n" \- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$called_fn_dir" "/.${FUNCNAME[0]}" "$reset"- fi- fi--}--function sub_recursive_passive() {-- # Create necessary directories- if ! mkdir -p .tmp subdomains; then- printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"- return 1- fi-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $SUB_RECURSIVE_PASSIVE == true ]] && [[ -s "subdomains/subdomains.txt" ]]; then- start_subfunc "${FUNCNAME[0]}" "Running: Subdomains recursive search passive"-- # If in multi mode and subdomains.txt doesn't exist, create it with the domain- if [[ -n $multi ]] && [[ ! -f "$dir/subdomains/subdomains.txt" ]]; then- printf "%b\n" "$domain" >"$dir/subdomains/subdomains.txt"- fi-- # Passive recursive- if [[ -s "subdomains/subdomains.txt" ]]; then- dsieve -if subdomains/subdomains.txt -f 3 -top "$DEEP_RECURSIVE_PASSIVE" >.tmp/subdomains_recurs_top.txt- fi-- if [[ $AXIOM != true ]]; then- if ! resolvers_update_quick_local; then- printf "%b[!] Failed to update resolvers locally.%b\n" "$bred" "$reset"- return 1- fi-- if [[ -s ".tmp/subdomains_recurs_top.txt" ]]; then- subfinder -all -dL .tmp/subdomains_recurs_top.txt -max-time "${SUBFINDER_ENUM_TIMEOUT}" \- -silent -o .tmp/passive_recursive_tmp.txt 2>>"$LOGFILE"- else- return 1- fi-- if [[ -s ".tmp/passive_recursive_tmp.txt" ]]; then- cat .tmp/passive_recursive_tmp.txt | anew -q .tmp/passive_recursive.txt- fi-- if [[ -s ".tmp/passive_recursive.txt" ]]; then- puredns resolve .tmp/passive_recursive.txt -w .tmp/passive_recurs_tmp.txt -r "$resolvers" --resolvers-trusted "$resolvers_trusted" \- -l "$PUREDNS_PUBLIC_LIMIT" --rate-limit-trusted "$PUREDNS_TRUSTED_LIMIT" \- --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \- 2>>"$LOGFILE" >/dev/null- fi-- else- if ! resolvers_update_quick_axiom; then- printf "%b[!] Failed to update resolvers on Axiom.%b\n" "$bred" "$reset"- return 1- fi-- if [[ -s ".tmp/subdomains_recurs_top.txt" ]]; then- axiom-scan .tmp/subdomains_recurs_top.txt -m subfinder -all -o .tmp/subfinder_prec.txt "$AXIOM_EXTRA_ARGS" 2>>"$LOGFILE" >/dev/null- else- return 1- fi-- if [[ -s ".tmp/subfinder_prec.txt" ]]; then- cat .tmp/subfinder_prec.txt | anew -q .tmp/passive_recursive.txt- fi-- if [[ -s ".tmp/passive_recursive.txt" ]]; then- axiom-scan .tmp/passive_recursive.txt -m puredns-resolve \- -r ${AXIOM_RESOLVERS_PATH} --resolvers-trusted ${AXIOM_RESOLVERS_TRUSTED_PATH} \- --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \- -o .tmp/passive_recurs_tmp.txt "$AXIOM_EXTRA_ARGS" 2>>"$LOGFILE" >/dev/null- fi- fi-- if [[ $INSCOPE == true ]]; then- if ! check_inscope .tmp/passive_recurs_tmp.txt 2>>"$LOGFILE" >/dev/null; then- printf "%b[!] check_inscope command failed.%b\n" "$bred" "$reset"- fi- fi-- if [[ -s ".tmp/passive_recurs_tmp.txt" ]]; then- if ! NUMOFLINES=$(grep "\.$domain$\|^$domain$" .tmp/passive_recurs_tmp.txt 2>>"$LOGFILE" |- grep -E '^([a-zA-Z0-9\.\-]+\.)+[a-zA-Z]{1,}$' |- sed '/^$/d' |- anew subdomains/subdomains.txt |- wc -l); then- NUMOFLINES=0- fi- else- NUMOFLINES=0- fi-- end_subfunc "${NUMOFLINES} new subs (recursive)" "${FUNCNAME[0]}"-- else- if [[ $SUB_RECURSIVE_PASSIVE == false ]]; then- printf "\n%b[%s] %s skipped due to mode or defined in reconftw.cfg.%b\n" \- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"- elif [[ ! -s "subdomains/subdomains.txt" ]]; then- printf "\n%s[%s] No subdomains to process.%b\n" \- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"- else- printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s%b\n\n" \- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$called_fn_dir" "/.${FUNCNAME[0]}" "$reset"- fi- fi--}--function sub_recursive_brute() {- # Create necessary directories- if ! mkdir -p .tmp subdomains; then- printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"- return 1- fi-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $SUB_RECURSIVE_BRUTE == true ]] && [[ -s "subdomains/subdomains.txt" ]]; then- start_subfunc "${FUNCNAME[0]}" "Running: Subdomains recursive search active"-- # If in multi mode and subdomains.txt doesn't exist, create it with the domain- if [[ -n $multi ]] && [[ ! -f "$dir/subdomains/subdomains.txt" ]]; then- echo "$domain" >"$dir/subdomains/subdomains.txt"- fi-- # Check the number of subdomains- subdomain_count=$(wc -l <subdomains/subdomains.txt)- if [[ $subdomain_count -le $DEEP_LIMIT ]]; then- # Generate top subdomains if not already done- if [[ ! -s ".tmp/subdomains_recurs_top.txt" ]]; then- dsieve -if subdomains/subdomains.txt -f 3 -top "$DEEP_RECURSIVE_PASSIVE" >.tmp/subdomains_recurs_top.txt- fi-- for subdomain_top in $(cat .tmp/subdomains_recurs_top.txt); do- if [[ $AXIOM != true ]]; then- if ! resolvers_update_quick_local; then- printf "%b[!] Failed to update resolvers locally.%b\n" "$bred" "$reset"- return 1- fi- puredns bruteforce "$subs_wordlist" "$subdomain_top" -r "$resolvers" --resolvers-trusted "$resolvers_trusted" \- -l "$PUREDNS_PUBLIC_LIMIT" --rate-limit-trusted "$PUREDNS_TRUSTED_LIMIT" \- --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \- -w .tmp/brute_recursive_result_part.txt 2>>"$LOGFILE" >/dev/null- cat .tmp/brute_recursive_result_part.txt | anew -q .tmp/brute_recursive.txt- else- if ! resolvers_update_quick_axiom; then- printf "%b[!] Failed to update resolvers on axiom.%b\n" "$bred" "$reset"- return 1- fi- axiom-scan "$subs_wordlist" -m puredns-single "$subdomain_top" \- -r ${AXIOM_RESOLVERS_PATH} --resolvers-trusted ${AXIOM_RESOLVERS_TRUSTED_PATH} \- --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \- -o .tmp/brute_recursive_result_part.txt $AXIOM_EXTRA_ARGS \- 2>>"$LOGFILE" >/dev/null- cat .tmp/brute_recursive_result_part.txt | anew -q .tmp/brute_recursive.txt- fi- done-- # Generate permutations- if [[ $PERMUTATIONS_OPTION == "gotator" ]]; then- if [[ -s ".tmp/brute_recursive.txt" ]]; then- gotator -sub .tmp/brute_recursive.txt -perm "${tools}/permutations_list.txt" $GOTATOR_FLAGS -silent \- 2>>"$LOGFILE" | head -c "$PERMUTATIONS_LIMIT" >.tmp/gotator1_recursive.txt- fi- else- if [[ -s ".tmp/brute_recursive.txt" ]]; then- ripgen -d .tmp/brute_recursive.txt -w "${tools}/permutations_list.txt" \- 2>>"$LOGFILE" | head -c "$PERMUTATIONS_LIMIT" >.tmp/gotator1_recursive.txt- fi- fi-- # Resolve permutations- if [[ $AXIOM != true ]]; then- if [[ -s ".tmp/gotator1_recursive.txt" ]]; then- puredns resolve .tmp/gotator1_recursive.txt -w .tmp/permute1_recursive.txt \- -r "$resolvers" --resolvers-trusted "$resolvers_trusted" \- -l "$PUREDNS_PUBLIC_LIMIT" --rate-limit-trusted "$PUREDNS_TRUSTED_LIMIT" \- --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \- 2>>"$LOGFILE" >/dev/null- fi- else- if [[ -s ".tmp/gotator1_recursive.txt" ]]; then- axiom-scan .tmp/gotator1_recursive.txt -m puredns-resolve \- -r ${AXIOM_RESOLVERS_PATH} --resolvers-trusted ${AXIOM_RESOLVERS_TRUSTED_PATH} \- --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \- -o .tmp/permute1_recursive.txt $AXIOM_EXTRA_ARGS \- 2>>"$LOGFILE" >/dev/null- fi- fi-- # Second round of permutations- if [[ $PERMUTATIONS_OPTION == "gotator" ]]; then- if [[ -s ".tmp/permute1_recursive.txt" ]]; then- gotator -sub .tmp/permute1_recursive.txt -perm "${tools}/permutations_list.txt" $GOTATOR_FLAGS -silent \- 2>>"$LOGFILE" | head -c "$PERMUTATIONS_LIMIT" >.tmp/gotator2_recursive.txt- fi- else- if [[ -s ".tmp/permute1_recursive.txt" ]]; then- ripgen -d .tmp/permute1_recursive.txt -w "${tools}/permutations_list.txt" \- 2>>"$LOGFILE" | head -c "$PERMUTATIONS_LIMIT" >.tmp/gotator2_recursive.txt- fi- fi-- # Resolve second round of permutations- if [[ $AXIOM != true ]]; then- if [[ -s ".tmp/gotator2_recursive.txt" ]]; then- puredns resolve .tmp/gotator2_recursive.txt -w .tmp/permute2_recursive.txt \- -r "$resolvers" --resolvers-trusted "$resolvers_trusted" \- -l "$PUREDNS_PUBLIC_LIMIT" --rate-limit-trusted "$PUREDNS_TRUSTED_LIMIT" \- --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \- 2>>"$LOGFILE" >/dev/null- fi- else- if [[ -s ".tmp/gotator2_recursive.txt" ]]; then- axiom-scan .tmp/gotator2_recursive.txt -m puredns-resolve \- -r ${AXIOM_RESOLVERS_PATH} --resolvers-trusted ${AXIOM_RESOLVERS_TRUSTED_PATH} \- --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \- -o .tmp/permute2_recursive.txt $AXIOM_EXTRA_ARGS \- 2>>"$LOGFILE" >/dev/null- fi- fi-- # Combine permutations- if [[ -s ".tmp/permute1_recursive.txt" ]] || [[ -s ".tmp/permute2_recursive.txt" ]]; then- cat .tmp/permute1_recursive.txt .tmp/permute2_recursive.txt 2>>"$LOGFILE" | anew -q .tmp/permute_recursive.txt- fi- else- end_subfunc "Skipping recursive search: Too many subdomains" "${FUNCNAME[0]}"- return 0- fi-- # Check inscope if applicable- if [[ $INSCOPE == true ]]; then- if [[ -s ".tmp/permute_recursive.txt" ]]; then- if ! check_inscope .tmp/permute_recursive.txt 2>>"$LOGFILE" >/dev/null; then- printf "%b[!] check_inscope command failed on permute_recursive.txt.%b\n" "$bred" "$reset"- fi- fi- if [[ -s ".tmp/brute_recursive.txt" ]]; then- if ! check_inscope .tmp/brute_recursive.txt 2>>"$LOGFILE" >/dev/null; then- printf "%b[!] check_inscope command failed on brute_recursive.txt.%b\n" "$bred" "$reset"- fi- fi- fi-- # Combine results for final validation- if [[ -s ".tmp/permute_recursive.txt" ]] || [[ -s ".tmp/brute_recursive.txt" ]]; then- if ! cat .tmp/permute_recursive.txt .tmp/brute_recursive.txt 2>>"$LOGFILE" | anew -q .tmp/brute_perm_recursive.txt; then- printf "%b[!] Failed to combine final results.%b\n" "$bred" "$reset"- return 1- fi- fi-- # Final resolve- if [[ $AXIOM != true ]]; then- if [[ -s ".tmp/brute_perm_recursive.txt" ]]; then- puredns resolve .tmp/brute_perm_recursive.txt -w .tmp/brute_perm_recursive_final.txt \- -r "$resolvers" --resolvers-trusted "$resolvers_trusted" \- -l "$PUREDNS_PUBLIC_LIMIT" --rate-limit-trusted "$PUREDNS_TRUSTED_LIMIT" \- --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \- 2>>"$LOGFILE" >/dev/null- fi- else- if [[ -s ".tmp/brute_perm_recursive.txt" ]]; then- axiom-scan .tmp/brute_perm_recursive.txt -m puredns-resolve \- -r ${AXIOM_RESOLVERS_PATH} --resolvers-trusted ${AXIOM_RESOLVERS_TRUSTED_PATH} \- --wildcard-tests "$PUREDNS_WILDCARDTEST_LIMIT" --wildcard-batch "$PUREDNS_WILDCARDBATCH_LIMIT" \- -o .tmp/brute_perm_recursive_final.txt $AXIOM_EXTRA_ARGS \- 2>>"$LOGFILE" >/dev/null- fi- fi-- # Process final results- if [[ -s ".tmp/brute_perm_recursive_final.txt" ]]; then- if ! NUMOFLINES=$(grep "\.$domain$\|^$domain$" .tmp/brute_perm_recursive_final.txt 2>>"$LOGFILE" |- grep -E '^([a-zA-Z0-9\.\-]+\.)+[a-zA-Z]{1,}$' |- sed '/^$/d' |- anew subdomains/subdomains.txt |- wc -l); then- NUMOFLINES=0- fi- else- NUMOFLINES=0- fi-- end_subfunc "${NUMOFLINES} new subs (recursive active)" "${FUNCNAME[0]}"-- else- if [[ $SUB_RECURSIVE_BRUTE == false ]]; then- printf "\n%b[%s] %s skipped due to mode or defined in reconftw.cfg.%b\n" \- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"- elif [[ ! -s "subdomains/subdomains.txt" ]]; then- printf "\n%s[%s] No subdomains to process.%b\n" \- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"- else- printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s%b\n\n" \- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" \- "$called_fn_dir" "/.${FUNCNAME[0]}" "$reset"- fi- fi-}--function subtakeover() {-- # Create necessary directories- if ! mkdir -p .tmp webs subdomains; then- printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"- return 1- fi-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $SUBTAKEOVER == true ]]; then- start_func "${FUNCNAME[0]}" "Looking for possible subdomain and DNS takeover"-- # Initialize takeover file- if ! touch .tmp/tko.txt; then- printf "%b[!] Failed to create .tmp/tko.txt.%b\n" "$bred" "$reset"- return 1- fi-- # Combine webs.txt and webs_uncommon_ports.txt if webs_all.txt doesn't exist- if [[ ! -s "webs/webs_all.txt" ]]; then- cat webs/webs.txt webs/webs_uncommon_ports.txt 2>/dev/null | anew -q webs/webs_all.txt- fi-- #cent update -p ${NUCLEI_TEMPLATES_PATH} &>/dev/null- if [[ $AXIOM != true ]]; then- maybe_update_nuclei- cat subdomains/subdomains.txt webs/webs_all.txt 2>/dev/null | nuclei -silent -nh -tags takeover \- -severity info,low,medium,high,critical -retries 3 -rl "$NUCLEI_RATELIMIT" \- -t "${NUCLEI_TEMPLATES_PATH}" -j -o .tmp/tko_json.txt 2>>"$LOGFILE" >/dev/null- else- cat subdomains/subdomains.txt webs/webs_all.txt 2>>"$LOGFILE" | sed '/^$/d' | anew -q .tmp/webs_subs.txt- if [[ -s ".tmp/webs_subs.txt" ]]; then- axiom-scan .tmp/webs_subs.txt -m nuclei --nuclei-templates "${NUCLEI_TEMPLATES_PATH}" \- -tags takeover -nh -severity info,low,medium,high,critical -retries 3 -rl "$NUCLEI_RATELIMIT" \- -t "${NUCLEI_TEMPLATES_PATH}" -j -o .tmp/tko_json.txt $AXIOM_EXTRA_ARGS 2>>"$LOGFILE" >/dev/null- fi- fi-- # Convert JSON to text- if [[ -s ".tmp/tko_json.txt" ]]; then- jq -r '["[" + .["template-id"] + (if .["matcher-name"] != null then ":" + .["matcher-name"] else "" end) + "] [" + .["type"] + "] [" + .info.severity + "] " + (.["matched-at"] // .host) + (if .["extracted-results"] != null then " " + (.["extracted-results"] | @json) else "" end)] | .[]' .tmp/tko_json.txt >.tmp/tko.txt- fi-- # DNS Takeover- cat .tmp/subs_no_resolved.txt .tmp/subdomains_dns.txt .tmp/scrap_subs.txt \- .tmp/analytics_subs_clean.txt .tmp/passive_recursive.txt 2>/dev/null | anew -q .tmp/subs_dns_tko.txt-- if [[ -s ".tmp/subs_dns_tko.txt" ]]; then- cat .tmp/subs_dns_tko.txt 2>/dev/null | dnstake -c "$DNSTAKE_THREADS" -s 2>>"$LOGFILE" |- sed '/^$/d' | anew -q .tmp/tko.txt- fi-- # Remove empty lines from tko.txt- sed_i '/^$/d' .tmp/tko.txt-- # Count new takeover entries- if ! NUMOFLINES=$(cat .tmp/tko.txt 2>>"$LOGFILE" | anew webs/takeover.txt | sed '/^$/d' | wc -l); then- printf "%b[!] Failed to count takeover entries.%b\n" "$bred" "$reset"- NUMOFLINES=0- fi-- if [[ $NUMOFLINES -gt 0 ]]; then- notification "${NUMOFLINES} new possible takeovers found" info- fi-- if [[ $FARADAY == true ]]; then- if ! faraday-cli status 2>>"$LOGFILE" >/dev/null; then- printf "%b[!] Faraday server is not running. Skipping Faraday integration.%b\n" "$bred" "$reset"- else- if [[ -s ".tmp/tko_json.txt" ]]; then- faraday-cli tool report -w $FARADAY_WORKSPACE --plugin-id nuclei .tmp/tko_json.txt 2>>"$LOGFILE" >/dev/null- fi- fi- fi-- end_func "Results are saved in $domain/webs/takeover.txt" "${FUNCNAME[0]}"-- else- if [[ $SUBTAKEOVER == false ]]; then- printf "\n%b[%s] %s skipped due to mode or defined in reconftw.cfg.%b\n" \- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"- else- printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s %b\n\n" \- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$called_fn_dir" ".${FUNCNAME[0]}" "$reset"- fi- fi--}--function zonetransfer() {-- # Create necessary directories- if ! mkdir -p subdomains; then- printf "%b[!] Failed to create subdomains directory.%b\n" "$bred" "$reset"- return 1- fi-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $ZONETRANSFER == true ]] && ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then- start_func "${FUNCNAME[0]}" "Zone transfer check"-- # Initialize output file- if ! : >"subdomains/zonetransfer.txt"; then- printf "%b[!] Failed to create zonetransfer.txt.%b\n" "$bred" "$reset"- return 1- fi-- # Perform zone transfer check- for ns in $(dig +short ns "$domain" 2>/dev/null); do- dig axfr "${domain}" @"$ns" 2>>"$LOGFILE" | tee -a "subdomains/zonetransfer.txt" >/dev/null- done-- # Check if zone transfer was successful- if [[ -s "subdomains/zonetransfer.txt" ]]; then- if ! grep -q "Transfer failed" "subdomains/zonetransfer.txt"; then- notification "Zone transfer found on ${domain}!" "info"- fi- fi-- end_func "Results are saved in $domain/subdomains/zonetransfer.txt" "${FUNCNAME[0]}"-- else- if [[ $ZONETRANSFER == false ]]; then- printf "\n%b[%s] %s skipped due to mode or defined in reconftw.cfg.%b\n" \- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"- elif [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then- printf "\n%s[%s] Domain is an IP address; skipping zone transfer.%b\n" \- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"- else- printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s%b\n\n" \- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$called_fn_dir" ".${FUNCNAME[0]}" "$reset"- fi- fi--}--function s3buckets() {- # Create necessary directories- if ! mkdir -p .tmp subdomains; then- printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"- return 1- fi-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $S3BUCKETS == true ]] && ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then- start_func "${FUNCNAME[0]}" "AWS S3 buckets search"-- # If in multi mode and subdomains.txt doesn't exist, create it- if [[ -n $multi ]] && [[ ! -f "$dir/subdomains/subdomains.txt" ]]; then- if ! printf "%b\n" "$domain" >"$dir/subdomains/subdomains.txt"; then- printf "%b[!] Failed to create subdomains.txt.%b\n" "$bred" "$reset"- return 1- fi- fi-- # Debug: Print current directory and tools variable- printf "Current directory: %s\n" "$(pwd)" >>"$LOGFILE"- printf "Tools directory: %s\n" "$tools" >>"$LOGFILE"-- # S3Scanner- if [[ $AXIOM != true ]]; then- if [[ -s "subdomains/subdomains.txt" ]]; then- s3scanner -bucket-file subdomains/subdomains.txt 2>>"$LOGFILE" | anew -q .tmp/s3buckets.txt- fi- else- axiom-scan subdomains/subdomains.txt -m s3scanner -o .tmp/s3buckets_tmp.txt "$AXIOM_EXTRA_ARGS" 2>>"$LOGFILE" >/dev/null-- if [[ -s ".tmp/s3buckets_tmp.txt" ]]; then- if ! cat .tmp/s3buckets_tmp.txt .tmp/s3buckets_tmp2.txt 2>>"$LOGFILE" | anew -q .tmp/s3buckets.txt; then- printf "%b[!] Failed to process s3buckets_tmp.txt.%b\n" "$bred" "$reset"- fi- if ! sed_i '/^$/d' .tmp/s3buckets.txt; then- printf "%b[!] Failed to clean s3buckets.txt.%b\n" "$bred" "$reset"- fi- fi- fi-- # Initialize the output file in the subdomains folder- if ! : >subdomains/cloudhunter_open_buckets.txt; then- printf "%b[!] Failed to initialize cloudhunter_open_buckets.txt.%b\n" "$bred" "$reset"- fi-- # Determine the CloudHunter permutations flag based on the config- PERMUTATION_FLAG=""- case "$CLOUDHUNTER_PERMUTATION" in- DEEP)- PERMUTATION_FLAG="-p $tools/CloudHunter/permutations-big.txt"- ;;- NORMAL)- PERMUTATION_FLAG="-p $tools/CloudHunter/permutations.txt"- ;;- NONE)- PERMUTATION_FLAG=""- ;;- *)- printf "%b[!] Invalid value for CLOUDHUNTER_PERMUTATION: %s.%b\n" "$bred" "$CLOUDHUNTER_PERMUTATION" "$reset"- return 1- ;;- esac-- # Debug: Print the full CloudHunter command- #printf "CloudHunter command: %s/venv/bin/python3 %s/cloudhunter.py %s -r %s/resolvers.txt -t 50 [URL]\n" "$tools/CloudHunter" "$tools/CloudHunter" "$PERMUTATION_FLAG" "$tools/CloudHunter" >>"$LOGFILE"-- # Debug: Check if files exist- if [[ -f "$tools/CloudHunter/cloudhunter.py" ]]; then- printf "cloudhunter.py exists\n" >>"$LOGFILE"- else- printf "cloudhunter.py not found\n" >>"$LOGFILE"- fi-- if [[ -n $PERMUTATION_FLAG ]]; then- permutation_file="${PERMUTATION_FLAG}"- if [[ -f $permutation_file ]]; then- printf "Permutations file exists\n" >>"$LOGFILE"- else- printf "Permutations file not found: %s\n" "$permutation_file" >>"$LOGFILE"- fi- fi-- if [[ -f "$tools/CloudHunter/resolvers.txt" ]]; then- printf "resolvers.txt exists\n" >>"$LOGFILE"- else- printf "resolvers.txt not found\n" >>"$LOGFILE"- fi-- printf "Processing domain: %s\n" "$domain" >>"$LOGFILE"- (- if ! cd "$tools/CloudHunter"; then- printf "%b[!] Failed to cd to %s.%b\n" "$bred" "$tools/CloudHunter" "$reset"- return 1- fi- if ! "${tools}/CloudHunter/venv/bin/python3" ./cloudhunter.py -p ${PERMUTATION_FLAG} -r ./resolvers.txt -t 50 "$domain"; then- printf "%b[!] CloudHunter command failed for domain %s.%b\n" "$bred" "$domain" "$reset"- fi- ) >>"$dir/subdomains/cloudhunter_open_buckets.txt" 2>>"$LOGFILE"-- # Process CloudHunter results- if [[ -s "subdomains/cloudhunter_open_buckets.txt" ]]; then- if ! NUMOFLINES1=$(cat subdomains/cloudhunter_open_buckets.txt 2>>"$LOGFILE" | anew subdomains/cloud_assets.txt | wc -l); then- printf "%b[!] Failed to process cloudhunter_open_buckets.txt.%b\n" "$bred" "$reset"- NUMOFLINES1=0- fi- if [[ $NUMOFLINES1 -gt 0 ]]; then- notification "${NUMOFLINES1} new cloud assets found" "info"- fi- else- NUMOFLINES1=0- fi-- # Process s3buckets results- if [[ -s ".tmp/s3buckets.txt" ]]; then- if ! NUMOFLINES2=$(cat .tmp/s3buckets.txt 2>>"$LOGFILE" | grep -aiv "not_exist" | grep -aiv "Warning:" | grep -aiv "invalid_name" | grep -aiv "^http" | awk 'NF' | anew subdomains/s3buckets.txt | sed '/^$/d' | wc -l); then- printf "%b[!] Failed to process s3buckets.txt.%b\n" "$bred" "$reset"- NUMOFLINES2=0- fi- if [[ $NUMOFLINES2 -gt 0 ]]; then- notification "${NUMOFLINES2} new S3 buckets found" "info"- fi- else- NUMOFLINES2=0- fi-- # Run trufflehog for S3 buckets- if [[ -s "subdomains/s3buckets.txt" ]]; then- while IFS= read -r bucket; do- trufflehog s3 --bucket="$bucket" -j 2>/dev/null | jq -c | anew -q subdomains/s3buckets_trufflehog.txt- done <subdomains/s3buckets.txt- fi-- # Run trufflehog for open buckets found by CloudHunter- if [[ -s "subdomains/cloudhunter_open_buckets.txt" ]]; then- while IFS= read -r line; do- if echo "$line" | grep -q "Aws Cloud"; then- # AWS S3 Bucket- bucket_name=$(echo "$line" | awk '{print $3}')- trufflehog s3 --bucket="$bucket_name" -j 2>/dev/null | jq -c | anew -q subdomains/cloudhunter_buckets_trufflehog.txt- elif echo "$line" | grep -q "Google Cloud"; then- # Google Cloud Storage- bucket_name=$(echo "$line" | awk '{print $3}')- trufflehog gcs --project-id="$bucket_name" -j 2>/dev/null | jq -c | anew -q subdomains/cloudhunter_buckets_trufflehog.txt- fi- done <subdomains/cloudhunter_open_buckets.txt- fi-- # Append cloud assets to asset store- append_assets_from_file cloud asset subdomains/cloudhunter_open_buckets.txt- append_assets_from_file cloud s3bucket subdomains/s3buckets.txt-- end_func "Results are saved in subdomains/s3buckets.txt, subdomains/cloud_assets.txt, subdomains/s3buckets_trufflehog.txt, and subdomains/cloudhunter_buckets_trufflehog.txt" "${FUNCNAME[0]}"- else- if [[ $S3BUCKETS == false ]]; then- printf "\n%b[%s] %s skipped due to mode or defined in reconftw.cfg.%b\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"- elif [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then- printf "\n%s[%s] Domain is an IP address; skipping S3 buckets search.%b\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"- return 0- else- printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s%b\n\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$called_fn_dir" ".${FUNCNAME[0]}" "$reset"- fi- fi-}--function cloud_extra_providers() {- mkdir -p subdomains .tmp-- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then- start_func "${FUNCNAME[0]}" "Extra cloud providers checks"- # Candidate names from domain and subdomains- company=$(unfurl format %r <<<"$domain")- printf "%s\n%s\n${domain%%.*}" "$company" "$domain" | sed 's/[^a-zA-Z0-9-]//g' | awk 'length>2' | sort -u >.tmp/cloudnames.txt- [[ -s subdomains/subdomains.txt ]] && awk -F. -v r=$(echo "$domain" | awk -F. '{print $(NF-1)"."$NF}') '{print $(NF-2)}' subdomains/subdomains.txt 2>/dev/null | sed 's/[^a-zA-Z0-9-]//g' | awk 'length>2' | sort -u >>.tmp/cloudnames.txt- sed_i 's/^\///; s/\.$//' .tmp/cloudnames.txt- sort -u .tmp/cloudnames.txt -o .tmp/cloudnames.txt-- # Common container names for Azure (best-effort)- printf "public\nstatic\nmedia\nimages\nassets\nbackup\nbackups\nfiles\ncdn" >.tmp/azcontainers.txt-- : >subdomains/cloud_extra.txt-- while IFS= read -r name; do- # GCS- for u in \- "https://storage.googleapis.com/$name/" \- "https://$name.storage.googleapis.com/"; do- code=$(curl -sk -o /dev/null -w '%{http_code}' "$u" || true)- if [[ $code =~ ^20|403$ ]]; then printf "GCS %s %s\n" "$name" "$u" | anew -q subdomains/cloud_extra.txt; fi- done-- # Azure Blob (requires container; try a few)- while IFS= read -r c; do- u="https://$name.blob.core.windows.net/$c?restype=container&comp=list"- code=$(curl -sk -o /dev/null -w '%{http_code}' "$u" || true)- if [[ $code =~ ^20|403$ ]]; then printf "AZURE %s %s\n" "$name/$c" "$u" | anew -q subdomains/cloud_extra.txt; fi- done <.tmp/azcontainers.txt-- # DigitalOcean Spaces (regional)- for r in ams3 nyc3 sfo3 sgp1 fra1 blr1; do- u="https://$name.$r.digitaloceanspaces.com/"- code=$(curl -sk -o /dev/null -w '%{http_code}' "$u" || true)- if [[ $code =~ ^20|403$ ]]; then printf "DOSPACE %s %s\n" "$name.$r" "$u" | anew -q subdomains/cloud_extra.txt; fi- done-- # Backblaze B2 (best-effort listing)- u="https://f000.backblazeb2.com/file/$name/"- code=$(curl -sk -o /dev/null -w '%{http_code}' "$u" || true)- if [[ $code =~ ^20|403$ ]]; then printf "B2 %s %s\n" "$name" "$u" | anew -q subdomains/cloud_extra.txt; fi-- done <.tmp/cloudnames.txt-- append_assets_from_file cloud asset subdomains/cloud_extra.txt- end_func "Results are saved in subdomains/cloud_extra.txt" "${FUNCNAME[0]}"- else- printf "\n${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} skipped or already processed.${reset}\n"- fi-}--###############################################################################################################-############################################# GEOLOCALIZATION INFO ############################################-###############################################################################################################--function geo_info() {-- # Create necessary directories- if ! mkdir -p hosts; then- printf "%b[!] Failed to create hosts directory.%b\n" "$bred" "$reset"- return 1- fi-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $GEO_INFO == true ]]; then- start_func "${FUNCNAME[0]}" "Running: ipinfo"-- ips_file="${dir}/hosts/ips.txt"-- # Check if ips.txt exists or is empty; if so, attempt to generate it- if [[ ! -s $ips_file ]]; then- # Attempt to generate hosts/ips.txt- if ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then- if [[ -s "subdomains/subdomains_dnsregs.json" ]]; then- jq -r 'select(.host) |"\(.host) - \((.a // [])[])", "\(.host) - \((.aaaa // [])[])"' <"subdomains/subdomains_dnsregs.json" |- grep -E ' - [0-9a-fA-F:.]+$' | sort -u | anew -q "subdomains/subdomains_ips.txt"- fi-- if [[ -s "subdomains/subdomains_ips.txt" ]]; then- cut -d ' ' -f3 subdomains/subdomains_ips.txt |- grep -aEiv "^(127|10|169\.254|172\.1[6-9]|172\.2[0-9]|172\.3[0-1]|192\.168)\." |- grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b" |- anew -q hosts/ips.txt- fi- else- printf "%b\n" "$domain" |- grep -aEiv "^(127|10|169\.254|172\.1[6-9]|172\.2[0-9]|172\.3[0-1]|192\.168)\." |- grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b" |- anew -q hosts/ips.txt- fi- fi-- if [[ -s $ips_file ]]; then- if ! touch "${dir}/hosts/ipinfo.txt"; then- printf "%b[!] Failed to create ipinfo.txt.%b\n" "$bred" "$reset"- fi-- while IFS= read -r ip; do- curl -s "https://ipinfo.io/widget/demo/$ip" >>"${dir}/hosts/ipinfo.txt"- done <"$ips_file"- fi-- end_func "Results are saved in hosts/ipinfo.txt" "${FUNCNAME[0]}"- else- if [[ $GEO_INFO == false ]]; then- printf "\n%b[%s] %s skipped due to mode or defined in reconftw.cfg.%b\n" \- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"- else- printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s%b\n\n" \- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$called_fn_dir" ".${FUNCNAME[0]}" "$reset"- fi- fi--}--###############################################################################################################-########################################### WEB DETECTION #####################################################-###############################################################################################################--function webprobe_simple() {-- # Create necessary directories- if ! mkdir -p .tmp webs subdomains; then- printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"- return 1- fi-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $WEBPROBESIMPLE == true ]]; then- start_subfunc "${FUNCNAME[0]}" "Running: HTTP probing $domain"-- # If in multi mode and subdomains.txt doesn't exist, create it- if [[ -n $multi ]] && [[ ! -f "$dir/subdomains/subdomains.txt" ]]; then- printf "%b\n" "$domain" >"$dir/subdomains/subdomains.txt"- touch .tmp/web_full_info.txt webs/web_full_info.txt- fi-- # Run httpx or axiom-scan- if [[ $AXIOM != true ]]; then- httpx ${HTTPX_FLAGS} -no-color -json -random-agent -threads "$HTTPX_THREADS" -rl "$HTTPX_RATELIMIT" \- -retries 2 -timeout "$HTTPX_TIMEOUT" -o .tmp/web_full_info_probe.txt \- <subdomains/subdomains.txt 2>>"$LOGFILE" >/dev/null- else- axiom-scan subdomains/subdomains.txt -m httpx ${HTTPX_FLAGS} -no-color -json -random-agent \- -threads "$HTTPX_THREADS" -rl "$HTTPX_RATELIMIT" -retries 2 -timeout "$HTTPX_TIMEOUT" \- -o .tmp/web_full_info_probe.txt "$AXIOM_EXTRA_ARGS" 2>>"$LOGFILE" >/dev/null- fi-- # Merge web_full_info files- cat .tmp/web_full_info.txt 2>>"$LOGFILE" |- jq -s 'try .' | jq 'try unique_by(.input)' | jq 'try .[]' 2>>"$LOGFILE" >webs/web_full_info.txt-- # Extract URLs- if [[ -s "webs/web_full_info.txt" ]]; then- jq -r 'try .url' webs/web_full_info.txt 2>/dev/null |- grep "$domain" |- grep -aEo 'https?://[^ ]+' |- sed 's/*.//' | anew -q .tmp/probed_tmp.txt- fi-- # Adaptive throttling heuristics: mark slow hosts (429/403) from httpx- if [[ -s "webs/web_full_info.txt" ]]; then- jq -r 'try select(.status_code==403 or .status_code==429) | .url' webs/web_full_info.txt 2>/dev/null |- awk -F/ '{print $3}' | sed 's/\:$//' | sort -u >.tmp/slow_hosts.txt- fi-- # Extract web info to plain text- if [[ -s "webs/web_full_info.txt" ]]; then- jq -r 'try . |"\(.url) [\(.status_code)] [\(.title)] [\(.webserver)] \(.tech)"' webs/web_full_info.txt |- grep "$domain" | anew -q webs/web_full_info_plain.txt- fi-- # Remove out-of-scope entries- if [[ -s $outOfScope_file ]]; then- if ! deleteOutScoped "$outOfScope_file" .tmp/probed_tmp.txt; then- printf "%b[!] Failed to delete out-of-scope entries.%b\n" "$bred" "$reset"- fi- fi-- touch .tmp/probed_tmp.txt-- # Count new websites- if ! NUMOFLINES=$(anew webs/webs.txt <.tmp/probed_tmp.txt 2>/dev/null | sed '/^$/d' | wc -l); then- printf "%b[!] Failed to count new websites.%b\n" "$bred" "$reset"- NUMOFLINES=0- fi-- # Update webs_all.txt- cat webs/webs.txt webs/webs_uncommon_ports.txt 2>/dev/null | anew -q webs/webs_all.txt-- # Asset store: append probed webs- append_assets_from_file web url webs/webs.txt-- end_subfunc "${NUMOFLINES} new websites resolved" "${FUNCNAME[0]}"-- # Send websites to proxy if conditions met- if [[ $PROXY == true ]] && [[ -n $proxy_url ]] && [[ $(wc -l <webs/webs.txt) -le $DEEP_LIMIT2 ]]; then- notification "Sending websites to proxy" "info"- ffuf -mc all -w webs/webs.txt -u FUZZ -replay-proxy "$proxy_url" 2>>"$LOGFILE" >/dev/null- fi-- else- if [[ $WEBPROBESIMPLE == false ]]; then- pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"- else- pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"- fi- fi-- # Emit plugin event- plugins_emit after_webprobe "$domain" "$dir"--}--function webprobe_full() {-- # Create necessary directories- if ! mkdir -p .tmp webs subdomains; then- printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"- return 1- fi-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $WEBPROBEFULL == true ]]; then- start_func "${FUNCNAME[0]}" "HTTP Probing Non-Standard Ports"-- # If in multi mode and subdomains.txt doesn't exist, create it- if [[ -n $multi ]] && [[ ! -f "$dir/subdomains/subdomains.txt" ]]; then- printf "%b\n" "$domain" >"$dir/subdomains/subdomains.txt"- touch webs/webs.txt- fi-- # Check if subdomains.txt is non-empty- if [[ -s "subdomains/subdomains.txt" ]]; then- if [[ $AXIOM != true ]]; then- # Run httpx on subdomains.txt- httpx -follow-host-redirects -random-agent -status-code \- -p "$UNCOMMON_PORTS_WEB" -threads "$HTTPX_UNCOMMONPORTS_THREADS" \- -timeout "$HTTPX_UNCOMMONPORTS_TIMEOUT" -silent -retries 2 \- -title -web-server -tech-detect -location -no-color -json \- -o .tmp/web_full_info_uncommon.txt <subdomains/subdomains.txt 2>>"$LOGFILE" >/dev/null- else- # Run axiom-scan with httpx module on subdomains.txt- axiom-scan subdomains/subdomains.txt -m httpx -follow-host-redirects \- -H "${HEADER}" -status-code -p "$UNCOMMON_PORTS_WEB" \- -threads "$HTTPX_UNCOMMONPORTS_THREADS" -timeout "$HTTPX_UNCOMMONPORTS_TIMEOUT" \- -silent -retries 2 -title -web-server -tech-detect -location -no-color -json \- -o .tmp/web_full_info_uncommon.txt "$AXIOM_EXTRA_ARGS" 2>>"$LOGFILE" >/dev/null- fi- fi-- # Process web_full_info_uncommon.txt- if [[ -s ".tmp/web_full_info_uncommon.txt" ]]; then- # Extract URLs- jq -r 'try .url' .tmp/web_full_info_uncommon.txt 2>/dev/null |- grep "$domain" |- grep -aEo 'https?://[^ ]+' |- sed 's/*.//' |- anew -q .tmp/probed_uncommon_ports_tmp.txt-- # Extract plain web info- jq -r 'try . | "\(.url) [\(.status_code)] [\(.title)] [\(.webserver)] \(.tech)"' .tmp/web_full_info_uncommon.txt |- grep "$domain" |- anew -q webs/web_full_info_uncommon_plain.txt-- # Update webs_full_info_uncommon.txt based on whether domain is IP- if [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then- cat .tmp/web_full_info_uncommon.txt 2>>"$LOGFILE" | anew -q webs/web_full_info_uncommon.txt- else- grep "$domain" .tmp/web_full_info_uncommon.txt | anew -q webs/web_full_info_uncommon.txt- fi-- # Count new websites- if ! NUMOFLINES=$(anew webs/webs_uncommon_ports.txt <.tmp/probed_uncommon_ports_tmp.txt | sed '/^$/d' | wc -l); then- printf "%b[!] Failed to count new websites.%b\n" "$bred" "$reset"- NUMOFLINES=0- fi-- # Notify user- notification "Uncommon web ports: ${NUMOFLINES} new websites" "good"-- # Display new uncommon ports websites- if [[ -s "webs/webs_uncommon_ports.txt" ]]; then- cat "webs/webs_uncommon_ports.txt"- fi-- # Update webs_all.txt- cat webs/webs.txt webs/webs_uncommon_ports.txt 2>/dev/null | anew -q webs/webs_all.txt-- # Send to proxy if conditions met- if [[ $PROXY == true ]] && [[ -n $proxy_url ]] && [[ $(wc -l <webs/webs_uncommon_ports.txt) -le $DEEP_LIMIT2 ]]; then- notification "Sending websites with uncommon ports to proxy" "info"- ffuf -mc all -w webs/webs_uncommon_ports.txt -u FUZZ -replay-proxy "$proxy_url" 2>>"$LOGFILE" >/dev/null- fi- fi- end_func "Results are saved in $domain/webs/webs_uncommon_ports.txt" "${FUNCNAME[0]}"- else- if [[ $WEBPROBEFULL == false ]]; then- pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"- else- pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"- fi- fi--}--function screenshot() {-- # Create necessary directories- if ! mkdir -p webs screenshots; then- printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"- return 1- fi-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $WEBSCREENSHOT == true ]]; then- start_func "${FUNCNAME[0]}" "Web Screenshots"-- # Combine webs.txt and webs_uncommon_ports.txt into webs_all.txt if it doesn't exist- if [[ ! -s "webs/webs_all.txt" ]]; then- cat webs/webs.txt webs/webs_uncommon_ports.txt 2>/dev/null | anew -q webs/webs_all.txt- fi-- # Run nuclei or axiom-scan based on AXIOM flag- if [[ $AXIOM != true ]]; then- if [[ -s "webs/webs_all.txt" ]]; then- nuclei -headless -id screenshot -V dir='screenshots' <webs/webs_all.txt 2>>"$LOGFILE"- fi- else- if [[ -s "webs/webs_all.txt" ]]; then- axiom-scan webs/webs_all.txt -m nuclei-screenshots -o screenshots "$AXIOM_EXTRA_ARGS" 2>>"$LOGFILE" >/dev/null- fi- fi- end_func "Results are saved in $domain/screenshots" "${FUNCNAME[0]}"- else- if [[ $WEBSCREENSHOT == false ]]; then- pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"- else- pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"- fi- fi--}--function virtualhosts() {-- # Create necessary directories- if ! mkdir -p .tmp/virtualhosts virtualhosts webs; then- printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"- return 1- fi-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $VIRTUALHOSTS == true ]]; then- start_func "${FUNCNAME[0]}" "Virtual Hosts Discovery"-- # Combine webs.txt and webs_uncommon_ports.txt into webs_all.txt if it doesn't exist- if [[ ! -s "webs/webs_all.txt" ]]; then- cat webs/webs.txt webs/webs_uncommon_ports.txt 2>/dev/null | anew -q webs/webs_all.txt- fi-- # Proceed only if webs_all.txt exists and is non-empty- if [[ -s "subdomains/subdomains.txt" ]] && [[ -s "hosts/ips.txt" ]]; then- VhostFinder -ips hosts/ips.txt -wordlist subdomains/subdomains.txt -verify | grep "+" | anew -q "$dir/webs/virtualhosts.txt"- end_func "Results are saved in $domain/webs/virtualhosts.txt" "${FUNCNAME[0]}"-- else- end_func "No subdomains or hosts file found, virtualhosts skipped." "${FUNCNAME[0]}"- fi-- # Optionally send to proxy if conditions are met- if [[ $PROXY == true ]] && [[ -n $proxy_url ]] && [[ $(wc -l <webs/webs_uncommon_ports.txt) -le $DEEP_LIMIT2 ]]; then- notification "Sending websites with uncommon ports to proxy" "info"- ffuf -mc all -w webs/webs_uncommon_ports.txt -u FUZZ -replay-proxy "$proxy_url" 2>>"$LOGFILE" >/dev/null- fi-- else- if [[ $VIRTUALHOSTS == false ]]; then- printf "\n${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} skipped in this mode or defined in reconftw.cfg ${reset}\n"- else- printf "${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} has already been processed. To force execution, delete:\n $called_fn_dir/.${FUNCNAME[0]} ${reset}\n\n"- fi- fi--}--###############################################################################################################-############################################# HOST SCAN #######################################################-###############################################################################################################--function favicon() {-- # Create necessary directories- if ! mkdir -p hosts .tmp/virtualhosts; then- printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"- return 1- fi-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } &&- [[ $FAVICON == true ]] &&- ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then-- start_func "${FUNCNAME[0]}" "Favicon IP Lookup"-- # Navigate to the fav-up tool directory- if ! pushd "${tools}/fav-up" >/dev/null; then- printf "%b[!] Failed to change directory to %s in %s @ line %s.%b\n" \- "$bred" "${tools}/fav-up" "${FUNCNAME[0]}" "${LINENO}" "$reset"- return 1- fi-- # Run the favicon IP lookup tool- timeout 10m "${tools}/fav-up/venv/bin/python3" "${tools}/fav-up/favUp.py" -w "$domain" -sc -o favicontest.json 2>>"$LOGFILE" >/dev/null-- # Process the results if favicontest.json exists and is not empty- if [[ -s "favicontest.json" ]]; then- jq -r 'try .found_ips' favicontest.json 2>>"$LOGFILE" |- grep -v "not-found" >favicontest.txt-- # Replace '|' with newlines- sed_i "s/|/\n/g" favicontest.txt-- # Move the processed IPs to the hosts directory- mv favicontest.txt "$dir/hosts/favicontest.txt" 2>>"$LOGFILE"-- # Remove the JSON file- rm -f favicontest.json 2>>"$LOGFILE"- fi-- # Return to the original directory- if ! popd >/dev/null; then- printf "%b[!] Failed to return to the previous directory in %s @ line %s.%b\n" \- "$bred" "${FUNCNAME[0]}" "${LINENO}" "$reset"- fi-- end_func "Results are saved in hosts/favicontest.txt" "${FUNCNAME[0]}"-- else- if [[ $FAVICON == false ]]; then- printf "\n${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} skipped due to configuration settings.${reset}\n"- elif [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then- # Domain is an IP, do nothing- return- else- printf "${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} has already been processed. To force execution, delete:\n $called_fn_dir/.${FUNCNAME[0]}${reset}\n\n"- fi- fi--}--function portscan() {-- # Create necessary directories- if ! mkdir -p .tmp subdomains hosts webs; then- printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"- return 1- fi-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $PORTSCANNER == true ]]; then- start_func "${FUNCNAME[0]}" "Port scan"-- # Determine if domain is IP address or domain name- if ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then- # Not an IP address- if [[ -s "subdomains/subdomains_ips.txt" ]]; then- cut -d ' ' -f3 subdomains/subdomains_ips.txt |- grep -aEiv "^(127|10|169\.254|172\.1[6-9]|172\.2[0-9]|172\.3[0-1]|192\.168)\." |- grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b" |- anew -q hosts/ips.txt- fi-- else- # Domain is an IP address- printf "%b\n" "$domain" | grep -aEiv "^(127|10|169\.254|172\.1[6-9]|172\.2[0-9]|172\.3[0-1]|192\.168)\." | grep -oE '\b([0-9]{1,3}\.){3}[0-9]{1,3}\b' | anew -q hosts/ips.txt- fi-- # Check for CDN providers- if [[ ! -s "hosts/cdn_providers.txt" ]]; then- if [[ -s "hosts/ips.txt" ]]; then- cat hosts/ips.txt | cdncheck -silent -resp -cdn -waf -nc 2>/dev/null | anew -q hosts/cdn_providers.txt- fi- fi-- if [[ -s "hosts/ips.txt" ]]; then- # Remove CDN IPs- comm -23 <(sort -u hosts/ips.txt) <(cut -d'[' -f1 hosts/cdn_providers.txt | sed 's/[[:space:]]*$//' | sort -u) |- grep -aEiv "^(127|10|169\.254|172\.1[6-9]|172\.2[0-9]|172\.3[0-1]|192\.168)\." | grep -oE '\b([0-9]{1,3}\.){3}[0-9]{1,3}\b' |- sort -u | anew -q .tmp/ips_nocdn.txt- fi-- # Display resolved IPs without CDN- printf "%b\n[%s] Resolved IP addresses (No CDN):%b\n\n" "$bblue" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"- if [[ -s ".tmp/ips_nocdn.txt" ]]; then- sort ".tmp/ips_nocdn.txt"- fi-- printf "%b\n[%s] Scanning ports...%b\n\n" "$bblue" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"-- ips_file="${dir}/hosts/ips.txt"-- # Discover IPv6 addresses from DNS JSON if enabled- if [[ $IPV6_SCAN == true ]]; then- if [[ -s "subdomains/subdomains_dnsregs.json" ]]; then- jq -r '.. | strings | select(test("^[0-9a-fA-F:]+$"))' <"subdomains/subdomains_dnsregs.json" |- grep -v '\\.' | sort -u | anew -q hosts/ips_v6.txt- fi- # Add target if it's an IPv6 literal- if [[ $domain =~ : ]]; then echo "$domain" | anew -q hosts/ips_v6.txt; fi- fi-- if [[ $PORTSCAN_PASSIVE == true ]]; then- if [[ ! -f $ips_file ]]; then- printf "%b[!] File %s does not exist.%b\n" "$bred" "$ips_file" "$reset"- else- json_array=()- while IFS= read -r cip; do- if ! json_result=$(curl -s "https://internetdb.shodan.io/${cip}"); then- printf "%b[!] Failed to retrieve data for IP %s.%b\n" "$bred" "$cip" "$reset"- else- json_array+=("$json_result")- fi- done <"$ips_file"- formatted_json="["- for ((i = 0; i < ${#json_array[@]}; i++)); do- formatted_json+="$(echo "${json_array[i]}" | tr -d '\n')"- if [ $i -lt $((${#json_array[@]} - 1)) ]; then- formatted_json+=", "- fi- done- formatted_json+="]"- if ! echo "$formatted_json" >"${dir}/hosts/portscan_shodan.txt"; then- printf "%b[!] Failed to write portscan_shodan.txt.%b\n" "$bred" "$reset"- fi- fi- fi-- if [[ $PORTSCAN_PASSIVE == true ]] && [[ ! -f "hosts/portscan_passive.txt" ]] && [[ -s ".tmp/ips_nocdn.txt" ]]; then- smap -iL .tmp/ips_nocdn.txt >hosts/portscan_passive.txt- fi-- if [[ $PORTSCAN_ACTIVE == true ]]; then- if [[ $AXIOM != true ]]; then- if [[ -s ".tmp/ips_nocdn.txt" ]]; then- $SUDO nmap $PORTSCAN_ACTIVE_OPTIONS -iL .tmp/ips_nocdn.txt -oA hosts/portscan_active 2>>"$LOGFILE" >/dev/null- fi- if [[ $IPV6_SCAN == true && -s "hosts/ips_v6.txt" ]]; then- $SUDO nmap -6 $PORTSCAN_ACTIVE_OPTIONS -iL hosts/ips_v6.txt -oA hosts/portscan_active_v6 2>>"$LOGFILE" >/dev/null- fi- else- if [[ -s ".tmp/ips_nocdn.txt" ]]; then- axiom-scan .tmp/ips_nocdn.txt -m nmapx $PORTSCAN_ACTIVE_OPTIONS \- -oA hosts/portscan_active $AXIOM_EXTRA_ARGS 2>>"$LOGFILE" >/dev/null- fi- fi- fi-- if [[ -s "hosts/portscan_active.xml" ]]; then- nmapurls <hosts/portscan_active.xml 2>>"$LOGFILE" | anew -q hosts/webs.txt- fi- if [[ -s "hosts/portscan_active_v6.xml" ]]; then- nmapurls <hosts/portscan_active_v6.xml 2>>"$LOGFILE" | anew -q hosts/webs_v6.txt- [[ -s hosts/webs_v6.txt ]] && cat hosts/webs_v6.txt | anew -q webs/webs.txt- fi-- if [[ $FARADAY == true ]]; then- # Check if the Faraday server is running- if ! faraday-cli status 2>>"$LOGFILE" >/dev/null; then- printf "%b[!] Faraday server is not running. Skipping Faraday integration.%b\n" "$bred" "$reset"- else- if [[ -s "hosts/portscan_active.xml" ]]; then- faraday-cli tool report -w $FARADAY_WORKSPACE --plugin-id nmap hosts/portscan_active.xml 2>>"$LOGFILE" >/dev/null- fi- fi- fi-- if [[ -s "hosts/webs.txt" ]]; then- if ! NUMOFLINES=$(wc -l <hosts/webs.txt); then- printf "%b[!] Failed to count lines in hosts/webs.txt.%b\n" "$bred" "$reset"- NUMOFLINES=0- fi- notification "Webs detected from port scan: ${NUMOFLINES} new websites" "good"- cat hosts/webs.txt- append_assets_from_file web url hosts/webs.txt- fi-- end_func "Results are saved in hosts/portscan_[passive|active|shodan].[txt|xml]" "${FUNCNAME[0]}"-- else- if [[ $PORTSCANNER == false ]]; then- printf "\n%b[%s] %s skipped due to mode or defined in reconftw.cfg.%b\n" \- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$reset"- else- printf "%b[%s] %s has already been processed. To force execution, delete:\n %s/.%s%b\n\n" \- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "${FUNCNAME[0]}" "$called_fn_dir" ".${FUNCNAME[0]}" "$reset"- fi- fi--}--function cdnprovider() {-- # Create necessary directories- if ! mkdir -p .tmp subdomains hosts; then- printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"- return 1- fi-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } &&- [[ $CDN_IP == true ]] &&- ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then-- start_func "${FUNCNAME[0]}" "CDN Provider Check"-- # Check if subdomains_dnsregs.json exists and is not empty- if [[ -s "subdomains/subdomains_ips.txt" ]]; then- cut -d ' ' -f3 subdomains/subdomains_ips.txt |- grep -aEiv "^(127|10|169\.254|172\.1[6-9]|172\.2[0-9]|172\.3[0-1]|192\.168)\." |- grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b" |- anew -q hosts/ips.txt- fi-- # Check if ips_cdn.txt exists and is not empty- if [[ -s "hosts/ips.txt" ]]; then- # Run cdncheck on the IPs and save to cdn_providers.txt- cdncheck -silent -resp -nc <hosts/ips.txt | anew -q "$dir/hosts/cdn_providers.txt"- fi-- end_func "Results are saved in hosts/cdn_providers.txt" "${FUNCNAME[0]}"-- else- if [[ $CDN_IP == false ]]; then- printf "\n${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} skipped due to configuration settings.${reset}\n"- elif [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then- # Domain is an IP, do nothing- return- else- printf "${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} has already been processed. To force execution, delete:\n $called_fn_dir/.${FUNCNAME[0]}${reset}\n\n"- fi- fi--}--###############################################################################################################-############################################# WEB SCAN ########################################################-###############################################################################################################--function waf_checks() {-- # Create necessary directories- if ! mkdir -p .tmp webs; then- printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"- return 1- fi-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $WAF_DETECTION == true ]]; then- start_func "${FUNCNAME[0]}" "Website's WAF Detection"-- # Combine webs.txt and webs_uncommon_ports.txt into webs_all.txt if it doesn't exist- if [[ ! -s "webs/webs_all.txt" ]]; then- cat webs/webs.txt webs/webs_uncommon_ports.txt 2>/dev/null | anew -q webs/webs_all.txt- fi-- # Proceed only if webs_all.txt exists and is non-empty- if [[ -s "webs/webs_all.txt" ]]; then- if [[ $AXIOM != true ]]; then- # Run wafw00f on webs_all.txt- wafw00f -i "webs/webs_all.txt" -o ".tmp/wafs.txt" 2>>"$LOGFILE" >/dev/null- else- # Run axiom-scan with wafw00f module on webs_all.txt- axiom-scan "webs/webs_all.txt" -m wafw00f -o ".tmp/wafs.txt" "$AXIOM_EXTRA_ARGS" 2>>"$LOGFILE" >/dev/null- fi-- # Process wafs.txt if it exists and is not empty- if [[ -s ".tmp/wafs.txt" ]]; then- # Format the wafs.txt file- sed -e 's/^[ \t]*//' -e 's/ \+ /\t/g' -e '/(None)/d' ".tmp/wafs.txt" | tr -s "\t" ";" >"webs/webs_wafs.txt"-- # Count the number of websites protected by WAF- if ! NUMOFLINES=$(sed '/^$/d' "webs/webs_wafs.txt" 2>>"$LOGFILE" | wc -l); then- printf "%b[!] Failed to count lines in webs_wafs.txt.%b\n" "$bred" "$reset"- NUMOFLINES=0- fi-- # Send a notification about the number of WAF-protected websites- notification "${NUMOFLINES} websites protected by WAF" "info"-- # End the function with a success message- end_func "Results are saved in webs/webs_wafs.txt" "${FUNCNAME[0]}"- else- # End the function indicating no results were found- end_func "No results found" "${FUNCNAME[0]}"- fi- else- # End the function indicating there are no websites to scan- end_func "No websites to scan" "${FUNCNAME[0]}"- fi- else- # Handle cases where WAF_DETECTION is false or the function has already been processed- if [[ $WAF_DETECTION == false ]]; then- pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"- elif [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then- # Domain is an IP address; skip the function- return- else- pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"- fi- fi--}--function nuclei_check() {-- # Create necessary directories- if ! mkdir -p .tmp webs subdomains nuclei_output; then- printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"- return 1- fi-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $NUCLEICHECK == true ]]; then- start_func "${FUNCNAME[0]}" "Templates-based Web Scanner"- #cent update -p ${NUCLEI_TEMPLATES_PATH} &>/dev/null- # Update nuclei templates once per run- maybe_update_nuclei-- # Handle multi mode and initialize subdomains.txt if necessary- if [[ -n $multi ]] && [[ ! -f "$dir/subdomains/subdomains.txt" ]]; then- printf "%b\n" "$domain" >"$dir/subdomains/subdomains.txt"- touch webs/webs.txt webs/webs_uncommon_ports.txt- fi-- # Combine webs.txt and webs_uncommon_ports.txt into webs_all.txt if it doesn't exist- if [[ ! -s "webs/webs_all.txt" ]]; then- cat webs/webs.txt webs/webs_uncommon_ports.txt 2>/dev/null | anew -q webs/webs_all.txt- fi-- # Combine url_extract_nodupes.txt, subdomains.txt, and webs_all.txt into webs_subs.txt if it doesn't exist- if [[ ! -s ".tmp/webs_subs.txt" ]]; then- cat subdomains/subdomains.txt webs/webs_all.txt 2>>"$LOGFILE" >.tmp/webs_subs.txt- fi-- # Prepare WAF-aware lists- WAF_LIST=.tmp/webs_waf.txt- NOWAF_LIST=.tmp/webs_nowaf.txt- if [[ -s webs/webs_wafs.txt ]]; then- cut -d';' -f1 webs/webs_wafs.txt | sed 's/https\?:\/\///' | sed 's/\/$//' | sort -u >.tmp/waf_hosts.txt- awk -F/ '{print $3}' .tmp/webs_subs.txt | sed 's/\:$//' | while read -r host; do- if grep -q "^$host$" .tmp/waf_hosts.txt; then- grep "://${host}[:/\n]" .tmp/webs_subs.txt | anew -q "$WAF_LIST"- else- grep "://${host}[:/\n]" .tmp/webs_subs.txt | anew -q "$NOWAF_LIST"- fi- done- else- cp .tmp/webs_subs.txt "$NOWAF_LIST"- fi-- # Include slow hosts (429/403) into WAF list as well- if [[ -s .tmp/slow_hosts.txt ]]; then- while read -r host; do- grep "://${host}[:/\n]" .tmp/webs_subs.txt | anew -q "$WAF_LIST"- done <.tmp/slow_hosts.txt- fi-- # Check if AXIOM is enabled- if [[ $AXIOM != true ]]; then- # Split severity levels into an array- IFS=',' read -ra severity_array <<<"$NUCLEI_SEVERITY"-- for crit in "${severity_array[@]}"; do- printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: Nuclei Severity: $crit ${reset}\n\n"- # Non-WAF at default rate- if [[ -s $NOWAF_LIST ]]; then- nuclei -l "$NOWAF_LIST" -severity "$crit" -nh -rl "$NUCLEI_RATELIMIT" -silent -retries 2 ${NUCLEI_EXTRA_ARGS} -t ${NUCLEI_TEMPLATES_PATH} -j -o "nuclei_output/${crit}_json.txt" 2>>"$LOGFILE" >/dev/null- fi- # WAF hosts at slower rate- if [[ -s $WAF_LIST ]]; then- local slow_rl- slow_rl=$((NUCLEI_RATELIMIT / 3 + 1))- nuclei -l "$WAF_LIST" -severity "$crit" -nh -rl "$slow_rl" -silent -retries 2 ${NUCLEI_EXTRA_ARGS} -t ${NUCLEI_TEMPLATES_PATH} -j -o "nuclei_output/${crit}_waf_json.txt" 2>>"$LOGFILE" >/dev/null- [[ -s nuclei_output/${crit}_waf_json.txt ]] && cat nuclei_output/${crit}_waf_json.txt >>nuclei_output/${crit}_json.txt- fi- # Parse the JSON output and save the results to a text file- if [[ -s "nuclei_output/${crit}_json.txt" ]]; then- jq -r '["[" + .["template-id"] + (if .["matcher-name"] != null then ":" + .["matcher-name"] else "" end) + "] [" + .["type"] + "] [" + .info.severity + "] " + (.["matched-at"] // .host) + (if .["extracted-results"] != null then " " + (.["extracted-results"] | @json) else "" end)] | .[]' nuclei_output/${crit}_json.txt >nuclei_output/${crit}.txt- # Asset store: append findings- append_assets_from_file finding value nuclei_output/${crit}.txt- # Display the results if the output file exists and is not empty- if [[ -s "nuclei_output/${crit}.txt" ]]; then- cat "nuclei_output/${crit}.txt"- fi- fi- done- printf "\n\n"- else- # Split severity levels into an array- IFS=',' read -ra severity_array <<<"$NUCLEI_SEVERITY"-- for crit in "${severity_array[@]}"; do- printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: Axiom Nuclei Severity: $crit. Check results in nuclei_output folder.${reset}\n\n"- # Run axiom-scan with nuclei module for each severity level- axiom-scan .tmp/webs_subs.txt -m nuclei \- --nuclei-templates "$NUCLEI_TEMPLATES_PATH" \- -severity "$crit" -nh -rl "$NUCLEI_RATELIMIT" \- -silent -retries 2 "$NUCLEI_EXTRA_ARGS" -j -o "nuclei_output/${crit}_json.txt" "$AXIOM_EXTRA_ARGS" 2>>"$LOGFILE" >/dev/null- # Parse the JSON output and save the results to a text file- if [[ -s "nuclei_output/${crit}_json.txt" ]]; then- jq -r '["[" + .["template-id"] + (if .["matcher-name"] != null then ":" + .["matcher-name"] else "" end) + "] [" + .["type"] + "] [" + .info.severity + "] " + (.["matched-at"] // .host) + (if .["extracted-results"] != null then " " + (.["extracted-results"] | @json) else "" end)] | .[]' nuclei_output/${crit}_json.txt >nuclei_output/${crit}.txt-- # Display the results if the output file exists and is not empty- if [[ -s "nuclei_output/${crit}.txt" ]]; then- cat "nuclei_output/${crit}.txt"- fi- fi- done- printf "\n\n"- fi-- # Faraday integration- if [[ $FARADAY == true ]]; then- # Check if the Faraday server is running- if ! faraday-cli status 2>>"$LOGFILE" >/dev/null; then- printf "%b[!] Faraday server is not running. Skipping Faraday integration.%b\n" "$bred" "$reset"- else- if [[ -s "nuclei_output/${crit}_json.txt" ]]; then- faraday-cli tool report -w $FARADAY_WORKSPACE --plugin-id nuclei nuclei_output/${crit}_json.txt 2>>"$LOGFILE" >/dev/null- fi- fi- fi-- end_func "Results are saved in $domain/nuclei_output folder" "${FUNCNAME[0]}"-- # Emit plugin event- plugins_emit after_nuclei "$domain" "$dir"- else- # Handle cases where NUCLEICHECK is false or the function has already been processed- if [[ $NUCLEICHECK == false ]]; then- pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"- elif [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then- # Domain is an IP address; skip the function- return- else- pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"- fi- fi--}--function graphql_scan() {- # Detect GraphQL endpoints and introspection- mkdir -p .tmp webs nuclei_output vulns/graphql-- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $GRAPHQL_CHECK == true ]]; then- start_func "${FUNCNAME[0]}" "GraphQL detection"- # Prepare input- [[ ! -s .tmp/webs_subs.txt ]] && cat subdomains/subdomains.txt webs/webs_all.txt 2>>"$LOGFILE" >.tmp/webs_subs.txt- maybe_update_nuclei- if [[ -s .tmp/webs_subs.txt ]]; then- nuclei -l .tmp/webs_subs.txt -tags graphql -nh -rl "$NUCLEI_RATELIMIT" -silent -retries 2 -t ${NUCLEI_TEMPLATES_PATH} -j -o nuclei_output/graphql_json.txt 2>>"$LOGFILE" >/dev/null- if [[ -s nuclei_output/graphql_json.txt ]]; then- jq -r '["[" + .["template-id"] + "] [" + .info.severity + "] " + (.["matched-at"] // .host)] | .[]' nuclei_output/graphql_json.txt >nuclei_output/graphql.txt- # Optionally run GQLSpection on endpoints- if [[ $GQLSPECTION == true ]]; then- jq -r '.["matched-at"] // .host' nuclei_output/graphql_json.txt | sort -u | while read -r ep; do- [[ -z $ep ]] && continue- hostfile="vulns/graphql/$(echo "$ep" | sed 's|^[^/]*//||; s|/.*$||')"- mkdir -p "$(dirname "$hostfile")" 2>>"$LOGFILE" || true- gqlspection -t "$ep" -o "${hostfile}.json" 2>>"$LOGFILE" >/dev/null || true- done- fi- fi- fi- end_func "Results are saved in nuclei_output/graphql* and vulns/graphql" "${FUNCNAME[0]}"- else- if [[ $GRAPHQL_CHECK == false ]]; then- printf "\n${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} skipped due to configuration settings.${reset}\n"- else- printf "${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} has already been processed. To force execution, delete:\n $called_fn_dir/.${FUNCNAME[0]}${reset}\n\n"- fi- fi-}--function param_discovery() {- mkdir -p webs .tmp-- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $PARAM_DISCOVERY == true ]]; then- start_func "${FUNCNAME[0]}" "Parameter discovery (arjun)"- local input_file="webs/url_extract_nodupes.txt"- [[ ! -s $input_file ]] && input_file="webs/webs_all.txt"- if [[ -s $input_file ]]; then- arjun -i "$input_file" -t "$ARJUN_THREADS" -oJ .tmp/arjun.json 2>>"$LOGFILE" >/dev/null || true- if [[ -s .tmp/arjun.json ]]; then- jq -r '..|.url? // empty' .tmp/arjun.json | sed 's/^/URL: /' | anew -q webs/params_discovered.txt- jq -r '..|.params? // empty | to_entries[] | .key' .tmp/arjun.json | sed 's/^/PARAM: /' | sort -u | anew -q webs/params_discovered.txt- fi- fi- end_func "Results are saved in webs/params_discovered.txt" "${FUNCNAME[0]}"- else- if [[ $PARAM_DISCOVERY == false ]]; then- printf "\n${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} skipped due to configuration settings.${reset}\n"- else- printf "${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} has already been processed. To force execution, delete:\n $called_fn_dir/.${FUNCNAME[0]}${reset}\n\n"- fi- fi-}--function grpc_reflection() {- mkdir -p hosts .tmp-- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $GRPC_SCAN == true ]]; then- start_func "${FUNCNAME[0]}" "gRPC reflection probing"- # Build target IP list- local ips_file="hosts/ips.txt"- local targets=()- [[ -s $ips_file ]] && targets+=($(cat "$ips_file"))- [[ -s "hosts/ips_v6.txt" ]] && targets+=($(cat "hosts/ips_v6.txt"))- printf "%s\n" "${targets[@]}" | sort -u >.tmp/grpc_ips.txt- if [[ -s .tmp/grpc_ips.txt ]]; then- # Probe common plaintext gRPC ports- while read -r ip; do- for p in 50051 50052; do- grpcurl -plaintext -max-msg-sz 10485760 -d '{}' "$ip:$p" list 2>>"$LOGFILE" | sed "s/^/[$ip:$p] /" | anew -q hosts/grpc_reflection.txt || true- done- done <.tmp/grpc_ips.txt- fi- end_func "Results are saved in hosts/grpc_reflection.txt" "${FUNCNAME[0]}"- else- if [[ $GRPC_SCAN == false ]]; then- printf "\n${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} skipped due to configuration settings.${reset}\n"- else- printf "${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} has already been processed. To force execution, delete:\n $called_fn_dir/.${FUNCNAME[0]}${reset}\n\n"- fi- fi-}--function fuzz() {-- # Create necessary directories- mkdir -p .tmp/fuzzing webs fuzzing-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $FUZZ == true ]] &&- ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then-- start_func "${FUNCNAME[0]}" "Web Directory Fuzzing"-- # Handle multi mode and initialize subdomains.txt if necessary- if [[ -n $multi ]] && [[ ! -f "$dir/webs/webs.txt" ]]; then- if ! printf "%b\n" "$domain" >"$dir/webs/webs.txt"; then- printf "%b[!] Failed to create webs.txt.%b\n" "$bred" "$reset"- fi- if ! touch webs/webs_uncommon_ports.txt; then- printf "%b[!] Failed to initialize webs_uncommon_ports.txt.%b\n" "$bred" "$reset"- fi- fi-- # Combine webs.txt and webs_uncommon_ports.txt into webs_all.txt if it doesn't exist- if [[ ! -s "webs/webs_all.txt" ]]; then- cat webs/webs.txt webs/webs_uncommon_ports.txt 2>/dev/null | anew -q webs/webs_all.txt- fi-- if [[ -s "webs/webs_all.txt" ]]; then- if [[ $AXIOM != true ]]; then- # Split targets by slow hosts- >.tmp/webs_slow.txt- >.tmp/webs_normal.txt- if [[ -s .tmp/slow_hosts.txt ]]; then- while read -r host; do- grep "://${host}[:/\n]" webs/webs_all.txt | anew -q .tmp/webs_slow.txt- done <.tmp/slow_hosts.txt- comm -23 <(sort -u webs/webs_all.txt) <(sort -u .tmp/webs_slow.txt) >.tmp/webs_normal.txt- else- cp webs/webs_all.txt .tmp/webs_normal.txt- fi-- # Normal targets- if [[ -s .tmp/webs_normal.txt ]]; then- interlace -tL .tmp/webs_normal.txt -threads ${INTERLACE_THREADS} -c "ffuf ${FFUF_FLAGS} -t ${FFUF_THREADS} -rate ${FFUF_RATELIMIT} -H \"${HEADER}\" -w ${fuzz_wordlist} -maxtime ${FFUF_MAXTIME} -u _target_/FUZZ -o _output_/_cleantarget_.json" -o $dir/.tmp/fuzzing 2>>"$LOGFILE" >/dev/null- fi- # Slow targets with reduced threads/rate- if [[ -s .tmp/webs_slow.txt ]]; then- slow_threads=$((FFUF_THREADS / 3))- [[ $slow_threads -lt 5 ]] && slow_threads=5- slow_rate=$FFUF_RATELIMIT- [[ ${FFUF_RATELIMIT:-0} -eq 0 ]] && slow_rate=50 || slow_rate=$((FFUF_RATELIMIT / 3 + 1))- interlace -tL .tmp/webs_slow.txt -threads ${INTERLACE_THREADS} -c "ffuf ${FFUF_FLAGS} -t ${slow_threads} -rate ${slow_rate} -H \"${HEADER}\" -w ${fuzz_wordlist} -maxtime ${FFUF_MAXTIME} -u _target_/FUZZ -o _output_/_cleantarget_.json" -o $dir/.tmp/fuzzing 2>>"$LOGFILE" >/dev/null- fi- for sub in $(cat webs/webs_all.txt); do- sub_out=$(echo $sub | sed -e 's|^[^/]*//||' -e 's|/.*$||')-- [ -s "$dir/.tmp/fuzzing/${sub_out}.json" ] && cat $dir/.tmp/fuzzing/${sub_out}.json | jq -r 'try .results[] | "\(.status) \(.length) \(.url)"' | sort -k1 | anew -q $dir/fuzzing/${sub_out}.txt- done- find $dir/fuzzing/ -type f -iname "*.txt" -exec cat {} + 2>>"$LOGFILE" | sort -k1 | anew -q $dir/fuzzing/fuzzing_full.txt- else- cached_download "${fuzzing_remote_list}" ".tmp/fuzzing_remote_list.txt" "onelistforallmicro.txt"- axiom-scan webs/webs_all.txt -m ffuf -wL .tmp/fuzzing_remote_list.txt -H "${HEADER}" $FFUF_FLAGS -s -maxtime $FFUF_MAXTIME -oJ $dir/.tmp/ffuf-content.json $AXIOM_EXTRA_ARGS 2>>"$LOGFILE" >/dev/null-- for sub in $(cat webs/webs_all.txt); do- sub_out=$(echo $sub | sed -e 's|^[^/]*//||' -e 's|/.*$||')- [ -s "$dir/.tmp/ffuf-content.json" ] && cat $dir/.tmp/ffuf-content.json | jq -r 'try .results[] | "\(.status) \(.length) \(.url)"' | grep $sub | sort -k1 | anew -q fuzzing/${sub_out}.txt- done- find $dir/fuzzing/ -type f -iname "*.txt" -exec cat {} + 2>>"$LOGFILE" | sort -k1 | anew -q $dir/fuzzing/fuzzing_full.txt- fi- end_func "Results are saved in $domain/fuzzing/*subdomain*.txt" ${FUNCNAME[0]}- else- end_func "No $domain/webs/webs_all.txt file found, fuzzing skipped " ${FUNCNAME[0]}- fi-- else- if [[ $FUZZ == false ]]; then- pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"- else- pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"- fi- fi--}--function iishortname() {-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $IIS_SHORTNAME == true ]]; then- start_func "${FUNCNAME[0]}" "IIS Shortname Scanner"-- # Ensure nuclei_output/info.txt exists and is not empty- if [[ -s "nuclei_output/info.txt" ]]; then- # Extract IIS version information and save to .tmp/iis_sites.txt- grep "iis-version" "nuclei_output/info.txt" | cut -d " " -f4 >.tmp/iis_sites.txt- fi-- # Proceed only if iis_sites.txt exists and is non-empty- if [[ -s ".tmp/iis_sites.txt" ]]; then- # Create necessary directories- mkdir -p "$dir/vulns/iis-shortname-shortscan/" "$dir/vulns/iis-shortname-sns/"-- # Run shortscan using interlace- interlace -tL .tmp/iis_sites.txt -threads "$INTERLACE_THREADS" \- -c "shortscan _target_ -F -s -p 1 > _output_/_cleantarget_.txt" \- -o "$dir/vulns/iis-shortname-shortscan/" 2>>"$LOGFILE" >/dev/null-- # Remove non-vulnerable shortscan results- find "$dir/vulns/iis-shortname-shortscan/" -type f -iname "*.txt" -print0 |- xargs --null grep -Z -L 'Vulnerable: Yes' |- xargs --null rm 2>>"$LOGFILE" >/dev/null-- # Run sns using interlace- interlace -tL .tmp/iis_sites.txt -threads "$INTERLACE_THREADS" \- -c "sns -u _target_ > _output_/_cleantarget_.txt" \- -o "$dir/vulns/iis-shortname-sns/" 2>>"$LOGFILE" >/dev/null-- # Remove non-vulnerable sns results- find "$dir/vulns/iis-shortname-sns/" -type f -iname "*.txt" -print0 |- xargs --null grep -Z 'Target is not vulnerable' |- xargs --null rm 2>>"$LOGFILE" >/dev/null-- fi- end_func "Results are saved in vulns/iis-shortname/" "${FUNCNAME[0]}"- else- # Handle cases where IIS_SHORTNAME is false or the function has already been processed- if [[ $IIS_SHORTNAME == false ]]; then- printf "\n${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} skipped due to configuration settings.${reset}\n"- elif [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then- # Domain is an IP address; skip the function- return- else- printf "${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} has already been processed. To force execution, delete:\n $called_fn_dir/.${FUNCNAME[0]}${reset}\n\n"- fi- fi--}--function cms_scanner() {-- # Create necessary directories- if ! mkdir -p .tmp/fuzzing webs cms; then- printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"- return 1- fi-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $CMS_SCANNER == true ]] &&- ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then-- start_func "${FUNCNAME[0]}" "CMS Scanner"-- rm -rf "$dir/cms/"*-- # Handle multi mode and initialize webs.txt if necessary- if [[ -n $multi ]] && [[ ! -f "$dir/webs/webs.txt" ]]; then- printf "%b\n" "$domain" >"$dir/webs/webs.txt"- touch webs/webs_uncommon_ports.txt- fi-- # Combine webs.txt and webs_uncommon_ports.txt into webs_all.txt if it doesn't exist- if [[ ! -s "webs/webs_all.txt" ]]; then- cat webs/webs.txt webs/webs_uncommon_ports.txt 2>/dev/null | anew -q webs/webs_all.txt- fi-- # Combine webs_all.txt into .tmp/cms.txt as a comma-separated list- if [[ -s "webs/webs_all.txt" ]]; then- tr '\n' ',' <webs/webs_all.txt >.tmp/cms.txt 2>>"$LOGFILE"- else- end_func "No webs/webs_all.txt file found, cms scanner skipped." "${FUNCNAME[0]}"- return- fi-- # Run CMSeeK with timeout- if ! timeout -k 1m "${CMSSCAN_TIMEOUT}s" "${tools}/CMSeeK/venv/bin/python3" "${tools}/CMSeeK/cmseek.py" -l .tmp/cms.txt --batch -r &>>"$LOGFILE"; then- exit_status=$?- if [[ ${exit_status} -eq 124 || ${exit_status} -eq 137 ]]; then- echo "TIMEOUT cmseek.py - investigate manually for $dir" >>"$LOGFILE"- end_func "TIMEOUT cmseek.py - investigate manually for $dir" "${FUNCNAME[0]}"- return- elif [[ ${exit_status} -ne 0 ]]; then- echo "ERROR cmseek.py - investigate manually for $dir" >>"$LOGFILE"- end_func "ERROR cmseek.py - investigate manually for $dir" "${FUNCNAME[0]}"- return- fi- fi-- # Process CMSeeK results- while IFS= read -r sub; do- sub_out=$(echo "$sub" | sed -e 's|^[^/]*//||' -e 's|/.*$||')- cms_json_path="${tools}/CMSeeK/Result/${sub_out}/cms.json"-- if [[ -s $cms_json_path ]]; then- cms_id=$(jq -r 'try .cms_id' "$cms_json_path")- if [[ -n $cms_id ]]; then- mv -f "${tools}/CMSeeK/Result/${sub_out}" "$dir/cms/" 2>>"$LOGFILE"- else- rm -rf "${tools}/CMSeeK/Result/${sub_out}" 2>>"$LOGFILE"- fi- fi- done <"webs/webs_all.txt"-- end_func "Results are saved in $domain/cms/*subdomain* folder" "${FUNCNAME[0]}"- else- # Handle cases where CMS_SCANNER is false or the function has already been processed- if [[ $CMS_SCANNER == false ]]; then- pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"- elif [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then- # Domain is an IP address; skip the function- return- else- pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"- fi- fi-}--function urlchecks() {-- # Create necessary directories- if ! mkdir -p .tmp webs; then- printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"- return 1- fi-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $URL_CHECK == true ]]; then- start_func "${FUNCNAME[0]}" "URL Extraction"-- # Combine webs.txt and webs_uncommon_ports.txt if webs_all.txt doesn't exist- if [[ ! -s "webs/webs_all.txt" ]]; then- cat webs/webs.txt webs/webs_uncommon_ports.txt 2>/dev/null | anew -q webs/webs_all.txt- fi-- if [[ -s "webs/webs_all.txt" ]]; then-- if [[ $URL_CHECK_PASSIVE == true ]]; then- urlfinder -d $domain -all -o .tmp/url_extract_tmp.txt 2>>"$LOGFILE" >/dev/null- if [[ -s $GITHUB_TOKENS ]]; then- github-endpoints -q -k -d "$domain" -t "$GITHUB_TOKENS" -o .tmp/github-endpoints.txt 2>>"$LOGFILE" >/dev/null- if [[ -s ".tmp/github-endpoints.txt" ]]; then- cat .tmp/github-endpoints.txt | anew -q .tmp/url_extract_tmp.txt- fi- fi- fi-- if [[ $AXIOM != true ]]; then- diff_webs=$(diff <(sort -u .tmp/probed_tmp.txt 2>>"$LOGFILE") <(sort -u webs/webs_all.txt 2>>"$LOGFILE") | wc -l)- if [[ $diff_webs != "0" ]] || [[ ! -s ".tmp/katana.txt" ]]; then- if [[ $URL_CHECK_ACTIVE == true ]]; then- # Split slow vs normal targets based on httpx status (403/429)- >.tmp/katana_targets_slow.txt- >.tmp/katana_targets_normal.txt- if [[ -s .tmp/slow_hosts.txt ]]; then- while read -r host; do- grep "://${host}[:/\n]" webs/webs_all.txt | anew -q .tmp/katana_targets_slow.txt- done <.tmp/slow_hosts.txt- comm -23 <(sort -u webs/webs_all.txt) <(sort -u .tmp/katana_targets_slow.txt) >.tmp/katana_targets_normal.txt- else- cp webs/webs_all.txt .tmp/katana_targets_normal.txt- fi-- >.tmp/katana.txt- # Normal targets- if [[ -s .tmp/katana_targets_normal.txt ]]; then- LINES=$(wc -l <.tmp/katana_targets_normal.txt)- if [[ $LINES -gt ${CHUNK_LIMIT:-2000} ]]; then- if [[ $DEEP == true ]]; then- process_in_chunks .tmp/katana_targets_normal.txt ${CHUNK_LIMIT:-2000} "katana -silent -list _chunk_ -jc -kf all -c $KATANA_THREADS -d 3 -fs rdn >> .tmp/katana.txt 2>>\"$LOGFILE\" >/dev/null"- else- process_in_chunks .tmp/katana_targets_normal.txt ${CHUNK_LIMIT:-2000} "katana -silent -list _chunk_ -jc -kf all -c $KATANA_THREADS -d 2 -fs rdn >> .tmp/katana.txt 2>>\"$LOGFILE\" >/dev/null"- fi- else- if [[ $DEEP == true ]]; then- timeout 4h katana -silent -list .tmp/katana_targets_normal.txt -jc -kf all -c "$KATANA_THREADS" -d 3 -fs rdn >>.tmp/katana.txt 2>>"$LOGFILE" >/dev/null- else- timeout 3h katana -silent -list .tmp/katana_targets_normal.txt -jc -kf all -c "$KATANA_THREADS" -d 2 -fs rdn >>.tmp/katana.txt 2>>"$LOGFILE" >/dev/null- fi- fi- fi-- # Slow targets with reduced concurrency- if [[ -s .tmp/katana_targets_slow.txt ]]; then- slow_c=$((KATANA_THREADS / 3))- [[ $slow_c -lt 2 ]] && slow_c=2- LINES=$(wc -l <.tmp/katana_targets_slow.txt)- if [[ $LINES -gt ${CHUNK_LIMIT:-2000} ]]; then- if [[ $DEEP == true ]]; then- process_in_chunks .tmp/katana_targets_slow.txt ${CHUNK_LIMIT:-2000} "katana -silent -list _chunk_ -jc -kf all -c $slow_c -d 3 -fs rdn >> .tmp/katana.txt 2>>\"$LOGFILE\" >/dev/null"- else- process_in_chunks .tmp/katana_targets_slow.txt ${CHUNK_LIMIT:-2000} "katana -silent -list _chunk_ -jc -kf all -c $slow_c -d 2 -fs rdn >> .tmp/katana.txt 2>>\"$LOGFILE\" >/dev/null"- fi- else- if [[ $DEEP == true ]]; then- timeout 4h katana -silent -list .tmp/katana_targets_slow.txt -jc -kf all -c "$slow_c" -d 3 -fs rdn >>.tmp/katana.txt 2>>"$LOGFILE" >/dev/null- else- timeout 3h katana -silent -list .tmp/katana_targets_slow.txt -jc -kf all -c "$slow_c" -d 2 -fs rdn >>.tmp/katana.txt 2>>"$LOGFILE" >/dev/null- fi- fi- fi- fi- fi- else- diff_webs=$(diff <(sort -u .tmp/probed_tmp.txt) <(sort -u webs/webs_all.txt) | wc -l)- if [[ $diff_webs != "0" ]] || [[ ! -s ".tmp/katana.txt" ]]; then- if [[ $URL_CHECK_ACTIVE == true ]]; then- if [[ $DEEP == true ]]; then- axiom-scan webs/webs_all.txt -m katana -jc -kf all -d 3 -fs rdn --max-runtime 4h -o .tmp/katana.txt "$AXIOM_EXTRA_ARGS" 2>>"$LOGFILE" >/dev/null- else- axiom-scan webs/webs_all.txt -m katana -jc -kf all -d 2 -fs rdn --max-runtime 3h -o .tmp/katana.txt "$AXIOM_EXTRA_ARGS" 2>>"$LOGFILE" >/dev/null- fi- fi- fi- fi-- if [[ -s ".tmp/katana.txt" ]]; then- sed_i '/^.\{2048\}./d' .tmp/katana.txt- cat .tmp/katana.txt | anew -q .tmp/url_extract_tmp.txt- fi-- if [[ -s ".tmp/url_extract_tmp.txt" ]]; then- grep -a "$domain" .tmp/url_extract_tmp.txt | grep -aEo 'https?://[^ ]+' | grep -iE '\.js([?#].*)?$|\.js([/?&].*)' | anew -q .tmp/url_extract_js.txt- grep -a "$domain" .tmp/url_extract_tmp.txt | grep -aEo 'https?://[^ ]+' | grep -iE '\.map([/?#].*)?$' | anew -q .tmp/url_extract_jsmap.txt- if [[ $DEEP == true ]] && [[ -s ".tmp/url_extract_js.txt" ]]; then- interlace -tL .tmp/url_extract_js.txt -threads 10 -c "${tools}/JSA/venv/bin/python3 ${tools}/JSA/jsa.py -f _target_ | anew -q .tmp/url_extract_tmp.txt" &>/dev/null- fi-- grep -a "$domain" .tmp/url_extract_tmp.txt | grep -aEo 'https?://[^ ]+' | grep "=" | qsreplace -a 2>>"$LOGFILE" | grep -aEiv "\.(eot|jpg|jpeg|gif|css|tif|tiff|png|ttf|otf|woff|woff2|ico|pdf|svg)$" | anew -q .tmp/url_extract_tmp2.txt-- if [[ -s ".tmp/url_extract_tmp2.txt" ]]; then- urless <.tmp/url_extract_tmp2.txt | anew -q .tmp/url_extract_uddup.txt 2>>"$LOGFILE" >/dev/null- fi-- if [[ -s ".tmp/url_extract_uddup.txt" ]]; then- if ! NUMOFLINES=$(anew webs/url_extract.txt <.tmp/url_extract_uddup.txt | sed '/^$/d' | wc -l); then- printf "%b[!] Failed to update url_extract.txt.%b\n" "$bred" "$reset"- NUMOFLINES=0- fi- notification "${NUMOFLINES} new URLs with parameters" "info"- # Asset store: append new URLs- append_assets_from_file url value webs/url_extract.txt- else- NUMOFLINES=0- fi-- end_func "Results are saved in $domain/webs/url_extract.txt" "${FUNCNAME[0]}"-- p1radup -i webs/url_extract.txt -o webs/url_extract_nodupes.txt -s 2>>"$LOGFILE" >/dev/null-- if [[ $PROXY == true ]] && [[ -n $proxy_url ]] && [[ $(wc -l <webs/url_extract.txt) -le $DEEP_LIMIT2 ]]; then- notification "Sending URLs to proxy" "info"- ffuf -mc all -w webs/url_extract.txt -u FUZZ -replay-proxy "$proxy_url" 2>>"$LOGFILE" >/dev/null- fi- fi- fi- else- if [[ $URL_CHECK == false ]]; then- pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"- else- pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"- fi- fi--}--function url_gf() {-- # Create necessary directories- if ! mkdir -p .tmp webs gf; then- printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"- return 1- fi-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $URL_GF == true ]] &&- ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then-- start_func "${FUNCNAME[0]}" "Vulnerable Pattern Search"-- # Ensure webs/url_extract.txt exists and is not empty- if [[ -s "webs/url_extract.txt" ]]; then- # Define an array of GF patterns- declare -A gf_patterns=(- ["xss"]="gf/xss.txt"- ["ssti"]="gf/ssti.txt"- ["ssrf"]="gf/ssrf.txt"- ["sqli"]="gf/sqli.txt"- ["redirect"]="gf/redirect.txt"- ["rce"]="gf/rce.txt"- ["potential"]="gf/potential.txt"- ["lfi"]="gf/lfi.txt"- )-- # Iterate over GF patterns and process each- for pattern in "${!gf_patterns[@]}"; do- output_file="${gf_patterns[$pattern]}"- printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: GF Pattern '$pattern'${reset}\n\n"- if [[ $pattern == "potential" ]]; then- # Special handling for 'potential' pattern- gf "$pattern" "webs/url_extract.txt" | cut -d ':' -f3-5 | anew -q "$output_file"- elif [[ $pattern == "redirect" && -s "gf/ssrf.txt" ]]; then- # Append SSFR results to redirect if ssrf.txt exists- gf "$pattern" "webs/url_extract.txt" | anew -q "$output_file"- else- # General handling for other patterns- gf "$pattern" "webs/url_extract.txt" | anew -q "$output_file"- fi- done-- # Process endpoints extraction- if [[ -s ".tmp/url_extract_tmp.txt" ]]; then- printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Extracting endpoints...${reset}\n\n"- grep -aEiv "\.(eot|jpg|jpeg|gif|css|tif|tiff|png|ttf|otf|woff|woff2|ico|pdf|svg|txt|js)$" ".tmp/url_extract_tmp.txt" |- unfurl -u format '%s://%d%p' 2>>"$LOGFILE" | anew -q "gf/endpoints.txt"- fi-- else- end_func "No webs/url_extract.txt file found, URL_GF check skipped." "${FUNCNAME[0]}"- return- fi-- end_func "Results are saved in $domain/gf folder" "${FUNCNAME[0]}"- else- # Handle cases where URL_GF is false or the function has already been processed- if [[ $URL_GF == false ]]; then- printf "\n${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} skipped due to configuration settings.${reset}\n"- elif [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then- # Domain is an IP address; skip the function- return- else- printf "${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} has already been processed. To force execution, delete:\n $called_fn_dir/.${FUNCNAME[0]}${reset}\n\n"- fi- fi--}--function url_ext() {-- # Create necessary directories- if ! mkdir -p .tmp webs gf; then- printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"- return 1- fi-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $URL_EXT == true ]] &&- ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then-- if [[ -s ".tmp/url_extract_tmp.txt" ]]; then- start_func "${FUNCNAME[0]}" "Vulnerable Pattern Search"-- # Define an array of file extensions- ext=("7z" "achee" "action" "adr" "apk" "arj" "ascx" "asmx" "asp" "aspx" "axd" "backup" "bak" "bat" "bin" "bkf" "bkp" "bok" "cab" "cer" "cfg" "cfm" "cnf" "conf" "config" "cpl" "crt" "csr" "csv" "dat" "db" "dbf" "deb" "dmg" "dmp" "doc" "docx" "drv" "email" "eml" "emlx" "env" "exe" "gadget" "gz" "html" "ica" "inf" "ini" "iso" "jar" "java" "jhtml" "json" "jsp" "key" "log" "lst" "mai" "mbox" "mbx" "md" "mdb" "msg" "msi" "nsf" "ods" "oft" "old" "ora" "ost" "pac" "passwd" "pcf" "pdf" "pem" "pgp" "php" "php3" "php4" "php5" "phtm" "phtml" "pkg" "pl" "plist" "pst" "pwd" "py" "rar" "rb" "rdp" "reg" "rpm" "rtf" "sav" "sh" "shtm" "shtml" "skr" "sql" "swf" "sys" "tar" "tar.gz" "tmp" "toast" "tpl" "txt" "url" "vcd" "vcf" "wml" "wpd" "wsdl" "wsf" "xls" "xlsm" "xlsx" "xml" "xsd" "yaml" "yml" "z" "zip")-- # Initialize the output file- if ! : >webs/urls_by_ext.txt; then- printf "%b[!] Failed to initialize webs/urls_by_ext.txt.%b\n" "$bred" "$reset"- fi-- # Iterate over extensions and extract matching URLs- for t in "${ext[@]}"; do-- # Extract unique matching URLs- matches=$(grep -aEi "\.(${t})($|/|\?)" ".tmp/url_extract_tmp.txt" | sort -u | sed '/^$/d')-- NUMOFLINES=$(echo "$matches" | wc -l)-- if [[ $NUMOFLINES -gt 0 ]]; then- printf "\n############################\n + %s + \n############################\n" "$t" >>webs/urls_by_ext.txt- echo "$matches" >>webs/urls_by_ext.txt- fi- done-- # Append ssrf.txt to redirect.txt if ssrf.txt exists and is not empty- if [[ -s "gf/ssrf.txt" ]]; then- cat "gf/ssrf.txt" | anew -q "gf/redirect.txt"- fi-- end_func "Results are saved in $domain/webs/urls_by_ext.txt" "${FUNCNAME[0]}"-- else- end_func "No .tmp/url_extract_tmp.txt file found, URL_EXT check skipped." "${FUNCNAME[0]}"- fi-- else- # Handle cases where URL_EXT is false or function already processed- if [[ $URL_EXT == false ]]; then- printf "\n${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} skipped in this mode or defined in reconftw.cfg ${reset}\n"- elif [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then- # Domain is an IP address; skip the function- return- else- printf "${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} has already been processed. To force execution, delete:\n $called_fn_dir/.${FUNCNAME[0]}${reset}\n\n"- fi- fi--}--function jschecks() {-- # Create necessary directories- if ! mkdir -p .tmp webs subdomains js; then- printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"- return 1- fi-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $JSCHECKS == true ]]; then- start_func "${FUNCNAME[0]}" "JavaScript Scan"-- [[ ! -s ".tmp/url_extract_js.txt" ]] && cat js/url_extract_js.txt | anew -q .tmp/url_extract_js.txt-- if [[ -s ".tmp/url_extract_js.txt" ]]; then-- printf "%bRunning: Fetching URLs 1/6%b\n" "$yellow" "$reset"- if [[ $AXIOM != true ]]; then- subjs -ua "Mozilla/5.0 (X11; Linux x86_64; rv:72.0) Gecko/20100101 Firefox/72.0" -c 40 <.tmp/url_extract_js.txt |- grep "$domain" |- grep -aEo 'https?://[^ ]+' | anew -q .tmp/subjslinks.txt- else- axiom-scan .tmp/url_extract_js.txt -m subjs -o .tmp/subjslinks.txt "$AXIOM_EXTRA_ARGS" 2>>"$LOGFILE" >/dev/null- fi-- if [[ -s ".tmp/subjslinks.txt" ]]; then- grep -Eiv "\.(eot|jpg|jpeg|gif|css|tif|tiff|png|ttf|otf|woff|woff2|ico|pdf|svg|txt|js)$" .tmp/subjslinks.txt |- anew -q js/nojs_links.txt- grep -iE '\.js([?#].*)?$|\.js([/?&].*)' .tmp/subjslinks.txt | anew -q .tmp/url_extract_js.txt- fi-- urless <.tmp/url_extract_js.txt |- anew -q js/url_extract_js.txt 2>>"$LOGFILE" >/dev/null-- printf "%bRunning: Resolving JS URLs 2/6%b\n" "$yellow" "$reset"- if [[ $AXIOM != true ]]; then- if [[ -s "js/url_extract_js.txt" ]]; then- httpx -follow-redirects -random-agent -silent -timeout "$HTTPX_TIMEOUT" -threads "$HTTPX_THREADS" \- -rl "$HTTPX_RATELIMIT" -status-code -content-type -retries 2 -no-color <js/url_extract_js.txt |- grep "[200]" | grep "javascript" | cut -d ' ' -f1 | anew -q js/js_livelinks.txt- fi- else- if [[ -s "js/url_extract_js.txt" ]]; then- axiom-scan js/url_extract_js.txt -m httpx -follow-host-redirects -H "$HEADER" -status-code \- -threads "$HTTPX_THREADS" -rl "$HTTPX_RATELIMIT" -timeout "$HTTPX_TIMEOUT" -silent \- -content-type -retries 2 -no-color -o .tmp/js_livelinks.txt "$AXIOM_EXTRA_ARGS" 2>>"$LOGFILE" >/dev/null- if [[ -s ".tmp/js_livelinks.txt" ]]; then- cat .tmp/js_livelinks.txt | anew .tmp/web_full_info.txt |- grep "[200]" | grep "javascript" | cut -d ' ' -f1 | anew -q js/js_livelinks.txt- fi- fi- fi-- printf "%bRunning: Extracting JS from sourcemaps 3/6%b\n" "$yellow" "$reset"- if ! mkdir -p .tmp/sourcemapper; then- printf "%b[!] Failed to create sourcemapper directory.%b\n" "$bred" "$reset"- fi- if [[ -s "js/js_livelinks.txt" ]]; then- interlace -tL js/js_livelinks.txt -threads "$INTERLACE_THREADS" \- -c "sourcemapper -jsurl '_target_' -output _output_/_cleantarget_" \- -o .tmp/sourcemapper 2>>"$LOGFILE" >/dev/null- fi-- if [[ -s ".tmp/url_extract_jsmap.txt" ]]; then- interlace -tL js/url_extract_jsmap.txt -threads "$INTERLACE_THREADS" \- -c "sourcemapper -url '_target_' -output _output_/_cleantarget_" \- -o .tmp/sourcemapper 2>>"$LOGFILE" >/dev/null- fi-- find .tmp/sourcemapper/ \( -name "*.js" -o -name "*.ts" \) -type f |- jsluice urls | jq -r .url | anew -q .tmp/js_endpoints.txt-- printf "%bRunning: Gathering endpoints 4/6%b\n" "$yellow" "$reset"- if [[ -s "js/js_livelinks.txt" ]]; then- xnLinkFinder -i js/js_livelinks.txt -sf subdomains/subdomains.txt -d "$XNLINKFINDER_DEPTH" \- -o .tmp/js_endpoints.txt 2>>"$LOGFILE" >/dev/null- fi-- if [[ -s ".tmp/js_endpoints.txt" ]]; then- sed_i '/^\//!d' .tmp/js_endpoints.txt- cat .tmp/js_endpoints.txt | anew -q js/js_endpoints.txt- fi-- printf "%bRunning: Gathering secrets 5/6%b\n" "$yellow" "$reset"- if [[ -s "js/js_livelinks.txt" ]]; then- if [[ $AXIOM != true ]]; then- cat js/js_livelinks.txt | mantra -ua \"$HEADER\" -s | anew -q js/js_secrets.txt 2>>"$LOGFILE" >/dev/null- else- axiom-exec "go install github.com/Brosck/mantra@latest" 2>>"$LOGFILE" >/dev/null- axiom-scan js/js_livelinks.txt -m mantra -ua "$HEADER" -s -o js/js_secrets.txt "$AXIOM_EXTRA_ARGS" &>/dev/null- fi- mkdir -p .tmp/sourcemapper/secrets- for i in $(cat js/js_secrets.txt | cut -d' ' -f2); do wget -q -P .tmp/sourcemapper/secrets $i; done- trufflehog filesystem .tmp/sourcemapper/ -j 2>/dev/null | jq -c | anew -q js/js_secrets_jsmap.txt- find .tmp/sourcemapper/ -type f -name "*.js" | jsluice secrets -j --patterns=~/Tools/jsluice_patterns.json | anew -q js/js_secrets_jsmap_jsluice.txt- fi-- printf "%bRunning: Building wordlist 6/6%b\n" "$yellow" "$reset"- if [[ -s "js/js_livelinks.txt" ]]; then- interlace -tL js/js_livelinks.txt -threads "$INTERLACE_THREADS" \- -c "python3 ${tools}/getjswords.py '_target_' | anew -q webs/dict_words.txt" 2>>"$LOGFILE" >/dev/null- fi- end_func "Results are saved in $domain/js folder" "${FUNCNAME[0]}"- else- end_func "No JS files to process" "${FUNCNAME[0]}"- fi- else- if [[ $JSCHECKS == false ]]; then- pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"- else- pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"- fi- fi--}--function websocket_checks() {- mkdir -p webs vulns .tmp-- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $URL_CHECK == true ]]; then- start_func "${FUNCNAME[0]}" "WebSocket discovery and handshake"- # Collect ws/wss endpoints from JS endpoints and URLs- touch .tmp/ws_endpoints_raw.txt- [[ -s js/js_endpoints.txt ]] && grep -aEo 'wss?://[^ ]+' js/js_endpoints.txt | anew -q .tmp/ws_endpoints_raw.txt- [[ -s webs/url_extract.txt ]] && grep -aEo 'wss?://[^ ]+' webs/url_extract.txt | anew -q .tmp/ws_endpoints_raw.txt- if [[ -s .tmp/ws_endpoints_raw.txt ]]; then- # Normalize and de-dup- cat .tmp/ws_endpoints_raw.txt | sed 's/\"//g' | sed 's/[\]\[ ]//g' | sort -u >.tmp/ws_endpoints.txt- # Handshake test and origin check- while IFS= read -r ws; do- [[ -z $ws ]] && continue- url_no_proto=$(echo "$ws" | sed 's|^wss\?://||')- host=$(echo "$url_no_proto" | cut -d'/' -f1)- # Prepare Sec-WebSocket headers for accurate handshake- wskey=$(head -c 16 /dev/urandom | base64 2>/dev/null || echo dGVzdGtleQ==)- code=$(curl -sk --http1.1 -o /dev/null -w '%{http_code}' \- -H 'Connection: Upgrade' -H 'Upgrade: websocket' \- -H "Host: $host" \- -H "Sec-WebSocket-Key: $wskey" \- -H 'Sec-WebSocket-Version: 13' \- "$ws" || true)- if [[ $code == "101" ]]; then- printf "HANDSHAKE %s\n" "$ws" | anew -q vulns/websockets.txt- # Origin test: send a cross-origin header, expect failure ideally- wskey2=$(head -c 16 /dev/urandom | base64 2>/dev/null || echo dGVzdGtleQ==)- code2=$(curl -sk --http1.1 -o /dev/null -w '%{http_code}' \- -H 'Connection: Upgrade' -H 'Upgrade: websocket' \- -H "Origin: https://evil.example" -H "Host: $host" \- -H "Sec-WebSocket-Key: $wskey2" \- -H 'Sec-WebSocket-Version: 13' \- "$ws" || true)- if [[ $code2 == "101" ]]; then- printf "ORIGIN-ALLOWED %s\n" "$ws" | anew -q vulns/websocket_misconfig.txt- fi- fi- done <.tmp/ws_endpoints.txt- fi- end_func "Results are saved in vulns/websocket_misconfig.txt" "${FUNCNAME[0]}"- else- printf "\n${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} skipped or already processed.${reset}\n"- fi-}--function wordlist_gen() {-- # Create necessary directories- if ! mkdir -p .tmp webs; then- printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"- return 1- fi-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $WORDLIST == true ]] &&- ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then-- start_func "${FUNCNAME[0]}" "Wordlist Generation"-- [[ -s ".tmp/url_extract_tmp.txt" ]] && cat webs/url_extract.txt | anew -q .tmp/url_extract_tmp.txt- # Ensure url_extract_tmp.txt exists and is not empty- if [[ -s ".tmp/url_extract_tmp.txt" ]]; then- # Define patterns for keys and values- cat ".tmp/url_extract_tmp.txt" | unfurl -u keys 2>>"$LOGFILE" |- sed 's/[][]//g' | sed 's/[#]//g' | sed 's/[}{]//g' |- anew -q webs/dict_keys.txt-- cat ".tmp/url_extract_tmp.txt" | unfurl -u values 2>>"$LOGFILE" |- sed 's/[][]//g' | sed 's/[#]//g' | sed 's/[}{]//g' |- anew -q webs/dict_values.txt-- printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Extracting words...${reset}\n"- tr "[:punct:]" "\n" <".tmp/url_extract_tmp.txt" | anew -q "webs/dict_words.txt"- fi-- end_func "Results are saved in $domain/webs/dict_[words|paths].txt" "${FUNCNAME[0]}"-- else- # Handle cases where WORDLIST is false or function already processed- if [[ $WORDLIST == false ]]; then- printf "\n${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} skipped in this mode or defined in reconftw.cfg ${reset}\n"- elif [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then- # Domain is an IP address; skip the function- return- else- printf "${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} has already been processed. To force execution, delete:\n $called_fn_dir/.${FUNCNAME[0]}${reset}\n\n"- fi- fi--}--function wordlist_gen_roboxtractor() {-- # Create necessary directories- if ! mkdir -p .tmp webs gf; then- printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"- return 1- fi-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $ROBOTSWORDLIST == true ]] &&- ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then-- start_func "${FUNCNAME[0]}" "Robots Wordlist Generation"-- # Combine webs.txt and webs_uncommon_ports.txt into webs_all.txt if it doesn't exist- if [[ ! -s "webs/webs_all.txt" ]]; then- cat webs/webs.txt webs/webs_uncommon_ports.txt 2>/dev/null | anew -q "webs/webs_all.txt"- fi-- # Proceed only if webs_all.txt exists and is non-empty- if [[ -s "webs/webs_all.txt" ]]; then- # Extract URLs using roboxtractor and append unique entries to robots_wordlist.txt- printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: Roboxtractor for Robots Wordlist${reset}\n\n"- roboxtractor -m 1 -wb <"webs/webs_all.txt" 2>>"$LOGFILE" | anew -q "webs/robots_wordlist.txt"- else- end_func "No webs/webs_all.txt file found, Robots Wordlist generation skipped." "${FUNCNAME[0]}"- return- fi-- end_func "Results are saved in $domain/webs/robots_wordlist.txt" "${FUNCNAME[0]}"-- # Handle Proxy if conditions are met- if [[ $PROXY == true ]] && [[ -n $proxy_url ]] && [[ "$(wc -l <"webs/robots_wordlist.txt")" -le $DEEP_LIMIT2 ]]; then- notification "Sending URLs to proxy" info- ffuf -mc all -w "webs/robots_wordlist.txt" -u "FUZZ" -replay-proxy "$proxy_url" 2>>"$LOGFILE" >/dev/null- fi-- else- # Handle cases where ROBOTSWORDLIST is false or function already processed- if [[ $ROBOTSWORDLIST == false ]]; then- printf "\n${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} skipped due to configuration settings.${reset}\n"- elif [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then- # Domain is an IP address; skip the function- return- else- printf "${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} has already been processed. To force execution, delete:\n $called_fn_dir/.${FUNCNAME[0]}${reset}\n\n"- fi- fi--}--function password_dict() {-- # Create necessary directories- if ! mkdir -p "$dir/webs"; then- printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"- return 1- fi-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $PASSWORD_DICT == true ]] &&- ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then-- start_func "${FUNCNAME[0]}" "Password Dictionary Generation"-- # Extract the first part of the domain- word="${domain%%.*}"-- # Run pydictor.py with specified parameters- python3 "${tools}/pydictor/pydictor.py" -extend "$word" --leet 0 1 2 11 21 --len "$PASSWORD_MIN_LENGTH" "$PASSWORD_MAX_LENGTH" -o "$dir/webs/password_dict.txt" 2>>"$LOGFILE" >/dev/null- end_func "Results are saved in $domain/webs/password_dict.txt" "${FUNCNAME[0]}"-- # Optionally, create a marker file to indicate the function has been processed- touch "$called_fn_dir/.${FUNCNAME[0]}"-- else- # Handle cases where PASSWORD_DICT is false or function already processed- if [[ $PASSWORD_DICT == false ]]; then- printf "\n${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} skipped due to configuration settings.${reset}\n"- elif [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then- # Domain is an IP address; skip the function- return- else- printf "${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] ${FUNCNAME[0]} has already been processed. To force execution, delete:\n $called_fn_dir/.${FUNCNAME[0]}${reset}\n\n"- fi- fi--}--###############################################################################################################-######################################### VULNERABILITIES #####################################################-###############################################################################################################--function brokenLinks() {-- # Create necessary directories- if ! mkdir -p .tmp webs vulns; then- printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"- return 1- fi-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $BROKENLINKS == true ]] &&- ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then-- start_func "${FUNCNAME[0]}" "Broken Links Checks"-- # Combine webs.txt and webs_uncommon_ports.txt into webs_all.txt if it doesn't exist- if [[ ! -s "webs/webs_all.txt" ]]; then- cat webs/webs.txt webs/webs_uncommon_ports.txt 2>/dev/null | anew -q "webs/webs_all.txt"- fi-- # Check if webs_all.txt exists and is not empty- if [[ -s "webs/webs_all.txt" ]]; then- if [[ $AXIOM != true ]]; then- # Use katana for scanning- if [[ ! -s ".tmp/katana.txt" ]]; then- if [[ $DEEP == true ]]; then- timeout 4h katana -silent -list "webs/webs_all.txt" -jc -kf all -c "$KATANA_THREADS" -d 3 -o ".tmp/katana.txt" 2>>"$LOGFILE" >/dev/null- else- timeout 3h katana -silent -list "webs/webs_all.txt" -jc -kf all -c "$KATANA_THREADS" -d 2 -o ".tmp/katana.txt" 2>>"$LOGFILE" >/dev/null- fi- fi- # Remove lines longer than 2048 characters- if [[ -s ".tmp/katana.txt" ]]; then- sed_i '/^.\{2048\}./d' ".tmp/katana.txt"- fi- else- # Use axiom-scan for scanning- if [[ ! -s ".tmp/katana.txt" ]]; then- if [[ $DEEP == true ]]; then- axiom-scan "webs/webs_all.txt" -m katana -jc -kf all -d 3 --max-runtime 4h -o ".tmp/katana.txt" $AXIOM_EXTRA_ARGS 2>>"$LOGFILE" >/dev/null- else- axiom-scan "webs/webs_all.txt" -m katana -jc -kf all -d 2 --max-runtime 3h -o ".tmp/katana.txt" $AXIOM_EXTRA_ARGS 2>>"$LOGFILE" >/dev/null- fi- # Remove lines longer than 2048 characters- if [[ -s ".tmp/katana.txt" ]]; then- sed_i '/^.\{2048\}./d' ".tmp/katana.txt"- fi- fi- fi-- # Process katana.txt to find broken links- if [[ -s ".tmp/katana.txt" ]]; then- httpx -follow-redirects -random-agent -status-code -threads "$HTTPX_THREADS" -rl "$HTTPX_RATELIMIT" -timeout "$HTTPX_TIMEOUT" -silent -retries 2 -no-color <".tmp/katana.txt" 2>>"$LOGFILE" |- grep "\[4" | cut -d ' ' -f1 | anew -q ".tmp/brokenLinks_total.txt"- fi-- # Update brokenLinks.txt with unique entries- if [[ -s ".tmp/brokenLinks_total.txt" ]]; then- NUMOFLINES=$(wc -l <".tmp/brokenLinks_total.txt" 2>>"$LOGFILE" | awk '{print $1}')- cat .tmp/brokenLinks_total.txt | anew -q "vulns/brokenLinks.txt"- NUMOFLINES=$(sed '/^$/d' "vulns/brokenLinks.txt" | wc -l)- notification "${NUMOFLINES} new broken links found" info- fi-- end_func "Results are saved in vulns/brokenLinks.txt" "${FUNCNAME[0]}"- else- end_func "No webs/webs_all.txt file found, Broken Links check skipped." "${FUNCNAME[0]}"- return- fi- else- # Handle cases where BROKENLINKS is false or function already processed- if [[ $BROKENLINKS == false ]]; then- pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"- elif [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then- # Domain is an IP address; skip the function- return- else- pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"- fi- fi--}--function xss() {-- # Create necessary directories- if ! mkdir -p .tmp webs vulns; then- printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"- return 1- fi-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $XSS == true ]] && [[ -s "gf/xss.txt" ]] &&- ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then-- start_func "${FUNCNAME[0]}" "XSS Analysis"-- # Process gf/xss.txt with qsreplace and Gxss- if [[ -s "gf/xss.txt" ]]; then- printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: XSS Payload Generation${reset}\n\n"- qsreplace FUZZ <"gf/xss.txt" | sed '/FUZZ/!d' | Gxss -c 100 -p Xss | qsreplace FUZZ | sed '/FUZZ/!d' |- anew -q ".tmp/xss_reflected.txt"- fi-- # Determine whether to use Axiom or Katana for scanning- if [[ $AXIOM != true ]]; then- # Using Katana- if [[ $DEEP == true ]]; then- DEPTH=3- else- DEPTH=2- fi-- if [[ -n $XSS_SERVER ]]; then- OPTIONS="-b ${XSS_SERVER} -w $DALFOX_THREADS"- else- printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] No XSS_SERVER defined, blind XSS skipped\n\n"- OPTIONS="-w $DALFOX_THREADS"- fi-- # Run Dalfox with Katana output- if [[ -s ".tmp/xss_reflected.txt" ]]; then- printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: Dalfox with Katana${reset}\n\n"- dalfox pipe --silence --no-color --no-spinner --only-poc r --ignore-return 302,404,403 --skip-bav $OPTIONS -d "$DEPTH" <".tmp/xss_reflected.txt" 2>>"$LOGFILE" |- anew -q "vulns/xss.txt"- fi- else- # Using Axiom- if [[ $DEEP == true ]]; then- DEPTH=3- AXIOM_ARGS="$AXIOM_EXTRA_ARGS"- else- DEPTH=2- AXIOM_ARGS="$AXIOM_EXTRA_ARGS"- fi-- if [[ -n $XSS_SERVER ]]; then- OPTIONS="-b ${XSS_SERVER} -w $DALFOX_THREADS"- else- printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] No XSS_SERVER defined, blind XSS skipped\n\n"- OPTIONS="-w $DALFOX_THREADS"- fi-- # Run Dalfox with Axiom-scan output- if [[ -s ".tmp/xss_reflected.txt" ]]; then- printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: Dalfox with Axiom${reset}\n\n"- axiom-scan ".tmp/xss_reflected.txt" -m dalfox --skip-bav $OPTIONS -d "$DEPTH" -o "vulns/xss.txt" $AXIOM_ARGS 2>>"$LOGFILE" >/dev/null- fi- fi-- end_func "Results are saved in vulns/xss.txt" "${FUNCNAME[0]}"- else- # Handle cases where XSS is false, no vulnerable URLs, or already processed- if [[ $XSS == false ]]; then- pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"- elif [[ ! -s "gf/xss.txt" ]]; then- pt_msg_warn "${FUNCNAME[0]} skipped: no candidate URLs for XSS"- else- pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"- fi- fi--}--function cors() {-- # Create necessary directories- if ! mkdir -p .tmp webs vulns; then- printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"- return 1- fi-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $CORS == true ]] &&- ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then-- start_func "${FUNCNAME[0]}" "CORS Scan"-- # Combine webs.txt and webs_uncommon_ports.txt into webs_all.txt if it doesn't exist- if [[ ! -s "webs/webs_all.txt" ]]; then- cat webs/webs.txt webs/webs_uncommon_ports.txt 2>/dev/null | anew -q "webs/webs_all.txt"- fi-- # Proceed only if webs_all.txt exists and is non-empty- if [[ -s "webs/webs_all.txt" ]]; then- printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: Corsy for CORS Scan${reset}\n\n"- "${tools}/Corsy/venv/bin/python3" "${tools}/Corsy/corsy.py" -i "webs/webs_all.txt" -o "vulns/cors.txt" 2>>"$LOGFILE" >/dev/null- else- end_func "No webs/webs_all.txt file found, CORS Scan skipped." "${FUNCNAME[0]}"- return- fi-- end_func "Results are saved in vulns/cors.txt" "${FUNCNAME[0]}"-- else- # Handle cases where CORS is false, no vulnerable URLs, or already processed- if [[ $CORS == false ]]; then- pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"- elif [[ ! -s "gf/xss.txt" ]]; then- pt_msg_warn "${FUNCNAME[0]} skipped: no candidate URLs for CORS"- else- pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"- fi- fi--}--function open_redirect() {-- # Create necessary directories- if ! mkdir -p .tmp webs vulns; then- printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"- return 1- fi-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $OPEN_REDIRECT == true ]] &&- [[ -s "gf/redirect.txt" ]] && ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then-- start_func "${FUNCNAME[0]}" "Open Redirects Checks"-- # Determine whether to proceed based on DEEP flag or number of URLs- URL_COUNT=$(wc -l <"gf/redirect.txt")- if [[ $DEEP == true ]] || [[ $URL_COUNT -le $DEEP_LIMIT ]]; then-- printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: Open Redirects Payload Generation${reset}\n\n"-- # Process redirect.txt with qsreplace and filter lines containing 'FUZZ'- qsreplace FUZZ <"gf/redirect.txt" | sed '/FUZZ/!d' | anew -q ".tmp/tmp_redirect.txt"-- # Run Oralyzer with the generated payloads- "${tools}/Oralyzer/venv/bin/python3" "${tools}/Oralyzer/oralyzer.py" -l ".tmp/tmp_redirect.txt" -p "${tools}/Oralyzer/payloads.txt" >"vulns/redirect.txt" 2>>"$LOGFILE"-- # Remove ANSI color codes from the output- sed -r -i "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2})?)?[mGK]//g" "vulns/redirect.txt"-- end_func "Results are saved in vulns/redirect.txt" "${FUNCNAME[0]}"- else- end_func "Skipping Open Redirects: Too many URLs to test, try with --deep flag." "${FUNCNAME[0]}"- printf "${bgreen}#######################################################################${reset}\n"- fi- else- # Handle cases where OPEN_REDIRECT is false, no vulnerable URLs, or already processed- if [[ $OPEN_REDIRECT == false ]]; then- pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"- elif [[ ! -s "gf/redirect.txt" ]]; then- pt_msg_warn "${FUNCNAME[0]} skipped: no candidate URLs for open redirect"- else- pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"- fi- fi--}--function ssrf_checks() {-- # Create necessary directories- if ! mkdir -p .tmp gf vulns; then- printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"- return 1- fi-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $SSRF_CHECKS == true ]] &&- [[ -s "gf/ssrf.txt" ]] && ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then-- start_func "${FUNCNAME[0]}" "SSRF Checks"-- # Handle COLLAB_SERVER configuration- if [[ -z $COLLAB_SERVER ]]; then- interactsh-client &>.tmp/ssrf_callback.txt &- sleep 2-- # Extract FFUFHASH from interactsh_callback.txt- COLLAB_SERVER_FIX="FFUFHASH.$(tail -n1 .tmp/ssrf_callback.txt | cut -c 16-)"- COLLAB_SERVER_URL="http://$COLLAB_SERVER_FIX"- INTERACT=true- else- COLLAB_SERVER_FIX="FFUFHASH.$(echo "$COLLAB_SERVER" | sed -r "s|https?://||")"- INTERACT=false- fi-- # Determine whether to proceed based on DEEP flag or URL count- URL_COUNT=$(wc -l <"gf/ssrf.txt")- if [[ $DEEP == true ]] || [[ $URL_COUNT -le $DEEP_LIMIT ]]; then-- printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: SSRF Payload Generation${reset}\n\n"-- # Generate temporary SSRF payloads- qsreplace "$COLLAB_SERVER_FIX" <"gf/ssrf.txt" | anew -q ".tmp/tmp_ssrf.txt"-- qsreplace "$COLLAB_SERVER_URL" <"gf/ssrf.txt" | anew -q ".tmp/tmp_ssrf.txt"-- # Run FFUF to find requested URLs- printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: FFUF for SSRF Requested URLs${reset}\n\n"- ffuf -v -H "${HEADER}" -t "$FFUF_THREADS" -rate "$FFUF_RATELIMIT" -w ".tmp/tmp_ssrf.txt" -u "FUZZ" 2>/dev/null |- grep "URL" | sed 's/| URL | //' | anew -q "vulns/ssrf_requested_url.txt"-- # Run FFUF with header injection for SSRF- printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: FFUF for SSRF Requested Headers with COLLAB_SERVER_FIX${reset}\n\n"- ffuf -v -w ".tmp/tmp_ssrf.txt:W1,${tools}/headers_inject.txt:W2" -H "${HEADER}" -H "W2: ${COLLAB_SERVER_FIX}" -t "$FFUF_THREADS" \- -rate "$FFUF_RATELIMIT" -u "W1" 2>/dev/null | anew -q "vulns/ssrf_requested_headers.txt"-- printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: FFUF for SSRF Requested Headers with COLLAB_SERVER_URL${reset}\n\n"- ffuf -v -w ".tmp/tmp_ssrf.txt:W1,${tools}/headers_inject.txt:W2" -H "${HEADER}" -H "W2: ${COLLAB_SERVER_URL}" -t "$FFUF_THREADS" \- -rate "$FFUF_RATELIMIT" -u "W1" 2>/dev/null | anew -q "vulns/ssrf_requested_headers.txt"-- # Allow time for callbacks to be received- sleep 5-- # Process SSRF callback results if INTERACT is enabled- if [[ $INTERACT == true ]] && [[ -s ".tmp/ssrf_callback.txt" ]]; then- tail -n +11 .tmp/ssrf_callback.txt | anew -q "vulns/ssrf_callback.txt"- NUMOFLINES=$(tail -n +12 .tmp/ssrf_callback.txt | sed '/^$/d' | wc -l)- notification "SSRF: ${NUMOFLINES} callbacks received" info- fi-- end_func "Results are saved in vulns/ssrf_*" "${FUNCNAME[0]}"- else- end_func "Skipping SSRF: Too many URLs to test, try with --deep flag." "${FUNCNAME[0]}"- printf "${bgreen}#######################################################################${reset}\n"- fi-- # Terminate interactsh-client if it was started- if [[ $INTERACT == true ]]; then- pkill -f interactsh-client &- fi-- else- # Handle cases where SSRF_CHECKS is false, no vulnerable URLs, or already processed- if [[ $SSRF_CHECKS == false ]]; then- pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"- elif [[ ! -s "gf/ssrf.txt" ]]; then- pt_msg_warn "${FUNCNAME[0]} skipped: no candidate URLs for SSRF"- else- pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"- fi- fi--}--function crlf_checks() {-- # Create necessary directories- if ! mkdir -p webs vulns; then- printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"- return 1- fi-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $CRLF_CHECKS == true ]] &&- ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then-- start_func "${FUNCNAME[0]}" "CRLF Checks"-- # Combine webs.txt and webs_uncommon_ports.txt into webs_all.txt if it doesn't exist- if [[ ! -s "webs/webs_all.txt" ]]; then- cat webs/webs.txt webs/webs_uncommon_ports.txt 2>/dev/null | anew -q "webs/webs_all.txt"- fi-- # Determine whether to proceed based on DEEP flag or number of URLs- URL_COUNT=$(wc -l <"webs/webs_all.txt")- if [[ $DEEP == true ]] || [[ $URL_COUNT -le $DEEP_LIMIT ]]; then-- printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: CRLF Fuzzing${reset}\n\n"-- # Run CRLFuzz- crlfuzz -l "webs/webs_all.txt" -o "vulns/crlf.txt" 2>>"$LOGFILE" >/dev/null-- end_func "Results are saved in vulns/crlf.txt" "${FUNCNAME[0]}"- else- end_func "Skipping CRLF: Too many URLs to test, try with --deep flag." "${FUNCNAME[0]}"- fi- else- # Handle cases where CRLF_CHECKS is false, no vulnerable URLs, or already processed- if [[ $CRLF_CHECKS == false ]]; then- pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"- elif [[ ! -s "vulns/crlf.txt" ]]; then- pt_msg_warn "${FUNCNAME[0]} skipped: no candidate URLs for CRLF"- else- pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"- fi- fi--}--function lfi() {-- # Create necessary directories- if ! mkdir -p .tmp gf vulns; then- printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"- return 1- fi-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $LFI == true ]] &&- [[ -s "gf/lfi.txt" ]] && ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then-- start_func "${FUNCNAME[0]}" "LFI Checks"-- # Ensure gf/lfi.txt is not empty- if [[ -s "gf/lfi.txt" ]]; then- printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: LFI Payload Generation${reset}\n\n"-- # Process lfi.txt with qsreplace and filter lines containing 'FUZZ'- qsreplace "FUZZ" <"gf/lfi.txt" | sed '/FUZZ/!d' | anew -q ".tmp/tmp_lfi.txt"-- # Determine whether to proceed based on DEEP flag or number of URLs- URL_COUNT=$(wc -l <".tmp/tmp_lfi.txt")- if [[ $DEEP == true ]] || [[ $URL_COUNT -le $DEEP_LIMIT ]]; then-- printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: LFI Fuzzing with FFUF${reset}\n\n"-- # Use Interlace to parallelize FFUF scanning- interlace -tL ".tmp/tmp_lfi.txt" -threads "$INTERLACE_THREADS" -c "ffuf -v -r -t ${FFUF_THREADS} -rate ${FFUF_RATELIMIT} -H \"${HEADER}\" -w \"${lfi_wordlist}\" -u \"_target_\" -mr \"root:\" " 2>>"$LOGFILE" |- grep "URL" | sed 's/| URL | //' | anew -q "vulns/lfi.txt"-- end_func "Results are saved in vulns/lfi.txt" "${FUNCNAME[0]}"- else- end_func "Skipping LFI: Too many URLs to test, try with --deep flag." "${FUNCNAME[0]}"- fi- else- end_func "No gf/lfi.txt file found, LFI Checks skipped." "${FUNCNAME[0]}"- return- fi- else- # Handle cases where LFI is false, no vulnerable URLs, or already processed- if [[ $LFI == false ]]; then- pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"- elif [[ ! -s "gf/lfi.txt" ]]; then- pt_msg_warn "${FUNCNAME[0]} skipped: no candidate URLs for LFI"- else- pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"- fi- fi--}--function ssti() {-- # Create necessary directories- if ! mkdir -p .tmp gf vulns; then- printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"- return 1- fi-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $SSTI == true ]] &&- [[ -s "gf/ssti.txt" ]] && ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then-- start_func "${FUNCNAME[0]}" "SSTI Checks"-- # Ensure gf/ssti.txt is not empty- if [[ -s "gf/ssti.txt" ]]; then- printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: SSTI Payload Generation${reset}\n\n"-- # Process ssti.txt with qsreplace and filter lines containing 'FUZZ'- qsreplace "FUZZ" <"gf/ssti.txt" | sed '/FUZZ/!d' | anew -q ".tmp/tmp_ssti.txt"-- # Determine whether to proceed based on DEEP flag or number of URLs- URL_COUNT=$(wc -l <".tmp/tmp_ssti.txt")- if [[ $DEEP == true ]] || [[ $URL_COUNT -le $DEEP_LIMIT ]]; then-- printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: SSTI Fuzzing with FFUF${reset}\n\n"-- # Use Interlace to parallelize FFUF scanning- interlace -tL ".tmp/tmp_ssti.txt" -threads "$INTERLACE_THREADS" -c "ffuf -v -r -t ${FFUF_THREADS} -rate ${FFUF_RATELIMIT} -H \"${HEADER}\" -w \"${ssti_wordlist}\" -u \"_target_\" -mr \"ssti49\"" 2>>"$LOGFILE" |- grep "URL" | sed 's/| URL | //' | anew -q "vulns/ssti.txt"-- end_func "Results are saved in vulns/ssti.txt" "${FUNCNAME[0]}"- else- end_func "Skipping SSTI: Too many URLs to test, try with --deep flag." "${FUNCNAME[0]}"- fi- else- end_func "No gf/ssti.txt file found, SSTI Checks skipped." "${FUNCNAME[0]}"- return- fi- else- # Handle cases where SSTI is false, no vulnerable URLs, or already processed- if [[ $SSTI == false ]]; then- pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"- elif [[ ! -s "gf/ssti.txt" ]]; then- pt_msg_warn "${FUNCNAME[0]} skipped: no candidate URLs for SSTI"- else- pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"- fi- fi--}--function sqli() {-- # Create necessary directories- if ! mkdir -p .tmp gf vulns; then- printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"- return 1- fi-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $SQLI == true ]] &&- [[ -s "gf/sqli.txt" ]] && ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then-- start_func "${FUNCNAME[0]}" "SQLi Checks"-- # Ensure gf/sqli.txt is not empty- if [[ -s "gf/sqli.txt" ]]; then- printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: SQLi Payload Generation${reset}\n\n"-- # Process sqli.txt with qsreplace and filter lines containing 'FUZZ'- qsreplace "FUZZ" <"gf/sqli.txt" | sed '/FUZZ/!d' | anew -q ".tmp/tmp_sqli.txt"-- # Determine whether to proceed based on DEEP flag or number of URLs- URL_COUNT=$(wc -l <".tmp/tmp_sqli.txt")- if [[ $DEEP == true ]] || [[ $URL_COUNT -le $DEEP_LIMIT ]]; then-- # Check if SQLMAP is enabled and run SQLMap- if [[ $SQLMAP == true ]]; then- printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: SQLMap for SQLi Checks${reset}\n\n"- python3 "${tools}/sqlmap/sqlmap.py" -m ".tmp/tmp_sqli.txt" -b -o --smart \- --batch --disable-coloring --random-agent --output-dir="vulns/sqlmap" 2>>"$LOGFILE" >/dev/null- fi-- # Check if GHAURI is enabled and run Ghauri- if [[ $GHAURI == true ]]; then- printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: Ghauri for SQLi Checks${reset}\n\n"- interlace -tL ".tmp/tmp_sqli.txt" -threads "$INTERLACE_THREADS" -c "ghauri -u _target_ --batch -H \"${HEADER}\" --force-ssl >> vulns/ghauri_log.txt" 2>>"$LOGFILE" >/dev/null- fi-- end_func "Results are saved in vulns/sqlmap folder" "${FUNCNAME[0]}"- else- end_func "Skipping SQLi: Too many URLs to test, try with --deep flag." "${FUNCNAME[0]}"- fi- else- end_func "No gf/sqli.txt file found, SQLi Checks skipped." "${FUNCNAME[0]}"- return- fi- else- # Handle cases where SQLI is false, no vulnerable URLs, or already processed- if [[ $SQLI == false ]]; then- pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"- elif [[ ! -s "gf/sqli.txt" ]]; then- pt_msg_warn "${FUNCNAME[0]} skipped: no candidate URLs for SQLi"- else- pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"- fi- fi--}--function test_ssl() {-- # Create necessary directories- if ! mkdir -p hosts vulns; then- printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"- return 1- fi-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $TEST_SSL == true ]]; then-- start_func "${FUNCNAME[0]}" "SSL Test"-- # Handle multi-domain scenarios- if [[ -n $multi ]] && [[ ! -f "$dir/hosts/ips.txt" ]]; then- echo "$domain" >"$dir/hosts/ips.txt"- fi-- # Run testssl.sh- printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: SSL Test with testssl.sh${reset}\n\n"- "${tools}/testssl.sh/testssl.sh" --quiet --color 0 -U -iL "$dir/hosts/ips.txt" 2>>"$LOGFILE" >"vulns/testssl.txt"-- end_func "Results are saved in vulns/testssl.txt" "${FUNCNAME[0]}"-- else- # Handle cases where TEST_SSL is false, no vulnerable URLs, or already processed- if [[ $TEST_SSL == false ]]; then- pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"- elif [[ ! -s "vulns/testssl.txt" ]]; then- pt_msg_warn "${FUNCNAME[0]} skipped: no candidate targets for SSL tests"- else- pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"- fi- fi--}--function spraying() {-- # Create necessary directories- if ! mkdir -p "vulns"; then- printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"- return 1- fi-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $SPRAY == true ]] &&- [[ -s "$dir/hosts/portscan_active.gnmap" ]] && ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then-- start_func "${FUNCNAME[0]}" "Password Spraying"-- # Ensure portscan_active.gnmap exists and is not empty- if [[ ! -s "$dir/hosts/portscan_active.gnmap" ]]; then- printf "%b[!] File $dir/hosts/portscan_active.gnmap does not exist or is empty.%b\n" "$bred" "$reset"- end_func "Port scan results missing. Password Spraying aborted." "${FUNCNAME[0]}"- return 1- fi-- printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: Password Spraying with BruteSpray${reset}\n\n"-- # Run BruteSpray for password spraying- brutespray -f "$dir/hosts/portscan_active.gnmap" -T "$BRUTESPRAY_CONCURRENCE" -o "$dir/vulns/brutespray" 2>>"$LOGFILE" >/dev/null-- end_func "Results are saved in vulns/brutespray folder" "${FUNCNAME[0]}"-- else- # Handle cases where SPRAY is false, required files are missing, or already processed- if [[ $SPRAY == false ]]; then- pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"- elif [[ ! -s "$dir/hosts/portscan_active.gnmap" ]]; then- pt_msg_warn "${FUNCNAME[0]} skipped: missing active port scan"- else- pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"- fi- fi--}--function command_injection() {-- # Create necessary directories- if ! mkdir -p .tmp gf vulns; then- printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"- return 1- fi-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $COMM_INJ == true ]] &&- [[ -s "gf/rce.txt" ]] && ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then-- start_func "${FUNCNAME[0]}" "Command Injection Checks"-- # Ensure gf/rce.txt is not empty and process it- if [[ -s "gf/rce.txt" ]]; then- printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: Command Injection Payload Generation${reset}\n\n"-- # Process rce.txt with qsreplace and filter lines containing 'FUZZ'- qsreplace "FUZZ" <"gf/rce.txt" | sed '/FUZZ/!d' | anew -q ".tmp/tmp_rce.txt"-- # Determine whether to proceed based on DEEP flag or number of URLs- URL_COUNT=$(wc -l <".tmp/tmp_rce.txt")- if [[ $DEEP == true ]] || [[ $URL_COUNT -le $DEEP_LIMIT ]]; then-- # Run Commix if enabled- if [[ $COMM_INJ == true ]]; then- printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: Commix for Command Injection Checks${reset}\n\n"- commix --batch -m ".tmp/tmp_rce.txt" --output-dir "vulns/command_injection" 2>>"$LOGFILE" >/dev/null- fi-- # Additional tools can be integrated here (e.g., Ghauri, sqlmap)-- end_func "Results are saved in vulns/command_injection folder" "${FUNCNAME[0]}"- else- end_func "Skipping Command Injection: Too many URLs to test, try with --deep flag." "${FUNCNAME[0]}"- fi- else- end_func "No gf/rce.txt file found, Command Injection Checks skipped." "${FUNCNAME[0]}"- return- fi- else- # Handle cases where COMM_INJ is false, no vulnerable URLs, or already processed- if [[ $COMM_INJ == false ]]; then- pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"- elif [[ ! -s "gf/rce.txt" ]]; then- pt_msg_warn "${FUNCNAME[0]} skipped: no candidate URLs for command injection"- else- pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"- fi- fi--}--function 4xxbypass() {-- # Create necessary directories- if ! mkdir -p .tmp fuzzing vulns; then- printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"- return 1- fi-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $BYPASSER4XX == true ]] &&- ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then-- # Extract relevant URLs starting with 4xx but not 404- printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: 403 Bypass${reset}\n\n"- grep -E '^4' "fuzzing/fuzzing_full.txt" 2>/dev/null | grep -Ev '^404' | awk '{print $3}' | anew -q ".tmp/403test.txt"-- # Count the number of URLs to process- URL_COUNT=$(wc -l <".tmp/403test.txt")- if [[ $DEEP == true ]] || [[ $URL_COUNT -le $DEEP_LIMIT ]]; then-- start_func "${FUNCNAME[0]}" "403 Bypass"-- # Navigate to nomore403 tool directory- if ! pushd "${tools}/nomore403" >/dev/null; then- printf "%b[!] Failed to navigate to nomore403 directory.%b\n" "$bred" "$reset"- end_func "Failed to navigate to nomore403 directory during 403 Bypass." "${FUNCNAME[0]}"- return 1- fi-- # Run nomore403 on the processed URLs- ./nomore403 <"$dir/.tmp/403test.txt" >"$dir/.tmp/4xxbypass.txt" 2>>"$LOGFILE"-- # Return to the original directory- if ! popd >/dev/null; then- printf "%b[!] Failed to return to the original directory.%b\n" "$bred" "$reset"- end_func "Failed to return to the original directory during 403 Bypass." "${FUNCNAME[0]}"- return 1- fi-- # Append unique bypassed URLs to the vulns directory- if [[ -s "$dir/.tmp/4xxbypass.txt" ]]; then- cat "$dir/.tmp/4xxbypass.txt" | anew -q "vulns/4xxbypass.txt"- fi-- end_func "Results are saved in vulns/4xxbypass.txt" "${FUNCNAME[0]}"-- else- notification "Too many URLs to bypass, skipping" warn- end_func "Skipping Command Injection: Too many URLs to test, try with --deep flag." "${FUNCNAME[0]}"- fi-- else- # Handle cases where BYPASSER4XX is false, no vulnerable URLs, or already processed- if [[ $BYPASSER4XX == false ]]; then- pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"- elif [[ ! -s "fuzzing/fuzzing_full.txt" ]]; then- pt_msg_warn "${FUNCNAME[0]} skipped: no candidate URLs for 4xx bypass"- else- pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"- fi- fi--}--function prototype_pollution() {-- # Create necessary directories- if ! mkdir -p .tmp webs vulns; then- printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"- return 1- fi-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $PROTO_POLLUTION == true ]] &&- ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then-- start_func "${FUNCNAME[0]}" "Prototype Pollution Checks"-- # Determine whether to proceed based on DEEP flag or number of URLs- URL_COUNT=$(wc -l <"webs/url_extract_nodupes.txt" 2>/dev/null)- if [[ $DEEP == true ]] || [[ $URL_COUNT -le $DEEP_LIMIT ]]; then-- # Ensure fuzzing_full.txt exists and has content- if [[ -s "webs/url_extract_nodupes.txt" ]]; then- printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: Prototype Pollution Mapping${reset}\n\n"-- # Process URL list with ppmap and save results- ppmap <"webs/url_extract_nodupes.txt" >".tmp/prototype_pollution.txt" 2>>"$LOGFILE"-- # Filter and save relevant results- if [[ -s ".tmp/prototype_pollution.txt" ]]; then- grep "EXPL" ".tmp/prototype_pollution.txt" | anew -q "vulns/prototype_pollution.txt"- fi-- end_func "Results are saved in vulns/prototype_pollution.txt" "${FUNCNAME[0]}"- else- printf "%b[!] File webs/url_extract_nodupes.txt is missing or empty.%b\n" "$bred" "$reset"- end_func "File webs/url_extract_nodupes.txt is missing or empty." "${FUNCNAME[0]}"- return 1- fi-- else- end_func "Skipping Prototype Pollution: Too many URLs to test, try with --deep flag." "${FUNCNAME[0]}"- fi-- else- # Handle cases where PROTO_POLLUTION is false, no vulnerable URLs, or already processed- if [[ $PROTO_POLLUTION == false ]]; then- pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"- elif [[ ! -s "webs/url_extract_nodupes.txt" ]]; then- pt_msg_warn "${FUNCNAME[0]} skipped: no candidate URLs for prototype pollution"- else- pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"- fi- fi--}--function smuggling() {-- # Create necessary directories- if ! mkdir -p .tmp webs vulns/smuggling; then- printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"- return 1- fi-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $SMUGGLING == true ]] &&- ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then-- start_func "${FUNCNAME[0]}" "HTTP Request Smuggling Checks"-- # Combine webs.txt and webs_uncommon_ports.txt into webs_all.txt if it doesn't exist- if [[ ! -s "webs/webs_all.txt" ]]; then- cat "webs/webs.txt" "webs/webs_uncommon_ports.txt" 2>/dev/null | anew -q "webs/webs_all.txt"- fi-- # Determine whether to proceed based on DEEP flag or number of URLs- URL_COUNT=$(wc -l <"webs/webs_all.txt")- if [[ $DEEP == true ]] || [[ $URL_COUNT -le $DEEP_LIMIT ]]; then-- printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: HTTP Request Smuggling Checks${reset}\n\n"-- # Run smugglex on the list of URLs- cat "$dir/webs/webs_all.txt" | smugglex -f plain -o "$dir/.tmp/smuggling.txt" 2>>"$LOGFILE" >/dev/null-- # Append unique smuggling results to vulns directory- if [[ -s "$dir/.tmp/smuggling.txt" ]]; then- cat "$dir/.tmp/smuggling.txt" | jq -c 2>>"$LOGFILE" >/dev/null | anew -q "vulns/smuggling.txt"- fi-- end_func "Findings are saved in vulns/smuggling.txt" "${FUNCNAME[0]}"-- else- notification "Too many URLs to bypass, skipping" warn- end_func "Skipping HTTP Request Smuggling: Too many URLs to test, try with --deep flag." "${FUNCNAME[0]}"- fi-- else- # Handle cases where SMUGGLING is false, no vulnerable URLs, or already processed- if [[ $SMUGGLING == false ]]; then- pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"- elif [[ ! -s "webs/webs_all.txt" ]]; then- pt_msg_warn "${FUNCNAME[0]} skipped: no candidate URLs for HTTP request smuggling"- else- pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"- fi- fi--}--function webcache() {-- # Create necessary directories- if ! mkdir -p .tmp webs vulns; then- printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"- return 1- fi-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $WEBCACHE == true ]] &&- ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then-- start_func "${FUNCNAME[0]}" "Web Cache Poisoning Checks"-- # Combine webs.txt and webs_uncommon_ports.txt into webs_all.txt if it doesn't exist- if [[ ! -s "webs/webs_all.txt" ]]; then- cat webs/webs.txt webs/webs_uncommon_ports.txt 2>/dev/null | anew -q "webs/webs_all.txt"- fi-- # Determine whether to proceed based on DEEP flag or number of URLs- URL_COUNT=$(wc -l <"webs/webs_all.txt")- if [[ $DEEP == true ]] || [[ $URL_COUNT -le $DEEP_LIMIT ]]; then-- printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: Web Cache Poisoning Checks${reset}\n\n"-- # Navigate to Web-Cache-Vulnerability-Scanner tool directory- if ! pushd "${tools}/Web-Cache-Vulnerability-Scanner" >/dev/null; then- printf "%b[!] Failed to navigate to Web-Cache-Vulnerability-Scanner directory.%b\n" "$bred" "$reset"- end_func "Failed to navigate to Web-Cache-Vulnerability-Scanner directory during Web Cache Poisoning Checks." "${FUNCNAME[0]}"- return 1- fi-- # Run the Web-Cache-Vulnerability-Scanner- Web-Cache-Vulnerability-Scanner -u "file:$dir/webs/webs_all.txt" -v 0 2>>"$LOGFILE" |- anew -q "$dir/.tmp/webcache.txt"-- # Return to the original directory- if ! popd >/dev/null; then- printf "%b[!] Failed to return to the original directory.%b\n" "$bred" "$reset"- end_func "Failed to return to the original directory during Web Cache Poisoning Checks." "${FUNCNAME[0]}"- return 1- fi-- # Append unique findings to vulns/webcache.txt- if [[ -s "$dir/.tmp/webcache.txt" ]]; then- cat "$dir/.tmp/webcache.txt" | anew -q "vulns/webcache.txt"- fi-- end_func "Results are saved in vulns/webcache.txt" "${FUNCNAME[0]}"-- else- end_func "Skipping Web Cache Poisoning: Too many URLs to test, try with --deep flag." "${FUNCNAME[0]}"- fi-- else- # Handle cases where WEBCACHE is false, no vulnerable URLs, or already processed- if [[ $WEBCACHE == false ]]; then- pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"- elif [[ ! -s "fuzzing/fuzzing_full.txt" ]]; then- pt_msg_warn "${FUNCNAME[0]} skipped: no candidate URLs for web cache tests"- else- pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"- fi- fi--}--function fuzzparams() {-- # Create necessary directories- if ! mkdir -p .tmp webs vulns; then- printf "%b[!] Failed to create directories.%b\n" "$bred" "$reset"- return 1- fi-- # Check if the function should run- if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $FUZZPARAMS == true ]] &&- ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then-- start_func "${FUNCNAME[0]}" "Fuzzing Parameters Values Checks"-- # Determine if we should proceed based on DEEP flag or number of URLs- URL_COUNT=$(wc -l <"webs/url_extract_nodupes.txt")- if [[ $DEEP == true ]] || [[ $URL_COUNT -le $DEEP_LIMIT2 ]]; then-- #cent update -p ${NUCLEI_TEMPLATES_PATH} &>/dev/null-- if [[ $AXIOM != true ]]; then- printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: Nuclei Setup and Execution${reset}\n\n"-- # Update Nuclei once per run- maybe_update_nuclei-- # Pull latest fuzzing templates- if ! git -C ${NUCLEI_FUZZING_TEMPLATES_PATH} pull 2>>"$LOGFILE"; then- printf "%b[!] Failed to pull latest fuzzing templates.%b\n" "$bred" "$reset"- end_func "Failed to pull latest fuzzing templates." "${FUNCNAME[0]}"- return 1- fi-- # Execute Nuclei with the fuzzing templates- nuclei -l webs/url_extract_nodupes.txt -nh -rl "$NUCLEI_RATELIMIT" -silent -retries 2 ${NUCLEI_EXTRA_ARGS} -t ${NUCLEI_TEMPLATES_PATH}/dast -dast -j -o ".tmp/fuzzparams_json.txt" <"webs/url_extract_nodupes.txt" 2>>"$LOGFILE" >/dev/null-- else- printf "${yellow}\n[$(date +'%Y-%m-%d %H:%M:%S')] Running: Axiom with Nuclei${reset}\n\n"-- axiom-scan webs/url_extract_nodupes.txt -m nuclei \- -dast -nh -rl "$NUCLEI_RATELIMIT" \- -silent -retries 2 "$NUCLEI_EXTRA_ARGS" -dast -j -o ".tmp/fuzzparams_json.txt" $AXIOM_EXTRA_ARGS 2>>"$LOGFILE" >/dev/null- fi-- # Convert JSON output to text- jq -r '["[" + .["template-id"] + (if .["matcher-name"] != null then ":" + .["matcher-name"] else "" end) + "] [" + .["type"] + "] [" + .info.severity + "] " + (.["matched-at"] // .host) + (if .["extracted-results"] != null then " " + (.["extracted-results"] | @json) else "" end)] | .[]' .tmp/fuzzparams_json.txt >.tmp/fuzzparams.txt-- # Append unique results to vulns/fuzzparams.txt- if [[ -s ".tmp/fuzzparams.txt" ]]; then- cat ".tmp/fuzzparams.txt" | anew -q "vulns/fuzzparams.txt"- fi-- # Faraday integration- if [[ $FARADAY == true ]]; then- # Check if the Faraday server is running- if ! faraday-cli status 2>>"$LOGFILE" >/dev/null; then- printf "%b[!] Faraday server is not running. Skipping Faraday integration.%b\n" "$bred" "$reset"- else- if [[ -s ".tmp/fuzzparams_json.txt" ]]; then- faraday-cli tool report -w $FARADAY_WORKSPACE --plugin-id nuclei .tmp/fuzzparams_json.txt 2>>"$LOGFILE" >/dev/null- fi- fi- fi-- end_func "Results are saved in vulns/fuzzparams.txt" "${FUNCNAME[0]}"-- else- end_func "Fuzzing Parameters Values: Too many entries to test, try with --deep flag" "${FUNCNAME[0]}"- fi-- else- # Handle cases where FUZZPARAMS is false, no vulnerable URLs, or already processed- if [[ $FUZZPARAMS == false ]]; then- pt_msg_warn "${FUNCNAME[0]} skipped due to configuration"- elif [[ ! -s "webs/url_extract_nodupes.txt" ]]; then- pt_msg_warn "${FUNCNAME[0]} skipped: no candidate URLs for parameter fuzzing"- else- pt_msg_warn "${FUNCNAME[0]} already processed. To force, delete ${called_fn_dir}/.${FUNCNAME[0]}"- fi- fi--}--###############################################################################################################-########################################## OPTIONS & MGMT #####################################################-###############################################################################################################--function deleteOutScoped() {- if [[ -s "$1" ]]; then- while IFS= read -r outscoped; do- [[ -z "$outscoped" ]] && continue- # Escape regex metacharacters to prevent injection- local escaped- escaped=$(printf '%s' "$outscoped" | sed 's/[.[\*^$()+?{|\\]/\\&/g')- if grep -q "^[*]" <<<"$outscoped"; then- escaped=$(printf '%s' "${outscoped:1}" | sed 's/[.[\*^$()+?{|\\]/\\&/g')- sed_i "/${escaped}$/d" "$2"- else- sed_i "/${escaped}/d" "$2"- fi- done < "$1"- fi-}--function cleanup_on_exit() {- printf "\n%b[%s] Interrupted. Cleaning up...%b\n" "$bred" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"- # Clean temporary chunk files- rm -rf -- "${dir:-.}/.tmp/chunks" 2>/dev/null- # Kill any background processes we spawned- jobs -p 2>/dev/null | xargs -r kill 2>/dev/null || true- # Log the interruption- echo "[$(date +'%Y-%m-%d %H:%M:%S')] Interrupted by signal" >>"${LOGFILE:-/dev/null}"- exit 130-}--function rotate_logs() {- local log_dir="$1"- local max_logs="${2:-10}"- local max_age_days="${3:-30}"-- [[ ! -d "$log_dir" ]] && return 0-- # Delete logs older than max_age_days- find "$log_dir" -name "*.txt" -type f -mtime +"${max_age_days}" -delete 2>/dev/null || true-- # If still too many, keep only the newest max_logs- local count- count=$(find "$log_dir" -name "*.txt" -type f 2>/dev/null | wc -l)- if [[ $count -gt $max_logs ]]; then- find "$log_dir" -name "*.txt" -type f -printf '%T@ %p\n' 2>/dev/null |- sort -n | head -n $((count - max_logs)) | cut -d' ' -f2- |- xargs -r rm -f -- 2>/dev/null || true- fi-}--function sanitize_interlace_input() {- # Remove lines containing shell metacharacters that could be exploited- # via interlace template substitution (_target_, _output_, _cleantarget_)- local infile="$1"- local outfile="${2:-$1}"- if [[ "$infile" == "$outfile" ]]; then- local tmpfile- tmpfile=$(mktemp)- grep -v '[;|&$`\\(){}]' "$infile" > "$tmpfile" 2>/dev/null || true- mv "$tmpfile" "$outfile"- else- grep -v '[;|&$`\\(){}]' "$infile" > "$outfile" 2>/dev/null || true- fi-}--function validate_config() {- local warnings=0- local errors=0-- # Check conflicting configs- if [[ ${VULNS_GENERAL:-false} == true && ${SUBDOMAINS_GENERAL:-false} == false ]]; then- printf "%b[WARN] VULNS_GENERAL=true but SUBDOMAINS_GENERAL=false -- vulnerability scans need subdomain data%b\n" "$yellow" "$reset"- warnings=$((warnings + 1))- fi-- # Validate numeric thread/rate variables- for var in FFUF_THREADS HTTPX_THREADS DALFOX_THREADS KATANA_THREADS HTTPX_RATELIMIT NUCLEI_RATELIMIT FFUF_RATELIMIT; do- if [[ -n "${!var:-}" && ! "${!var}" =~ ^[0-9]+$ ]]; then- printf "%b[ERROR] %s must be numeric, got: %s%b\n" "$bred" "$var" "${!var}" "$reset"- errors=$((errors + 1))- fi- done-- # Check Axiom tool availability if enabled- if [[ ${AXIOM:-false} == true ]] && ! command -v axiom-scan >/dev/null 2>&1; then- printf "%b[WARN] AXIOM=true but axiom-scan not found in PATH%b\n" "$yellow" "$reset"- warnings=$((warnings + 1))- fi-- if [[ $errors -gt 0 ]]; then- printf "%b[ERROR] Configuration has %d error(s). Please fix before running.%b\n" "$bred" "$errors" "$reset"- return $E_CONFIG- fi- if [[ $warnings -gt 0 ]]; then- printf "%b[INFO] Configuration has %d warning(s).%b\n" "$yellow" "$warnings" "$reset"- fi- return 0-}--function getElapsedTime {- runtime=""- local T=$2-$1- local D=$((T / 60 / 60 / 24))- local H=$((T / 60 / 60 % 24))- local M=$((T / 60 % 60))- local S=$((T % 60))- ((D > 0)) && runtime="$runtime$D days, "- ((H > 0)) && runtime="$runtime$H hours, "- ((M > 0)) && runtime="$runtime$M minutes, "- runtime="$runtime$S seconds."-}--# Retry with exponential backoff-# Usage: retry_with_backoff <max_attempts> <command> [args...]-# Example: retry_with_backoff 3 curl -s "https://example.com"-function retry_with_backoff() {- local max_attempts="$1"- shift- local attempt=1- local delay=1- local max_delay=60-- while [ $attempt -le "$max_attempts" ]; do- if "$@"; then- return 0- fi-- if [ $attempt -lt "$max_attempts" ]; then- printf "%b[%s] Attempt %d/%d failed. Retrying in %d seconds...%b\n" \- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "$attempt" "$max_attempts" "$delay" "$reset" >>"$LOGFILE"- sleep "$delay"-- # Exponential backoff with max cap- delay=$((delay * 2))- if [ $delay -gt $max_delay ]; then- delay=$max_delay- fi- fi-- attempt=$((attempt + 1))- done-- printf "%b[%s] Command failed after %d attempts: %s%b\n" \- "$bred" "$(date +'%Y-%m-%d %H:%M:%S')" "$max_attempts" "$*" "$reset" >>"$LOGFILE"- return 1-}--# Check available disk space-# Usage: check_disk_space <required_gb> <path>-# Returns 0 if enough space, 1 otherwise-function check_disk_space() {- local required_gb="$1"- local check_path="${2:-.}"-- # Get available space in GB- local available_gb- if [[ "$OSTYPE" == "darwin"* ]]; then- # macOS- available_gb=$(df -g "$check_path" | awk 'NR==2 {print $4}')- else- # Linux- available_gb=$(df -BG "$check_path" | awk 'NR==2 {gsub(/G/, "", $4); print $4}')- fi-- if [ -z "$available_gb" ] || [ "$available_gb" -lt "$required_gb" ]; then- printf "%b[%s] WARNING: Insufficient disk space. Required: %dGB, Available: %dGB at %s%b\n" \- "$bred" "$(date +'%Y-%m-%d %H:%M:%S')" "$required_gb" "${available_gb:-0}" "$check_path" "$reset"- return 1- fi-- printf "%b[%s] Disk space OK: %dGB available at %s%b\n" \- "$bgreen" "$(date +'%Y-%m-%d %H:%M:%S')" "$available_gb" "$check_path" "$reset"- return 0-}--# Show progress bar for operations-# Usage: progress_bar <current> <total> <message>-function progress_bar() {- local current=$1- local total=$2- local message="${3:-Processing}"- local width=50-- # Calculate percentage- local percent=$((current * 100 / total))- local filled=$((width * current / total))- local empty=$((width - filled))-- # Build progress bar- local bar=""- for ((i=0; i<filled; i++)); do bar="${bar}█"; done- for ((i=0; i<empty; i++)); do bar="${bar}░"; done-- # Print progress (using \r to overwrite the line)- printf "\r%b[%s] %s [%s] %d%% (%d/%d)%b" \- "$bblue" "$(date +'%Y-%m-%d %H:%M:%S')" "$message" "$bar" "$percent" "$current" "$total" "$reset"-- # Print newline when complete- if [ "$current" -eq "$total" ]; then- printf "\n"- fi-}--# Execute command in dry-run mode if enabled-# Usage: run_command <command> [args...]-function run_command() {- if [[ "${DRY_RUN:-false}" == "true" ]]; then- printf "%b[DRY-RUN] Would execute: %s%b\n" "$yellow" "$*" "$reset"- return 0- else- "$@"- fi-}--# Cross-platform sed_i wrapper-# Usage: sed_i 's/old/new/g' file.txt-# Works on both macOS (BSD sed) and Linux (GNU sed)-function sed_i() {- if [[ $# -lt 2 ]]; then- echo "Usage: sed_i 'pattern' file" >&2- return 1- fi-- local pattern="$1"- local file="$2"-- # Check if we're using GNU sed or BSD sed- if sed --version >/dev/null 2>&1; then- # GNU sed (Linux or installed via brew on macOS)- sed -i "$pattern" "$file"- else- # BSD sed (default macOS)- sed -i '' "$pattern" "$file"- fi-}--###############################################################################################################-#################################### RATE LIMITING ADAPTATIVO #################################################-###############################################################################################################--# Adaptive rate limiting - detects rate limit errors and adjusts automatically-# Global variables for rate limiting-ADAPTIVE_RATE_LIMIT=${ADAPTIVE_RATE_LIMIT:-false}-CURRENT_RATE_LIMIT=${NUCLEI_RATELIMIT:-150}-MIN_RATE_LIMIT=10-MAX_RATE_LIMIT=500-RATE_LIMIT_BACKOFF_FACTOR=0.5-RATE_LIMIT_INCREASE_FACTOR=1.2--# Detect rate limit errors in command output-# Usage: detect_rate_limit_error <output_file_or_string>-function detect_rate_limit_error() {- local output="$1"-- # Check for common rate limit indicators- if grep -qiE "(429|too many requests|rate limit|limit exceeded|503|service unavailable)" <<< "$output"; then- return 0 # Rate limit detected- fi- return 1 # No rate limit detected-}--# Adjust rate limit based on errors-# Usage: adjust_rate_limit <increase|decrease>-function adjust_rate_limit() {- local action="$1"-- [[ "$ADAPTIVE_RATE_LIMIT" != "true" ]] && return 0-- case "$action" in- decrease)- local new_limit=$(awk "BEGIN {printf \"%.0f\", $CURRENT_RATE_LIMIT * $RATE_LIMIT_BACKOFF_FACTOR}")- if [ "$new_limit" -lt "$MIN_RATE_LIMIT" ]; then- new_limit=$MIN_RATE_LIMIT- fi- CURRENT_RATE_LIMIT=$new_limit- printf "%b[%s] Rate limit decreased to %d req/s due to errors%b\n" \- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "$CURRENT_RATE_LIMIT" "$reset" | tee -a "$LOGFILE"- ;;- increase)- local new_limit=$(awk "BEGIN {printf \"%.0f\", $CURRENT_RATE_LIMIT * $RATE_LIMIT_INCREASE_FACTOR}")- if [ "$new_limit" -gt "$MAX_RATE_LIMIT" ]; then- new_limit=$MAX_RATE_LIMIT- fi- CURRENT_RATE_LIMIT=$new_limit- printf "%b[%s] Rate limit increased to %d req/s%b\n" \- "$bgreen" "$(date +'%Y-%m-%d %H:%M:%S')" "$CURRENT_RATE_LIMIT" "$reset" >> "$LOGFILE"- ;;- esac-- # Update tool-specific rate limits- NUCLEI_RATELIMIT=$CURRENT_RATE_LIMIT- FFUF_RATELIMIT=$CURRENT_RATE_LIMIT- HTTPX_RATELIMIT=$CURRENT_RATE_LIMIT-}--# Execute command with adaptive rate limiting-# Usage: run_with_adaptive_rate <command> [args...]-function run_with_adaptive_rate() {- [[ "$ADAPTIVE_RATE_LIMIT" != "true" ]] && { "$@"; return $?; }-- local max_retries=3- local retry=0- local temp_output=$(mktemp)-- while [ $retry -lt $max_retries ]; do- if "$@" 2>&1 | tee "$temp_output"; then- # Command succeeded, check if we can increase rate- if [ $retry -eq 0 ]; then- adjust_rate_limit increase- fi- rm -f "$temp_output"- return 0- fi-- # Check if failure was due to rate limiting- if detect_rate_limit_error "$(cat "$temp_output")"; then- adjust_rate_limit decrease- retry=$((retry + 1))- if [ $retry -lt $max_retries ]; then- printf "%b[%s] Retrying with lower rate limit (%d/%d)...%b\n" \- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "$retry" "$max_retries" "$reset" | tee -a "$LOGFILE"- sleep 2- fi- else- # Non rate-limit error, don't retry- rm -f "$temp_output"- return 1- fi- done-- rm -f "$temp_output"- return 1-}--###############################################################################################################-####################################### SECURITY ################################################-###############################################################################################################--# Sanitize domain input to prevent command injection-# Usage: sanitize_domain <domain>-# Returns: sanitized domain string-function sanitize_domain() {- local input_domain="$1"-- # Remove any characters that are not alphanumeric, dots, or hyphens- # This prevents command injection via malicious domain names- local sanitized=$(echo "$input_domain" | tr -cd 'a-zA-Z0-9.-')-- # Additional validations- # Remove leading/trailing dots and hyphens- sanitized=$(echo "$sanitized" | sed 's/^[.-]*//; s/[.-]*$//')-- # Check if domain is empty after sanitization- if [[ -z "$sanitized" ]]; then- printf "%b[%s] ERROR: Invalid domain after sanitization: '%s'%b\n" \- "$bred" "$(date +'%Y-%m-%d %H:%M:%S')" "$input_domain" "$reset" >&2- return 1- fi-- # Check for basic domain format (at least one dot for TLD)- if [[ ! "$sanitized" =~ \. ]]; then- printf "%b[%s] WARNING: Domain '%s' has no TLD, may be invalid%b\n" \- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "$sanitized" "$reset" >&2- fi-- # If sanitization removed characters, warn user- if [[ "$input_domain" != "$sanitized" ]]; then- printf "%b[%s] INFO: Domain sanitized from '%s' to '%s'%b\n" \- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "$input_domain" "$sanitized" "$reset" >&2- fi-- echo "$sanitized"- return 0-}--# Validate and sanitize IP/CIDR input-# Usage: sanitize_ip <ip_or_cidr>-function sanitize_ip() {- local input="$1"-- # Allow digits, dots, and slash for CIDR- local sanitized=$(echo "$input" | tr -cd '0-9./,')-- if [[ -z "$sanitized" ]]; then- printf "%b[%s] ERROR: Invalid IP/CIDR after sanitization: '%s'%b\n" \- "$bred" "$(date +'%Y-%m-%d %H:%M:%S')" "$input" "$reset" >&2- return 1- fi-- echo "$sanitized"- return 0-}--###############################################################################################################-####################################### CACHÉ DE RECURSOS #####################################################-###############################################################################################################--CACHE_DIR="${SCRIPTPATH}/.cache"-CACHE_MAX_AGE_DAYS=30 # 1 month--# Initialize cache directory-function cache_init() {- mkdir -p "$CACHE_DIR"/{wordlists,resolvers,tools}-}--# Check if cached file is still valid (less than 30 days old)-# Usage: cache_is_valid <cache_file>-# Returns: 0 if valid, 1 if expired or missing-function cache_is_valid() {- local cache_file="$1"-- [[ ! -f "$cache_file" ]] && return 1-- # Get file age in days- local file_age_seconds- if [[ "$OSTYPE" == "darwin"* ]]; then- # macOS- file_age_seconds=$(( $(date +%s) - $(stat -f %m "$cache_file") ))- else- # Linux- file_age_seconds=$(( $(date +%s) - $(stat -c %Y "$cache_file") ))- fi-- local file_age_days=$((file_age_seconds / 86400))-- if [ $file_age_days -lt $CACHE_MAX_AGE_DAYS ]; then- printf "%b[%s] Using cached file (age: %d days): %s%b\n" \- "$bgreen" "$(date +'%Y-%m-%d %H:%M:%S')" "$file_age_days" "$(basename "$cache_file")" "$reset" >> "$LOGFILE"- return 0- else- printf "%b[%s] Cache expired (age: %d days): %s%b\n" \- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "$file_age_days" "$(basename "$cache_file")" "$reset" >> "$LOGFILE"- return 1- fi-}--# Download file with caching support-# Usage: cached_download <url> <destination> [cache_name]-# If cache exists and is valid, copies from cache instead of downloading-function cached_download() {- local url="$1"- local destination="$2"- local cache_name="${3:-$(basename "$url")}"- local cache_file="$CACHE_DIR/$cache_name"-- cache_init-- # Check if we have valid cached version- if cache_is_valid "$cache_file"; then- cp "$cache_file" "$destination"- return 0- fi-- # Download fresh copy- printf "%b[%s] Downloading: %s%b\n" \- "$bblue" "$(date +'%Y-%m-%d %H:%M:%S')" "$(basename "$url")" "$reset"-- if curl -sL "$url" -o "$destination"; then- # Save to cache for future use- cp "$destination" "$cache_file"- printf "%b[%s] Cached for future use: %s%b\n" \- "$bgreen" "$(date +'%Y-%m-%d %H:%M:%S')" "$cache_name" "$reset" >> "$LOGFILE"- return 0- else- printf "%b[%s] Download failed: %s%b\n" \- "$bred" "$(date +'%Y-%m-%d %H:%M:%S')" "$url" "$reset" >&2- return 1- fi-}--# Clear old cache files-# Usage: cache_clean [max_age_days]-function cache_clean() {- local max_age="${1:-$CACHE_MAX_AGE_DAYS}"-- [[ ! -d "$CACHE_DIR" ]] && return 0-- local cleaned=0- while IFS= read -r -d '' file; do- local file_age_seconds- if [[ "$OSTYPE" == "darwin"* ]]; then- file_age_seconds=$(( $(date +%s) - $(stat -f %m "$file") ))- else- file_age_seconds=$(( $(date +%s) - $(stat -c %Y "$file") ))- fi-- local file_age_days=$((file_age_seconds / 86400))-- if [ $file_age_days -gt $max_age ]; then- rm -f "$file"- cleaned=$((cleaned + 1))- fi- done < <(find "$CACHE_DIR" -type f -print0 2>/dev/null)-- if [ $cleaned -gt 0 ]; then- printf "%b[%s] Cleaned %d expired cache files%b\n" \- "$bgreen" "$(date +'%Y-%m-%d %H:%M:%S')" "$cleaned" "$reset"- fi-}--###############################################################################################################-####################################### LOGGING ##################################################-###############################################################################################################--# Structured JSON logging (optional, controlled by STRUCTURED_LOGGING config)-STRUCTURED_LOGGING=${STRUCTURED_LOGGING:-false}-STRUCTURED_LOG_FILE=""--# Initialize structured logging-function log_init() {- [[ "$STRUCTURED_LOGGING" != "true" ]] && return 0-- STRUCTURED_LOG_FILE="${dir}/.log/structured_$(date +%Y%m%d_%H%M%S).jsonl"- mkdir -p "$(dirname "$STRUCTURED_LOG_FILE")"-- printf "%b[%s] Structured logging enabled: %s%b\n" \- "$bgreen" "$(date +'%Y-%m-%d %H:%M:%S')" "$STRUCTURED_LOG_FILE" "$reset"-}--# Log structured JSON event-# Usage: log_json <level> <function> <message> [key1=val1] [key2=val2] ...-function log_json() {- [[ "$STRUCTURED_LOGGING" != "true" ]] && return 0- [[ -z "$STRUCTURED_LOG_FILE" ]] && return 0-- local level="$1"- local function="$2"- local message="$3"- shift 3-- # Build JSON object- local json_obj=$(jq -n \- --arg ts "$(date -Iseconds)" \- --arg lvl "$level" \- --arg fn "$function" \- --arg msg "$message" \- --arg domain "${domain:-N/A}" \- '{timestamp:$ts, level:$lvl, function:$fn, message:$msg, domain:$domain}')-- # Add extra key-value pairs if provided- for kv in "$@"; do- if [[ "$kv" =~ ^([^=]+)=(.+)$ ]]; then- local key="${BASH_REMATCH[1]}"- local val="${BASH_REMATCH[2]}"- json_obj=$(echo "$json_obj" | jq --arg k "$key" --arg v "$val" '. + {($k): $v}')- fi- done-- echo "$json_obj" >> "$STRUCTURED_LOG_FILE"-}--# Convenience wrappers for different log levels-function log_info() {- log_json "INFO" "${FUNCNAME[1]:-main}" "$@"-}--function log_warn() {- log_json "WARN" "${FUNCNAME[1]:-main}" "$@"-}--function log_error() {- log_json "ERROR" "${FUNCNAME[1]:-main}" "$@"-}--function log_success() {- log_json "SUCCESS" "${FUNCNAME[1]:-main}" "$@"-}--###############################################################################################################-######################################### INCREMENTAL MODE ####################################################-###############################################################################################################--# Incremental mode - only scan new assets since last run-# This mode compares current results with previous runs and only processes new findings--INCREMENTAL_MODE=${INCREMENTAL_MODE:-false}-INCREMENTAL_DIR=".incremental"--# Initialize incremental mode structure-function incremental_init() {- [[ "$INCREMENTAL_MODE" != "true" ]] && return 0-- mkdir -p "$INCREMENTAL_DIR"/{subdomains,webs,hosts,vulns,previous}-- printf "%b[%s] Incremental mode enabled - will only process new findings%b\n" \- "$bgreen" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"-}--# Save current state for next incremental run-# Usage: incremental_save <type> <file>-function incremental_save() {- [[ "$INCREMENTAL_MODE" != "true" ]] && return 0-- local type="$1"- local file="$2"-- if [[ -s "$file" ]]; then- cp "$file" "$INCREMENTAL_DIR/previous/${type}_$(date +%Y%m%d_%H%M%S).txt"- cp "$file" "$INCREMENTAL_DIR/previous/${type}_latest.txt"- printf "%b[%s] Saved %s state for incremental mode%b\n" \- "$bgreen" "$(date +'%Y-%m-%d %H:%M:%S')" "$type" "$reset" >> "$LOGFILE"- fi-}--# Get new items compared to previous run-# Usage: incremental_diff <type> <current_file> <output_file>-# Returns: 0 if new items found, 1 if no new items-function incremental_diff() {- [[ "$INCREMENTAL_MODE" != "true" ]] && { cp "$2" "$3" 2>/dev/null; return 0; }-- local type="$1"- local current_file="$2"- local output_file="$3"- local previous_file="$INCREMENTAL_DIR/previous/${type}_latest.txt"-- if [[ ! -f "$previous_file" ]]; then- # First run, all items are new- cp "$current_file" "$output_file" 2>/dev/null- local count=$(wc -l < "$output_file" 2>/dev/null || echo 0)- printf "%b[%s] Incremental mode: First run for %s - %d items total%b\n" \- "$bblue" "$(date +'%Y-%m-%d %H:%M:%S')" "$type" "$count" "$reset"- return 0- fi-- # Compare and get only new items- if [[ -s "$current_file" ]]; then- comm -13 <(sort -u "$previous_file") <(sort -u "$current_file") | sed '/^$/d' > "$output_file"- local new_count=$(wc -l < "$output_file" 2>/dev/null || echo 0)- local total_count=$(wc -l < "$current_file" 2>/dev/null || echo 0)- local previous_count=$(wc -l < "$previous_file" 2>/dev/null || echo 0)-- printf "%b[%s] Incremental mode %s: %d new (previous: %d, total: %d)%b\n" \- "$bblue" "$(date +'%Y-%m-%d %H:%M:%S')" "$type" "$new_count" "$previous_count" "$total_count" "$reset"-- if [[ $new_count -eq 0 ]]; then- return 1 # No new items- fi- return 0 # New items found- else- touch "$output_file"- return 1- fi-}--# Generate incremental report-function incremental_report() {- [[ "$INCREMENTAL_MODE" != "true" ]] && return 0-- local report_file="$INCREMENTAL_DIR/incremental_report_$(date +%Y%m%d_%H%M%S).txt"-- {- echo "==============================================="- echo "Incremental Scan Report"- echo "Domain: $domain"- echo "Date: $(date +'%Y-%m-%d %H:%M:%S')"- echo "==============================================="- echo ""-- # Subdomain changes- if [[ -f "$INCREMENTAL_DIR/previous/subdomains_latest.txt" ]]; then- local new_subs=$(comm -13 <(sort -u "$INCREMENTAL_DIR/previous/subdomains_latest.txt" 2>/dev/null || touch /tmp/empty) \- <(sort -u "subdomains/subdomains.txt" 2>/dev/null || touch /tmp/empty) | wc -l)- echo "New Subdomains: $new_subs"- if [[ $new_subs -gt 0 ]]; then- echo "---"- comm -13 <(sort -u "$INCREMENTAL_DIR/previous/subdomains_latest.txt" 2>/dev/null || touch /tmp/empty) \- <(sort -u "subdomains/subdomains.txt" 2>/dev/null || touch /tmp/empty) | head -20- [[ $new_subs -gt 20 ]] && echo "... and $((new_subs - 20)) more"- echo ""- fi- fi-- # Web changes- if [[ -f "$INCREMENTAL_DIR/previous/webs_latest.txt" ]]; then- local new_webs=$(comm -13 <(sort -u "$INCREMENTAL_DIR/previous/webs_latest.txt" 2>/dev/null || touch /tmp/empty) \- <(sort -u "webs/webs.txt" 2>/dev/null || touch /tmp/empty) | wc -l)- echo "New Webs: $new_webs"- if [[ $new_webs -gt 0 ]]; then- echo "---"- comm -13 <(sort -u "$INCREMENTAL_DIR/previous/webs_latest.txt" 2>/dev/null || touch /tmp/empty) \- <(sort -u "webs/webs.txt" 2>/dev/null || touch /tmp/empty) | head -20- [[ $new_webs -gt 20 ]] && echo "... and $((new_webs - 20)) more"- echo ""- fi- fi-- echo "==============================================="- echo "Full report saved to: $report_file"- echo "==============================================="- } | tee "$report_file"-- printf "%b[%s] Incremental report generated: %s%b\n" \- "$bgreen" "$(date +'%Y-%m-%d %H:%M:%S')" "$report_file" "$reset"-}--# Check if incremental mode should skip heavy operations-# Usage: incremental_should_skip-# Returns: 0 to skip, 1 to continue-function incremental_should_skip() {- [[ "$INCREMENTAL_MODE" != "true" ]] && return 1 # Don't skip-- # Check if we have new findings- local new_subs=$(cat .tmp/subs_new_count 2>/dev/null || echo 1)- local new_webs=$(cat .tmp/webs_new_count 2>/dev/null || echo 1)-- if [[ $new_subs -eq 0 && $new_webs -eq 0 ]]; then- printf "%b[%s] Incremental mode: No new assets found, skipping heavy scans%b\n" \- "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"- return 0 # Skip- fi-- return 1 # Don't skip-}--###############################################################################################################--function zipSnedOutputFolder {- zip_name1=$(date +"%Y_%m_%d-%H.%M.%S")- zip_name="${zip_name1}_${domain}.zip" 2>>"$LOGFILE" >/dev/null- (cd "$dir" && zip -r "$zip_name" .) 2>>"$LOGFILE" >/dev/null- echo "Sending zip file "${dir}/${zip_name}""- if [[ -s "${dir}/$zip_name" ]]; then- sendToNotify "$dir/$zip_name"- rm -f "${dir}/$zip_name"- else- notification "No Zip file to send" warn- fi-}--function isAsciiText {- IS_ASCII="False"- if [[ $(file $1 | grep -o 'ASCII text$') == "ASCII text" ]]; then- IS_ASCII="True"- else- IS_ASCII="False"- fi-}--function output() {- mkdir -p "$dir_output"- # Ensure both $dir and $dir_output are absolute paths- dir="$(realpath "$dir")"- dir_output="$(realpath "$dir_output")"-- # Prevent accidental deletion if $dir_output is a parent of $dir- if [[ $dir == "$dir_output"* ]]; then- echo "[!] Output directory is a parent of the working directory. Aborting to prevent data loss."- return 1- fi-- cp -r "$dir" "$dir_output"-- # Only delete if source and destination are clearly different and safe- # Safety: refuse to delete outside of Recon/ directory- if [[ "$(dirname "$dir")" != "$dir_output" ]]; then- if [[ "$dir" == "${SCRIPTPATH}/Recon/"* ]]; then- rm -rf -- "$dir"- else- echo "[!] Refusing to delete directory outside Recon/: $dir"- return 1- fi- fi-}--function remove_big_files() {- rm -rf .tmp/gotator*.txt 2>>"$LOGFILE"- rm -rf .tmp/brute_recursive_wordlist.txt 2>>"$LOGFILE"- rm -rf .tmp/subs_dns_tko.txt 2>>"$LOGFILE"- rm -rf .tmp/subs_no_resolved.txt .tmp/subdomains_dns.txt .tmp/brute_dns_tko.txt .tmp/scrap_subs.txt .tmp/analytics_subs_clean.txt .tmp/gotator1.txt .tmp/gotator2.txt .tmp/passive_recursive.txt .tmp/brute_recursive_wordlist.txt .tmp/gotator1_recursive.txt .tmp/gotator2_recursive.txt 2>>"$LOGFILE"- find .tmp -type f -size +200M -exec rm -f {} + 2>>"$LOGFILE"-}--function notification() {- if [[ -n $1 ]] && [[ -n $2 ]]; then- if [[ $NOTIFICATION == true ]]; then- NOTIFY="notify -silent"- else- NOTIFY=""- fi- if [[ -z $3 ]]; then- current_date=$(date +'%Y-%m-%d %H:%M:%S')- else- current_date="$3"- fi-- case $2 in- info)- text="\n${bblue}[$current_date] ${1} ${reset}"- ;;- warn)- text="\n${yellow}[$current_date] ${1} ${reset}"- ;;- error)- text="\n${bred}[$current_date] ${1} ${reset}"- ;;- good)- text="\n${bgreen}[$current_date] ${1} ${reset}"- ;;- esac-- # Print to terminal- printf "${text}\n"-- # Send to notify if notifications are enabled- if [[ -n $NOTIFY ]]; then- # Remove color codes for the notification- clean_text=$(printf "%b" "${text} - ${domain}" | sed 's/\x1B\[[0-9;]*[JKmsu]//g')- printf "%s" "${clean_text}" | $NOTIFY >/dev/null 2>&1- fi- fi-}--function transfer {- if [[ $# -eq 0 ]]; then- echo "No arguments specified.\nUsage:\n transfer <file|directory>\n ... | transfer <file_name>" >&2- return 1- fi-- if tty -s; then- file="$1"- file_name=$(basename "$file")- if [[ ! -e $file ]]; then- echo "$file: No such file or directory" >&2- return 1- fi- tar -czvf /tmp/$file_name $file >/dev/null 2>&1 && curl -s https://bashupload.com/$file.tgz --data-binary @/tmp/$file_name | grep wget- else- file_name=$1- tar -czvf /tmp/$file_name $file >/dev/null 2>&1 && curl -s https://bashupload.com/$file.tgz --data-binary @/tmp/$file_name | grep wget- fi-}--function sendToNotify {- if [[ -z $1 ]]; then- printf "\n${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] No file provided to send ${reset}\n"- else- if [[ -z $NOTIFY_CONFIG ]]; then- NOTIFY_CONFIG=~/.config/notify/provider-config.yaml- fi- if [[ -n "$(find "${1}" -prune -size +8000000c)" ]]; then- printf '%s is larger than 8MB, sending over external service\n' "${1}"- transfer "${1}" | notify -silent- return 0- fi- if grep -q '^ telegram\|^telegram\|^ telegram' $NOTIFY_CONFIG; then- notification "[$(date +'%Y-%m-%d %H:%M:%S')] Sending ${domain} data over Telegram" info- telegram_chat_id=$(sed -n '/^telegram:/,/^[^ ]/p' ${NOTIFY_CONFIG} | sed -n 's/^[ ]*telegram_chat_id:[ ]*"\([^"]*\)".*/\1/p')- telegram_key=$(sed -n '/^telegram:/,/^[^ ]/p' ${NOTIFY_CONFIG} | sed -n 's/^[ ]*telegram_api_key:[ ]*"\([^"]*\)".*/\1/p')- curl -F "chat_id=${telegram_chat_id}" -F "document=@${1}" https://api.telegram.org/bot${telegram_key}/sendDocument 2>>"$LOGFILE" >/dev/null- fi- if grep -q '^ discord\|^discord\|^ discord' $NOTIFY_CONFIG; then- notification "[$(date +'%Y-%m-%d %H:%M:%S')] Sending ${domain} data over Discord" info- discord_url=$(sed -n '/^discord:/,/^[^ ]/p' ${NOTIFY_CONFIG} | sed -n 's/^[ ]*discord_webhook_url:[ ]*"\([^"]*\)".*/\1/p')- curl -v -i -H "Accept: application/json" -H "Content-Type: multipart/form-data" -X POST -F 'payload_json={"username": "test", "content": "hello"}' -F file1=@${1} $discord_url 2>>"$LOGFILE" >/dev/null- fi- if [[ -n $slack_channel ]] && [[ -n $slack_auth ]]; then- notification "[$(date +'%Y-%m-%d %H:%M:%S')] Sending ${domain} data over Slack" info- curl -F file=@${1} -F "initial_comment=reconftw zip file" -F channels=${slack_channel} -H "Authorization: Bearer ${slack_auth}" https://slack.com/api/files.upload 2>>"$LOGFILE" >/dev/null- fi- fi-}--function start_func() {- printf "${bgreen}#######################################################################"- notification "${2}" info- echo "[$current_date] Start function: ${1} " >>"${LOGFILE}"- start=$(date +%s)-}--function end_func() {- touch "$called_fn_dir/.${2}"- end=$(date +%s)- getElapsedTime "$start" "$end"- notification "${2} Finished in ${runtime}" info- echo "[$current_date] End function: ${2} " >>"${LOGFILE}"- printf "${bblue}[$current_date] ${1} ${reset}\n"- printf "${bgreen}#######################################################################${reset}\n"-}--function start_subfunc() {- notification " ${2}" info- echo "[$current_date] Start subfunction: ${1} " >>"${LOGFILE}"- start_sub=$(date +%s)-}--function end_subfunc() {- touch "$called_fn_dir/.${2}"- end_sub=$(date +%s)- getElapsedTime "$start_sub" "$end_sub"- notification " ${1} in ${runtime}" good- echo "[$current_date] End subfunction: ${1} " >>"${LOGFILE}"-}--function check_inscope() {- cat "$1" | inscope >"${1}_tmp" && cp "${1}_tmp" "$1" && rm -f "${1}_tmp"-}--function maybe_update_nuclei() {- # Update nuclei templates once per run per target directory- mkdir -p .tmp- local stamp_file=".tmp/.nuclei_updated"- if [[ ! -f $stamp_file ]]; then- if [[ -n ${NUCLEI_TEMPLATES_PATH-} ]]; then- nuclei -update-templates -update-template-dir "${NUCLEI_TEMPLATES_PATH}" 2>>"$LOGFILE" >/dev/null || true # non-fatal: template update failure shouldn't block scan- else- nuclei -update 2>>"$LOGFILE" >/dev/null || true # non-fatal: template update failure shouldn't block scan- fi- if [[ -n ${NUCLEI_FUZZING_TEMPLATES_PATH-} && -d ${NUCLEI_FUZZING_TEMPLATES_PATH} ]]; then- nuclei -update-templates -update-template-dir "${NUCLEI_FUZZING_TEMPLATES_PATH}" 2>>"$LOGFILE" >/dev/null || true # non-fatal- fi- touch "$stamp_file"- fi-}--# Plugin framework-PLUGINS_LOADED=false-function plugins_load() {- local plugdir="${SCRIPTPATH}/modules"- if [[ -d $plugdir ]]; then- for f in "$plugdir"/*.sh; do- [[ -f $f ]] && source "$f" || true- done- fi- PLUGINS_LOADED=true-}--function plugins_emit() {- local event="$1"- shift || true- if declare -F reconftw_plugins >/dev/null 2>&1; then- reconftw_plugins "$event" "$@" || true- fi-}--# Asset store-function append_asset() {- # Usage: append_asset type key value extras...- [[ $ASSET_STORE != true ]] && return 0- local type="$1"- shift- local key="$1"- shift- local val="$1"- shift- local now- now=$(date +'%Y-%m-%d %H:%M:%S')- mkdir -p .tmp- printf '{"type":"%s","%s":"%s","ts":"%s","source":"%s"}\n' \- "$type" "$key" "${val//\"/\\\"}" "$now" "${FUNCNAME[1]}" >>assets.jsonl 2>/dev/null-}--function append_assets_from_file() {- # Usage: append_assets_from_file type key file- [[ $ASSET_STORE != true ]] && return 0- local type="$1"- local key="$2"- local file="$3"- [[ ! -s $file ]] && return 0- while IFS= read -r line; do- [[ -z $line ]] && continue- append_asset "$type" "$key" "$line"- done <"$file"-}--# Chunk helper-function process_in_chunks() {- # process_in_chunks <file> <chunk_size> <command with _chunk_ placeholder>- local infile="$1"- local chunksize="$2"- shift 2- [[ ! -s $infile ]] && return 0- local lines- lines=$(wc -l <"$infile" 2>/dev/null || echo 0)- if [[ $lines -le $chunksize ]]; then- bash -lc "$*"- return $?- fi- mkdir -p .tmp/chunks- split -l "$chunksize" -d "$infile" .tmp/chunks/part_- for part in .tmp/chunks/part_*; do- local cmd- cmd="${*//_chunk_/\"$part\"}"- bash -lc "$cmd"- done-}--function resolvers_update() {-- if [[ $generate_resolvers == true ]]; then- if [[ $AXIOM != true ]]; then- if [[ ! -s $resolvers ]] || [[ $(find "$resolvers" -mtime +1 -print) ]]; then- notification "Resolvers seem older than 1 day\n Generating custom resolvers..." warn- rm -f -- "$resolvers" 2>>"$LOGFILE"- dnsvalidator -tL https://public-dns.info/nameservers.txt -threads $DNSVALIDATOR_THREADS -o $resolvers 2>>"$LOGFILE" >/dev/null- dnsvalidator -tL https://raw.githubusercontent.com/blechschmidt/massdns/master/lists/resolvers.txt -threads $DNSVALIDATOR_THREADS -o tmp_resolvers 2>>"$LOGFILE" >/dev/null- [ -s "tmp_resolvers" ] && cat tmp_resolvers | anew -q $resolvers- [ -s "tmp_resolvers" ] && rm -f tmp_resolvers 2>>"$LOGFILE" >/dev/null- [ ! -s "$resolvers" ] && wget -q -O - ${resolvers_url} >$resolvers- [ ! -s "$resolvers_trusted" ] && wget -q -O - ${resolvers_trusted_url} >$resolvers_trusted- notification "Updated\n" good- fi- else- notification "Checking resolvers lists...\n Accurate resolvers are the key to great results\n This may take around 10 minutes if it's not updated" warn- axiom-exec "([[ \$(find \"${AXIOM_RESOLVERS_PATH}\" -mtime +1 -print) ]] || [[ \$(wc -l < \"${AXIOM_RESOLVERS_PATH}\") -le 40 ]]) && dnsvalidator -tL https://public-dns.info/nameservers.txt -threads 200 -o ${AXIOM_RESOLVERS_PATH}" &>/dev/null- axiom-exec "wget -q -O - ${resolvers_url} > ${AXIOM_RESOLVERS_PATH}" 2>>"$LOGFILE" >/dev/null- axiom-exec "wget -q -O - ${resolvers_trusted_url} > ${AXIOM_RESOLVERS_TRUSTED_PATH}" 2>>"$LOGFILE" >/dev/null- notification "Updated\n" good- fi- generate_resolvers=false- else-- if [[ ! -s $resolvers ]] || [[ $(find "$resolvers" -mtime +1 -print) ]]; then- notification "Resolvers seem older than 1 day\n Downloading new resolvers..." warn- cached_download "${resolvers_url}" "$resolvers" "resolvers.txt"- cached_download "${resolvers_trusted_url}" "$resolvers_trusted" "resolvers_trusted.txt"- notification "Resolvers updated\n" good- fi- fi--}--function resolvers_update_quick_local() {- if [[ $update_resolvers == true ]]; then- cached_download "${resolvers_url}" "$resolvers" "resolvers.txt"- cached_download "${resolvers_trusted_url}" "$resolvers_trusted" "resolvers_trusted.txt"- fi-}--function resolvers_update_quick_axiom() {- axiom-exec "wget -q -O - ${resolvers_url} > ${AXIOM_RESOLVERS_PATH}" 2>>"$LOGFILE" >/dev/null- axiom-exec "wget -q -O - ${resolvers_trusted_url} > ${AXIOM_RESOLVERS_TRUSTED_PATH}" 2>>"$LOGFILE" >/dev/null-}--function resolvers_optimize_local() {- # Experimental: dedupe resolvers; prefer faster ones if dnsx available- sort -u "$resolvers" -o "$resolvers" 2>/dev/null || true- sort -u "$resolvers_trusted" -o "$resolvers_trusted" 2>/dev/null || true-}--function ipcidr_target() {- IP_CIDR_REGEX='(((25[0-5]|2[0-4][0-9]|1?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|1?[0-9][0-9]?))(\/([8-9]|[1-2][0-9]|3[0-2]))([^0-9.]|$)|(((25[0-5]|2[0-4][0-9]|1?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|1?[0-9][0-9]?)$)'- if [[ $1 =~ ^$IP_CIDR_REGEX ]]; then- echo $1 | mapcidr -silent | anew -q target_reconftw_ipcidr.txt- if [[ -s "./target_reconftw_ipcidr.txt" ]]; then- [ "$REVERSE_IP" = true ] && cat ./target_reconftw_ipcidr.txt | hakip2host | cut -d' ' -f 3 | unfurl -u domains 2>/dev/null | sed -e 's/*\.//' -e 's/\.$//' -e '/\./!d' | anew -q ./target_reconftw_ipcidr.txt- if [[ $(cat ./target_reconftw_ipcidr.txt | wc -l) -eq 1 ]]; then- domain=$(cat ./target_reconftw_ipcidr.txt)- elif [[ $(cat ./target_reconftw_ipcidr.txt | wc -l) -gt 1 ]]; then- unset domain- list=${PWD}/target_reconftw_ipcidr.txt- fi- fi- if [[ -n $2 ]]; then- cat $list | anew -q $2- sed_i '/\/[0-9]*$/d' $2- fi- fi-}--function axiom_launch() {- # let's fire up a FLEET!- if [[ $AXIOM_FLEET_LAUNCH == true ]] && [[ -n $AXIOM_FLEET_NAME ]] && [[ -n $AXIOM_FLEET_COUNT ]]; then- start_func ${FUNCNAME[0]} "Launching our Axiom fleet"-- # Check to see if we have a fleet already, if so, SKIP THIS!- NUMOFNODES=$(timeout 30 axiom-ls | grep -c "$AXIOM_FLEET_NAME" || true)- if [[ $NUMOFNODES -ge $AXIOM_FLEET_COUNT ]]; then- axiom-select "$AXIOM_FLEET_NAME*"- end_func "Axiom fleet $AXIOM_FLEET_NAME already has $NUMOFNODES instances" info- else- if [[ $NUMOFNODES -eq 0 ]]; then- startcount=$AXIOM_FLEET_COUNT- else- startcount=$((AXIOM_FLEET_COUNT - NUMOFNODES))- fi- # Build args safely to avoid word-splitting issues- local -a AXIOM_FLEET_ARGS=(-i "$startcount")- # Regions intentionally disabled here per original comment- # To re-enable: [[ -n ${AXIOM_FLEET_REGIONS-} ]] && AXIOM_FLEET_ARGS+=( --regions="${AXIOM_FLEET_REGIONS}" )-- # Show the exact command with proper quoting- printf 'axiom-fleet %q' "${AXIOM_FLEET_NAME}"- printf ' %q' "${AXIOM_FLEET_ARGS[@]}"- echo- axiom-fleet "${AXIOM_FLEET_NAME}" "${AXIOM_FLEET_ARGS[@]}"- axiom-select "$AXIOM_FLEET_NAME*"- if [[ -n $AXIOM_POST_START ]]; then- bash -lc "$AXIOM_POST_START" 2>>"$LOGFILE" >/dev/null- fi-- NUMOFNODES=$(timeout 30 axiom-ls | grep -c "$AXIOM_FLEET_NAME" || true)- end_func "Axiom fleet $AXIOM_FLEET_NAME launched $NUMOFNODES instances" info- fi- fi-}--function axiom_shutdown() {- if [[ $AXIOM_FLEET_LAUNCH == true ]] && [[ $AXIOM_FLEET_SHUTDOWN == true ]] && [[ -n $AXIOM_FLEET_NAME ]]; then- #if [[ "$mode" == "subs_menu" ]] || [[ "$mode" == "list_recon" ]] || [[ "$mode" == "passive" ]] || [[ "$mode" == "all" ]]; then- if [[ $mode == "subs_menu" ]] || [[ $mode == "passive" ]] || [[ $mode == "all" ]]; then- notification "Automatic Axiom fleet shutdown is not enabled in this mode" info- return- fi- axiom-rm -f "$AXIOM_FLEET_NAME*" || true- axiom-ls | grep "$AXIOM_FLEET_NAME" || true- notification "Axiom fleet $AXIOM_FLEET_NAME shutdown" info- fi-}--function axiom_selected() {-- if [[ ! $(axiom-ls | tail -n +2 | sed '$ d' | wc -l) -gt 0 ]]; then- notification "No axiom instances running ${reset}\n\n" error- exit- fi-- if [[ ! $(cat ~/.axiom/selected.conf | sed '/^\s*$/d' | wc -l) -gt 0 ]]; then- notification "No axiom instances selected ${reset}\n\n" error- exit- fi-}--function start() {-- global_start=$(date +%s)-- # Validate configuration before starting- validate_config || exit $?-- # Check available disk space before starting (require at least 5GB by default)- local required_space_gb="${MIN_DISK_SPACE_GB:-5}"- if ! check_disk_space "$required_space_gb" "."; then- printf "%b[%s] WARNING: Low disk space detected. Continuing anyway...%b\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"- # Not exiting, just warning - user can set MIN_DISK_SPACE_GB=0 to disable- fi-- # Raise ulimit for long-running VPS jobs (fail-soft on failure)- if [[ ${RAISE_ULIMIT:-true} == "true" ]]; then- ULIMIT_TARGET=${ULIMIT_TARGET:-65535}- ulimit -n "$ULIMIT_TARGET" 2>>"${LOGFILE:-/dev/null}" >/dev/null || true- fi-- # Log version and key flags- {- printf "[%s] reconFTW version: %s\n" "$(date +'%Y-%m-%d %H:%M:%S')" "$reconftw_version"- printf "[%s] Flags: OSINT=%s SUBDOMAINS_GENERAL=%s VULNS_GENERAL=%s DEEP=%s\n" \- "$(date +'%Y-%m-%d %H:%M:%S')" "$OSINT" "$SUBDOMAINS_GENERAL" "$VULNS_GENERAL" "$DEEP"- } >>"${LOGFILE:-/dev/null}"- if [[ $upgrade_before_running == true ]]; then- ${SCRIPTPATH}/install.sh --tools- fi- tools_installed-- # Initialize incremental mode if enabled- incremental_init-- #[[ -n "$domain" ]] && ipcidr_target $domain-- if [[ -z $domain ]]; then- if [[ -n $list ]]; then- if [[ -z $domain ]]; then- domain="Multi"- dir="${SCRIPTPATH}/Recon/$domain"- called_fn_dir="$dir"/.called_fn- fi- if [[ $list == /* ]]; then- mkdir -p "$dir/webs"- cp "$list" "$dir/webs/webs.txt"- else- mkdir -p "$dir/webs"- cp "${SCRIPTPATH}/${list}" "$dir/webs/webs.txt"- fi- fi- else- dir="${SCRIPTPATH}/Recon/$domain"- called_fn_dir="$dir"/.called_fn- fi-- if [[ -z $domain ]]; then- notification "${bred} No domain or list provided ${reset}\n\n" error- exit- fi-- if [[ ! -d $called_fn_dir ]]; then- mkdir -p "$called_fn_dir"- fi- mkdir -p "$dir"- cd "$dir" || {- echo "Failed to cd directory in ${FUNCNAME[0]} @ line ${LINENO}"- exit 1- }- if [[ $AXIOM == true ]]; then- if [[ -n $domain ]]; then- echo "$domain" | anew -q target.txt- list="${dir}/target.txt"- fi- fi- mkdir -p {.log,.tmp,webs,hosts,vulns,osint,screenshots,subdomains}- chmod 700 .tmp 2>/dev/null || true-- # Load plugins and emit start event- plugins_load- plugins_emit start "$domain" "$dir"-- NOW=$(date +"%F")- NOWT=$(date +"%T")- LOGFILE="${dir}/.log/${NOW}_${NOWT}.txt"- touch ".log/${NOW}_${NOWT}.txt"- echo "[$(date +'%Y-%m-%d %H:%M:%S')] Start ${NOW} ${NOWT}" >"${LOGFILE}"- enable_command_trace-- # Rotate old log files- rotate_logs "${dir}/.log" "${MAX_LOG_FILES:-10}" "${MAX_LOG_AGE_DAYS:-30}"-- # Trap for cleanup on unexpected exit- trap 'cleanup_on_exit' INT TERM-- # Initialize structured logging if enabled- log_init-- # Initialize cache for wordlists/resolvers- cache_init-- # init time saved estimator- TIME_SAVED_EST=0-- # Non-fatal error trap: log and continue- trap 'rc=$?; ts=$(date +"%Y-%m-%d %H:%M:%S"); cmd=${BASH_COMMAND}; loc_fn=${FUNCNAME[0]:-main}; loc_ln=${BASH_LINENO[0]:-0}; msg="[$ts] ERR($rc) @ ${loc_fn}:${loc_ln} :: ${cmd}"; if [[ -n "${LOGFILE:-}" ]]; then echo "$msg" >>"$LOGFILE"; else echo "$msg" >&2; fi' ERR-- printf "\n"- printf "${bred}[$(date +'%Y-%m-%d %H:%M:%S')] Target: ${domain}\n\n"- printf "%b[LEGAL]%b Authorized testing only. By running this scan you confirm you have explicit permission for the specified targets and will comply with all applicable laws and program rules. Unauthorized use is prohibited.\n\n" "$yellow" "$reset"-}--function end() {-- if [[ $opt_ai ]]; then- notification "[$(date +'%Y-%m-%d %H:%M:%S')] Sending ${domain} data to AI" info- mkdir -p "${dir}/ai_result" 2>>"${LOGFILE}"- "${tools}/reconftw_ai/venv/bin/python3" "${tools}/reconftw_ai/reconftw_ai.py" --results-dir ${dir} --output-dir ${dir}/ai_result --model ${AI_MODEL} --output-format ${AI_REPORT_TYPE} --report-type ${AI_REPORT_PROFILE} --prompts-file ${tools}/reconftw_ai/prompts.json 2>>"${LOGFILE}" >/dev/null- fi-- find "$dir" -type f -empty -print | grep -v '.called_fn' | grep -v '.log' | grep -v '.tmp' | xargs -r rm -f -- 2>>"$LOGFILE" >/dev/null- find "$dir" -type d -empty -print -delete 2>>"$LOGFILE" >/dev/null-- echo "[$(date +'%Y-%m-%d %H:%M:%S')] End" >>"${LOGFILE}"-- if [[ $PRESERVE != true ]]; then- find "$dir" -type f -empty | grep -v "called_fn" | xargs -r rm -f -- 2>>"$LOGFILE" >/dev/null- find "$dir" -type d -empty | grep -v "called_fn" | xargs -r rm -rf -- 2>>"$LOGFILE" >/dev/null- fi-- if [[ $REMOVETMP == true ]]; then- rm -rf -- "$dir/.tmp"- fi-- if [[ $REMOVELOG == true ]]; then- rm -rf -- "$dir/.log"- fi-- if [[ $FARADAY == true ]]; then- if ! faraday-cli status 2>>"$LOGFILE" >/dev/null; then- printf "%b[!] Faraday server is not running. Skipping Faraday integration.%b\n" "$bred" "$reset"- else- if [[ -s ".tmp/tko_json.txt" ]]; then- faraday-cli tool report -w $FARADAY_WORKSPACE --plugin-id nuclei .tmp/tko_json.txt 2>>"$LOGFILE" >/dev/null- fi- if [[ -s "hosts/portscan_active.xml" ]]; then- faraday-cli tool report -w $FARADAY_WORKSPACE --plugin-id nmap hosts/portscan_active.xml 2>>"$LOGFILE" >/dev/null- fi- if [[ -s ".tmp/fuzzparams_json.txt" ]]; then- faraday-cli tool report -w $FARADAY_WORKSPACE --plugin-id nuclei .tmp/fuzzparams_json.txt 2>>"$LOGFILE" >/dev/null- fi- if [[ -s "nuclei_output/info_json.txt" ]]; then- faraday-cli tool report -w $FARADAY_WORKSPACE --plugin-id nuclei nuclei_output/info_json.txt 2>>"$LOGFILE" >/dev/null- fi- if [[ -s "nuclei_output/low_json.txt" ]]; then- faraday-cli tool report -w $FARADAY_WORKSPACE --plugin-id nuclei nuclei_output/low_json.txt 2>>"$LOGFILE" >/dev/null- fi- if [[ -s "nuclei_output/medium_json.txt" ]]; then- faraday-cli tool report -w $FARADAY_WORKSPACE --plugin-id nuclei nuclei_output/medium_json.txt 2>>"$LOGFILE" >/dev/null- fi- if [[ -s "nuclei_output/high_json.txt" ]]; then- faraday-cli tool report -w $FARADAY_WORKSPACE --plugin-id nuclei nuclei_output/high_json.txt 2>>"$LOGFILE" >/dev/null- fi- if [[ -s "nuclei_output/critical_json.txt" ]]; then- faraday-cli tool report -w $FARADAY_WORKSPACE --plugin-id nuclei nuclei_output/critical_json.txt 2>>"$LOGFILE" >/dev/null- fi- notification "Information sent to Faraday" "good"- fi- fi-- if [[ -n $dir_output ]]; then- output- finaldir=$dir_output- else- finaldir=$dir- fi- #Zip the output folder and send it via tg/discord/slack- if [[ $SENDZIPNOTIFY == true ]]; then- zipSnedOutputFolder- fi-- # Screenshot diffs (hashing)- if [[ -d screenshots ]]; then- if [[ -f screenshots/hashes.txt ]]; then mv screenshots/hashes.txt screenshots/hashes_prev.txt 2>>"$LOGFILE" || true; fi- find screenshots -type f -name '*.png' -print0 | xargs -0 -I{} sh -c 'sha256sum "$1" 2>/dev/null || shasum -a 256 "$1"' -- {} | sed 's| ./||' >screenshots/hashes.txt 2>>"$LOGFILE" || true- if [[ -f screenshots/hashes_prev.txt ]]; then- comm -3 <(cut -d' ' -f1,2 screenshots/hashes_prev.txt | sort) <(cut -d' ' -f1,2 screenshots/hashes.txt | sort) | awk '{print $2}' | sed '/^$/d' >screenshots/diff_changed.txt 2>>"$LOGFILE" || true- fi- fi-- # Emit end plugin event- plugins_emit end "$domain" "$dir"+# Standard exit/return codes (guard for re-source in test harnesses)+if [[ -z "${E_SUCCESS+x}" ]]; then+ readonly E_SUCCESS=0+ readonly E_GENERAL=1+ readonly E_MISSING_DEP=2+ readonly E_INVALID_INPUT=3+ readonly E_NETWORK=4+ readonly E_DISK_SPACE=5+ readonly E_PERMISSION=6+ readonly E_TIMEOUT=7+ readonly E_CONFIG=8+fi- # Build hotlist (risk summary)- build_hotlist || true+# Welcome to reconFTW main script+# ██▀███ ▓█████ ▄████▄ ▒█████ ███▄ █ █████▒▄▄▄█████▓ █ █░+# ▓██ ▒ ██▒▓█ ▀ ▒██▀ ▀█ ▒██▒ ██▒ ██ ▀█ █ ▓██ ▒ ▓ ██▒ ▓▒▓█░ █ ░█░+# ▓██ ░▄█ ▒▒███ ▒▓█ ▄ ▒██░ ██▒▓██ ▀█ ██▒▒████ ░ ▒ ▓██░ ▒░▒█░ █ ░█+# ▒██▀▀█▄ ▒▓█ ▄ ▒▓▓▄ ▄██▒▒██ ██░▓██▒ ▐▌██▒░▓█▒ ░ ░ ▓██▓ ░ ░█░ █ ░█+# ░██▓ ▒██▒░▒████▒▒ ▓███▀ ░░ ████▓▒░▒██░ ▓██░░▒█░ ▒██▒ ░ ░░██▒██▓+# ░ ▒▓ ░▒▓░░░ ▒░ ░░ ░▒ ▒ ░░ ▒░▒░▒░ ░ ▒░ ▒ ▒ ▒ ░ ▒ ░░ ░ ▓░▒ ▒+# ░▒ ░ ▒░ ░ ░ ░ ░ ▒ ░ ▒ ▒░ ░ ░░ ░ ▒░ ░ ░ ▒ ░ ░+# ░░ ░ ░ ░ ░ ░ ░ ▒ ░ ░ ░ ░ ░ ░ ░ ░+# ░ ░ ░░ ░ ░ ░ ░ ░+#- global_end=$(date +%s)- getElapsedTime $global_start $global_end- printf "${bgreen}#######################################################################${reset}\n"- notification "Finished Recon on: ${domain} under ${finaldir} in: ${runtime}" good "$(date +'%Y-%m-%d %H:%M:%S')"- [ "$SOFT_NOTIFICATION" = true ] && echo "[$(date +'%Y-%m-%d %H:%M:%S')] Finished Recon on: ${domain} under ${finaldir} in: ${runtime}" | notify -silent- printf "${bgreen}#######################################################################${reset}\n"+# Detect if the script is being run (not sourced) in MacOS with Homebrew Bash+if [[ "${BASH_SOURCE[0]}" == "${0}" && $OSTYPE == "darwin"* && $BASH != "/opt/homebrew/bin/bash" ]]; then+ exec /opt/homebrew/bin/bash "$0" "$@"+fi-}+# timeout/gtimeout compatibility+if command -v timeout >/dev/null 2>&1; then+ TIMEOUT_CMD="timeout"+elif command -v gtimeout >/dev/null 2>&1; then+ TIMEOUT_CMD="gtimeout"+else+ TIMEOUT_CMD=""+fi-function build_hotlist() {- mkdir -p .tmp- declare -A score- # Nuclei high/critical- for f in nuclei_output/high_json.txt nuclei_output/critical_json.txt; do- [[ -s $f ]] || continue- jq -r '.["matched-at"] // .host' "$f" 2>/dev/null | while read -r h; do- [[ -z $h ]] && continue- score["$h"]=$((${score["$h"]:-0} + 10))- done- done- # Takeovers- [[ -s webs/takeover.txt ]] && while read -r h; do score["$h"]=$((${score["$h"]:-0} + 8)); done <webs/takeover.txt- # Secrets- for s in js/js_secrets.txt js/js_secrets_jsmap.txt js/js_secrets_jsmap_jsluice.txt; do- [[ -s $s ]] || continue- awk '{print $1}' "$s" | while read -r h; do score["$h"]=$((${score["$h"]:-0} + 6)); done- done- # Real IPs via favicon- if [[ -s hosts/favicontest.txt ]]; then- while read -r ip; do- score["$ip"]=$((${score["$ip"]:-0} + 4))- done <hosts/favicontest.txt- fi- # New assets bonus- for p in .tmp/subs_new_only.txt webs/url_extract.txt; do- [[ -s $p ]] || continue- while read -r l; do- host=$(echo "$l" | unfurl -u domains 2>/dev/null)- [[ -z $host ]] && continue- score["$host"]=$((${score["$host"]:-0} + 2))- done <"$p"- done- # Emit hotlist sorted- {- for k in "${!score[@]}"; do printf "%s %s\n" "${score[$k]}" "$k"; done | sort -nr | head -n "${HOTLIST_TOP:-50}"- } >hotlist.txt- [[ -s hotlist.txt ]] && notification "Hotlist ready (top ${HOTLIST_TOP:-50})" info-}+# Ensure a safe default for early log redirections+# If LOGFILE is unset or empty, send logs to /dev/null until later initialization+: "${LOGFILE:=/dev/null}"###############################################################################################################-########################################### MODES & MENUS #####################################################+############################################## MODULE LOADING ################################################################################################################################################################-function passive() {- start- domain_info- ip_info- emails- google_dorks- #github_dorks- github_repos- metadata- apileaks- third_party_misconfigs- SUBNOERROR=false- SUBANALYTICS=false- SUBBRUTE=false- SUBSCRAPING=false- SUBPERMUTE=false- SUBREGEXPERMUTE=false- SUB_RECURSIVE_BRUTE=false- WEBPROBESIMPLE=false- if [[ $AXIOM == true ]]; then- axiom_launch- axiom_selected- fi-- subdomains_full- remove_big_files- favicon- cdnprovider- PORTSCAN_ACTIVE=false- portscan- geo_info-- if [[ $AXIOM == true ]]; then- axiom_shutdown- fi-- end-}--function all() {- start- recon- vulns- end-}--function osint() {- domain_info- ip_info- emails- google_dorks- #github_dorks- github_repos- metadata- apileaks- third_party_misconfigs- zonetransfer- favicon- mail_hygiene- cloud_enum_scan-}--function vulns() {- if [[ $VULNS_GENERAL == true ]]; then- cors- open_redirect- ssrf_checks- crlf_checks- lfi- ssti- sqli- xss- command_injection- prototype_pollution- smuggling- webcache- spraying- brokenLinks- fuzzparams- 4xxbypass- test_ssl- fi-}--function multi_osint() {-- global_start=$(date +%s)-- #[[ -n "$domain" ]] && ipcidr_target $domain-- if [[ -s "$list" ]]; then- sed_i 's/\r$//' "$list"- else- notification "Target list not provided" error- exit- fi-- workdir="${SCRIPTPATH}/Recon/${multi}"- mkdir -p "$workdir" || {- echo "Failed to create directory '$workdir' in ${FUNCNAME[0]} @ line ${LINENO}"- exit 1- }- cd "$workdir" || {- echo "Failed to cd directory '$workdir' in ${FUNCNAME[0]} @ line ${LINENO}"- exit 1- }- mkdir -p {.log,.tmp,webs,hosts,vulns,osint,screenshots,subdomains}-- NOW=$(date +"%F")- NOWT=$(date +"%T")- LOGFILE="${workdir}/.log/${NOW}_${NOWT}.txt"- touch ".log/${NOW}_${NOWT}.txt"- echo "[$(date +'%Y-%m-%d %H:%M:%S')] Start ${NOW} ${NOWT}" >"${LOGFILE}"- enable_command_trace-- while IFS= read -r domain; do- [[ -z "$domain" ]] && continue- dir="$workdir/targets/$domain"- called_fn_dir="$dir/.called_fn"- mkdir -p "$dir"- cd "$dir" || {- echo "Failed to cd directory '$dir' in ${FUNCNAME[0]} @ line ${LINENO}"- exit 1- }- mkdir -p {.log,.tmp,webs,hosts,vulns,osint,screenshots,subdomains}- NOW=$(date +"%F")- NOWT=$(date +"%T")- LOGFILE="${dir}/.log/${NOW}_${NOWT}.txt"- touch ".log/${NOW}_${NOWT}.txt"- echo "[$(date +'%Y-%m-%d %H:%M:%S')] Start ${NOW} ${NOWT}" >"${LOGFILE}"- domain_info- ip_info- emails- google_dorks- #github_dorks- github_repos- metadata- apileaks- third_party_misconfigs- zonetransfer- favicon- done < "$list"- cd "$workdir" || {- echo "Failed to cd directory '$workdir' in ${FUNCNAME[0]} @ line ${LINENO}"- exit 1- }- dir=$workdir- domain=$multi- end-}--function recon() {- domain_info- ip_info- emails- google_dorks- #github_dorks- github_repos- metadata- apileaks- third_party_misconfigs- zonetransfer- favicon-- if [[ $AXIOM == true ]]; then- axiom_launch- axiom_selected- fi-- subdomains_full- webprobe_full- subtakeover- remove_big_files- s3buckets- cloud_extra_providers- screenshot- # virtualhosts- cdnprovider- portscan- geo_info- # Quick-rescan gating- subs_new=$(cat .tmp/subs_new_count 2>/dev/null || echo 1)- webs_new=$(cat .tmp/webs_new_count 2>/dev/null || echo 1)- if [[ $QUICK_RESCAN == true && $subs_new -eq 0 && $webs_new -eq 0 ]]; then- notification "Quick rescan: no new subs/webs; skipping heavy web stages" info- # estimate time saved for skipped modules- TIME_SAVED_EST=$((${TIME_SAVED_EST:-0} + \- ${TIME_EST_WAF:-0} + ${TIME_EST_NUCLEI:-600} + ${TIME_EST_API:-300} + ${TIME_EST_GQL:-180} + \- ${TIME_EST_FUZZ:-900} + ${TIME_EST_IIS:-60} + ${TIME_EST_URLCHECKS:-300} + ${TIME_EST_JSCHECKS:-300} + \- ${TIME_EST_PARAM:-240} + ${TIME_EST_GRPC:-120}))- else- waf_checks- nuclei_check- graphql_scan- fuzz- iishortname- urlchecks- jschecks- websocket_checks- param_discovery- grpc_reflection- fi-- if [[ $AXIOM == true ]]; then- axiom_shutdown- fi-- cms_scanner- url_gf- wordlist_gen- wordlist_gen_roboxtractor- password_dict- url_ext-}--function multi_recon() {-- [ "$SOFT_NOTIFICATION" = true ] && echo "$(date +'%Y-%m-%d %H:%M:%S') Recon successfully started on ${multi}" | notify -silent-- global_start=$(date +%s)-- #[[ -n "$domain" ]] && ipcidr_target $domain-- if [[ -s "$list" ]]; then- sed_i 's/\r$//' "$list"- mapfile -t targets < "$list"- else- notification "Target list not provided" error- exit- fi-- workdir="${SCRIPTPATH}/Recon/${multi}"- mkdir -p "$workdir" || {- echo "Failed to create directory '$workdir' in ${FUNCNAME[0]} @ line ${LINENO}"- exit 1- }- cd "$workdir" || {- echo "Failed to cd directory '$workdir' in ${FUNCNAME[0]} @ line ${LINENO}"- exit 1- }-- mkdir -p {.log,.tmp,webs,hosts,vulns,osint,screenshots,subdomains}- NOW=$(date +"%F")- NOWT=$(date +"%T")- LOGFILE="${workdir}/.log/${NOW}_${NOWT}.txt"- touch ".log/${NOW}_${NOWT}.txt"- echo "[$(date +'%Y-%m-%d %H:%M:%S')] Start ${NOW} ${NOWT}" >"${LOGFILE}"-- [ -n "$flist" ] && LISTTOTAL=$(wc -l < "$flist")-- for domain in "${targets[@]}"; do- [[ -z "$domain" ]] && continue- dir="$workdir/targets/$domain"- called_fn_dir="$dir/.called_fn"-- # Ensure directories exist- mkdir -p "$dir" || {- echo "Failed to create directory '$dir' in ${FUNCNAME[0]} @ line ${LINENO}"- exit 1- }- mkdir -p "$called_fn_dir" || {- echo "Failed to create directory '$called_fn_dir' in ${FUNCNAME[0]} @ line ${LINENO}"- exit 1- }-- cd "$dir" || {- echo "Failed to cd to directory '$dir' in ${FUNCNAME[0]} @ line ${LINENO}"- exit 1- }-- mkdir -p {.log,.tmp,webs,hosts,vulns,osint,screenshots,subdomains}-- NOW=$(date +"%F")- NOWT=$(date +"%T")- LOGFILE="${dir}/.log/${NOW}_${NOWT}.txt"-- # Ensure the .log directory exists before touching the file- mkdir -p .log-- touch "$LOGFILE" || {- echo "Failed to create log file: $LOGFILE"- exit 1- }- echo "[$(date +'%Y-%m-%d %H:%M:%S')] Start ${NOW} ${NOWT}" >"$LOGFILE"- enable_command_trace- loopstart=$(date +%s)-- domain_info- ip_info- emails- google_dorks- #github_dorks- github_repos- metadata- apileaks- third_party_misconfigs- zonetransfer- favicon- currently=$(date +"%H:%M:%S")- loopend=$(date +%s)- getElapsedTime "$loopstart" "$loopend"- printf "${bgreen}#######################################################################${reset}\n"- printf "${bgreen}[$(date +'%Y-%m-%d %H:%M:%S')] $domain finished 1st loop in ${runtime} $currently ${reset}\n"- if [[ -n $flist ]]; then- POSINLIST=$(grep -nrE "^${domain}$" "$flist" | cut -f1 -d':')- printf "\n${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] $domain is $POSINLIST of $LISTTOTAL${reset}\n"- fi- printf "${bgreen}#######################################################################${reset}\n"- done- cd "$workdir" || {- echo "Failed to cd directory '$workdir' in ${FUNCNAME[0]} @ line ${LINENO}"- exit 1- }-- if [[ $AXIOM == true ]]; then- axiom_launch- axiom_selected- fi-- for domain in "${targets[@]}"; do- [[ -z "$domain" ]] && continue- loopstart=$(date +%s)- dir="$workdir/targets/$domain"- called_fn_dir="$dir/.called_fn"- cd "$dir" || {- echo "Failed to cd directory '$dir' in ${FUNCNAME[0]} @ line ${LINENO}"- exit 1- }- subdomains_full- webprobe_full- subtakeover- remove_big_files- screenshot- # virtualhosts- cdnprovider- portscan- geo_info- currently=$(date +"%H:%M:%S")- loopend=$(date +%s)- getElapsedTime "$loopstart" "$loopend"- printf "${bgreen}#######################################################################${reset}\n"- printf "${bgreen}[$(date +'%Y-%m-%d %H:%M:%S')] $domain finished 2nd loop in ${runtime} $currently ${reset}\n"- if [[ -n $flist ]]; then- POSINLIST=$(grep -nrE "^${domain}$" "$flist" | cut -f1 -d':')- printf "\n${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] $domain is $POSINLIST of $LISTTOTAL${reset}\n"- fi- printf "${bgreen}#######################################################################${reset}\n"- done- cd "$workdir" || {- echo "Failed to cd directory '$workdir' in ${FUNCNAME[0]} @ line ${LINENO}"- exit 1- }-- notification "############################# Total data ############################" info- NUMOFLINES_pwndb_total=$(find . -type f -name 'passwords.txt' -exec cat {} + | anew osint/passwords.txt | sed '/^$/d' | wc -l)- NUMOFLINES_subs_total=$(find . -type f -name 'subdomains.txt' -exec cat {} + | anew subdomains/subdomains.txt | sed '/^$/d' | wc -l)- NUMOFLINES_subtko_total=$(find . -type f -name 'takeover.txt' -exec cat {} + | anew webs/takeover.txt | sed '/^$/d' | wc -l)- NUMOFLINES_webs_total=$(find . -type f -name 'webs.txt' -exec cat {} + | anew webs/webs.txt | sed '/^$/d' | wc -l)- NUMOFLINES_webs_total_uncommon=$(find . -type f -name 'webs_uncommon_ports.txt' -exec cat {} + | anew webs/webs_uncommon_ports.txt | sed '/^$/d' | wc -l)- NUMOFLINES_ips_total=$(find . -type f -name 'ips.txt' -exec cat {} + | anew hosts/ips.txt | sed '/^$/d' | wc -l)- NUMOFLINES_cloudsprov_total=$(find . -type f -name 'cdn_providers.txt' -exec cat {} + | anew hosts/cdn_providers.txt | sed '/^$/d' | wc -l)- find . -type f -name 'portscan_active.gnmap' -exec cat {} + | tee hosts/portscan_active.gnmap 2>>"$LOGFILE" >/dev/null- find . -type f -name 'portscan_passive.txt' -exec cat {} + | tee hosts/portscan_passive.txt 2>&1 >>"$LOGFILE" >/dev/null-- notification "- ${NUMOFLINES_pwndb_total} total creds leaked" good- notification "- ${NUMOFLINES_subs_total} total subdomains" good- notification "- ${NUMOFLINES_subtko_total} total probably subdomain takeovers" good- notification "- ${NUMOFLINES_webs_total} total websites" good- notification "- ${NUMOFLINES_webs_total_uncommon} total websites on uncommon ports" good- notification "- ${NUMOFLINES_ips_total} total ips" good- notification "- ${NUMOFLINES_cloudsprov_total} total IPs belongs to cloud" good- s3buckets- waf_checks- nuclei_check- for domain in "${targets[@]}"; do- [[ -z "$domain" ]] && continue- loopstart=$(date +%s)- dir="$workdir/targets/$domain"- called_fn_dir="$dir/.called_fn"- cd "$dir" || {- echo "Failed to cd directory '$dir' in ${FUNCNAME[0]} @ line ${LINENO}"- exit 1- }- loopstart=$(date +%s)- fuzz- iishortname- urlchecks- jschecks- currently=$(date +"%H:%M:%S")- loopend=$(date +%s)- getElapsedTime "$loopstart" "$loopend"- printf "${bgreen}#######################################################################${reset}\n"- printf "${bgreen}[$(date +'%Y-%m-%d %H:%M:%S')] $domain finished 3rd loop in ${runtime} $currently ${reset}\n"- if [[ -n $flist ]]; then- POSINLIST=$(grep -nrE "^${domain}$" "$flist" | cut -f1 -d':')- printf "\n${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] $domain is $POSINLIST of $LISTTOTAL${reset}\n"- fi- printf "${bgreen}#######################################################################${reset}\n"- done-- if [[ $AXIOM == true ]]; then- axiom_shutdown- fi-- for domain in "${targets[@]}"; do- [[ -z "$domain" ]] && continue- loopstart=$(date +%s)- dir="$workdir/targets/$domain"- called_fn_dir="$dir/.called_fn"- cd "$dir" || {- echo "Failed to cd directory '$dir' in ${FUNCNAME[0]} @ line ${LINENO}"- exit 1- }- cms_scanner- url_gf- wordlist_gen- wordlist_gen_roboxtractor- password_dict- url_ext- currently=$(date +"%H:%M:%S")- loopend=$(date +%s)- getElapsedTime "$loopstart" "$loopend"- printf "${bgreen}#######################################################################${reset}\n"- printf "${bgreen}[$(date +'%Y-%m-%d %H:%M:%S')] $domain finished final loop in ${runtime} $currently ${reset}\n"- if [[ -n $flist ]]; then- POSINLIST=$(grep -nrE "^${domain}$" "$flist" | cut -f1 -d':')- printf "\n${yellow}[$(date +'%Y-%m-%d %H:%M:%S')] $domain is $POSINLIST of $LISTTOTAL${reset}\n"- fi- printf "${bgreen}#######################################################################${reset}\n"- done- cd "$workdir" || {- echo "Failed to cd directory '$workdir' in ${FUNCNAME[0]} @ line ${LINENO}"- exit 1- }- dir=$workdir- domain=$multi- end- [ "$SOFT_NOTIFICATION" = true ] && echo "$(date +'%Y-%m-%d %H:%M:%S') Finished Recon on: ${multi} in ${runtime}" | notify -silent-}--function multi_custom() {-- global_start=$(date +%s)-- if [[ -s "$list" ]]; then- sed_i 's/\r$//' "$list"- else- notification "Target list not provided" error- exit- fi+# Determine script path for module loading+# (full SCRIPTPATH is set later during config phase; use a temporary value here)+_INIT_SCRIPTPATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd -P)"+SCRIPTPATH="${_INIT_SCRIPTPATH}"- dir="${SCRIPTPATH}/Recon/${multi}"- if [[ -z "$multi" || "$dir" != "${SCRIPTPATH}/Recon/"* ]]; then- echo "[!] Refusing to remove '$dir' -- safety check failed"- return 1- fi- rm -rf -- "$dir"- mkdir -p "$dir" || {- echo "Failed to create directory '$dir' in ${FUNCNAME[0]} @ line ${LINENO}"- exit 1- }- cd "$dir" || {- echo "Failed to cd directory '$dir' in ${FUNCNAME[0]} @ line ${LINENO}"- exit 1- }+# Source all modules in dependency order+source "${_INIT_SCRIPTPATH}/modules/utils.sh"+source "${_INIT_SCRIPTPATH}/modules/core.sh"+source "${_INIT_SCRIPTPATH}/modules/osint.sh"+source "${_INIT_SCRIPTPATH}/modules/subdomains.sh"+source "${_INIT_SCRIPTPATH}/modules/web.sh"+source "${_INIT_SCRIPTPATH}/modules/vulns.sh"+source "${_INIT_SCRIPTPATH}/modules/axiom.sh"+source "${_INIT_SCRIPTPATH}/modules/modes.sh"- mkdir -p {.called_fn,.log}- called_fn_dir="$dir/.called_fn"- NOW=$(date +"%F")- NOWT=$(date +"%T")- LOGFILE="${dir}/.log/${NOW}_${NOWT}.txt"- touch ".log/${NOW}_${NOWT}.txt"- echo "[$(date +'%Y-%m-%d %H:%M:%S')] Start ${NOW} ${NOWT}" >"${LOGFILE}"- enable_command_trace-- [ -n "$flist" ] && entries=$(wc -l < "$flist")-- if [[ $AXIOM == true ]]; then- axiom_launch- axiom_selected- fi-- custom_function_list=$(echo "$custom_function" | tr ',' '\n')- func_total=$(echo "$custom_function_list" | wc -l)-- func_count=0- domain=$(cat "$flist")- for custom_f in $custom_function_list; do- ((func_count = func_count + 1))-- loopstart=$(date +%s)-- $custom_f-- currently=$(date +"%H:%M:%S")- loopend=$(date +%s)- getElapsedTime "$loopstart" "$loopend"- printf "${bgreen}#######################################################################${reset}\n"- printf "${bgreen}[$(date +'%Y-%m-%d %H:%M:%S')] Finished $custom_f ($func_count/$func_total) for $entries entries in ${runtime} $currently ${reset}\n"- printf "${bgreen}#######################################################################${reset}\n"- done-- if [[ $AXIOM == true ]]; then- axiom_shutdown- fi-- end-}--function subs_menu() {- start-- if [[ $AXIOM == true ]]; then- axiom_launch- axiom_selected- fi-- subdomains_full- webprobe_full- subtakeover- remove_big_files- screenshot- # virtualhosts- zonetransfer- s3buckets-- if [[ $AXIOM == true ]]; then- axiom_shutdown- fi-- end-}--function webs_menu() {- subtakeover- remove_big_files- screenshot- # virtualhosts- waf_checks- nuclei_check- graphql_scan- fuzz- cms_scanner- iishortname- urlchecks- jschecks- websocket_checks- url_gf- wordlist_gen- wordlist_gen_roboxtractor- password_dict- url_ext- param_discovery- grpc_reflection- vulns- end-}--function zen_menu() {- start- if [[ $AXIOM == true ]]; then- axiom_launch- axiom_selected- fi- subdomains_full- webprobe_full- subtakeover- remove_big_files- s3buckets- screenshot- # virtualhosts- cdnprovider- waf_checks- nuclei_check- graphql_scan- fuzz- iishortname- if [[ $AXIOM == true ]]; then- axiom_shutdown- fi- cms_scanner- end-}--function help() {- pt_header "Usage"- printf "\n Usage: $0 [-d domain.tld] [-m name] [-l list.txt] [-x oos.txt] [-i in.txt] "- printf "\n [-r] [-s] [-p] [-a] [-w] [-n] [-z] [-c] [-y] [-h] [-f] [--ai] [--deep] [-o OUTPUT]\n\n"- printf " ${bblue}TARGET OPTIONS${reset}\n"- printf " -d domain.tld Target domain\n"- printf " -m company Target company name\n"- printf " -l list.txt Targets list (One on each line)\n"- printf " -x oos.txt Excludes subdomains list (Out Of Scope)\n"- printf " -i in.txt Includes subdomains list\n"- printf " \n"- printf " ${bblue}MODE OPTIONS${reset}\n"- printf " -r, --recon Recon - Performs full recon process (without attacks)\n"- printf " -s, --subdomains Subdomains - Performs Subdomain Enumeration, Web probing and check for sub-tko\n"- printf " -p, --passive Passive - Performs only passive steps\n"- printf " -a, --all All - Performs all checks and active exploitations\n"- printf " -w, --web Web - Performs web checks from list of subdomains\n"- printf " -n, --osint OSINT - Checks for public intel data\n"- printf " -z, --zen Zen - Performs a recon process covering the basics and some vulns\n"- printf " -c, --custom Custom - Launches specific function against target, u need to know the function name first\n"- printf " -y, --ai AI - Analyzes ReconFTW results using a local LLM\n"- printf " -h Help - Show help section\n"- printf " \n"- printf " ${bblue}GENERAL OPTIONS${reset}\n"- printf " --deep Deep scan (Enable some slow options for deeper scan)\n"- printf " -f config_file Alternate reconftw.cfg file\n"- printf " -o output/path Define output folder\n"- printf " -v, --vps Axiom distributed VPS\n"- printf " -q Rate limit in requests per second\n"- printf " --check-tools Exit if one of the tools is missing\n"- printf " --quick-rescan Skip heavy steps if no new subs/webs this run\n"- printf " --incremental Only scan new findings since last run\n"- printf " --adaptive-rate Automatically adjust rate limits on errors (429/503)\n"- printf " --dry-run Show what would be executed without running commands\n"- printf " \n"- printf " ${bblue}USAGE EXAMPLES${reset}\n"- printf " ${byellow}Perform full recon (without attacks):${reset}\n"- printf " ./reconftw.sh -d example.com -r\n"- printf " \n"- printf " ${byellow}Perform subdomain enumeration on multiple targets:${reset}\n"- printf " ./reconftw.sh -l targets.txt -s\n"- printf " \n"- printf " ${byellow}Perform Web based scanning on a subdomains list:${reset}\n"- printf " ./reconftw.sh -d example.com -l targets.txt -w\n"- printf " \n"- printf " ${byellow}Multidomain recon:${reset}\n"- printf " ./reconftw.sh -m company -l domainlist.txt -r\n"- printf " \n"- printf " ${byellow}Perform full recon (with active attacks) along Out-Of-Scope subdomains list:${reset}\n"- printf " ./reconftw.sh -d example.com -x out.txt -a\n"- printf " \n"- printf " ${byellow}Analyze ReconFTW results with AI:${reset}\n"- printf " ./reconftw.sh -d example.com -r --ai\n"- printf " \n"- printf " ${byellow}Run custom function:${reset}\n"- printf " ./reconftw.sh -d example.com -c nuclei_check \n"-}+# Allow sourcing functions without execution (for testing)+# Must be checked before argument parsing to avoid side effects+if [[ "${1:-}" == "--source-only" ]]; then+ return 0 2>/dev/null || exit 0+fi########################################################################################################################################################## START SCRIPT #####################################################@@ -7491,196 +80,210 @@ function help() {# macOS PATH initialization, thanks @0xtavian <3if [[ $OSTYPE == "darwin"* ]]; then- if ! command -v brew &>/dev/null; then- printf "\n%bBrew is not installed or not in the PATH.%b\n\n" "$bred" "$reset"- exit 1- fi- if [[ ! -x "$(brew --prefix gnu-getopt)/bin/getopt" ]]; then- printf "\n%bBrew formula gnu-getopt is not installed.%b\n\n" "$bred" "$reset"- exit 1- fi- if [[ ! -d "$(brew --prefix coreutils)/libexec/gnubin" ]]; then- printf "\n%bBrew formula coreutils is not installed.%b\n\n" "$bred" "$reset"- exit 1- fi- if [[ ! -d "$(brew --prefix gnu-sed)/libexec/gnubin" ]]; then- printf "\n%bBrew formula gnu-sed is not installed.%b\n\n" "$bred" "$reset"- exit 1- fi- # Prefix is different depending on Intel vs Apple Silicon- PATH="$(brew --prefix gnu-getopt)/bin:$PATH"- PATH="$(brew --prefix coreutils)/libexec/gnubin:$PATH"- PATH="$(brew --prefix gnu-sed)/libexec/gnubin:$PATH"+ if ! command -v brew &>/dev/null; then+ printf "\n%bBrew is not installed or not in the PATH.%b\n\n" "$bred" "$reset"+ exit 1+ fi+ if [[ ! -x "$(brew --prefix gnu-getopt)/bin/getopt" ]]; then+ printf "\n%bBrew formula gnu-getopt is not installed.%b\n\n" "$bred" "$reset"+ exit 1+ fi+ if [[ ! -d "$(brew --prefix coreutils)/libexec/gnubin" ]]; then+ printf "\n%bBrew formula coreutils is not installed.%b\n\n" "$bred" "$reset"+ exit 1+ fi+ if [[ ! -d "$(brew --prefix gnu-sed)/libexec/gnubin" ]]; then+ printf "\n%bBrew formula gnu-sed is not installed.%b\n\n" "$bred" "$reset"+ exit 1+ fi+ # Prefix is different depending on Intel vs Apple Silicon+ PATH="$(brew --prefix gnu-getopt)/bin:$PATH"+ PATH="$(brew --prefix coreutils)/libexec/gnubin:$PATH"+ PATH="$(brew --prefix gnu-sed)/libexec/gnubin:$PATH"fi-PROGARGS=$(getopt -o 'd:m:l:x:i:o:f:q:c:zrspanwvyh' --long 'domain:,list:,recon,subdomains,passive,all,web,osint,zen,deep,help,vps,ai,check-tools,quick-rescan,incremental,adaptive-rate,dry-run' -n 'reconFTW' -- "$@")+PROGARGS=$(getopt -o 'd:m:l:x:i:o:f:q:c:zrspanwvyh' --long 'domain:,list:,recon,subdomains,passive,all,web,osint,zen,deep,help,vps,ai,check-tools,health-check,quick-rescan,incremental,adaptive-rate,dry-run' -n 'reconFTW' -- "$@")exit_status=$?if [[ $exit_status -ne 0 ]]; then- UNKNOWN_ARGUMENT=true+ UNKNOWN_ARGUMENT=truefi# Note the quotes around "$PROGARGS": they are essential!-# shellcheck disable=SC2086 -- Standard getopt idiom; PROGARGS is sanitized getopt output+# shellcheck disable=SC2086eval set -- "$PROGARGS"unset PROGARGSwhile true; do- case "$1" in- '-d' | '--domain')- # Sanitize domain input to prevent command injection- if ! domain=$(sanitize_domain "$2"); then- printf "%b[%s] ERROR: Invalid domain provided: '%s'%b\n" \- "$bred" "$(date +'%Y-%m-%d %H:%M:%S')" "$2" "$reset"- exit 1- fi- ipcidr_target "$domain"- shift 2- continue- ;;- '-m')- multi=$2- shift 2- continue- ;;- '-l' | '--list')- list="$2"- while IFS= read -r t; do- [[ -z "$t" ]] && continue- ipcidr_target "$t" "$list"- done < "$list"- shift 2- continue- ;;- '-x')- outOfScope_file=$2- shift 2- continue- ;;- '-i')- inScope_file=$2- shift 2- continue- ;;- # modes- '-r' | '--recon')- opt_mode='r'- shift- continue- ;;- '-s' | '--subdomains')- opt_mode='s'- shift- continue- ;;- '-p' | '--passive')- opt_mode='p'- shift- continue- ;;- '-a' | '--all')- opt_mode='a'- shift- continue- ;;- '-w' | '--web')- opt_mode='w'- shift- continue- ;;- '-n' | '--osint')- opt_mode='n'- shift- continue- ;;- '-c' | '--custom')- custom_function=$2- opt_mode='c'- shift 2- continue- ;;- '-z' | '--zen')- opt_mode='z'- shift- continue- ;;- '-y' | '--ai')- opt_ai=true- shift- continue- ;;- # extra stuff- '-o')- if [[ $2 != /* ]]; then- dir_output=$PWD/$2- else- dir_output=$2- fi- shift 2- continue- ;;- '-v' | '--vps')- command -v axiom-ls &>/dev/null || {- printf "\n Axiom is needed for this mode and is not installed \n You have to install it manually \n" && exit- }- AXIOM=true- shift- continue- ;;- '-f')- CUSTOM_CONFIG=$2- shift 2- continue- ;;- '-q')- rate_limit=$2- shift 2- continue- ;;- '--deep')- opt_deep=true- shift- continue- ;;-- '--')- shift- break- ;;- '--check-tools')- CHECK_TOOLS_OR_EXIT=true- shift- continue- ;;- '--quick-rescan')- QUICK_RESCAN=true- shift- continue- ;;- '--incremental')- INCREMENTAL_MODE=true- shift- continue- ;;- '--adaptive-rate')- ADAPTIVE_RATE_LIMIT=true- shift- continue- ;;- '--dry-run')- DRY_RUN=true- shift- continue- ;;- '--help' | '-h')- break- ;;- *)- # echo "Unknown argument: $1"- UNKNOWN_ARGUMENT=true- break- ;;- esac+ case "$1" in+ '-d' | '--domain')+ # Sanitize target input to prevent command injection+ target_input="$2"+ if [[ "$target_input" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+(/[0-9]+)?$ ]]; then+ if ! domain=$(sanitize_ip "$target_input"); then+ printf "%b[%s] ERROR: Invalid IP/CIDR provided: '%s'%b\n" \+ "$bred" "$(date +'%Y-%m-%d %H:%M:%S')" "$target_input" "$reset"+ exit 1+ fi+ else+ if ! domain=$(sanitize_domain "$target_input"); then+ printf "%b[%s] ERROR: Invalid domain provided: '%s'%b\n" \+ "$bred" "$(date +'%Y-%m-%d %H:%M:%S')" "$target_input" "$reset"+ exit 1+ fi+ fi+ ipcidr_target "$domain"+ shift 2+ continue+ ;;+ '-m')+ multi=$2+ shift 2+ continue+ ;;+ '-l' | '--list')+ list="$2"+ while IFS= read -r t; do+ [[ -z "$t" ]] && continue+ ipcidr_target "$t" "$list"+ done <"$list"+ shift 2+ continue+ ;;+ '-x')+ outOfScope_file=$2+ shift 2+ continue+ ;;+ '-i')+ inScope_file=$2+ shift 2+ continue+ ;;+ # modes+ '-r' | '--recon')+ opt_mode='r'+ shift+ continue+ ;;+ '-s' | '--subdomains')+ opt_mode='s'+ shift+ continue+ ;;+ '-p' | '--passive')+ opt_mode='p'+ shift+ continue+ ;;+ '-a' | '--all')+ opt_mode='a'+ shift+ continue+ ;;+ '-w' | '--web')+ opt_mode='w'+ shift+ continue+ ;;+ '-n' | '--osint')+ opt_mode='n'+ shift+ continue+ ;;+ '-c' | '--custom')+ custom_function=$2+ opt_mode='c'+ shift 2+ continue+ ;;+ '-z' | '--zen')+ opt_mode='z'+ shift+ continue+ ;;+ '-y' | '--ai')+ opt_ai=true+ shift+ continue+ ;;+ # extra stuff+ '-o')+ if [[ $2 != /* ]]; then+ dir_output=$PWD/$2+ else+ dir_output=$2+ fi+ shift 2+ continue+ ;;+ '-v' | '--vps')+ command -v axiom-ls &>/dev/null || {+ printf "\n Axiom is needed for this mode and is not installed \n You have to install it manually \n" && exit+ }+ AXIOM=true+ shift+ continue+ ;;+ '-f')+ CUSTOM_CONFIG=$2+ shift 2+ continue+ ;;+ '-q')+ rate_limit=$2+ shift 2+ continue+ ;;+ '--deep')+ opt_deep=true+ shift+ continue+ ;;++ '--')+ shift+ break+ ;;+ '--check-tools')+ CHECK_TOOLS_OR_EXIT=true+ shift+ continue+ ;;+ '--health-check')+ HEALTH_CHECK=true+ shift+ continue+ ;;+ '--quick-rescan')+ QUICK_RESCAN=true+ shift+ continue+ ;;+ '--incremental')+ INCREMENTAL_MODE=true+ shift+ continue+ ;;+ '--adaptive-rate')+ ADAPTIVE_RATE_LIMIT=true+ shift+ continue+ ;;+ '--dry-run')+ DRY_RUN=true+ shift+ continue+ ;;+ '--help' | '-h')+ break+ ;;+ *)+ # echo "Unknown argument: $1"+ UNKNOWN_ARGUMENT=true+ break+ ;;+ esacdone# Initialize some variables@@ -7699,55 +302,55 @@ done# This is the first thing to do to read in alternate configSCRIPTPATH="$(- cd "$(dirname "$0")" >/dev/null 2>&1 || exit- pwd -P+ cd "$(dirname "$0")" >/dev/null 2>&1 || exit+ pwd -P)". "${SCRIPTPATH}"/reconftw.cfg || {- echo "Error importing reconftw.cfg"- exit 1+ echo "Error importing reconftw.cfg"+ exit 1}# Source optional secrets file (gitignored, for API keys and tokens)[[ -f "${SCRIPTPATH}/secrets.cfg" ]] && . "${SCRIPTPATH}/secrets.cfg"if [[ -s $CUSTOM_CONFIG ]]; then- # shellcheck source=/home/six2dez/Tools/reconftw/custom_config.cfg- . "${CUSTOM_CONFIG}" || {- echo "Error importing reconftw.ctg"- exit 1- }+ # shellcheck source=/home/six2dez/Tools/reconftw/custom_config.cfg+ . "${CUSTOM_CONFIG}" || {+ echo "Error importing reconftw.ctg"+ exit 1+ }fiif [[ $opt_deep ]]; then- DEEP=true+ DEEP=truefiif [[ $rate_limit ]]; then- NUCLEI_RATELIMIT=$rate_limit- FFUF_RATELIMIT=$rate_limit- HTTPX_RATELIMIT=$rate_limit+ NUCLEI_RATELIMIT=$rate_limit+ FFUF_RATELIMIT=$rate_limit+ HTTPX_RATELIMIT=$rate_limitfiif [[ -n $outOfScope_file ]]; then- isAsciiText $outOfScope_file- if [[ "False" == "$IS_ASCII" ]]; then- printf "\n\n${bred} Out of Scope file is not a text file${reset}\n\n"- exit- fi+ isAsciiText $outOfScope_file+ if [[ "False" == "$IS_ASCII" ]]; then+ printf "\n\n${bred} Out of Scope file is not a text file${reset}\n\n"+ exit+ fifiif [[ -n $inScope_file ]]; then- isAsciiText $inScope_file- if [[ "False" == "$IS_ASCII" ]]; then- printf "\n\n${bred} In Scope file is not a text file${reset}\n\n"- exit- fi+ isAsciiText $inScope_file+ if [[ "False" == "$IS_ASCII" ]]; then+ printf "\n\n${bred} In Scope file is not a text file${reset}\n\n"+ exit+ fifiif [[ $(id -u | grep -o '^0$') == "0" ]]; then- SUDO=" "+ SUDO=" "else- SUDO="sudo"+ SUDO="sudo"fistartdir=${PWD}@@ -7758,186 +361,187 @@ check_version# Check critical dependencies before proceedingif [[ "${SKIP_CRITICAL_CHECK:-false}" != "true" ]]; then- check_critical_dependencies+ check_critical_dependencies+fi++# Run health check if requested and exit+if [[ "${HEALTH_CHECK:-false}" == "true" ]]; then+ health_check+ exit $?fi# Show DRY_RUN mode warning if enabledif [[ "${DRY_RUN:-false}" == "true" ]]; then- printf "\n%b#######################################################################%b\n" "$bgreen" "$reset"- printf "%b[%s] DRY-RUN MODE ENABLED - Commands will be shown but not executed%b\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"- printf "%b#######################################################################%b\n\n" "$bgreen" "$reset"+ printf "\n%b#######################################################################%b\n" "$bgreen" "$reset"+ printf "%b[%s] DRY-RUN MODE ENABLED - Commands will be shown but not executed%b\n" "$yellow" "$(date +'%Y-%m-%d %H:%M:%S')" "$reset"+ printf "%b#######################################################################%b\n\n" "$bgreen" "$reset"fistartdir=${PWD}if [[ -n $list ]]; then- if [[ $list == ./* ]]; then- flist="${startdir}/${list:2}"- elif [[ $list == ~* ]]; then- flist="${HOME}/${list:2}"- elif [[ $list == /* ]]; then- flist=$list- else- flist="$startdir/$list"- fi+ if [[ $list == ./* ]]; then+ flist="${startdir}/${list:2}"+ elif [[ $list == ~* ]]; then+ flist="${HOME}/${list:2}"+ elif [[ $list == /* ]]; then+ flist=$list+ else+ flist="$startdir/$list"+ fielse- flist=''-fi--# Allow sourcing functions without execution (for testing)-if [[ "${1:-}" == "--source-only" ]]; then- return 0 2>/dev/null || exit 0+ flist=''ficase $opt_mode in-'r')- if [[ -n $multi ]]; then- if [[ $AXIOM == true ]]; then- mode="multi_recon"- fi- multi_recon- exit- fi- if [[ -n $list ]]; then- if [[ $AXIOM == true ]]; then- mode="list_recon"- fi- sed_i 's/\r$//' "$list"- while IFS= read -r domain; do- [[ -z "$domain" ]] && continue- start- recon- end- done < "$list"- else- if [[ $AXIOM == true ]]; then- mode="recon"- fi- start- recon- end- fi- ;;-'s')- if [[ -n $list ]]; then- if [[ $AXIOM == true ]]; then- mode="subs_menu"- fi- sed_i 's/\r$//' "$list"- while IFS= read -r domain; do- [[ -z "$domain" ]] && continue- subs_menu- done < "$list"- else- subs_menu- fi- ;;-'p')- if [[ -n $list ]]; then- if [[ $AXIOM == true ]]; then- mode="passive"- fi- sed_i 's/\r$//' "$list"- while IFS= read -r domain; do- [[ -z "$domain" ]] && continue- passive- done < "$list"- else- passive- fi- ;;-'a')- export VULNS_GENERAL=true- if [[ -n $list ]]; then- if [[ $AXIOM == true ]]; then- mode="all"- fi- sed_i 's/\r$//' "$list"- while IFS= read -r domain; do- [[ -z "$domain" ]] && continue- all- done < "$list"- else- all- fi- ;;-'w')- if [[ -n $list ]]; then- start- if [[ $list == /* ]]; then- cp "$list" "$dir/webs/webs.txt"- else- cp "${SCRIPTPATH}/$list" "$dir/webs/webs.txt"- fi- else- printf "\n\n${bred} Web mode needs a website list file as target (./reconftw.sh -l target.txt -w) ${reset}\n\n"- exit- fi- webs_menu- exit- ;;-'n')- PRESERVE=true- if [[ -n $multi ]]; then- multi_osint- exit- fi- if [[ -n $list ]]; then- sed_i 's/\r$//' "$list"- while IFS= read -r domain; do- [[ -z "$domain" ]] && continue- start- osint- end- done < "$list"- else- start- osint- end- fi- ;;-'z')- if [[ -n $list ]]; then- if [[ $AXIOM == true ]]; then- mode="zen_menu"- fi- sed_i 's/\r$//' "$list"- while IFS= read -r domain; do- [[ -z "$domain" ]] && continue- zen_menu- done < "$list"- else- zen_menu- fi- ;;-'c')- if [[ -n $multi ]]; then- if [[ $AXIOM == true ]]; then- mode="multi_custom"- fi- multi_custom- else- export DIFF=true- dir="${SCRIPTPATH}/Recon/$domain"- cd $dir || {- echo "Failed to cd directory '$dir'"- exit 1- }- LOGFILE="${dir}/.log/${NOW}_${NOWT}.txt"- called_fn_dir=$dir/.called_fn- $custom_function- cd ${SCRIPTPATH} || {- echo "Failed to cd directory '$dir'"- exit 1- }- fi- exit- ;;- # No mode selected. EXIT!-*)- help- tools_installed- if [[ $UNKNOWN_ARGUMENT == true ]]; then- exit 1- fi- ;;+ 'r')+ if [[ -n $multi ]]; then+ if [[ $AXIOM == true ]]; then+ mode="multi_recon"+ fi+ multi_recon+ exit+ fi+ if [[ -n $list ]]; then+ if [[ $AXIOM == true ]]; then+ mode="list_recon"+ fi+ sed_i 's/\r$//' "$list"+ while IFS= read -r domain; do+ [[ -z "$domain" ]] && continue+ start+ recon+ end+ done <"$list"+ else+ if [[ $AXIOM == true ]]; then+ mode="recon"+ fi+ start+ recon+ end+ fi+ ;;+ 's')+ if [[ -n $list ]]; then+ if [[ $AXIOM == true ]]; then+ mode="subs_menu"+ fi+ sed_i 's/\r$//' "$list"+ while IFS= read -r domain; do+ [[ -z "$domain" ]] && continue+ subs_menu+ done <"$list"+ else+ subs_menu+ fi+ ;;+ 'p')+ if [[ -n $list ]]; then+ if [[ $AXIOM == true ]]; then+ mode="passive"+ fi+ sed_i 's/\r$//' "$list"+ while IFS= read -r domain; do+ [[ -z "$domain" ]] && continue+ passive+ done <"$list"+ else+ passive+ fi+ ;;+ 'a')+ export VULNS_GENERAL=true+ if [[ -n $list ]]; then+ if [[ $AXIOM == true ]]; then+ mode="all"+ fi+ sed_i 's/\r$//' "$list"+ while IFS= read -r domain; do+ [[ -z "$domain" ]] && continue+ all+ done <"$list"+ else+ all+ fi+ ;;+ 'w')+ if [[ -n $list ]]; then+ start+ if [[ $list == /* ]]; then+ cp "$list" "$dir/webs/webs.txt"+ else+ cp "${SCRIPTPATH}/$list" "$dir/webs/webs.txt"+ fi+ else+ printf "\n\n${bred} Web mode needs a website list file as target (./reconftw.sh -l target.txt -w) ${reset}\n\n"+ exit+ fi+ webs_menu+ exit+ ;;+ 'n')+ PRESERVE=true+ if [[ -n $multi ]]; then+ multi_osint+ exit+ fi+ if [[ -n $list ]]; then+ sed_i 's/\r$//' "$list"+ while IFS= read -r domain; do+ [[ -z "$domain" ]] && continue+ start+ osint+ end+ done <"$list"+ else+ start+ osint+ end+ fi+ ;;+ 'z')+ if [[ -n $list ]]; then+ if [[ $AXIOM == true ]]; then+ mode="zen_menu"+ fi+ sed_i 's/\r$//' "$list"+ while IFS= read -r domain; do+ [[ -z "$domain" ]] && continue+ zen_menu+ done <"$list"+ else+ zen_menu+ fi+ ;;+ 'c')+ if [[ -n $multi ]]; then+ if [[ $AXIOM == true ]]; then+ mode="multi_custom"+ fi+ multi_custom+ else+ export DIFF=true+ dir="${SCRIPTPATH}/Recon/$domain"+ cd $dir || {+ echo "Failed to cd directory '$dir'"+ exit 1+ }+ LOGFILE="${dir}/.log/${NOW}_${NOWT}.txt"+ called_fn_dir=$dir/.called_fn+ $custom_function+ cd ${SCRIPTPATH} || {+ echo "Failed to cd directory '$dir'"+ exit 1+ }+ fi+ exit+ ;;+ # No mode selected. EXIT!+ *)+ help+ tools_installed+ if [[ $UNKNOWN_ARGUMENT == true ]]; then+ exit 1+ fi+ ;;esacdiff --git a/tests/run_tests.sh b/tests/run_tests.shnew file mode 100644index 0000000..212bb31--- /dev/null+++ b/tests/run_tests.sh@@ -0,0 +1,25 @@+#!/bin/bash+# Run all reconFTW tests+# Requires: bats-core (https://github.com/bats-core/bats-core)++set -euo pipefail++SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"+BATS="${BATS:-bats}"++if ! command -v "$BATS" >/dev/null 2>&1; then+ echo "bats-core not found. Install: https://github.com/bats-core/bats-core"+ echo " brew install bats-core (macOS)"+ echo " apt install bats (Debian/Ubuntu)"+ exit 1+fi++echo "Running unit tests..."+"$BATS" "$SCRIPT_DIR"/unit/*.bats++if [[ "${1:-}" == "--all" ]]; then+ echo "Running integration tests..."+ "$BATS" "$SCRIPT_DIR"/integration/*.bats+fi++echo "All tests passed."diff --git a/tests/unit/test_phase6.bats b/tests/unit/test_phase6.batsnew file mode 100644index 0000000..160d116--- /dev/null+++ b/tests/unit/test_phase6.bats@@ -0,0 +1,61 @@+#!/usr/bin/env bats++# Unit tests for Phase 6 features (Incremental, Dry-Run, Adaptive Rate)++setup() {+ local project_root+ project_root="$(cd "$(dirname "$BATS_TEST_FILENAME")/../.." && pwd)"+ export SCRIPTPATH="$project_root"+ export LOGFILE="/dev/null"+ export bred='' bblue='' bgreen='' byellow='' yellow='' reset=''+ source "$project_root/reconftw.sh" --source-only+}++@test "run_command executes command in normal mode" {+ run run_command echo "hello"+ [ "$status" -eq 0 ]+ [ "$output" = "hello" ]+}++@test "run_command prints command in dry-run mode" {+ export DRY_RUN="true"+ run run_command echo "hello"+ [ "$status" -eq 0 ]+ [[ "$output" == *"[DRY-RUN] Would execute: echo hello"* ]]+}++@test "incremental_init creates directory structure" {+ export INCREMENTAL_MODE="true"+ export INCREMENTAL_DIR=".tmp_incremental"+ run incremental_init+ [ "$status" -eq 0 ]+ [ -d "$INCREMENTAL_DIR/previous" ]+ rm -rf "$INCREMENTAL_DIR"+}++@test "incremental_diff finds new items" {+ export INCREMENTAL_MODE="true"+ export INCREMENTAL_DIR=".tmp_incremental"+ mkdir -p "$INCREMENTAL_DIR/previous"++ echo "item1" > "$INCREMENTAL_DIR/previous/test_latest.txt"+ echo "item1" > "current.txt"+ echo "item2" >> "current.txt"++ run incremental_diff "test" "current.txt" "new.txt"+ [ "$status" -eq 0 ]+ [[ "$output" == *"Incremental mode test: 1 new"* ]]+ [ "$(cat new.txt)" = "item2" ]++ rm -rf "$INCREMENTAL_DIR" "current.txt" "new.txt"+}++@test "detect_rate_limit_error detects 429" {+ run detect_rate_limit_error "Error: 429 Too Many Requests"+ [ "$status" -eq 0 ]+}++@test "detect_rate_limit_error ignores normal output" {+ run detect_rate_limit_error "Found 10 subdomains"+ [ "$status" -eq 1 ]+}\ No newline at end of filediff --git a/tests/unit/test_sanitize.bats b/tests/unit/test_sanitize.batsindex 1a1645e..16b5e83 100644--- a/tests/unit/test_sanitize.bats+++ b/tests/unit/test_sanitize.bats@@ -3,14 +3,17 @@# Unit tests for reconFTW sanitization functionssetup() {- export SCRIPTPATH="$(cd "$(dirname "$BATS_TEST_FILENAME")/../.." && pwd)"+ local project_root+ project_root="$(cd "$(dirname "$BATS_TEST_FILENAME")/../.." && pwd)"export tools="$HOME/Tools"export LOGFILE="/dev/null"export bred='' bblue='' bgreen='' byellow='' yellow='' reset=''export NOTIFICATION=falseexport AXIOM=false- source "$SCRIPTPATH/reconftw.cfg" 2>/dev/null || true- source "$SCRIPTPATH/reconftw.sh" --source-only 2>/dev/null || true+ source "$project_root/reconftw.cfg" 2>/dev/null || true+ # Restore SCRIPTPATH after cfg overrides it with $0+ export SCRIPTPATH="$project_root"+ source "$project_root/reconftw.sh" --source-only}@test "sanitize_domain accepts valid domain" {@@ -23,6 +26,16 @@ setup() {[ "$result" = "sub.example.com" ]}+@test "sanitize_domain converts to lowercase" {+ result=$(sanitize_domain "EXAMPLE.COM")+ [ "$result" = "example.com" ]+}++@test "sanitize_domain handles mixed case" {+ result=$(sanitize_domain "Sub.ExAmPlE.CoM")+ [ "$result" = "sub.example.com" ]+}+@test "sanitize_domain rejects command injection attempt" {run sanitize_domain '; rm -rf /'[ "$status" -ne 0 ]diff --git a/tests/unit/test_utils.bats b/tests/unit/test_utils.batsindex 9be67f8..9593633 100644--- a/tests/unit/test_utils.bats+++ b/tests/unit/test_utils.bats@@ -3,16 +3,18 @@# Unit tests for reconFTW utility functionssetup() {- export SCRIPTPATH="$(cd "$(dirname "$BATS_TEST_FILENAME")/../.." && pwd)"+ local project_root+ project_root="$(cd "$(dirname "$BATS_TEST_FILENAME")/../.." && pwd)"# Set minimal required variables before sourcingexport tools="$HOME/Tools"export LOGFILE="/dev/null"export bred='' bblue='' bgreen='' byellow='' yellow='' reset=''export NOTIFICATION=falseexport AXIOM=false- # Source the config first, then the script- source "$SCRIPTPATH/reconftw.cfg" 2>/dev/null || true- source "$SCRIPTPATH/reconftw.sh" --source-only 2>/dev/null || true+ # Source the config first, then restore SCRIPTPATH (cfg overrides it with $0)+ source "$project_root/reconftw.cfg" 2>/dev/null || true+ export SCRIPTPATH="$project_root"+ source "$project_root/reconftw.sh" --source-only}@test "getElapsedTime calculates zero duration" {