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

feat(01-01): add EXIT-only sentinel trap + resume banner in start()

six2dez199f198aa342
diff --git a/modules/modes.sh b/modules/modes.sh
index 0acede2..cbd9311 100644
--- a/modules/modes.sh
+++ b/modules/modes.sh
@@ -77,6 +77,9 @@ function start() {
fi
if [[ "${FORCE_RESCAN:-false}" == "true" ]]; then
rm -f "$called_fn_dir"/.* 2>>"${LOGFILE:-/dev/null}" || true
+ # Explicitly clear .inprogress_* orphans so a --force run never inherits
+ # a fake resume condition regardless of shell dotglob settings (D-05).
+ rm -f "$called_fn_dir"/.inprogress_* 2>>"${LOGFILE:-/dev/null}" || true
fi
mkdir -p "$dir"
cd "$dir" || {
@@ -116,6 +119,7 @@ function start() {
# Trap for cleanup on unexpected exit
trap 'cleanup_on_exit' INT TERM
+ trap '_cleanup_inprogress' EXIT # silent EXIT-only sentinel sweep (D-02)
# Initialize structured logging if enabled
log_init
@@ -154,6 +158,28 @@ function start() {
if [[ "${FORCE_RESCAN:-false}" == "true" ]]; then
_print_msg WARN "Force rescan enabled: ignoring cached module markers"
fi
+
+ # Resume banner (D-04): detect .inprogress_<fn> sentinels left behind by a
+ # prior crashed run and emit exactly ONE WARN line naming the affected
+ # functions. Guarded against unset called_fn_dir and skipped under
+ # FORCE_RESCAN (Step C already wiped any orphans there).
+ if [[ -n "${called_fn_dir:-}" ]] && [[ "${FORCE_RESCAN:-false}" != "true" ]]; then
+ local -a _leftover
+ mapfile -t _leftover < <(ls -1 "${called_fn_dir}"/.inprogress_* 2>/dev/null)
+ if ((${#_leftover[@]} > 0)); then
+ local _prefix="${called_fn_dir}/.inprogress_"
+ local -a _names=()
+ local _f
+ for _f in "${_leftover[@]}"; do
+ _names+=("${_f#"$_prefix"}")
+ done
+ local _joined
+ _joined=$(IFS=,; printf "%s" "${_names[*]}")
+ _print_msg WARN "resume: ${#_leftover[@]} functions re-running after interruption (${_joined})"
+ log_json "WARN" "resume" "Inprogress sentinels found" "reason=inprogress_leftover" "funcs=${_joined}"
+ fi
+ fi
+
if [[ "${MONITOR_MODE:-false}" == "true" ]] && [[ "${MONITOR_CYCLE:-1}" -gt 1 ]]; then
notification "Monitor cycle ${MONITOR_CYCLE}: skipping repeated tools check" info
else
diff --git a/modules/utils.sh b/modules/utils.sh
index b5be718..0e5d4a0 100644
--- a/modules/utils.sh
+++ b/modules/utils.sh
@@ -141,10 +141,16 @@ function cleanup_on_exit() {
# Log the interruption
echo "[$(date +'%Y-%m-%d %H:%M:%S')] Interrupted by signal (exit code: $exit_code)" >>"${LOGFILE:-/dev/null}"
-
+
exit "$exit_code"
}
+# Remove stale .inprogress_<fn> sentinels on EXIT (D-02). Does not call exit/kill/print — safe to fire on every shell exit, including successful runs.
+function _cleanup_inprogress() {
+ [[ -n "${called_fn_dir:-}" ]] && rm -f "${called_fn_dir}"/.inprogress_* 2>/dev/null
+ return 0
+}
+
function rotate_logs() {
local log_dir="$1"
local max_logs="${2:-10}"