-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor payload testing and add output handling; move test functions…
… to letsgo package
- Loading branch information
1 parent
6ddbbff
commit 3d03cf4
Showing
3 changed files
with
76 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package letsgo | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
"strings" | ||
"sync" | ||
|
||
"github.com/CX330Blake/letsgo/pkg/output" | ||
) | ||
|
||
// Send request and check response | ||
func testEach(url string, param string, fileRoot string, extension string, wordlist string) { | ||
// If the file root is set, asure it ends with a slash | ||
if fileRoot != "" && !strings.HasSuffix(fileRoot, "/") { | ||
fileRoot += "/" | ||
} | ||
|
||
fullURL := fmt.Sprintf("%s?%s=%s%s", url, param, fileRoot, wordlist) | ||
if extension != "" && strings.HasPrefix(extension, ".") { | ||
fullURL = fmt.Sprintf("%s?%s=%s%s%%00%s", url, param, fileRoot, wordlist, extension) | ||
} else if extension != "" && !strings.HasPrefix(extension, ".") { | ||
fullURL = fmt.Sprintf("%s?%s=%s%s%%00.%s", url, param, fileRoot, wordlist, extension) | ||
} | ||
|
||
resp, err := http.Get(fullURL) | ||
if err != nil { | ||
// color.Red("[!] Request failed: %v\n", err) | ||
return | ||
} | ||
defer resp.Body.Close() | ||
|
||
// Simple check if the response might indicate a vulnerability | ||
if resp.StatusCode == http.StatusOK { | ||
output.Good("[+] Found Possible Vuln URL: %s (Status: %d)\n", fullURL, resp.StatusCode) | ||
} | ||
} | ||
|
||
// Multi-threaded testing | ||
func Test(url string, param string, fileRoot string, extension string, wordlist []string) { | ||
_, err := http.Get(url) | ||
if err != nil { | ||
output.Err("[!] Host seems down...\n") | ||
return | ||
} | ||
|
||
var wg sync.WaitGroup | ||
|
||
for _, payload := range wordlist { | ||
wg.Add(1) | ||
go func(wl string) { | ||
defer wg.Done() | ||
testEach(url, param, fileRoot, extension, wl) | ||
}(payload) | ||
} | ||
|
||
wg.Wait() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package output | ||
|
||
import "github.com/fatih/color" | ||
|
||
func Good(format string, a ...interface{}) { | ||
color.Green(format, a...) | ||
} | ||
|
||
func Err(format string, a ...interface{}) { | ||
color.Red(format, a...) | ||
} | ||
|
||
func Warn(format string, a ...interface{}) { | ||
color.Yellow(format, a...) | ||
} |