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
parsing fixes
six2dez1e4819c6b9ca
diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.ymlindex fd1e364..07b49c2 100644--- a/.github/workflows/codeql.yml+++ b/.github/workflows/codeql.yml@@ -29,11 +29,11 @@ jobs:steps:- name: Checkout repository- uses: actions/checkout@v3+ uses: actions/checkout@v4# Initializes the CodeQL tools for scanning.- name: Initialize CodeQL- uses: github/codeql-action/init@v2+ uses: github/codeql-action/init@v3with:languages: ${{ matrix.language }}# If you wish to specify custom queries, you can do so here or in a config file.@@ -47,7 +47,7 @@ jobs:# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).# If this step fails, then you should remove it and run the build manually (see below)- name: Autobuild- uses: github/codeql-action/autobuild@v2+ uses: github/codeql-action/autobuild@v3# ℹ️ Command-line programs to run using the OS shell.# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun@@ -60,6 +60,6 @@ jobs:# ./location_of_script_within_repo/buildscript.sh- name: Perform CodeQL Analysis- uses: github/codeql-action/analyze@v2+ uses: github/codeql-action/analyze@v3with:category: "/language:${{matrix.language}}"diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.ymlindex 961716a..e3acfad 100644--- a/.github/workflows/tests.yml+++ b/.github/workflows/tests.yml@@ -31,7 +31,7 @@ jobs:run: sudo apt-get update && sudo apt-get install -y shellcheck- name: Run shellcheck- run: shellcheck -S warning reconftw.sh modules/*.sh lib/*.sh install.sh+ run: shellcheck -S error reconftw.sh modules/*.sh lib/*.sh install.shunit-fast:name: unit-fastdiff --git a/Docker/Dockerfile b/Docker/Dockerfileindex c439851..67efb63 100644--- a/Docker/Dockerfile+++ b/Docker/Dockerfile@@ -12,6 +12,9 @@ ARG LANGUAGE=en_USFROM ubuntu:24.04 AS base+# NOTE: This image intentionally runs as root. Some recon tooling relies on privileged operations+# (e.g., raw sockets/capabilities) and is commonly executed with elevated permissions.+LABEL org.label-schema.name='reconftw'LABEL org.label-schema.description='A simple script for full recon'LABEL org.label-schema.usage='https://github.com/six2dez/reconftw'@@ -61,13 +64,13 @@ apt updateapt full-upgrade -f -y --allow-downgradesapt install -y --no-install-recommends apt-utils ca-certificates curl git lsb-release nano wget vim jq htop net-tools dnsutils nmap python3 python3-pip unzip whois-###>> Congifure Locales <<###+###>> Configure Locales <<###apt install -y --no-install-recommends localessed -i -- "/${LANG}/s/^# //g" /etc/locale.gendpkg-reconfigure localesupdate-locale LANG=${LANG}-###>> Congifure localepurge <<###+###>> Configure localepurge <<###apt install -y --no-install-recommends localepurgesed -i -- '/^USE_DPKG/s/^/#/' /etc/locale.nopurgedpkg-reconfigure localepurgediff --git a/README.md b/README.mdindex 4124e83..7007e83 100644--- a/README.md+++ b/README.md@@ -353,7 +353,7 @@ cd reconftw4. **Customization**:- Modify the Docker image or build your own; see the [Docker Guide](https://github.com/six2dez/reconftw/wiki/4.-Docker).- 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.+ - Mount your notify config at `~/.config/notify/provider-config.yaml` inside the container if you use notifications.5. **Secrets at Runtime**:@@ -1265,7 +1265,7 @@ reconftw/```bashmake test # Unit tests-make test-security # Security tests+make test-security # Security testsmake test-all # All testsmake lint # Shellcheckmake lint-fix # Auto-fix with shfmtdiff --git a/Terraform/README.md b/Terraform/README.mdindex 8fc3fb4..6974a22 100644--- a/Terraform/README.md+++ b/Terraform/README.md@@ -2,6 +2,9 @@This is an automated script created to work under AWS by using Terraform and Ansible. It allows you to easily deploy it or to easily adapt it into your IaaC strategy.+> Note (best-effort): This Terraform/Ansible setup is provided as a reference. Cloud images, SSH usernames, and+> package repos change over time, so you may need to adjust it for your environment. It is not covered by reconFTW CI.+## RequirementsYou would need to have installed:@@ -10,17 +13,18 @@ You would need to have installed:- Terraform (<https://learn.hashicorp.com/tutorials/terraform/install-cli>)- Ansible (<https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html>)-As well as both `access_key` and `secret_key` (<https://aws.amazon.com/premiumsupport/knowledge-center/create-access-key/>)+And AWS credentials configured via the standard AWS provider chain (e.g., `AWS_PROFILE`, env vars, or an IAM role).## Deploying reconFTW on the AWS Cloud using Terraform and AnsibleNote: **this will charge costs (unless you are in the Free Tier)**-1. Move to the Terraform folder (optional but recommended): `cd terraform`+1. Move to the Terraform folder (optional but recommended): `cd Terraform`- Put your own Subfinder config file and reconFTW config file on the files/ folder1. Create a key pair to be used, e.g: `ssh-keygen -f terraform-keys -t ecdsa -b 521`1. Run `terraform init`1. Run `terraform apply`+ - You will be prompted for `allowed_ssh_cidr` (recommended: your public IP + `/32`)1. Type "yes" and hit enter1. Wait, because it can take up to 15 min.1. Once the process has finished, you can now login, using `ssh admin@ip -i terraform-keys`diff --git a/Terraform/outputs.tf b/Terraform/outputs.tfnew file mode 100644index 0000000..719b276--- /dev/null+++ b/Terraform/outputs.tf@@ -0,0 +1,10 @@+output "public_ip" {+ description = "Public IP address of the reconFTW instance."+ value = aws_instance.reconftw.public_ip+}++output "ssh_command" {+ description = "SSH command example (run from Terraform/ directory unless you use an absolute key path)."+ value = "ssh ${var.ssh_user}@${aws_instance.reconftw.public_ip} -i ${var.private_key_path}"+}+diff --git a/Terraform/reconFTW.yml b/Terraform/reconFTW.ymlindex 6c951b0..38da797 100644--- a/Terraform/reconFTW.yml+++ b/Terraform/reconFTW.yml@@ -1,37 +1,37 @@---- hosts: allbecome: true+ vars:+ reconftw_repo: "https://github.com/six2dez/reconftw.git"+ reconftw_dest: "/opt/reconftw"+ reconftw_branch_default: "main"tasks:- - name: Update and upgrade apt packages- become: true- apt:- upgrade: no- update_cache: yes- cache_valid_time: 86400 #One day+ - name: Update apt cache+ ansible.builtin.apt:+ update_cache: yes+ cache_valid_time: 86400- - name: Install GoLang- apt:- name: golang- state: present- - name: Install rsync- apt:- name: rsync- state: present- - name: Add Go into the PATH variable- shell: echo "export PATH=$PATH:/usr/local/go/bin" > /etc/profile.d/go.sh- - name: Install Git- apt:+ - name: Ensure git is installed (required to clone the repo)+ ansible.builtin.apt:name: gitstate: present- - name: Clone ReconFTW- git:- repo: https://github.com/six2dez/reconftw.git- dest: /opt/reconftw/- clone: yes- update: yes- - name: Install ReconFTW- command: chdir=/opt/reconftw/ ./install.sh- - name: Copy reconftw.cfg File- synchronize:++ - name: Clone reconFTW+ ansible.builtin.git:+ repo: "{{ reconftw_repo }}"+ dest: "{{ reconftw_dest }}"+ version: "{{ reconftw_branch | default(reconftw_branch_default) }}"+ update: yes++ - name: Install reconFTW dependencies and tools+ ansible.builtin.command: ./install.sh --verbose+ args:+ chdir: "{{ reconftw_dest }}"++ - name: Copy reconftw.cfg+ ansible.builtin.copy:src: files/reconftw.cfg- dest: /opt/reconftw/reconftw.cfg\ No newline at end of file+ dest: "{{ reconftw_dest }}/reconftw.cfg"+ owner: root+ group: root+ mode: "0644"diff --git a/Terraform/terraform-reconFTW.tf b/Terraform/terraform-reconFTW.tfindex 127b55e..cfa8901 100644--- a/Terraform/terraform-reconFTW.tf+++ b/Terraform/terraform-reconFTW.tf@@ -1,50 +1,90 @@+terraform {+ required_version = ">= 1.3.0"+ required_providers {+ aws = {+ source = "hashicorp/aws"+ version = ">= 5.0"+ }+ }+}+provider "aws" {- region = "eu-central-1"- access_key = "CHANGEME"- secret_key = "CHANGEME"+ region = var.aws_region}-resource "aws_key_pair" "terraform-keys" {- key_name = "terraform-keys"- public_key = "${file("${path.root}/terraform-keys.pub")}"+# Best-effort: Debian AMI naming/owners can change. Adjust filters if needed.+data "aws_ami" "debian" {+ most_recent = true+ owners = ["136693071363"] # Debian++ filter {+ name = "name"+ values = ["debian-12-amd64-*"]+ }++ filter {+ name = "virtualization-type"+ values = ["hvm"]+ }++ filter {+ name = "root-device-type"+ values = ["ebs"]+ }}-resource "aws_instance" "reconFTW_Instance" {- ami = "ami-0f1026b68319bad6c" #debian- instance_type = "t3.small"- key_name = aws_key_pair.terraform-keys.key_name- vpc_security_group_ids = ["${aws_security_group.reconFTW_SG.id}"]- associate_public_ip_address = true-- provisioner "remote-exec" {-- inline = ["sudo hostname"]- connection {- host = "${self.public_ip}"- type = "ssh"- user = "admin"- private_key = "${file("${path.root}/terraform-keys")}"- }- }- provisioner "local-exec" {- command = "ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i '${self.public_ip},' -u admin --private-key terraform-keys reconFTW.yml"- }+resource "aws_key_pair" "reconftw" {+ key_name = var.key_name+ public_key = file("${path.module}/${var.public_key_path}")++ tags = merge({ Name = "reconftw" }, var.tags)}-resource "aws_security_group" "reconFTW_SG" {- name = "Security Group for reconFTW"+resource "aws_security_group" "reconftw" {+ name_prefix = "reconftw-"+ description = "Security group for reconFTW"- ingress {- from_port = 22- to_port = 22- protocol = "tcp"- cidr_blocks = ["0.0.0.0/0"]- }- egress {- from_port = 0- to_port = 0- protocol = "-1"- cidr_blocks = ["0.0.0.0/0"]+ ingress {+ description = "SSH"+ from_port = 22+ to_port = 22+ protocol = "tcp"+ cidr_blocks = [var.allowed_ssh_cidr]+ }++ egress {+ from_port = 0+ to_port = 0+ protocol = "-1"+ cidr_blocks = ["0.0.0.0/0"]+ }++ tags = merge({ Name = "reconftw" }, var.tags)+}++resource "aws_instance" "reconftw" {+ ami = data.aws_ami.debian.id+ instance_type = var.instance_type+ key_name = aws_key_pair.reconftw.key_name+ vpc_security_group_ids = [aws_security_group.reconftw.id]+ associate_public_ip_address = true++ tags = merge({ Name = "reconftw" }, var.tags)++ provisioner "remote-exec" {+ inline = ["sudo hostname"]++ connection {+ host = self.public_ip+ type = "ssh"+ user = var.ssh_user+ private_key = file("${path.module}/${var.private_key_path}")}+ }++ provisioner "local-exec" {+ working_dir = path.module+ command = "ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i '${self.public_ip},' -u ${var.ssh_user} --private-key ${var.private_key_path} -e reconftw_branch=${var.reconftw_branch} reconFTW.yml"+ }}diff --git a/Terraform/variables.tf b/Terraform/variables.tfnew file mode 100644index 0000000..4b51898--- /dev/null+++ b/Terraform/variables.tf@@ -0,0 +1,53 @@+variable "aws_region" {+ description = "AWS region to deploy into."+ type = string+ default = "eu-central-1"+}++variable "instance_type" {+ description = "EC2 instance type."+ type = string+ default = "t3.medium"+}++variable "allowed_ssh_cidr" {+ description = "CIDR block allowed to SSH to the instance (e.g., 1.2.3.4/32)."+ type = string+}++variable "key_name" {+ description = "Name of the EC2 key pair to create/use."+ type = string+ default = "terraform-keys"+}++variable "public_key_path" {+ description = "Public key file path (relative to this Terraform folder)."+ type = string+ default = "terraform-keys.pub"+}++variable "private_key_path" {+ description = "Private key file path (relative to this Terraform folder)."+ type = string+ default = "terraform-keys"+}++variable "ssh_user" {+ description = "SSH username for the selected AMI."+ type = string+ default = "admin"+}++variable "reconftw_branch" {+ description = "Git branch/tag to deploy on the instance via Ansible."+ type = string+ default = "main"+}++variable "tags" {+ description = "Extra tags to apply to created resources."+ type = map(string)+ default = {}+}+diff --git a/install.sh b/install.shindex 139531d..d6b9c8c 100755--- a/install.sh+++ b/install.sh@@ -217,6 +217,7 @@ declare -A gotools=(["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"+ ["asnmap"]="go install -v github.com/projectdiscovery/asnmap/cmd/asnmap@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"@@ -800,7 +801,7 @@ function install_system_packages() {# 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+ $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 libimage-exiftool-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@@ -820,7 +821,7 @@ function install_brew() {/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"fibrew 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 --formula bash coreutils gnu-getopt gnu-sed python pipx massdns jq gcc cmake ruby git curl wget zip pv bind whois exiftool nmap lynx medusa shodan &>/dev/nullbrew install rustup &>/dev/nullrustup-init -y &>/dev/nullcargo install smugglex &>/dev/null@@ -831,7 +832,7 @@ function 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 install -y python3 python3-pip gcc cmake ruby git curl libpcap whois perl-Image-ExifTool 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 systemsif ! python3 - <<-'PYCHK' &>/dev/null; then@@ -896,7 +897,7 @@ function install_yum() {# 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+ $SUDO pacman -Sy --noconfirm python python-pip base-devel gcc cmake ruby git curl libpcap python-pipx whois perl-image-exiftool wget zip pv bind openssl libffi libxml2 libxslt zlib nmap jq lynx medusa xorg-server-xvfb &>/dev/nullcurl https://sh.rustup.rs -sSf | sh -s -- -y >/dev/null 2>&1source "${HOME}/.cargo/env"cargo install smugglex &>/dev/null@@ -921,7 +922,7 @@ function setup_reconftw_venv() {fiif [[ -x "${venv_dir}/bin/pip" ]]; then"${venv_dir}/bin/pip" install -U pip &>/dev/null || true- "${venv_dir}/bin/pip" install jsbeautifier &>/dev/null || true+ "${venv_dir}/bin/pip" install jsbeautifier requests &>/dev/null || trueelsemsg_warn "[!] venv pip not found at ${venv_dir}/bin/pip"fidiff --git a/lib/common.sh b/lib/common.shindex b400e28..5b2675e 100644--- a/lib/common.sh+++ b/lib/common.sh@@ -32,6 +32,36 @@ ensure_workdirs() {ensure_dirs .tmp webs subdomains hosts vulns osint fuzzing js screenshots}+# Ensure webs/webs_all.txt exists and is populated from the current web targets.+# This avoids pipefail noise when one of the source files doesn't exist yet.+# Usage: ensure_webs_all+ensure_webs_all() {+ if ! ensure_dirs webs .tmp; then+ return 1+ fi++ local out="webs/webs_all.txt"+ local tmp=".tmp/webs_all_candidates.txt"++ : >"$tmp" 2>/dev/null || return 1++ [[ -s "webs/webs.txt" ]] && cat "webs/webs.txt" >>"$tmp"+ [[ -s "webs/webs_uncommon_ports.txt" ]] && cat "webs/webs_uncommon_ports.txt" >>"$tmp"++ touch "$out" 2>/dev/null || return 1++ if [[ -s "$tmp" ]]; then+ # Strip empty lines to avoid polluting target lists.+ if command -v anew &>/dev/null; then+ sed '/^$/d' "$tmp" | anew -q "$out" 2>/dev/null || true+ else+ sed '/^$/d' "$tmp" >>"$out" 2>/dev/null || return 1+ fi+ fi++ return 0+}+################################################################################ File Operations###############################################################################diff --git a/lib/config.sh b/lib/config.shdeleted file mode 100644index b7ee516..0000000--- a/lib/config.sh+++ /dev/null@@ -1,325 +0,0 @@-#!/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--# Local output helpers (prefer global UI if available)-_cfg_warn() {- if declare -F print_warnf >/dev/null 2>&1; then- print_warnf "$@"- else- printf "[WARN] $1\n" "${@:2}" >&2- fi-}--_cfg_error() {- if declare -F print_errorf >/dev/null 2>&1; then- print_errorf "$@"- else- printf "[ERROR] $1\n" "${@:2}" >&2- fi-}--# 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- _cfg_error "Configuration directory not found: %s" "$config_dir"- 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- _cfg_error "Configuration validation failed"- errors=$((errors + 1))- fi-- if [[ $errors -gt 0 ]]; then- _cfg_warn "%d configuration errors detected" "$errors"- 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- _cfg_warn "Config file has overly permissive permissions (%s): %s" "$perms" "$conf_file"- fi-- # Check for dangerous patterns before sourcing- if grep -qE '(eval[[:space:]]|\$\(.*\)|`.*`|rm[[:space:]]+-rf)' "$conf_file" 2>/dev/null; then- _cfg_error "Config file contains potentially dangerous commands: %s" "$conf_file"- return $E_CONFIG_INVALID- fi-- # Source the file with error handling- # shellcheck source=/dev/null- if ! source "$conf_file" 2>/dev/null; then- _cfg_error "Failed to load config file: %s" "$conf_file"- 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- _cfg_warn "Invalid boolean value for %s: %s (expected true/false)" "$var" "$value"- return 1- fi- fi-- # Numeric validation- if [[ "$var" =~ _THREADS$|_RATELIMIT$|_TIMEOUT$ ]]; then- if [[ ! "$value" =~ ^[0-9]+$ ]]; then- _cfg_warn "Invalid numeric value for %s: %s" "$var" "$value"- 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- _cfg_warn "VULNS_GENERAL=true but SUBDOMAINS_GENERAL=false"- 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- _cfg_error "%s must be numeric, got: %s" "$var" "$var_value"- 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- _cfg_error "MIN_RATE_LIMIT > MAX_RATE_LIMIT"- errors=$((errors + 1))- fi- fi- fi-- # Validate Axiom configuration- if [[ "${AXIOM:-false}" == true ]]; then- if ! command -v axiom-scan &>/dev/null; then- _cfg_warn "AXIOM=true but axiom-scan not found"- warnings=$((warnings + 1))- fi- fi-- if [[ $errors -gt 0 ]]; then- _cfg_error "Configuration validation failed"- 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- _cfg_error "Legacy config file not found: %s" "$old_config"- 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/modules/modes.sh b/modules/modes.shindex 1b59690..46f1de9 100644--- a/modules/modes.sh+++ b/modules/modes.sh@@ -91,6 +91,9 @@ function start() {fimkdir -p {.log,.tmp,webs,hosts,vulns,osint,screenshots,subdomains}chmod 700 .tmp 2>/dev/null || true+ # Baseline inputs expected by multiple modules (avoid pipefail errors on missing files).+ touch webs/webs.txt webs/webs_uncommon_ports.txt webs/webs_all.txt \+ subdomains/subdomains.txt .tmp/web_full_info.txt 2>/dev/null || true# Load plugins and emit start eventplugins_load@@ -572,6 +575,8 @@ function multi_osint() {exit 1}mkdir -p {.log,.tmp,webs,hosts,vulns,osint,screenshots,subdomains}+ touch webs/webs.txt webs/webs_uncommon_ports.txt webs/webs_all.txt \+ subdomains/subdomains.txt .tmp/web_full_info.txt 2>/dev/null || trueNOW=$(date +"%F")NOWT=$(date +"%T")@@ -593,6 +598,8 @@ function multi_osint() {exit 1}mkdir -p {.log,.tmp,webs,hosts,vulns,osint,screenshots,subdomains}+ touch webs/webs.txt webs/webs_uncommon_ports.txt webs/webs_all.txt \+ subdomains/subdomains.txt .tmp/web_full_info.txt 2>/dev/null || trueNOW=$(date +"%F")NOWT=$(date +"%T")LOGFILE="${dir}/.log/${NOW}_${NOWT}.txt"@@ -776,6 +783,8 @@ function multi_recon() {}mkdir -p {.log,.tmp,webs,hosts,vulns,osint,screenshots,subdomains}+ touch webs/webs.txt webs/webs_uncommon_ports.txt webs/webs_all.txt \+ subdomains/subdomains.txt .tmp/web_full_info.txt 2>/dev/null || trueNOW=$(date +"%F")NOWT=$(date +"%T")LOGFILE="${workdir}/.log/${NOW}_${NOWT}.txt"@@ -808,6 +817,8 @@ function multi_recon() {}mkdir -p {.log,.tmp,webs,hosts,vulns,osint,screenshots,subdomains}+ touch webs/webs.txt webs/webs_uncommon_ports.txt webs/webs_all.txt \+ subdomains/subdomains.txt .tmp/web_full_info.txt 2>/dev/null || trueNOW=$(date +"%F")NOWT=$(date +"%T")diff --git a/modules/subdomains.sh b/modules/subdomains.shindex d8d2fc1..daf87b2 100644--- a/modules/subdomains.sh+++ b/modules/subdomains.sh@@ -710,6 +710,10 @@ function sub_tls() {returnfi+ # Always reset temp outputs to avoid stale data from previous runs.+ : >".tmp/subdomains_tlsx_clean.txt"+ : >".tmp/subdomains_tlsx_resolved.txt"+if [[ $DEEP == true ]]; thenif [[ $AXIOM != true ]]; thencat subdomains/subdomains.txt | tlsx -san -cn -silent -ro -c "$TLSX_THREADS" \@@ -732,7 +736,9 @@ function sub_tls() {if [[ -s ".tmp/subdomains_tlsx.txt" ]]; thengrep "\.${DOMAIN_ESCAPED}$\|^${DOMAIN_ESCAPED}$" .tmp/subdomains_tlsx.txt \| grep -aEo 'https?://[^ ]+' \- | sed "s/|__ //" | anew -q .tmp/subdomains_tlsx_clean.txt+ | sed "s/|__ //" \+ | sed '/^$/d' \+ | anew -q .tmp/subdomains_tlsx_clean.txt || truefiif [[ $AXIOM != true ]]; then@@ -1130,8 +1136,13 @@ function sub_scraping() {[[ -s ".tmp/web_full_info3.txt" ]] && webinfo_files+=(".tmp/web_full_info3.txt")if [[ ${#webinfo_files[@]} -gt 0 ]]; then- cat "${webinfo_files[@]}" 2>>"$LOGFILE" \- | jq -s 'try .' | jq 'try unique_by(.input)' | jq 'try .[]' 2>>"$LOGFILE" >.tmp/web_full_info.txt+ # Keep .tmp/web_full_info.txt as JSONL (1 JSON object per line) for later merges.+ : >.tmp/web_full_info.txt+ if ! cat "${webinfo_files[@]}" 2>>"$LOGFILE" \+ | jq -cs 'unique_by(.input)[]' 2>>"$LOGFILE" >.tmp/web_full_info.txt; then+ : >.tmp/web_full_info.txt+ log_note "sub_scraping: failed to merge web_full_info JSON; continuing without cache" "${FUNCNAME[0]}" "${LINENO}"+ fielselog_note "sub_scraping: web_full_info files missing/empty; skipping merge" "${FUNCNAME[0]}" "${LINENO}"fi@@ -1773,6 +1784,7 @@ function subtakeover() {print_warnf "Failed to create directories."return 1fi+ touch subdomains/subdomains.txt webs/webs.txt webs/webs_uncommon_ports.txt webs/webs_all.txt 2>/dev/null || true# Check if the function should runif { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $SUBTAKEOVER == true ]]; then@@ -1784,10 +1796,8 @@ function subtakeover() {return 1fi- # 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+ # Build/refresh webs_all.txt from current web targets.+ ensure_webs_all || true#cent update -p ${NUCLEI_TEMPLATES_PATH} &>/dev/nullif [[ $AXIOM != true ]]; thendiff --git a/modules/web.sh b/modules/web.shindex e74826a..25f1385 100644--- a/modules/web.sh+++ b/modules/web.sh@@ -99,14 +99,17 @@ function webprobe_simple() {if ! ensure_dirs .tmp webs subdomains; then 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 { [[ ! -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+ # Baseline cache files (some modules merge into these).+ touch .tmp/web_full_info.txt .tmp/web_full_info_probe.txt webs/web_full_info.txt 2>/dev/null || true++ # 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-scanif [[ $AXIOM != true ]]; then@@ -119,11 +122,22 @@ function webprobe_simple() {run_command 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 current probe output with prior cache/state.- cat .tmp/web_full_info_probe.txt .tmp/web_full_info.txt 2>>"$LOGFILE" \- | jq -s 'try .' | jq 'try unique_by(.input)' | jq 'try .[]' 2>>"$LOGFILE" >webs/web_full_info.txt+ fi++ # Merge current probe output with prior cache/state.+ touch .tmp/web_full_info_probe.txt .tmp/web_full_info.txt 2>/dev/null || true+ if ! cat .tmp/web_full_info_probe.txt .tmp/web_full_info.txt 2>>"$LOGFILE" \+ | jq -cs 'unique_by(.input)[]' 2>>"$LOGFILE" >webs/web_full_info.txt; then+ log_note "webprobe_simple: failed to merge httpx JSON; falling back to probe-only" "${FUNCNAME[0]}" "${LINENO}"+ awk 'match($0, /^[[:space:]]*\\{/) {print}' .tmp/web_full_info_probe.txt >.tmp/web_full_info_merge_input.jsonl 2>/dev/null || true+ if [[ -s ".tmp/web_full_info_merge_input.jsonl" ]]; then+ jq -cs 'unique_by(.input)[]' .tmp/web_full_info_merge_input.jsonl 2>>"$LOGFILE" >webs/web_full_info.txt || : >webs/web_full_info.txt+ else+ : >webs/web_full_info.txt+ fi+ fi+ # Keep cache as JSONL for later merges.+ cp webs/web_full_info.txt .tmp/web_full_info.txt 2>/dev/null || true# Extract URLsif [[ -s "webs/web_full_info.txt" ]]; then@@ -158,13 +172,13 @@ function webprobe_simple() {if ! NUMOFLINES=$(anew webs/webs.txt <.tmp/probed_tmp.txt 2>/dev/null | sed '/^$/d' | wc -l); thenprint_warnf "Failed to count new websites."NUMOFLINES=0- fi+ fi- # Update webs_all.txt- cat webs/webs.txt webs/webs_uncommon_ports.txt 2>/dev/null | anew -q webs/webs_all.txt+ # Update webs_all.txt+ ensure_webs_all || true- # Asset store: append probed webs- append_assets_from_file web url webs/webs.txt+ # Asset store: append probed webs+ append_assets_from_file web url webs/webs.txtend_subfunc "${NUMOFLINES} new websites resolved" "${FUNCNAME[0]}"@@ -249,15 +263,15 @@ function webprobe_full() {fi# Notify user- notification "Uncommon web ports: ${NUMOFLINES} new websites" "good"+ notification "Uncommon web ports: ${NUMOFLINES} new websites" "good"- # Update webs_all.txt- cat webs/webs.txt webs/webs_uncommon_ports.txt 2>/dev/null | anew -q webs/webs_all.txt+ # Update webs_all.txt+ ensure_webs_all || true- # 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"- run_command ffuf -mc all -w webs/webs_uncommon_ports.txt -u FUZZ -replay-proxy "$proxy_url" 2>>"$LOGFILE" >/dev/null+ # 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"+ run_command ffuf -mc all -w webs/webs_uncommon_ports.txt -u FUZZ -replay-proxy "$proxy_url" 2>>"$LOGFILE" >/dev/nullfifiend_func "Results are saved in $domain/webs/webs_uncommon_ports.txt" "${FUNCNAME[0]}"@@ -281,15 +295,13 @@ function screenshot() {if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $WEBSCREENSHOT == true ]]; thenstart_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+ # Build/refresh webs_all.txt from current web targets.+ ensure_webs_all || true- # Run nuclei or axiom-scan based on AXIOM flag- if [[ $AXIOM != true ]]; then- if [[ -s "webs/webs_all.txt" ]]; then- run_command nuclei -headless -id screenshot -V dir='screenshots' <webs/webs_all.txt 2>>"$LOGFILE" >/dev/null+ # Run nuclei or axiom-scan based on AXIOM flag+ if [[ $AXIOM != true ]]; then+ if [[ -s "webs/webs_all.txt" ]]; then+ run_command nuclei -headless -id screenshot -V dir='screenshots' <webs/webs_all.txt 2>>"$LOGFILE" >/dev/nullfielseif [[ -s "webs/webs_all.txt" ]]; then@@ -316,15 +328,13 @@ function virtualhosts() {if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $VIRTUALHOSTS == true ]]; thenstart_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+ # Build/refresh webs_all.txt from current web targets.+ ensure_webs_all || true- # 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]}"+ # 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]}"elseend_func "No subdomains or hosts file found, virtualhosts skipped." "${FUNCNAME[0]}"@@ -362,10 +372,7 @@ function favirecon_tech() {start_func "${FUNCNAME[0]}" "Favicon Technology Recon"- # 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+ ensure_webs_all || trueif [[ -s "webs/webs_all.txt" ]]; thenlocal fav_cmd=(@@ -715,52 +722,49 @@ function waf_checks() {if ! ensure_dirs .tmp webs; then 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- run_command 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- run_command 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- print_warnf "Failed to count lines in webs_wafs.txt."- 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"+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $WAF_DETECTION == true ]]; then+ start_func "${FUNCNAME[0]}" "Website's WAF Detection"++ ensure_webs_all || true++ # 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+ run_command 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+ run_command 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+ print_warnf "Failed to count lines in webs_wafs.txt."+ 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 functionreturn@@ -882,10 +886,7 @@ function nuclei_check() {touch webs/webs.txt webs/webs_uncommon_ports.txtfi- # 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+ ensure_webs_all || true# Combine webs_all.txt targets (with protocol) - avoid duplicate scansif [[ ! -s ".tmp/webs_subs.txt" ]]; then@@ -1084,7 +1085,15 @@ _fuzz_run_axiom() {while read -r sub; dolocal sub_outsub_out=$(echo "$sub" | sed -e 's|^[^/]*//||' -e 's|/.*$||')- [[ -s "$dir/.tmp/ffuf-content.json" ]] && jq -r 'try .results[] | "\(.status) \(.length) \(.url)"' "$dir/.tmp/ffuf-content.json" | grep "$sub" | sort -k1 | anew -q "fuzzing/${sub_out}.txt"+ if [[ -s "$dir/.tmp/ffuf-content.json" ]]; then+ local tmp_out=".tmp/ffuf_${sub_out}.txt"+ jq -r --arg sub "$sub" 'try .results[] | select(.url | contains($sub)) | "\(.status) \(.length) \(.url)"' "$dir/.tmp/ffuf-content.json" 2>>"$LOGFILE" \+ | sort -k1 >"$tmp_out" || true+ if [[ -s "$tmp_out" ]]; then+ anew -q "fuzzing/${sub_out}.txt" <"$tmp_out" 2>>"$LOGFILE" || true+ fi+ rm -f "$tmp_out" 2>/dev/null || true+ fidone <webs/webs_all.txt}@@ -1108,9 +1117,7 @@ function fuzz() {touch webs/webs_uncommon_ports.txt 2>>"$LOGFILE" || truefi- 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+ ensure_webs_all || trueif [[ -s "webs/webs_all.txt" ]]; thenif [[ $AXIOM != true ]]; then@@ -1140,10 +1147,13 @@ function iishortname() {if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } && [[ $IIS_SHORTNAME == true ]]; thenstart_func "${FUNCNAME[0]}" "IIS Shortname Scanner"+ ensure_dirs .tmp || true+ : >.tmp/iis_sites.txt+# Ensure nuclei_output/info.txt exists and is not emptyif [[ -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+ # Extract IIS targets (if any) without triggering pipefail on "no matches".+ awk '/iis-version/ {print $4}' "nuclei_output/info.txt" >.tmp/iis_sites.txtfi# Proceed only if iis_sites.txt exists and is non-empty@@ -1291,10 +1301,7 @@ function urlchecks() {local waymore_timeout_cmd="${TIMEOUT_CMD:-timeout}"local katana_headless_flags=""- # 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+ ensure_webs_all || trueif [[ -s "webs/webs_all.txt" ]]; thenlocal katana_target_count=0@@ -1647,24 +1654,23 @@ function jschecks() {urless <.tmp/url_extract_js.txt \| anew -q js/url_extract_js.txt 2>>"$LOGFILE" >/dev/null- [[ "${OUTPUT_VERBOSITY:-1}" -ge 2 ]] && printf "%bRunning: Resolving JS URLs 2/6%b\n" "$yellow" "$reset"- if [[ $AXIOM != true ]]; then- if [[ -s "js/url_extract_js.txt" ]]; then- run_command 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- run_command 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 || true- fi- fi- fi+ [[ "${OUTPUT_VERBOSITY:-1}" -ge 2 ]] && printf "%bRunning: Resolving JS URLs 2/6%b\n" "$yellow" "$reset"+ if [[ $AXIOM != true ]]; then+ if [[ -s "js/url_extract_js.txt" ]]; then+ run_command 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 \+ | awk '/\\[200\\]/ && /javascript/ {print $1}' | anew -q js/js_livelinks.txt || true+ fi+ else+ if [[ -s "js/url_extract_js.txt" ]]; then+ run_command 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+ awk '/\\[200\\]/ && /javascript/ {print $1}' .tmp/js_livelinks.txt | anew -q js/js_livelinks.txt || true+ fi+ fi+ fi[[ "${OUTPUT_VERBOSITY:-1}" -ge 2 ]] && printf "%bRunning: Extracting JS from sourcemaps 3/6%b\n" "$yellow" "$reset"if ! mkdir -p .tmp/sourcemapper; then@@ -1863,10 +1869,7 @@ function wordlist_gen_roboxtractor() {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+ ensure_webs_all || true# Proceed only if webs_all.txt exists and is non-emptyif [[ -s "webs/webs_all.txt" ]]; then@@ -1919,9 +1922,7 @@ function password_dict() {: >"$dict_output"# Ensure web targets exist for cewl.- 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+ ensure_webs_all || trueif [[ "$dict_engine" == "cewl" ]]; thenlocal cewl_cmd=()@@ -2017,17 +2018,14 @@ function brokenLinks() {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"+ 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+ ensure_webs_all || true- # Check if webs_all.txt exists and is not empty- if [[ -s "webs/webs_all.txt" ]]; then- local bl_engine="${BROKENLINKS_ENGINE:-second-order}"- if [[ "$bl_engine" == "second-order" ]]; then+ # Check if webs_all.txt exists and is not empty+ if [[ -s "webs/webs_all.txt" ]]; then+ local bl_engine="${BROKENLINKS_ENGINE:-second-order}"+ if [[ "$bl_engine" == "second-order" ]]; thenlocal so_depth="${SECOND_ORDER_DEPTH:-1}"[[ $DEEP == true ]] && so_depth=$((so_depth + 1))diff --git a/tests/unit/test_ensure_webs_all.bats b/tests/unit/test_ensure_webs_all.batsnew file mode 100644index 0000000..8adc5f9--- /dev/null+++ b/tests/unit/test_ensure_webs_all.bats@@ -0,0 +1,31 @@+#!/usr/bin/env bats++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=''++ export TEST_DIR="$BATS_TEST_TMPDIR/reconftw_webs_all"+ mkdir -p "$TEST_DIR"+ cd "$TEST_DIR"++ source "$project_root/reconftw.sh" --source-only+}++teardown() {+ [[ -d "$TEST_DIR" ]] && rm -rf "$TEST_DIR"+}++@test "ensure_webs_all creates webs/webs_all.txt from webs/webs.txt" {+ mkdir -p webs+ printf "https://a.example.com\n" > webs/webs.txt+ rm -f webs/webs_uncommon_ports.txt++ run ensure_webs_all+ [ "$status" -eq 0 ]+ [ -f "webs/webs_all.txt" ]+ grep -q "https://a.example.com" "webs/webs_all.txt"+}+diff --git a/tests/unit/test_sub_tls_no_match.bats b/tests/unit/test_sub_tls_no_match.batsnew file mode 100644index 0000000..a6866a4--- /dev/null+++ b/tests/unit/test_sub_tls_no_match.bats@@ -0,0 +1,64 @@+#!/usr/bin/env bats++setup() {+ local project_root+ project_root="$(cd "$(dirname "$BATS_TEST_FILENAME")/../.." && pwd)"+ export SCRIPTPATH="$project_root"+ export bred='' bblue='' bgreen='' byellow='' yellow='' reset=''++ export TEST_DIR="$BATS_TEST_TMPDIR/reconftw_sub_tls"+ mkdir -p "$TEST_DIR"++ export dir="$TEST_DIR/example.com"+ export called_fn_dir="$dir/.called_fn"+ mkdir -p "$called_fn_dir" "$dir"+ cd "$dir"++ mkdir -p .tmp subdomains webs++ export domain="example.com"+ export DIFF=false+ export AXIOM=false+ export DEEP=false+ export TLSX_THREADS=1+ export TLS_PORTS="443"+ export RESOLVER_IQ=false+ export INSCOPE=false++ export LOGFILE="$dir/.tmp/test.log"+ : >"$LOGFILE"++ export MOCK_BIN="$TEST_DIR/mockbin"+ mkdir -p "$MOCK_BIN"+ export PATH="$MOCK_BIN:$PATH"++ cat > "$MOCK_BIN/tlsx" <<'SH'+#!/usr/bin/env bash+# Emit non-matching output; keep it non-empty so grep filters run.+echo "https://notexample.invalid"+SH+ chmod +x "$MOCK_BIN/tlsx"++ source "$project_root/reconftw.sh" --source-only+ export DOMAIN_ESCAPED+ DOMAIN_ESCAPED=$(escape_domain_regex "$domain")+}++teardown() {+ [[ -d "$TEST_DIR" ]] && rm -rf "$TEST_DIR"+}++@test "sub_tls does not raise ERR trap when tlsx output has no matches" {+ printf "a.%s\n" "$domain" > subdomains/subdomains.txt++ set -E+ trap 'echo "ERR($?) :: $BASH_COMMAND" >>"$LOGFILE"' ERR++ sub_tls+ [ "$?" -eq 0 ]++ # Our trap should stay empty for this scenario (no-match is not an error).+ ! grep -q '^ERR\\(' "$LOGFILE"+ [ -f ".tmp/subdomains_tlsx_clean.txt" ]+}+diff --git a/tests/unit/test_webprobe_simple_merge.bats b/tests/unit/test_webprobe_simple_merge.batsindex 27b6c2b..c0e8c63 100644--- a/tests/unit/test_webprobe_simple_merge.bats+++ b/tests/unit/test_webprobe_simple_merge.bats@@ -63,3 +63,61 @@ SHgrep -q "new.example.com" "webs/web_full_info.txt"}+@test "webprobe_simple works when prior web_full_info cache is missing" {+ mkdir -p .tmp webs subdomains+ rm -f .tmp/web_full_info.txt+ printf "a.example.com\n" > subdomains/subdomains.txt++ cat > "$MOCK_BIN/httpx" <<'SH'+#!/usr/bin/env bash+out=""+while [[ $# -gt 0 ]]; do+ case "$1" in+ -o)+ out="$2"+ shift 2+ ;;+ *)+ shift+ ;;+ esac+done+printf '%s\n' '{"input":"new","url":"https://new.example.com"}' > "$out"+SH+ chmod +x "$MOCK_BIN/httpx"++ run webprobe_simple+ [ "$status" -eq 0 ]+ [ -s "webs/web_full_info.txt" ]+ grep -q "new.example.com" "webs/web_full_info.txt"+}++@test "webprobe_simple falls back when cache contains non-JSON" {+ mkdir -p .tmp webs subdomains+ printf "a.example.com\n" > subdomains/subdomains.txt+ printf '%s\n' 'NOT_JSON' > .tmp/web_full_info.txt++ cat > "$MOCK_BIN/httpx" <<'SH'+#!/usr/bin/env bash+out=""+while [[ $# -gt 0 ]]; do+ case "$1" in+ -o)+ out="$2"+ shift 2+ ;;+ *)+ shift+ ;;+ esac+done+printf '%s\n' '{"input":"new","url":"https://new.example.com"}' > "$out"+SH+ chmod +x "$MOCK_BIN/httpx"++ run webprobe_simple+ [ "$status" -eq 0 ]+ [ -s "webs/web_full_info.txt" ]+ grep -q "new.example.com" "webs/web_full_info.txt"+ ! grep -q "NOT_JSON" ".tmp/web_full_info.txt"+}