CRITICAL FIX: Quote escaping in awk file handles
ROOT CAUSE IDENTIFIED: The previous fix didn't work because of broken quote escaping. The pattern "'""'/file.txt" was creating filenames with literal single quote characters, making file paths invalid and causing awk to silently fail. PROPER FIX: - Pass TEMP_DIR to awk using -v tmpdir="$TEMP_DIR" - Replace all quoted paths with simple tmpdir "/file.txt" concatenation - This avoids quote escaping issues entirely (standard awk best practice) CHANGED PATHS: - "'""'/high_failure_ips.txt" → tmpdir "/high_failure_ips.txt" - "'""'/high_success_ips.txt" → tmpdir "/high_success_ips.txt" - "'""'/ip_success_rates.txt" → tmpdir "/ip_success_rates.txt" IMPACT: Script will now complete analyze_success_rates() and continue to full report generation with fingerprinting, domain targeting, and URL analysis sections.
This commit is contained in:
@@ -1412,7 +1412,7 @@ analyze_success_rates() {
|
|||||||
print_info "Analyzing request success rates and behavior patterns..."
|
print_info "Analyzing request success rates and behavior patterns..."
|
||||||
|
|
||||||
# Calculate success rate (200/301/302 vs 404/403) for each IP
|
# Calculate success rate (200/301/302 vs 404/403) for each IP
|
||||||
awk -F'|' '
|
awk -F'|' -v tmpdir="$TEMP_DIR" '
|
||||||
{
|
{
|
||||||
ip = $1
|
ip = $1
|
||||||
status = $4
|
status = $4
|
||||||
@@ -1438,19 +1438,19 @@ analyze_success_rates() {
|
|||||||
|
|
||||||
# High failure rate indicates scanning/probing
|
# High failure rate indicates scanning/probing
|
||||||
if (fail_rate >= 80 && total[ip] >= 20) {
|
if (fail_rate >= 80 && total[ip] >= 20) {
|
||||||
print ip "|" total[ip] "|" fail_rate "|scanner" >> "'"$TEMP_DIR"'/high_failure_ips.txt"
|
print ip "|" total[ip] "|" fail_rate "|scanner" >> tmpdir "/high_failure_ips.txt"
|
||||||
}
|
}
|
||||||
# Very high success rate + high volume could be scraping
|
# Very high success rate + high volume could be scraping
|
||||||
else if (success_rate >= 90 && total[ip] >= 100) {
|
else if (success_rate >= 90 && total[ip] >= 100) {
|
||||||
print ip "|" total[ip] "|" success_rate "|scraper" >> "'"$TEMP_DIR"'/high_success_ips.txt"
|
print ip "|" total[ip] "|" success_rate "|scraper" >> tmpdir "/high_success_ips.txt"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Output all rates for later analysis
|
# Output all rates for later analysis
|
||||||
print ip "|" total[ip] "|" success_rate "|" fail_rate >> "'"$TEMP_DIR"'/ip_success_rates.txt"
|
print ip "|" total[ip] "|" success_rate "|" fail_rate >> tmpdir "/ip_success_rates.txt"
|
||||||
}
|
}
|
||||||
close("'"$TEMP_DIR"'/high_failure_ips.txt")
|
close(tmpdir "/high_failure_ips.txt")
|
||||||
close("'"$TEMP_DIR"'/high_success_ips.txt")
|
close(tmpdir "/high_success_ips.txt")
|
||||||
close("'"$TEMP_DIR"'/ip_success_rates.txt")
|
close(tmpdir "/ip_success_rates.txt")
|
||||||
}' < "$TEMP_DIR/parsed_logs.txt"
|
}' < "$TEMP_DIR/parsed_logs.txt"
|
||||||
|
|
||||||
# Touch files if they don't exist
|
# Touch files if they don't exist
|
||||||
|
|||||||
Reference in New Issue
Block a user