From 2dd728b202cd225455aac47c40312a88c9d62abe Mon Sep 17 00:00:00 2001 From: Will Kapcio <18176030+whiskeykilo@users.noreply.github.com> Date: Mon, 19 Aug 2024 01:20:37 -0400 Subject: [PATCH] Fix touch errors in multi-recon by ensuring directories exist before file operations --- reconftw.sh | 44 +++++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/reconftw.sh b/reconftw.sh index f744b5b9..d8909324 100755 --- a/reconftw.sh +++ b/reconftw.sh @@ -3341,19 +3341,37 @@ function multi_recon() { for domain in $targets; do 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}" + 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" loopstart=$(date +%s) domain_info