printResponse prints the results of HTTP requests in a tabular format with colored output based on the status codes.
(result Result, technique string)
| 856 | |
| 857 | // printResponse prints the results of HTTP requests in a tabular format with colored output based on the status codes. |
| 858 | func printResponse(result Result, technique string) { |
| 859 | printMutex.Lock() |
| 860 | defer printMutex.Unlock() |
| 861 | result.technique = technique |
| 862 | result.score = scoreResult(result) |
| 863 | result.likelihood = classifyLikelihood(result.score) |
| 864 | result.scoreReason = scoreReason(result) |
| 865 | result.familyKey = resultFamilyKey(result) |
| 866 | |
| 867 | // If verbose mode is enabled, directly print the result |
| 868 | if getVerbose() || technique == "http-versions" || technique == "http-parser" { |
| 869 | printResult(result) |
| 870 | writeResultToOutput(result, technique) |
| 871 | markTechniqueProduced(technique) |
| 872 | recordFinding(result) |
| 873 | return |
| 874 | } |
| 875 | |
| 876 | // In non-verbose (smart) mode: only show results that differ from the default response. |
| 877 | // Default request itself is always shown. |
| 878 | if !result.defaultReq && !isInteresting(result) { |
| 879 | return |
| 880 | } |
| 881 | if !result.defaultReq && result.score == 0 { |
| 882 | return |
| 883 | } |
| 884 | |
| 885 | // Filter by specific status codes if filtering is enabled |
| 886 | if len(statusCodes) > 0 { |
| 887 | statusMatch := false |
| 888 | for _, code := range statusCodes { |
| 889 | if strconv.Itoa(result.statusCode) == code { |
| 890 | statusMatch = true |
| 891 | break |
| 892 | } |
| 893 | } |
| 894 | if !statusMatch { |
| 895 | return |
| 896 | } |
| 897 | } |
| 898 | |
| 899 | // Check for unique global output if uniqueOutput is enabled |
| 900 | if uniqueOutput { |
| 901 | globalKey := fmt.Sprintf("%d-%d", result.statusCode, result.contentLength) |
| 902 | |
| 903 | uniqueResultsMutex.Lock() |
| 904 | if uniqueResults[globalKey] { |
| 905 | uniqueResultsMutex.Unlock() |
| 906 | return |
| 907 | } |
| 908 | uniqueResults[globalKey] = true |
| 909 | uniqueResultsMutex.Unlock() |
| 910 | } |
| 911 | |
| 912 | // Additional deduplication by technique |
| 913 | uniqueResultsByTechMutex.Lock() |
| 914 | if _, exists := uniqueResultsByTechnique[technique]; !exists { |
| 915 | uniqueResultsByTechnique[technique] = make(map[string]bool) |