Skip to content

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

style: fix remaining shellcheck warnings

six2dezada62ff8950d
diff --git a/lib/config.sh b/lib/config.sh
index 770310f..ede9174 100644
--- a/lib/config.sh
+++ b/lib/config.sh
@@ -96,6 +96,7 @@ function _load_config_file() {
fi
# Source the file with error handling
+ # shellcheck source=/dev/null
if ! source "$conf_file" 2>/dev/null; then
printf "[ERROR] Failed to load config file: %s\n" "$conf_file" >&2
return $E_CONFIG_SYNTAX
diff --git a/lib/validation.sh b/lib/validation.sh
index b57a103..29c7d38 100644
--- a/lib/validation.sh
+++ b/lib/validation.sh
@@ -5,6 +5,7 @@
set -o pipefail
# Error codes
+# shellcheck disable=SC2034 # These are exported for use in modules
readonly E_INVALID_DOMAIN=20
readonly E_INVALID_IP=21
readonly E_INVALID_PATH=22
diff --git a/modules/axiom.sh b/modules/axiom.sh
index b083687..2a92730 100644
--- a/modules/axiom.sh
+++ b/modules/axiom.sh
@@ -6,6 +6,7 @@
# This file is sourced by reconftw.sh - do not execute directly
# shellcheck disable=SC2154 # Variables defined in reconftw.cfg
+# shellcheck disable=SC2034 # Variables exported for use in other modules
[[ -z "${SCRIPTPATH:-}" ]] && {
echo "Error: This module must be sourced by reconftw.sh" >&2
diff --git a/modules/core.sh b/modules/core.sh
index 5b50588..7a1aeab 100644
--- a/modules/core.sh
+++ b/modules/core.sh
@@ -92,6 +92,7 @@ function banner_grabber() {
fi
# Source the banner file
+ # shellcheck source=/dev/null
source "$banner_file"
# Collect all banner variable names
@@ -583,7 +584,9 @@ function incremental_diff() {
function incremental_report() {
[[ "$INCREMENTAL_MODE" != "true" ]] && return 0
- local report_file="$INCREMENTAL_DIR/incremental_report_$(date +%Y%m%d_%H%M%S).txt"
+ local report_file
+ local new_subs new_webs
+ report_file="$INCREMENTAL_DIR/incremental_report_$(date +%Y%m%d_%H%M%S).txt"
{
echo "==============================================="
@@ -595,7 +598,7 @@ function incremental_report() {
# 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) \
+ 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
@@ -609,7 +612,7 @@ function incremental_report() {
# 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) \
+ 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
@@ -637,8 +640,9 @@ 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)
+ local new_subs new_webs
+ new_subs=$(cat .tmp/subs_new_count 2>/dev/null || echo 1)
+ 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" \
@@ -665,6 +669,7 @@ function zipSnedOutputFolder {
}
function isAsciiText {
+ # shellcheck disable=SC2034 # IS_ASCII used by callers
IS_ASCII="False"
if [[ $(file $1 | grep -o 'ASCII text$') == "ASCII text" ]]; then
IS_ASCII="True"
@@ -849,11 +854,13 @@ function maybe_update_nuclei() {
}
# Plugin framework
+# shellcheck disable=SC2034 # PLUGINS_LOADED used for state tracking
PLUGINS_LOADED=false
function plugins_load() {
local plugdir="${SCRIPTPATH}/plugins"
if [[ -d $plugdir ]]; then
for f in "$plugdir"/*.sh; do
+ # shellcheck source=/dev/null
[[ -f $f ]] && source "$f" || true
done
fi
diff --git a/modules/modes.sh b/modules/modes.sh
index ed627af..4eb056c 100644
--- a/modules/modes.sh
+++ b/modules/modes.sh
@@ -276,6 +276,7 @@ function passive() {
metadata
apileaks
third_party_misconfigs
+ # shellcheck disable=SC2034 # These flags control module behavior
SUBNOERROR=false
SUBANALYTICS=false
SUBBRUTE=false
@@ -293,6 +294,7 @@ function passive() {
remove_big_files
favicon
cdnprovider
+ # shellcheck disable=SC2034 # PORTSCAN_ACTIVE controls scan behavior
PORTSCAN_ACTIVE=false
portscan
geo_info
diff --git a/modules/subdomains.sh b/modules/subdomains.sh
index 28ecf89..db7cf00 100644
--- a/modules/subdomains.sh
+++ b/modules/subdomains.sh
@@ -1839,7 +1839,8 @@ function cloud_extra_providers() {
# 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
+ # shellcheck disable=SC2046 # Word splitting intended for awk
+ [[ -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
diff --git a/modules/utils.sh b/modules/utils.sh
index 05e24b8..3bb300a 100644
--- a/modules/utils.sh
+++ b/modules/utils.sh
@@ -304,9 +304,10 @@ function adjust_rate_limit() {
[[ "$ADAPTIVE_RATE_LIMIT" != "true" ]] && return 0
+ local new_limit
case "$action" in
decrease)
- local new_limit=$(awk "BEGIN {printf \"%.0f\", $CURRENT_RATE_LIMIT * $RATE_LIMIT_BACKOFF_FACTOR}")
+ 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
@@ -315,7 +316,7 @@ function adjust_rate_limit() {
"$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}")
+ 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
@@ -327,7 +328,9 @@ function adjust_rate_limit() {
# Update tool-specific rate limits
NUCLEI_RATELIMIT=$CURRENT_RATE_LIMIT
+ # shellcheck disable=SC2034 # Used by external tools
FFUF_RATELIMIT=$CURRENT_RATE_LIMIT
+ # shellcheck disable=SC2034 # Used by external tools
HTTPX_RATELIMIT=$CURRENT_RATE_LIMIT
}
@@ -341,7 +344,8 @@ function run_with_adaptive_rate() {
local max_retries=3
local retry=0
- local temp_output=$(mktemp)
+ local temp_output
+ temp_output=$(mktemp)
while [ $retry -lt $max_retries ]; do
if "$@" 2>&1 | tee "$temp_output"; then
@@ -421,9 +425,10 @@ function sanitize_domain() {
# Usage: sanitize_ip <ip_or_cidr>
function sanitize_ip() {
local input="$1"
+ local sanitized
# Allow digits, dots, and slash for CIDR
- local sanitized=$(echo "$input" | tr -cd '0-9./,')
+ sanitized=$(echo "$input" | tr -cd '0-9./,')
if [[ -z "$sanitized" ]]; then
printf "%b[%s] ERROR: Invalid IP/CIDR after sanitization: '%s'%b\n" \
diff --git a/modules/vulns.sh b/modules/vulns.sh
index 8ff179d..5ec01e1 100644
--- a/modules/vulns.sh
+++ b/modules/vulns.sh
@@ -884,9 +884,7 @@ function fuzzparams() {
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
diff --git a/modules/web.sh b/modules/web.sh
index 394091a..bc5b7c1 100644
--- a/modules/web.sh
+++ b/modules/web.sh
@@ -815,6 +815,7 @@ function grpc_reflection() {
# Build target IP list
local ips_file="hosts/ips.txt"
local targets=()
+ # shellcheck disable=SC2207 # Word splitting intended for array population
[[ -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
@@ -865,8 +866,8 @@ function fuzz() {
if [[ -s "webs/webs_all.txt" ]]; then
if [[ $AXIOM != true ]]; then
# Split targets by slow hosts
- >.tmp/webs_slow.txt
- >.tmp/webs_normal.txt
+ : >.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
@@ -890,8 +891,6 @@ function fuzz() {
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
@@ -1084,8 +1083,8 @@ function urlchecks() {
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
+ : >.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
@@ -1095,7 +1094,7 @@ function urlchecks() {
cp webs/webs_all.txt .tmp/katana_targets_normal.txt
fi
- >.tmp/katana.txt
+ : >.tmp/katana.txt
# Normal targets
if [[ -s .tmp/katana_targets_normal.txt ]]; then
LINES=$(wc -l <.tmp/katana_targets_normal.txt)
diff --git a/reconftw.sh b/reconftw.sh
index c552491..45f7bb0 100755
--- a/reconftw.sh
+++ b/reconftw.sh
@@ -7,6 +7,7 @@ set +e
IFS=$'\n\t'
# Standard exit/return codes (guard for re-source in test harnesses)
+# shellcheck disable=SC2034 # These are exported for use in modules and custom scripts
if [[ -z "${E_SUCCESS+x}" ]]; then
readonly E_SUCCESS=0
readonly E_GENERAL=1