* Check for Parameter Encoding */
()
| 824 | |
| 825 | /* Check for Parameter Encoding */ |
| 826 | func ScanParameterEncoding() reportResult { |
| 827 | var repResult reportResult |
| 828 | repResult.Technique = "Parameter Encoding" |
| 829 | |
| 830 | if len(impactfulQueries) == 0 { |
| 831 | msg := "No impactful query parameters were found beforehand. Run the query parameter scan (maybe with a different wordlist)." |
| 832 | Print(msg+"\n", Yellow) |
| 833 | repResult.HasError = true |
| 834 | repResult.ErrorMessages = append(repResult.ErrorMessages, msg) |
| 835 | return repResult |
| 836 | } else { |
| 837 | msg := fmt.Sprintf("The following parameters were found to be impactful and will be tested for parameter encoding: %s\n", impactfulQueries) |
| 838 | Print(msg, Cyan) |
| 839 | } |
| 840 | |
| 841 | threads := Config.Threads |
| 842 | if Config.Website.Cache.CBisHTTPMethod { |
| 843 | threads = 1 // No multithreading if HTTP Method is used... Otherwise there will be a lot of false negatives/positives |
| 844 | PrintVerbose("Can only scan single threaded because a HTTP Method is used as Cachebuster...\n", Yellow, 1) |
| 845 | } |
| 846 | sem := make(chan int, threads) |
| 847 | var wg sync.WaitGroup |
| 848 | var m sync.Mutex |
| 849 | |
| 850 | if len(impactfulQueries) > 500 { // only test first 500 impactful queries. TODO decrease amount as such a high amount most likely means they are false positives anyways |
| 851 | shortenedQueries := []string{} |
| 852 | for i := range 500 { |
| 853 | shortenedQueries = append(shortenedQueries, impactfulQueries[i]) |
| 854 | } |
| 855 | impactfulQueries = shortenedQueries |
| 856 | } |
| 857 | impactfulQueries = append(impactfulQueries, impactfulQueries...) // we want to test each impactful query parameter 2times. One time with the poison in the first and second with the poison in the second appearance |
| 858 | |
| 859 | wg.Add(len(impactfulQueries)) |
| 860 | |
| 861 | for is, s := range impactfulQueries { |
| 862 | poison := "p" + randInt() |
| 863 | prependCB := false // shall be true for the second test of the cachebuster |
| 864 | |
| 865 | go func(is int, s string, poison string, secondHalf bool) { |
| 866 | defer wg.Done() |
| 867 | sem <- 1 |
| 868 | defer func() { <-sem }() // Freigabe der Semaphore, egal was passiert. Dadurch werden Deadlocks verhindert |
| 869 | |
| 870 | url := Config.Website.Url.String() |
| 871 | ogValue := "foobar" |
| 872 | if strings.Contains(strings.ToLower(url), "?"+s+"=") || strings.Contains(strings.ToLower(url), "&"+s+"=") { |
| 873 | url, ogValue, _ = removeParam(url, s) |
| 874 | } |
| 875 | |
| 876 | var parameters []string |
| 877 | if is >= len(impactfulQueries)/2 { |
| 878 | parameters = []string{urlEncodeAll(s) + "=" + poison, s + "=" + ogValue} |
| 879 | } else { |
| 880 | parameters = []string{s + "=" + ogValue, urlEncodeAll(s) + "=" + poison} |
| 881 | } |
| 882 | |
| 883 | msg := fmt.Sprintf("Testing now Parameter Encoding (%d/%d) %s\n", is+1, len(impactfulQueries)*2, s) |
no test coverage detected