Skip to content

Commit 27ab868

Browse files
committed
Fix double-encoding feature
1 parent 7943369 commit 27ab868

1 file changed

Lines changed: 36 additions & 47 deletions

File tree

cmd/requester.go

Lines changed: 36 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -355,9 +355,7 @@ func requestMethodsCaseSwitching(options RequestOptions) {
355355
w.WaitAllDone()
356356
}
357357

358-
// requestHeaders makes HTTP requests using a list of headers from a file and prints the results. It can also bypass IP address restrictions by specifying a bypass IP address.
359358
// requestHeaders makes HTTP requests using a list of headers from a file and prints the results.
360-
// It can also bypass IP address restrictions by specifying a bypass IP address.
361359
func requestHeaders(options RequestOptions) {
362360
color.Cyan("\n━━━━━━━━━━━━━━━━━━ HEADERS ━━━━━━━━━━━━━━━━━━━")
363361

@@ -600,33 +598,48 @@ func requestDoubleEncoding(options RequestOptions) {
600598
return
601599
}
602600

603-
uripath := strings.Trim(parsedURL.Path, "/")
604-
605-
if len(uripath) == 0 {
601+
originalPath := parsedURL.Path
602+
if len(originalPath) == 0 || originalPath == "/" {
606603
log.Println("No path to modify")
607604
return
608605
}
609606

610-
encodedPath := url.QueryEscape(url.QueryEscape(uripath))
611-
encodedUri := parsedURL.Scheme + "://" + parsedURL.Host + "/" + encodedPath
612-
613607
w := goccm.New(maxGoroutines)
614-
w.Wait()
615-
go func(encodedUri string) {
616-
defer w.Done()
617-
statusCode, response, err := request(options.method, encodedUri, options.headers, options.proxy, options.rateLimit, options.timeout, options.redirect)
618-
if err != nil {
619-
log.Println(err)
620-
}
621608

622-
result := Result{
623-
line: encodedUri,
624-
statusCode: statusCode,
625-
contentLength: len(response),
626-
defaultReq: false,
609+
for i, c := range originalPath {
610+
if c == '/' {
611+
continue
627612
}
628-
printResponse(result, "double-encoding")
629-
}(encodedUri)
613+
614+
singleEncoded := fmt.Sprintf("%%%X", c)
615+
doubleEncoded := url.QueryEscape(singleEncoded)
616+
617+
modifiedPath := []rune(originalPath)
618+
modifiedPath[i] = []rune(doubleEncoded)[0]
619+
modifiedPathStr := originalPath[:i] + doubleEncoded + originalPath[i+1:]
620+
621+
encodedUri := fmt.Sprintf("%s://%s%s", parsedURL.Scheme, parsedURL.Host, modifiedPathStr)
622+
623+
time.Sleep(time.Duration(delay) * time.Millisecond)
624+
w.Wait()
625+
go func(encodedUri string, modifiedChar rune) {
626+
defer w.Done()
627+
628+
statusCode, response, err := request(options.method, encodedUri, options.headers, options.proxy, options.rateLimit, options.timeout, options.redirect)
629+
if err != nil {
630+
log.Println(err)
631+
return
632+
}
633+
634+
result := Result{
635+
line: fmt.Sprintf("%s", encodedUri),
636+
statusCode: statusCode,
637+
contentLength: len(response),
638+
defaultReq: false,
639+
}
640+
printResponse(result, "double-encoding")
641+
}(encodedUri, c)
642+
}
630643

631644
w.WaitAllDone()
632645
}
@@ -739,7 +752,7 @@ func requestPathCaseSwitching(options RequestOptions) {
739752
}
740753

741754
pathCombinations := generateCaseCombinations(uripath)
742-
selectedPaths := selectRandomCombinations(pathCombinations, 60)
755+
selectedPaths := selectRandomCombinations(pathCombinations, 20)
743756
w := goccm.New(maxGoroutines)
744757

745758
for _, path := range selectedPaths {
@@ -771,30 +784,6 @@ func requestPathCaseSwitching(options RequestOptions) {
771784
}(path)
772785
}
773786

774-
for _, z := range uripath {
775-
time.Sleep(time.Duration(delay) * time.Millisecond)
776-
w.Wait()
777-
go func(z rune) {
778-
defer w.Done()
779-
780-
encodedChar := fmt.Sprintf("%%%X", z) // convert rune to its hexadecimal ASCII value
781-
newpath := strings.Replace(uripath, string(z), encodedChar, 1)
782-
783-
var fullpath string
784-
if options.uri[len(options.uri)-1:] == "/" {
785-
fullpath = baseuri + "/" + newpath + "/"
786-
} else {
787-
fullpath = baseuri + "/" + newpath
788-
}
789-
790-
statusCode, response, err := request(options.method, fullpath, options.headers, options.proxy, options.rateLimit, options.timeout, options.redirect)
791-
if err != nil {
792-
log.Println(err)
793-
}
794-
795-
printResponse(Result{fullpath, statusCode, len(response), false}, "path-case-switching")
796-
}(z)
797-
}
798787
w.WaitAllDone()
799788
}
800789

0 commit comments

Comments
 (0)